Commit 10d82218 authored by John van Groningen's avatar John van Groningen

add arity to STE_Generic (not yet used)

parent 8a6262fa
......@@ -1255,9 +1255,9 @@ where
instance_def_to_dcl {ins_ident, ins_pos} (decl_index, decls)
= (inc decl_index, [Declaration {decl_ident = ins_ident, decl_pos = ins_pos, decl_kind = STE_Instance, decl_index = decl_index} : decls])
generic_def_to_dcl {gen_ident, gen_member_ident, gen_pos} (decl_index, decls)
# generic_decl = Declaration { decl_ident = gen_ident, decl_pos = gen_pos, decl_kind = STE_Generic, decl_index = decl_index }
# member_decl = Declaration { decl_ident = gen_member_ident, decl_pos = gen_pos, decl_kind = STE_Generic, decl_index = decl_index }
generic_def_to_dcl {gen_ident, gen_member_ident, gen_type={st_arity}, gen_pos} (decl_index, decls)
# generic_decl = Declaration { decl_ident = gen_ident, decl_pos = gen_pos, decl_kind = STE_Generic st_arity, decl_index = decl_index }
# member_decl = Declaration { decl_ident = gen_member_ident, decl_pos = gen_pos, decl_kind = STE_Generic st_arity, decl_index = decl_index }
= (inc decl_index, [generic_decl, member_decl : decls])
gen_case_def_to_dcl {gc_gcf=GCF gc_ident _, gc_pos} (decl_index, decls)
......@@ -1460,7 +1460,7 @@ renumber_icl_definitions_without_functions_as_dcl_definitions (Yes icl_to_dcl_in
= (Declaration {icl_decl_symbol & decl_index=icl_to_dcl_index_table.[cClassDefs,decl_index]},cdefs)
renumber_icl_decl_symbol (Declaration icl_decl_symbol=:{decl_kind = STE_Instance, decl_index}) cdefs
= (Declaration {icl_decl_symbol & decl_index=icl_to_dcl_index_table.[cInstanceDefs,decl_index]},cdefs)
renumber_icl_decl_symbol (Declaration icl_decl_symbol=:{decl_kind = STE_Generic, decl_index}) cdefs
renumber_icl_decl_symbol (Declaration icl_decl_symbol=:{decl_kind = STE_Generic _, decl_index}) cdefs
= (Declaration {icl_decl_symbol & decl_index=icl_to_dcl_index_table.[cGenericDefs,decl_index]},cdefs)
renumber_icl_decl_symbol (Declaration icl_decl_symbol=:{decl_kind = STE_GenericCase, decl_index}) cdefs
= (Declaration {icl_decl_symbol & decl_index=icl_to_dcl_index_table.[cGenericCaseDefs,decl_index]},cdefs)
......@@ -1583,7 +1583,7 @@ where
add_to_conversion_table dcl_common (Declaration {decl_kind=STE_DclMacroOrLocalMacroFunction _})
(moved_dcl_defs, dcl_cons_and_member_defs, conversion_table, icl_sizes, icl_defs, cs)
= (moved_dcl_defs, dcl_cons_and_member_defs, conversion_table, icl_sizes, icl_defs, cs)
add_to_conversion_table dcl_common decl=:(Declaration dcl=:{decl_kind=decl_kind=:STE_Generic,decl_ident=decl_ident=:{id_info},decl_index,decl_pos})
add_to_conversion_table dcl_common decl=:(Declaration dcl=:{decl_kind=decl_kind=:STE_Generic _,decl_ident=decl_ident=:{id_info},decl_index,decl_pos})
(moved_dcl_defs,dcl_cons_and_member_defs, conversion_table, icl_sizes, icl_defs, cs)
# (entry=:{ste_kind,ste_index,ste_def_level}, cs_symbol_table) = readPtr id_info cs.cs_symbol_table
| ste_kind == STE_Empty
......@@ -1711,7 +1711,7 @@ where
# (members,st) = copy_and_redirect_member_symbols (member_index+1) com_member_defs td_pos (new_member_defs,conversion_table,icl_sizes,icl_decl_symbols,cs)
= ([member:members],st)
= ([],(new_member_defs,conversion_table,icl_sizes,icl_decl_symbols,cs))
add_dcl_definition {com_generic_defs} dcl=:(Declaration {decl_kind=STE_Generic, decl_index, decl_pos, decl_ident={id_info}})
add_dcl_definition {com_generic_defs} dcl=:(Declaration {decl_kind=STE_Generic _, decl_index, decl_pos, decl_ident={id_info}})
(new_type_defs, new_class_defs, new_cons_defs, new_selector_defs, new_member_defs, new_generic_defs, copied_defs, conversion_table, icl_sizes, icl_decl_symbols, cs)
# generic_def = com_generic_defs.[decl_index]
| generic_def.gen_member_ident.id_info==id_info
......@@ -3767,7 +3767,7 @@ where
= cs
<=< adjust_predef_symbols PD_TypeUNIT PD_TypeGenericDict0 mod_index STE_Type
<=< adjust_predef_symbols PD_ConsUNIT PD_CGenTypeApp mod_index STE_Constructor
<=< adjustPredefSymbol PD_GenericBimap mod_index STE_Generic
<=< adjustPredefSymbol PD_GenericBimap mod_index (STE_Generic -1)
| mod_index==cs_predef_symbols.[PD_StdMisc].pds_def
= cs
<=< adjustPredefSymbol PD_abort mod_index STE_DclFunction
......
......@@ -897,9 +897,9 @@ checkExpression free_vars (PE_Generic id=:{id_name,id_info} kind) e_input e_stat
where
check_generic_expr :: ![FreeVar] !SymbolTableEntry !Ident !TypeKind !ExpressionInput !*ExpressionState !*ExpressionInfo !*CheckState
-> (!Expression, ![FreeVar], !*ExpressionState, !*ExpressionInfo, !*CheckState)
check_generic_expr free_vars entry=:{ste_kind=STE_Generic,ste_index} id kind e_input=:{ei_mod_index} e_state e_info cs
check_generic_expr free_vars entry=:{ste_kind=STE_Generic _,ste_index} id kind e_input=:{ei_mod_index} e_state e_info cs
= check_it free_vars ei_mod_index ste_index id kind e_input e_state e_info cs
check_generic_expr free_vars entry=:{ste_kind=STE_Imported STE_Generic mod_index, ste_index} id kind e_input e_state e_info cs
check_generic_expr free_vars entry=:{ste_kind=STE_Imported (STE_Generic _) mod_index, ste_index} id kind e_input e_state e_info cs
= check_it free_vars mod_index ste_index id kind e_input e_state e_info cs
check_generic_expr free_vars entry=:{ste_kind=STE_Empty} id kind e_input e_state e_info cs=:{cs_error}
= (EE, free_vars, e_state, e_info, { cs & cs_error = checkError id "undefined generic" cs_error })
......@@ -1449,10 +1449,10 @@ where
#! (var_expr_ptr, es_expr_heap) = newPtr EI_Empty es_expr_heap
= (Var {var_ident = id, var_info_ptr = info_ptr, var_expr_ptr = var_expr_ptr}, free_vars,
{e_state & es_expr_heap = es_expr_heap}, e_info, cs)
check_id_expression {ste_kind = STE_Generic} is_expr_list free_vars id e_input e_state e_info cs=:{cs_error}
check_id_expression {ste_kind = STE_Generic _} is_expr_list free_vars id e_input e_state e_info cs=:{cs_error}
= (EE, free_vars, e_state, e_info,
{ cs & cs_error = checkError id "generic: missing kind argument" cs_error})
check_id_expression {ste_kind = STE_Imported STE_Generic _} is_expr_list free_vars id e_input e_state e_info cs=:{cs_error}
check_id_expression {ste_kind = STE_Imported (STE_Generic _) _} is_expr_list free_vars id e_input e_state e_info cs=:{cs_error}
= (EE, free_vars, e_state, e_info,
{ cs & cs_error = checkError id "generic: missing kind argument" cs_error})
check_id_expression entry is_expr_list free_vars id=:{id_info} e_input e_state e_info cs
......
......@@ -171,7 +171,7 @@ where
| not found
= (gen_dep, check_generic_dep_error gd_ident "generic dependency not defined" cs)
= case decl_kind of
STE_Imported STE_Generic generic_module
STE_Imported (STE_Generic _) generic_module
-> ({gen_dep & gd_ident = Ident decl_ident, gd_index = {gi_module = generic_module, gi_index = decl_index}}, cs)
_
-> (gen_dep, check_generic_dep_error gd_ident "not a generic function" cs)
......@@ -400,9 +400,9 @@ get_generic_index {id_name,id_info} mod_index cs=:{cs_symbol_table}
# (ste, cs_symbol_table) = readPtr id_info cs_symbol_table
# cs & cs_symbol_table = cs_symbol_table
= case ste.ste_kind of
STE_Generic
STE_Generic _
-> ({gi_module=mod_index,gi_index = ste.ste_index}, cs)
STE_Imported STE_Generic imported_generic_module
STE_Imported (STE_Generic _) imported_generic_module
-> ({gi_module=imported_generic_module,gi_index = ste.ste_index}, cs)
_ -> ( {gi_module=NoIndex,gi_index = NoIndex}
, {cs & cs_error = checkError id_name "undefined generic function" cs.cs_error})
......
......@@ -100,6 +100,7 @@ instance <<< IdentPos, StringPos
}
retrieveGlobalDefinition :: !SymbolTableEntry !STE_Kind !Index -> (!Index, !Index)
retrieveGlobalGenericDefinition :: !SymbolTableEntry !Index -> (!Index, !Index, !Int)
addLocalFunctionDefsToSymbolTable :: !Level !Index !Index !Bool !*{#FunDef} !*SymbolTable !*ErrorAdmin -> (!*{# FunDef}, !*SymbolTable, !*ErrorAdmin)
addLocalDclMacroDefsToSymbolTable :: !Level !Int !Index !Index !*{#*{#FunDef}} !*SymbolTable !*ErrorAdmin -> (!*{#*{#FunDef}}, !*SymbolTable, !*ErrorAdmin)
......
......@@ -13,7 +13,7 @@ where
toInt STE_Constructor = cConstructorDefs
toInt (STE_Field _) = cSelectorDefs
toInt STE_Class = cClassDefs
toInt STE_Generic = cGenericDefs
toInt (STE_Generic _) = cGenericDefs
toInt STE_GenericCase = cGenericCaseDefs
toInt STE_Member = cMemberDefs
toInt STE_Instance = cInstanceDefs
......@@ -136,6 +136,15 @@ retrieveGlobalDefinition {ste_kind,ste_def_level,ste_index} requ_kind mod_index
= (ste_index, mod_index)
= (NotFound, mod_index)
retrieveGlobalGenericDefinition :: !SymbolTableEntry !Index -> (!Index, !Index, !Int)
retrieveGlobalGenericDefinition {ste_kind = STE_Imported (STE_Generic arity) decl_index, ste_def_level, ste_index} mod_index
= (ste_index, decl_index, arity)
retrieveGlobalGenericDefinition {ste_kind = STE_Generic arity,ste_def_level,ste_index} mod_index
| ste_def_level == cGlobalScope
= (ste_index, mod_index, arity)
retrieveGlobalGenericDefinition _ mod_index
= (NotFound, mod_index ,-1)
getBelongingSymbols :: !Declaration !v:{#DclModule} -> (!BelongingSymbols, !v:{#DclModule})
getBelongingSymbols (Declaration {decl_kind=STE_Imported STE_Type def_mod_index, decl_index}) dcl_modules
# (td_rhs,dcl_modules) = dcl_modules![def_mod_index].dcl_common.com_type_defs.[decl_index].td_rhs
......
......@@ -365,7 +365,7 @@ check_context_class (TCGeneric gtc=:{gtc_generic, gtc_kind}) tc_types mod_index
{ glob_module = -1
, glob_object = {ds_ident = genericIdentToClassIdent gen_ident.id_name gtc_kind, ds_arity = 1, ds_index = -1}
}
# (generic_index, generic_module) = retrieveGlobalDefinition entry STE_Generic mod_index
# (generic_index, generic_module, generic_function_arity) = retrieveGlobalGenericDefinition entry mod_index
| generic_index <> NotFound
| gtc_generic.glob_object.ds_arity == 1
# checked_gen =
......
......@@ -622,7 +622,7 @@ checkExplicitImportCompleteness dcls_explicit explicit_qualified_imports dcl_mod
continuation (STE_DclMacroOrLocalMacroFunction _) dcl_common dcl_functions cci ccs
# (macro,ccs) = ccs!box_ccs.ccs_macro_defs.[mod_index,decl_index]
= check_completeness macro cci ccs
continuation STE_Generic dcl_common dcl_functions cci ccs
continuation (STE_Generic _) dcl_common dcl_functions cci ccs
= check_completeness dcl_common.com_generic_defs.[decl_index] cci ccs
instance toString STE_Kind where
......@@ -633,7 +633,7 @@ instance toString STE_Kind where
toString (STE_Field _) = "field"
toString STE_Class = "class"
toString STE_Member = "class member"
toString STE_Generic = "generic"
toString (STE_Generic _) = "generic"
toString STE_Instance = "instance"
toString ste = "<<unknown symbol kind>>"
......@@ -820,7 +820,7 @@ instance check_completeness GenericDef where
instance check_completeness GenericDependency where
check_completeness {gd_ident=Ident ident, gd_index={gi_module, gi_index}} cci ccs
= check_whether_ident_is_imported ident gi_module gi_index STE_Generic cci ccs
= check_whether_ident_is_imported ident gi_module gi_index (STE_Generic -1) cci ccs
instance check_completeness (Global x) | check_completeness x where
check_completeness { glob_object } cci ccs
......@@ -844,9 +844,9 @@ instance check_completeness MemberDef where
instance check_completeness MemberDefault where
check_completeness (DeriveDefault generic_ident {gi_module,gi_index} No) cci ccs
= check_whether_ident_is_imported generic_ident gi_module gi_index STE_Generic cci ccs
= check_whether_ident_is_imported generic_ident gi_module gi_index (STE_Generic -1) cci ccs
check_completeness (DeriveDefault generic_ident {gi_module,gi_index} (Yes {igi_ident,igi_g_index})) cci ccs
# ccs = check_whether_ident_is_imported generic_ident gi_module gi_index STE_Generic cci ccs
# ccs = check_whether_ident_is_imported generic_ident gi_module gi_index (STE_Generic -1) cci ccs
= check_whether_ident_is_imported igi_ident igi_g_index.gi_module igi_g_index.gi_index STE_Member cci ccs
check_completeness _ _ ccs
= ccs
......@@ -888,7 +888,7 @@ instance check_completeness SymbIdent where
SK_OverloadedFunction {glob_module,glob_object}
-> check_whether_ident_is_imported symb_ident glob_module glob_object STE_Member cci ccs
SK_Generic {glob_module,glob_object} _
-> check_whether_ident_is_imported symb_ident glob_module glob_object STE_Generic cci ccs
-> check_whether_ident_is_imported symb_ident glob_module glob_object (STE_Generic 0) cci ccs
where
check_completeness_for_function symb_ident {glob_object,glob_module} cci ccs
= check_whether_ident_is_imported symb_ident glob_module glob_object (STE_FunctionOrMacro []) cci ccs
......@@ -949,7 +949,7 @@ instance check_completeness TypeContext where
(check_whether_ident_is_imported ds_ident glob_module ds_index STE_Class cci ccs)
check_completeness {tc_class=TCGeneric {gtc_generic={glob_module,glob_object={ds_ident,ds_index}}}, tc_types} cci ccs
= check_completeness tc_types cci
(check_whether_ident_is_imported ds_ident glob_module ds_index STE_Generic cci ccs)
(check_whether_ident_is_imported ds_ident glob_module ds_index (STE_Generic -1) cci ccs)
instance check_completeness (TypeDef TypeRhs) where
check_completeness td=:{td_rhs} cci ccs
......@@ -1087,7 +1087,7 @@ ste_kind_to_name_space_n (STE_DclMacroOrLocalMacroFunction _) = ExpressionNameSp
ste_kind_to_name_space_n STE_Type = TypeNameSpaceN
ste_kind_to_name_space_n STE_Class = ClassNameSpaceN
ste_kind_to_name_space_n (STE_Field _) = FieldNameSpaceN
ste_kind_to_name_space_n STE_Generic = GenericNameSpaceN
ste_kind_to_name_space_n (STE_Generic _) = GenericNameSpaceN
ste_kind_to_name_space_n _ = OtherNameSpaceN
search_qualified_ident :: !Ident {#Char} !NameSpaceN !*CheckState -> (!Bool,!DeclarationRecord,!*CheckState)
......
......@@ -45,7 +45,7 @@ instance == FunctionOrMacroIndex
| STE_Field !Ident // IC_Selector
| STE_Class
| STE_Member
| STE_Generic
| STE_Generic !Int /*arity*/
| STE_GenericCase
| STE_GenericDeriveClass
| STE_Instance
......
......@@ -958,7 +958,7 @@ where
(<<<) file
STE_DclFunction
= file <<< "STE_DclFunction"
(<<<) file STE_Generic = file <<< "STE_Generic"
(<<<) file (STE_Generic _) = file <<< "STE_Generic"
(<<<) file STE_GenericCase = file <<< "STE_GenericCase"
(<<<) file STE_GenericDeriveClass = file <<< "STE_GenericDeriveClass"
(<<<) file
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment