aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormartinw2001-01-19 10:48:10 +0000
committermartinw2001-01-19 10:48:10 +0000
commitc3a59ece66a9f8b91ebfdf3fbd556ffd241b528c (patch)
treef9792c858af73c71c67e6238cdacb0893efbfd0f
parentexploiting "reuse unique nodes" option (diff)
refactoring
git-svn-id: https://svn.cs.ru.nl/repos/clean-compiler/trunk@290 1f8540f1-abd5-4d5b-9d24-4c5ce8603e2d
-rw-r--r--frontend/StdCompare.dcl2
-rw-r--r--frontend/StdCompare.icl3
-rw-r--r--frontend/checksupport.dcl12
-rw-r--r--frontend/checksupport.icl216
-rw-r--r--frontend/checktypes.icl4
-rw-r--r--frontend/comparedefimp.dcl2
-rw-r--r--frontend/comparedefimp.icl93
-rw-r--r--frontend/explicitimports.dcl15
-rw-r--r--frontend/explicitimports.icl187
-rw-r--r--frontend/utilities.icl1
10 files changed, 301 insertions, 234 deletions
diff --git a/frontend/StdCompare.dcl b/frontend/StdCompare.dcl
index 097900d..31f1597 100644
--- a/frontend/StdCompare.dcl
+++ b/frontend/StdCompare.dcl
@@ -14,7 +14,7 @@ instance =< Int, Expression, {# Char}, Ident, [a] | =< a, BasicType //, (Global
instance =< Type, SymbIdent
instance == BasicType, TypeVar, TypeSymbIdent, DefinedSymbol, TypeContext , BasicValue,
- FunKind, (Global a) | == a, Priority, Assoc, Type, ConsVariable
+ FunKind, (Global a) | == a, Priority, Assoc, Type, ConsVariable, SignClassification
instance < MemberDef
diff --git a/frontend/StdCompare.icl b/frontend/StdCompare.icl
index fb34ff4..5b03c09 100644
--- a/frontend/StdCompare.icl
+++ b/frontend/StdCompare.icl
@@ -94,6 +94,9 @@ instance == Assoc
where
(==) a1 a2 = equal_constructor a1 a2
+instance == SignClassification where
+ (==) sc1 sc2 = sc1.sc_pos_vect == sc2.sc_pos_vect && sc1.sc_neg_vect == sc2.sc_neg_vect
+
:: CompareValue :== Int
Smaller :== -1
Greater :== 1
diff --git a/frontend/checksupport.dcl b/frontend/checksupport.dcl
index 2fbd3a2..0aa9847 100644
--- a/frontend/checksupport.dcl
+++ b/frontend/checksupport.dcl
@@ -150,8 +150,10 @@ retrieveGlobalDefinition :: !SymbolTableEntry !STE_Kind !Index -> (!Index, !Inde
// -> (!Int, ![Declaration], !.ExplImpInfos, !.Heap SymbolTableEntry);
addLocalFunctionDefsToSymbolTable :: !Level !Index !Index !Bool !*{#FunDef} !*SymbolTable !*ErrorAdmin -> (!*{# FunDef}, !*SymbolTable, !*ErrorAdmin)
addDefToSymbolTable :: !Level !Index !Ident !STE_Kind !*SymbolTable !*ErrorAdmin -> (!* SymbolTable, !*ErrorAdmin)
-addDeclaredSymbolsToSymbolTable2 :: .Bool .Int !{!Declaration} !{!Declaration} !*CheckState -> .CheckState;
+addDeclarationsOfDclModToSymbolTable :: .Int !{!Declaration} !{!Declaration} !*CheckState -> .CheckState;
addGlobalDefinitionsToSymbolTable :: ![Declaration] !*CheckState -> .CheckState;
+addSymbol :: !(Optional a) !Ident !Position !STE_Kind !STE_Kind !.Int !.Int !Int !*CheckState -> (!Bool, !.CheckState)
+addImportedFunctionOrMacro :: !(Optional IndexRange) !Ident !Int !*CheckState -> (!Bool, !.CheckState)
removeFieldFromSelectorDefinition :: !Ident .Int .Int !*(Heap SymbolTableEntry) -> .Heap SymbolTableEntry;
removeDeclarationsFromSymbolTable :: ![Declaration] !Int !*SymbolTable -> *SymbolTable
removeLocalIdentsFromSymbolTable :: .Int !.[Ident] !*(Heap SymbolTableEntry) -> .Heap SymbolTableEntry;
@@ -167,20 +169,16 @@ local_declaration_for_import :: !u:Declaration .Index -> v:Declaration, [u <= v]
get_ident :: !ImportDeclaration -> Ident
getBelongingSymbolsFromID :: !ImportDeclaration -> Optional [ImportedIdent]
-mw_addIndirectlyImportedSymbol :: !(Optional a) !Ident !Position !STE_Kind !STE_Kind !.Int !.Int !Int !*CheckState -> (!Bool, !.CheckState)
-updateExplImpForMarkedSymbol :: !Index Declaration !SymbolTableEntry !u:{#DclModule} !{!{!*ExplImpInfo}} !*SymbolTable
- -> (!u:{#DclModule}, !{!{!.ExplImpInfo}},!.SymbolTable)
-
:: BelongingSymbols
= BS_Constructors ![DefinedSymbol]
| BS_Fields !{#FieldSymbol}
| BS_Members !{#DefinedSymbol}
| BS_Nothing
-getBelongingSymbols :: !Declaration !{#x:DclModule} -> (!.BelongingSymbols, !{#x:DclModule})
+getBelongingSymbols :: !Declaration !v:{#DclModule} -> (!BelongingSymbols, !v:{#DclModule})
nrOfBelongingSymbols :: !BelongingSymbols -> Int
import_ident :: Ident
restoreHeap :: !Ident !*SymbolTable -> .SymbolTable
-temp_try_a_new_thing_XXX yes no :== no
+expand_syn_types_late_XXX yes no :== no
diff --git a/frontend/checksupport.icl b/frontend/checksupport.icl
index 1510546..dabd555 100644
--- a/frontend/checksupport.icl
+++ b/frontend/checksupport.icl
@@ -9,6 +9,7 @@ import RWSDebug
:: VarHeap :== Heap VarInfo
+cUndef :== -1
CS_NotChecked :== -1
NotFound :== -1
@@ -235,60 +236,7 @@ retrieveGlobalDefinition {ste_kind,ste_def_level,ste_index} requ_kind mod_index
= (NotFound, mod_index)
-updateExplImpForMarkedSymbol :: !Index Declaration !SymbolTableEntry !u:{#DclModule} !{!{!*ExplImpInfo}} !*SymbolTable
- -> (!u:{#DclModule}, !{!{!.ExplImpInfo}}, !.SymbolTable)
-updateExplImpForMarkedSymbol mod_index decl {ste_kind=STE_ExplImpComponentNrs component_numbers inst_indices}
- dcl_modules expl_imp_infos cs_symbol_table
- = foldSt (addExplImpInfo mod_index decl inst_indices) component_numbers
- (dcl_modules, expl_imp_infos, cs_symbol_table)
-updateExplImpForMarkedSymbol _ decl {ste_kind=STE_Instance class_ident} dcl_modules expl_imp_infos cs_symbol_table
- // this alternative is only for old syntax (cs_symbol_table argument is not necessary for new syntax)
- # cs_symbol_table
- = checkExplImpForInstance decl class_ident cs_symbol_table
- = (dcl_modules, expl_imp_infos, cs_symbol_table)
-updateExplImpForMarkedSymbol _ decl {ste_kind=STE_Imported (STE_Instance class_ident) _} dcl_modules expl_imp_infos cs_symbol_table
- // this alternative is only for old syntax (cs_symbol_table argument is not necessary for new syntax)
- # cs_symbol_table
- = checkExplImpForInstance decl class_ident cs_symbol_table
- = (dcl_modules, expl_imp_infos, cs_symbol_table)
-updateExplImpForMarkedSymbol _ _ entry dcl_modules expl_imp_infos cs_symbol_table
- = (dcl_modules, expl_imp_infos, cs_symbol_table)
-
-addExplImpInfo :: !Index Declaration ![Declaration] !ComponentNrAndIndex !(!u:{#DclModule}, !{!{!*ExplImpInfo}}, !v:SymbolTable)
- -> (!u:{#DclModule}, !{!{!.ExplImpInfo}}, !v:SymbolTable)
-addExplImpInfo mod_index decl instances { cai_component_nr, cai_index } (dcl_modules, expl_imp_infos, cs_symbol_table)
- # (ExplImpInfo eii_ident eii_declaring_modules, expl_imp_infos)
- = replaceTwoDimArrElt cai_component_nr cai_index TemporarilyFetchedAway expl_imp_infos
- (di_belonging, dcl_modules, cs_symbol_table)
- = get_belonging_symbol_nrs decl dcl_modules cs_symbol_table
- di
- = { di_decl = decl, di_instances = instances, di_belonging = di_belonging }
- new_expl_imp_info
- = ExplImpInfo eii_ident (ikhInsert` False mod_index di eii_declaring_modules)
- = (dcl_modules, { expl_imp_infos & [cai_component_nr,cai_index] = new_expl_imp_info }, cs_symbol_table)
- where
- get_belonging_symbol_nrs :: !Declaration !{#x:DclModule} !u:(Heap SymbolTableEntry)
- -> (!.NumberSet,!{#x:DclModule},!u:Heap SymbolTableEntry)
- get_belonging_symbol_nrs decl dcl_modules cs_symbol_table
- # (all_belonging_symbols, dcl_modules)
- = getBelongingSymbols decl dcl_modules
- nr_of_belongs
- = nrOfBelongingSymbols all_belonging_symbols
- (_, belonging_bitvect, cs_symbol_table)
- = foldlBelongingSymbols set_bit all_belonging_symbols (0, bitvectCreate nr_of_belongs, cs_symbol_table)
- = (bitvectToNumberSet belonging_bitvect, dcl_modules, cs_symbol_table)
-
- set_bit {id_info} (bit_nr, bitvect, cs_symbol_table)
- # ({ste_kind}, cs_symbol_table)
- = readPtr id_info cs_symbol_table
- = ( bit_nr+1
- , case ste_kind of
- STE_Empty -> bitvect
- _ -> bitvectSet bit_nr bitvect
- , cs_symbol_table
- )
-
-getBelongingSymbols :: !Declaration !{#x:DclModule} -> (!.BelongingSymbols, !{#x:DclModule})
+getBelongingSymbols :: !Declaration !v:{#DclModule} -> (!BelongingSymbols, !v:{#DclModule})
getBelongingSymbols {dcl_kind=STE_Imported STE_Type def_mod_index, dcl_index} dcl_modules
# ({td_rhs}, dcl_modules)
= dcl_modules![def_mod_index].dcl_common.com_type_defs.[dcl_index]
@@ -322,55 +270,12 @@ nrOfBelongingSymbols BS_Nothing
| BS_Members !{#DefinedSymbol}
| BS_Nothing
-foldlBelongingSymbols f bs st
- :== case bs of
- BS_Constructors constructors
- -> foldSt (\{ds_ident} st -> f ds_ident st) constructors st
- BS_Fields fields
- -> foldlArraySt (\{fs_name} st -> f fs_name st) fields st
- BS_Members members
- -> foldlArraySt (\{ds_ident} st -> f ds_ident st) members st
- BS_Nothing
- -> st
-
-checkExplImpForInstance decl class_ident cs_symbol_table
- // this function is only for old syntax
- | switch_import_syntax False True
- = cs_symbol_table
- # (class_ste, cs_symbol_table)
- = readPtr class_ident.id_info cs_symbol_table
- = case class_ste.ste_kind of
- STE_ExplImpComponentNrs component_numbers inst_indices_accu
- -> writePtr class_ident.id_info
- { class_ste & ste_kind = STE_ExplImpComponentNrs component_numbers [decl:inst_indices_accu]}
- cs_symbol_table
- _
- -> cs_symbol_table
-
-
removeImportsAndLocalsOfModuleFromSymbolTable :: !Declarations !*(Heap SymbolTableEntry) -> .Heap SymbolTableEntry
-removeImportsAndLocalsOfModuleFromSymbolTable {dcls_import,dcls_local} symbol_table
+removeImportsAndLocalsOfModuleFromSymbolTable {dcls_import,dcls_local_for_import} symbol_table
# symbol_table = remove_declared_symbols_in_array 0 dcls_import symbol_table
- = remove_declared_symbols dcls_local symbol_table
+ = remove_declared_symbols_in_array 0 dcls_local_for_import symbol_table
where
- remove_declared_symbols :: ![Declaration] !*SymbolTable -> !*SymbolTable
- remove_declared_symbols [symbol=:{dcl_ident={id_info},dcl_index}:symbols] symbol_table
- #! entry = sreadPtr id_info symbol_table
- # {ste_kind,ste_def_level} = entry
- | ste_kind == STE_Empty || ste_def_level > cModuleScope
- = remove_declared_symbols symbols symbol_table
- # symbol_table = symbol_table <:= (id_info, entry.ste_previous)
- = case ste_kind of
- STE_Field selector_id
- -> remove_declared_symbols symbols (removeFieldFromSelectorDefinition selector_id NoIndex dcl_index symbol_table)
- STE_Imported (STE_Field selector_id) def_mod
- -> remove_declared_symbols symbols (removeFieldFromSelectorDefinition selector_id def_mod dcl_index symbol_table)
- _
- -> remove_declared_symbols symbols symbol_table
- remove_declared_symbols [] symbol_table
- = symbol_table
-
remove_declared_symbols_in_array :: !Int !{!Declaration} !*SymbolTable -> !*SymbolTable
remove_declared_symbols_in_array symbol_index symbols symbol_table
| symbol_index<size symbols
@@ -414,49 +319,62 @@ addDefToSymbolTable level def_index def_ident=:{id_info} def_kind symbol_table e
= (symbol_table <:= (id_info,entry), error)
= (symbol_table, checkError def_ident " already defined" error)
-addDeclaredSymbolsToSymbolTable2 :: .Bool .Int !{!Declaration} !{!Declaration} !*CheckState -> .CheckState;
-addDeclaredSymbolsToSymbolTable2 is_dcl_mod ste_index locals imported cs
- # cs=add_imports_in_array_to_symbol_table 0 is_dcl_mod imported cs
+addDeclarationsOfDclModToSymbolTable :: .Int !{!Declaration} !{!Declaration} !*CheckState -> .CheckState;
+addDeclarationsOfDclModToSymbolTable ste_index locals imported cs
+ # cs=add_imports_in_array_to_symbol_table 0 imported cs
= addLocalSymbolsForImportToSymbolTable 0 locals ste_index cs
-
-add_imports_in_array_to_symbol_table symbol_index is_dcl_mod symbols cs=:{cs_x}
- | symbol_index<size symbols
- #! ({dcl_ident,dcl_pos,dcl_kind},symbols) = symbols![symbol_index]
- = case dcl_kind of
- STE_Imported def_kind def_mod
- | is_dcl_mod || def_mod <> cs_x.x_main_dcl_module_n
+ where
+ add_imports_in_array_to_symbol_table symbol_index symbols cs=:{cs_x}
+ | symbol_index<size symbols
+ #! ({dcl_ident,dcl_pos,dcl_kind},symbols) = symbols![symbol_index]
+ = case dcl_kind of
+ STE_Imported def_kind def_mod
#! dcl_index= symbols.[symbol_index].dcl_index
- -> add_imports_in_array_to_symbol_table (symbol_index+1) is_dcl_mod symbols (addIndirectlyImportedSymbolOld dcl_ident dcl_pos dcl_kind def_kind dcl_index def_mod cs)
- -> add_imports_in_array_to_symbol_table (symbol_index+1) is_dcl_mod symbols cs
- STE_FunctionOrMacro _
+ (_, cs)
+ = addSymbol No dcl_ident dcl_pos dcl_kind
+ def_kind dcl_index def_mod cUndef cs
+ -> add_imports_in_array_to_symbol_table (symbol_index+1) symbols cs
+ STE_FunctionOrMacro _
#! dcl_index= symbols.[symbol_index].dcl_index
- -> add_imports_in_array_to_symbol_table (symbol_index+1) is_dcl_mod symbols (addImportedFunctionOrMacro dcl_ident dcl_index cs)
- = cs
-
-addLocalSymbolsForImportToSymbolTable :: !Int !{!Declaration} Int !*CheckState -> .CheckState;
-addLocalSymbolsForImportToSymbolTable symbol_index symbols mod_index cs
- | symbol_index<size symbols
- # ({dcl_ident,dcl_pos,dcl_kind,dcl_index},symbols) = symbols![symbol_index]
- = case dcl_kind of
- STE_FunctionOrMacro _
- -> addLocalSymbolsForImportToSymbolTable (symbol_index+1) symbols mod_index
- (addImportedFunctionOrMacro dcl_ident dcl_index cs)
- STE_Imported def_kind def_mod
- -> addLocalSymbolsForImportToSymbolTable (symbol_index+1) symbols mod_index
- (addIndirectlyImportedSymbolOld dcl_ident dcl_pos dcl_kind def_kind dcl_index mod_index cs)
- = cs
-
-addImportedFunctionOrMacro :: !Ident .Int !*CheckState -> .CheckState;
-addImportedFunctionOrMacro ident=:{id_info} def_index cs=:{cs_symbol_table}
+ (_, cs)
+ = addImportedFunctionOrMacro No dcl_ident dcl_index cs
+ -> add_imports_in_array_to_symbol_table (symbol_index+1) symbols cs
+ = cs
+
+ addLocalSymbolsForImportToSymbolTable :: !Int !{!Declaration} Int !*CheckState -> .CheckState;
+ addLocalSymbolsForImportToSymbolTable symbol_index symbols mod_index cs
+ | symbol_index<size symbols
+ # ({dcl_ident,dcl_pos,dcl_kind,dcl_index},symbols) = symbols![symbol_index]
+ = case dcl_kind of
+ STE_FunctionOrMacro _
+ # (_, cs)
+ = addImportedFunctionOrMacro No dcl_ident dcl_index cs
+ -> addLocalSymbolsForImportToSymbolTable (symbol_index+1) symbols mod_index cs
+ STE_Imported def_kind def_mod
+ # (_, cs)
+ = addSymbol No dcl_ident dcl_pos dcl_kind
+ def_kind dcl_index mod_index cUndef cs
+ -> addLocalSymbolsForImportToSymbolTable (symbol_index+1) symbols mod_index cs
+ = cs
+
+addImportedFunctionOrMacro :: !(Optional IndexRange) !Ident !Int !*CheckState -> (!Bool, !.CheckState)
+addImportedFunctionOrMacro opt_dcl_macro_range ident=:{id_info} def_index cs=:{cs_symbol_table}
#! entry = sreadPtr id_info cs_symbol_table
= case entry.ste_kind of
STE_Empty
- -> { cs & cs_symbol_table = NewEntry cs.cs_symbol_table id_info (STE_FunctionOrMacro []) def_index cModuleScope entry}
+ -> (True, { cs & cs_symbol_table = NewEntry cs.cs_symbol_table id_info (STE_FunctionOrMacro [])
+ def_index cModuleScope entry})
STE_FunctionOrMacro _
- | entry.ste_index == def_index
- -> cs
+ | entry.ste_index == def_index || within_opt_range opt_dcl_macro_range def_index
+ -> (False, cs)
_
- -> { cs & cs_error = checkError ident " multiply imported" cs.cs_error}
+ -> (False, { cs & cs_error = checkError ident "multiply defined" cs.cs_error})
+ where
+ within_opt_range (Yes {ir_from, ir_to}) i
+ = ir_from<=i && i<ir_to
+ within_opt_range No _
+ = False
+
addFieldToSelectorDefinition :: !Ident (Global .Int) !*CheckState -> .CheckState;
addFieldToSelectorDefinition {id_info} glob_field_index cs=:{cs_symbol_table}
@@ -468,28 +386,8 @@ addFieldToSelectorDefinition {id_info} glob_field_index cs=:{cs_symbol_table}
_
-> { cs & cs_symbol_table = NewEntry cs.cs_symbol_table id_info (STE_Selector [glob_field_index]) NoIndex cModuleScope entry }
-addIndirectlyImportedSymbolOld :: !Ident !Position !STE_Kind !STE_Kind !.Int !.Int !*CheckState -> .CheckState;
-addIndirectlyImportedSymbolOld ident pos dcl_kind def_kind def_index def_mod cs=:{cs_symbol_table}
- # (entry, cs_symbol_table) = readPtr ident.id_info cs_symbol_table
- = add_indirectly_imported_symbol entry ident pos def_kind def_index def_mod { cs & cs_symbol_table = cs_symbol_table }
- where
- add_indirectly_imported_symbol /*entry=:*/{ste_kind = STE_Empty} {id_name,id_info} _ def_kind def_index def_mod cs=:{cs_symbol_table}
- // JVG: read the entry again, because it is boxed
- # (entry, cs_symbol_table) = readPtr id_info cs_symbol_table
- # cs = { cs & cs_symbol_table = NewEntry cs_symbol_table id_info dcl_kind def_index cModuleScope entry}
- = case def_kind of
- STE_Field selector_id
- -> addFieldToSelectorDefinition selector_id { glob_module = def_mod, glob_object = def_index } cs
- _
- -> cs
- add_indirectly_imported_symbol /*entry=:*/{ste_kind = STE_Imported kind mod_index, ste_index} ident=:{id_info} _ def_kind def_index def_mod cs
- | kind == def_kind && mod_index == def_mod && ste_index == def_index
- = cs
- add_indirectly_imported_symbol entry ident pos def_kind def_index def_mod cs=:{cs_error}
- = { cs & cs_error = checkErrorWithIdentPos (newPosition ident pos) " multiply imported" cs_error}
-
-mw_addIndirectlyImportedSymbol :: !(Optional a) !Ident !Position !STE_Kind !STE_Kind !.Int !.Int !Int !*CheckState -> (!Bool, !.CheckState)
-mw_addIndirectlyImportedSymbol yes_for_icl_module ident pos dcl_kind def_kind def_index def_mod importing_mod cs=:{cs_symbol_table}
+addSymbol :: !(Optional a) !Ident !Position !STE_Kind !STE_Kind !.Int !.Int !Int !*CheckState -> (!Bool, !.CheckState)
+addSymbol yes_for_icl_module ident pos dcl_kind def_kind def_index def_mod importing_mod cs=:{cs_symbol_table}
# (entry, cs_symbol_table) = readPtr ident.id_info cs_symbol_table
= add_indirectly_imported_symbol yes_for_icl_module entry ident pos def_kind def_index def_mod
importing_mod { cs & cs_symbol_table = cs_symbol_table }
@@ -547,9 +445,9 @@ where
removeDeclarationsFromSymbolTable :: ![Declaration] !Int !*SymbolTable -> *SymbolTable
removeDeclarationsFromSymbolTable decls scope symbol_table
- = unsafeFold2St (remove_declaration scope) decls [1..] symbol_table
+ = foldSt (remove_declaration scope) decls symbol_table
where
- remove_declaration scope decl=:{dcl_ident={id_info}, dcl_index} decl_nr symbol_table
+ remove_declaration scope decl=:{dcl_ident={id_info}, dcl_index} symbol_table
# ({ste_kind,ste_previous}, symbol_table)
= readPtr id_info symbol_table
= case ste_kind of
@@ -723,4 +621,4 @@ restoreHeap {id_info} cs_symbol_table
= readPtr id_info cs_symbol_table
= writePtr id_info ste_previous cs_symbol_table
-temp_try_a_new_thing_XXX yes no :== no
+expand_syn_types_late_XXX yes no :== no
diff --git a/frontend/checktypes.icl b/frontend/checktypes.icl
index 7211cf6..2b8f743 100644
--- a/frontend/checktypes.icl
+++ b/frontend/checktypes.icl
@@ -418,7 +418,7 @@ where
| type_index == nr_of_types
| cs.cs_error.ea_ok && not is_main_dcl
# marks = createArray nr_of_types CS_NotChecked
- {exp_type_defs,exp_modules,exp_type_heaps,exp_error} = (temp_try_a_new_thing_XXX id (expand_syn_types module_index 0 nr_of_types))
+ {exp_type_defs,exp_modules,exp_type_heaps,exp_error} = (expand_syn_types_late_XXX id (expand_syn_types module_index 0 nr_of_types))
{ exp_type_defs = ts.ts_type_defs, exp_modules = ts.ts_modules, exp_marks = marks,
exp_type_heaps = ti_type_heaps, exp_error = cs.cs_error }
= (exp_type_defs, ts.ts_cons_defs, ts.ts_selector_defs, exp_modules, ti_var_heap, exp_type_heaps, { cs & cs_error = exp_error })
@@ -437,7 +437,7 @@ expand_syn_types module_index type_index nr_of_types expst
expandSynonymTypes :: !.Index !*{#CheckedTypeDef} !*{#.DclModule} !*TypeHeaps !*ErrorAdmin
-> (!.{#CheckedTypeDef},!.{#DclModule},!.TypeHeaps,!.ErrorAdmin)
expandSynonymTypes module_index exp_type_defs exp_modules exp_type_heaps exp_error
- | temp_try_a_new_thing_XXX False True
+ | expand_syn_types_late_XXX False True
= abort "expandSynonymTypes"
#! nr_of_types
= size exp_type_defs
diff --git a/frontend/comparedefimp.dcl b/frontend/comparedefimp.dcl
index bf3ddae..c13df7d 100644
--- a/frontend/comparedefimp.dcl
+++ b/frontend/comparedefimp.dcl
@@ -4,6 +4,6 @@ import syntax, checksupport
// compare definition and implementation module
-compareDefImp :: !{#Int} !{!FunctionBody} !Int !*{# DclModule} !*IclModule !*Heaps !*ErrorAdmin
+compareDefImp :: !{#Int} !{!FunctionBody} !Int {#CheckedTypeDef} !*{# DclModule} !*IclModule !*Heaps !*ErrorAdmin
-> (!.{# DclModule}, !.IclModule,!.Heaps,!.ErrorAdmin)
diff --git a/frontend/comparedefimp.icl b/frontend/comparedefimp.icl
index 65fad5e..3c713e9 100644
--- a/frontend/comparedefimp.icl
+++ b/frontend/comparedefimp.icl
@@ -29,10 +29,11 @@ import syntax, checksupport, compare_constructor, utilities, StdCompare
, tc_dcl_modules
:: !.{#DclModule}
, tc_icl_type_defs
- :: !{CheckedTypeDef}
+ :: !{#CheckedTypeDef}
, tc_type_conversions
:: !Conversions
, tc_visited_syn_types // to detect cycles in type synonyms
+ // only for no in expand_syn_types_late_XXX
:: !.{#Bool}
, tc_main_dcl_module_n
:: !Int
@@ -73,7 +74,8 @@ import syntax, checksupport, compare_constructor, utilities, StdCompare
}
:: OptionalCorrespondenceNumber = CorrespondenceNumber !Int | Bound | Unbound
-
+ // Bound is only used for no case in expand_syn_types_late_XXX
+
class t_corresponds a :: !a !a -> *TypesCorrespondMonad
// whether two types correspond
class e_corresponds a :: !a !a -> ExpressionsCorrespondMonad
@@ -87,26 +89,30 @@ class CorrespondenceNumber a where
initial_hwn hwn_heap = { hwn_heap = hwn_heap, hwn_number = 0 }
-compareDefImp :: !{#Int} !{!FunctionBody} !Int !*{# DclModule} !*IclModule !*Heaps !*ErrorAdmin
+compareDefImp :: !{#Int} !{!FunctionBody} !Int {#CheckedTypeDef} !*{# DclModule} !*IclModule !*Heaps !*ErrorAdmin
-> (!.{# DclModule}, !.IclModule,!.Heaps,!.ErrorAdmin)
-compareDefImp size_uncopied_icl_defs untransformed main_dcl_module_n dcl_modules icl_module heaps error_admin
+compareDefImp size_uncopied_icl_defs untransformed main_dcl_module_n type_defs_of_icl_mod dcl_modules
+ icl_module heaps error_admin
// icl definitions with indices >= size_uncopied_icl_defs.[def_type] don't have to be compared,
// because they are copies of definitions that appear exclusively in the dcl module
-// # (main_dcl_module, dcl_modules) = dcl_modules![cIclModIndex]
# (main_dcl_module, dcl_modules) = dcl_modules![main_dcl_module_n]
= case main_dcl_module.dcl_conversions of
No -> (dcl_modules, icl_module, heaps, error_admin)
Yes conversion_table
- # {dcl_functions, dcl_macros, dcl_common, dcl_instances} = main_dcl_module
+ # {dcl_functions, dcl_macros, dcl_common} = main_dcl_module
{icl_common, icl_functions}
= icl_module
{hp_var_heap, hp_expression_heap, hp_type_heaps={th_vars, th_attrs}}
= heaps
- { com_type_defs=icl_com_type_defs, com_cons_defs=icl_com_cons_defs,
+ { com_type_defs, com_cons_defs=icl_com_cons_defs,
com_selector_defs=icl_com_selector_defs, com_class_defs=icl_com_class_defs,
com_member_defs=icl_com_member_defs, com_instance_defs = icl_com_instance_defs }
= icl_common
- (icl_type_defs, icl_com_type_defs) = memcpy icl_com_type_defs
+ icl_com_type_defs
+ = expand_syn_types_late_XXX type_defs_of_icl_mod com_type_defs
+ (icl_type_defs, icl_com_type_defs)
+ = expand_syn_types_late_XXX (icl_com_type_defs, icl_com_type_defs)
+ (memcpy icl_com_type_defs)
tc_state
= { tc_type_vars = initial_hwn th_vars
, tc_attr_vars = initial_hwn th_attrs
@@ -150,7 +156,8 @@ compareDefImp size_uncopied_icl_defs untransformed main_dcl_module_n dcl_modules
{ tc_type_vars, tc_attr_vars, tc_dcl_modules }
= tc_state
icl_common
- = { icl_common & com_type_defs=icl_com_type_defs, com_cons_defs=icl_com_cons_defs,
+ = { icl_common & com_type_defs=expand_syn_types_late_XXX com_type_defs icl_com_type_defs,
+ com_cons_defs=icl_com_cons_defs,
com_selector_defs=icl_com_selector_defs, com_class_defs=icl_com_class_defs,
com_member_defs=icl_com_member_defs, com_instance_defs = icl_com_instance_defs }
heaps
@@ -159,10 +166,16 @@ compareDefImp size_uncopied_icl_defs untransformed main_dcl_module_n dcl_modules
-> ( tc_dcl_modules, { icl_module & icl_common = icl_common, icl_functions = icl_functions },
heaps, error_admin )
where
- memcpy :: !*{#CheckedTypeDef} -> (!.{CheckedTypeDef}, !.{#CheckedTypeDef})
+ memcpy :: !u:{#CheckedTypeDef} -> (!.{#CheckedTypeDef}, !u:{#CheckedTypeDef})
memcpy original
+ | expand_syn_types_late_XXX True False
+ = abort "memcpy not used"
#! size = size original
- # new = createArray size (abort "don't make that array strict !")
+ | size==0
+ = ({}, original)
+ # (el0, original)
+ = original![0]
+ # new = createArray size el0
= iFoldSt (\i (dst, src=:{[i]=src_i}) -> ({ dst & [i] = src_i }, src)) 0 size (new, original)
compareWithConversions size_uncopied_icl_defs conversions dclDefs iclDefs tc_state error_admin
@@ -314,7 +327,7 @@ instance CorrespondenceNumber TypeVarInfo where
toCorrespondenceNumber TVI_Empty
= Unbound
toCorrespondenceNumber (TVI_AType _)
- = Bound
+ = expand_syn_types_late_XXX (abort "not used!!!") Bound
fromCorrespondenceNumber number
= TVI_CorrespondenceNumber number
@@ -355,6 +368,11 @@ instance t_corresponds [a] | t_corresponds a where
t_corresponds _ _
= return False
+instance t_corresponds (a, b) | t_corresponds a & t_corresponds b where
+ t_corresponds (a1, b1) (a2, b2)
+ = t_corresponds a1 a2
+ &&& t_corresponds b1 b2
+
/*2.0
instance t_corresponds {# a} | t_corresponds a & Array {#} a
@@ -397,7 +415,7 @@ instance t_corresponds (Global DefinedSymbol) where
instance t_corresponds (TypeDef TypeRhs) where
t_corresponds dclDef iclDef
- = t_corresponds_TypeDef dclDef iclDef
+ = (expand_syn_types_late_XXX t_corresponds_TypeDef` t_corresponds_TypeDef) dclDef iclDef
where
t_corresponds_TypeDef dclDef iclDef tc_state
// | False--->("comparing:", dclDef, iclDef)
@@ -424,20 +442,30 @@ instance t_corresponds (TypeDef TypeRhs) where
= (corresponds, tc_state)
# attributes_correspond = (is_TA_Unique dclDef.td_attribute)==(is_TA_Unique iclDef.td_attribute)
= (attributes_correspond, tc_state)
-
- root_has_anonymous_attr (TA_Var lhs_attr_var) syn_type=:(SynType a_type=:{at_attribute=TA_Var rhs_attr_var})
- = rhs_attr_var.av_info_ptr==lhs_attr_var.av_info_ptr
- root_has_anonymous_attr _ _
- = False
-
- coerce (SynType atype)
- = SynType { atype & at_attribute = TA_Anonymous }
-
- isnt_abstract (AbstractType _) = False
- isnt_abstract _ = True
+ where
+ root_has_anonymous_attr (TA_Var lhs_attr_var) syn_type=:(SynType a_type=:{at_attribute=TA_Var rhs_attr_var})
+ = rhs_attr_var.av_info_ptr==lhs_attr_var.av_info_ptr
+ root_has_anonymous_attr _ _
+ = False
+
+ coerce (SynType atype)
+ = SynType { atype & at_attribute = TA_Anonymous }
+
+ isnt_abstract (AbstractType _) = False
+ isnt_abstract _ = True
+
+ is_TA_Unique TA_Unique = True
+ is_TA_Unique _ = False
- is_TA_Unique TA_Unique = True
- is_TA_Unique _ = False
+ t_corresponds_TypeDef` dclDef iclDef tc_state
+// | False--->("comparing:", dclDef, iclDef)
+// = undef
+ # tc_state = init_attr_vars dclDef.td_attrs tc_state
+ tc_state = init_attr_vars iclDef.td_attrs tc_state
+ tc_state = init_atype_vars dclDef.td_args tc_state
+ tc_state = init_atype_vars iclDef.td_args tc_state
+ = t_corresponds (dclDef.td_args, (dclDef.td_rhs, (dclDef.td_context, dclDef.td_attribute)))
+ (iclDef.td_args, (iclDef.td_rhs, (iclDef.td_context, iclDef.td_attribute))) tc_state
instance t_corresponds TypeContext where
t_corresponds dclDef iclDef
@@ -456,8 +484,14 @@ instance t_corresponds ATypeVar where
instance t_corresponds AType where
t_corresponds dclDef iclDef
- = t_corresponds_at_type dclDef iclDef
+ = (expand_syn_types_late_XXX t_corresponds_at_type` t_corresponds_at_type) dclDef iclDef
where
+ t_corresponds_at_type` dclDef iclDef
+ | dclDef.at_annotation<>iclDef.at_annotation
+ = return False
+ = t_corresponds dclDef.at_attribute iclDef.at_attribute
+ &&& t_corresponds dclDef.at_type iclDef.at_type
+
t_corresponds_at_type dclDef iclDef tc_state
| dclDef.at_annotation<>iclDef.at_annotation
= (False, tc_state)
@@ -561,7 +595,8 @@ instance t_corresponds TypeAttribute where
t_corresponds (TA_RootVar dclDef) (TA_RootVar iclDef)
= PA_BUG (return True) (t_corresponds dclDef iclDef)
t_corresponds _ TA_Anonymous
- = return True
+ | expand_syn_types_late_XXX False True
+ = return True
t_corresponds TA_None icl
= case icl of
TA_Multi-> return True
@@ -745,8 +780,6 @@ instance e_corresponds DefinedSymbol where
instance e_corresponds FunctionBody where
// both bodies are either CheckedBodies or TransformedBodies
e_corresponds dclDef iclDef
-// | False--->("e_corresponds", from_body dclDef, from_body iclDef)
-// = undef
= e_corresponds (from_body dclDef) (from_body iclDef)
where
from_body (TransformedBody {tb_args, tb_rhs}) = (tb_args, [tb_rhs])
diff --git a/frontend/explicitimports.dcl b/frontend/explicitimports.dcl
index 0104e79..e1c5c64 100644
--- a/frontend/explicitimports.dcl
+++ b/frontend/explicitimports.dcl
@@ -13,9 +13,16 @@ import syntax, checksupport
}
+markExplImpSymbols :: !Int !*(!*{!*{!u:ExplImpInfo}}, !*SymbolTable)
+ -> (!.[Ident],!(!{!{!u:ExplImpInfo}},!.SymbolTable))
+
+updateExplImpForMarkedSymbol :: !Index Declaration !SymbolTableEntry !u:{#DclModule} !{!{!*ExplImpInfo}} !*SymbolTable
+ -> (!u:{#DclModule}, !{!{!.ExplImpInfo}}, !.SymbolTable)
+
solveExplicitImports :: !(IntKeyHashtable [(Int,Position,[ImportNrAndIdents])]) !{#Int} !Index
- !*(!{#x:DclModule},!*{#Int},!{!*ExplImpInfo},!*CheckState)
- -> (!.SolvedImports,!(!{#x:DclModule},!.{#Int},!{!.ExplImpInfo},!.CheckState))
-checkExplicitImportCompleteness :: ![(Declaration, Position)] !*{#DclModule} !*{#FunDef} !*ExpressionHeap !*CheckState
- -> (!.{#DclModule},!.{#FunDef},!.ExpressionHeap,!.CheckState)
+ !*(!v:{#DclModule},!*{#Int},!{!*ExplImpInfo},!*CheckState)
+ -> (!.SolvedImports,!(!v:{#DclModule},!.{#Int},!{!.ExplImpInfo},!.CheckState))
+
+checkExplicitImportCompleteness :: ![([Declaration], Position)] !*{#DclModule} !*{#FunDef} !*ExpressionHeap !*CheckState
+ -> (!.{#DclModule},!.{#FunDef},!.ExpressionHeap,!.CheckState)
diff --git a/frontend/explicitimports.icl b/frontend/explicitimports.icl
index 891f508..91bc360 100644
--- a/frontend/explicitimports.icl
+++ b/frontend/explicitimports.icl
@@ -25,9 +25,130 @@ implies a b :== not a || b
, si_implicit :: ![(Index, Position)] // module indices
}
+
+markExplImpSymbols :: !Int !*(!*{!*{!u:ExplImpInfo}}, !*SymbolTable)
+ -> (!.[Ident],!(!{!{!u:ExplImpInfo}},!.SymbolTable))
+markExplImpSymbols component_nr (expl_imp_info, cs_symbol_table)
+ #! nr_of_expl_imp_symbols
+ = size expl_imp_info.[component_nr]
+ (new_symbols, expl_imp_info, cs_symbol_table)
+ = iFoldSt (mark_symbol component_nr) 0 nr_of_expl_imp_symbols ([], expl_imp_info, cs_symbol_table)
+ = (new_symbols, (expl_imp_info, cs_symbol_table))
+ where
+ mark_symbol component_nr i
+ (changed_symbols_accu, expl_imp_info, cs_symbol_table)
+ # (eii_ident, expl_imp_info)
+ = do_a_lot_just_to_read_an_array component_nr i expl_imp_info
+ (ste, cs_symbol_table)
+ = readPtr eii_ident.id_info cs_symbol_table
+ cai
+ = { cai_component_nr = component_nr, cai_index = i }
+ = case ste.ste_kind of
+ STE_ExplImpComponentNrs component_nrs _
+ # new_ste_kind
+ = STE_ExplImpComponentNrs [cai:component_nrs] []
+ cs_symbol_table
+ = writePtr eii_ident.id_info { ste & ste_kind = new_ste_kind } cs_symbol_table
+ -> (changed_symbols_accu, expl_imp_info, cs_symbol_table)
+ _
+ # new_ste
+ = { ste & ste_kind = STE_ExplImpComponentNrs [cai] [], ste_previous = ste }
+ -> ([eii_ident:changed_symbols_accu], expl_imp_info, writePtr eii_ident.id_info new_ste cs_symbol_table)
+
+ do_a_lot_just_to_read_an_array component_nr i expl_imp_info
+ # (eii, expl_imp_info)
+ = replaceTwoDimArrElt component_nr i TemporarilyFetchedAway expl_imp_info
+ (eii_ident, eii)
+ = get_eei_ident eii
+ = (eii_ident, { expl_imp_info & [component_nr, i] = eii })
+
+
+
+updateExplImpForMarkedSymbol :: !Index Declaration !SymbolTableEntry !u:{#DclModule} !{!{!*ExplImpInfo}} !*SymbolTable
+ -> (!u:{#DclModule}, !{!{!.ExplImpInfo}}, !.SymbolTable)
+updateExplImpForMarkedSymbol mod_index decl {ste_kind=STE_ExplImpComponentNrs component_numbers inst_indices}
+ dcl_modules expl_imp_infos cs_symbol_table
+ = foldSt (addExplImpInfo mod_index decl inst_indices) component_numbers
+ (dcl_modules, expl_imp_infos, cs_symbol_table)
+updateExplImpForMarkedSymbol _ decl {ste_kind=STE_Instance class_ident} dcl_modules expl_imp_infos cs_symbol_table
+ // this alternative is only for old syntax (cs_symbol_table argument is not necessary for new syntax)
+ # cs_symbol_table
+ = optStoreInstanceWithClassSymbol decl class_ident cs_symbol_table
+ = (dcl_modules, expl_imp_infos, cs_symbol_table)
+updateExplImpForMarkedSymbol _ decl {ste_kind=STE_Imported (STE_Instance class_ident) _} dcl_modules expl_imp_infos cs_symbol_table
+ // this alternative is only for old syntax (cs_symbol_table argument is not necessary for new syntax)
+ # cs_symbol_table
+ = optStoreInstanceWithClassSymbol decl class_ident cs_symbol_table
+ = (dcl_modules, expl_imp_infos, cs_symbol_table)
+updateExplImpForMarkedSymbol _ _ entry dcl_modules expl_imp_infos cs_symbol_table
+ = (dcl_modules, expl_imp_infos, cs_symbol_table)
+
+
+addExplImpInfo :: !Index Declaration ![Declaration] !ComponentNrAndIndex !(!u:{#DclModule}, !{!{!*ExplImpInfo}}, !v:SymbolTable)
+ -> (!u:{#DclModule}, !{!{!.ExplImpInfo}}, !v:SymbolTable)
+addExplImpInfo mod_index decl instances { cai_component_nr, cai_index } (dcl_modules, expl_imp_infos, cs_symbol_table)
+ # (ExplImpInfo eii_ident eii_declaring_modules, expl_imp_infos)
+ = replaceTwoDimArrElt cai_component_nr cai_index TemporarilyFetchedAway expl_imp_infos
+ (di_belonging, dcl_modules, cs_symbol_table)
+ = get_belonging_symbol_nrs decl dcl_modules cs_symbol_table
+ di
+ = { di_decl = decl, di_instances = instances, di_belonging = di_belonging }
+ new_expl_imp_info
+ = ExplImpInfo eii_ident (ikhInsert` False mod_index di eii_declaring_modules)
+ = (dcl_modules, { expl_imp_infos & [cai_component_nr,cai_index] = new_expl_imp_info }, cs_symbol_table)
+ where
+ get_belonging_symbol_nrs :: !Declaration !v:{#DclModule} !u:(Heap SymbolTableEntry)
+ -> (!.NumberSet,!v:{#DclModule},!u:Heap SymbolTableEntry)
+ get_belonging_symbol_nrs decl dcl_modules cs_symbol_table
+ # (all_belonging_symbols, dcl_modules)
+ = getBelongingSymbols decl dcl_modules
+ nr_of_belongs
+ = nrOfBelongingSymbols all_belonging_symbols
+ (_, belonging_bitvect, cs_symbol_table)
+ = foldlBelongingSymbols set_bit all_belonging_symbols (0, bitvectCreate nr_of_belongs, cs_symbol_table)
+ = (bitvectToNumberSet belonging_bitvect, dcl_modules, cs_symbol_table)
+
+ set_bit {id_info} (bit_nr, bitvect, cs_symbol_table)
+ # ({ste_kind}, cs_symbol_table)
+ = readPtr id_info cs_symbol_table
+ = ( bit_nr+1
+ , case ste_kind of
+ STE_Empty -> bitvect
+ _ -> bitvectSet bit_nr bitvect
+ , cs_symbol_table
+ )
+
+
+optStoreInstanceWithClassSymbol decl class_ident cs_symbol_table
+ // this function is only for old syntax
+ | switch_import_syntax False True
+ = cs_symbol_table
+ # (class_ste, cs_symbol_table)
+ = readPtr class_ident.id_info cs_symbol_table
+ = case class_ste.ste_kind of
+ STE_ExplImpComponentNrs component_numbers inst_indices_accu
+ -> writePtr class_ident.id_info
+ { class_ste & ste_kind = STE_ExplImpComponentNrs component_numbers [decl:inst_indices_accu]}
+ cs_symbol_table
+ _
+ -> cs_symbol_table
+
+
+
+foldlBelongingSymbols f bs st
+ :== case bs of
+ BS_Constructors constructors
+ -> foldSt (\{ds_ident} st -> f ds_ident st) constructors st
+ BS_Fields fields
+ -> foldlArraySt (\{fs_name} st -> f fs_name st) fields st
+ BS_Members members
+ -> foldlArraySt (\{ds_ident} st -> f ds_ident st) members st
+ BS_Nothing
+ -> st
+
solveExplicitImports :: !(IntKeyHashtable [(Int,Position,[ImportNrAndIdents])]) !{#Int} !Index
- !*(!{#x:DclModule},!*{#Int},!{!*ExplImpInfo},!*CheckState)
- -> (!.SolvedImports,!(!{#x:DclModule},!.{#Int},!{!.ExplImpInfo},!.CheckState))
+ !*(!v:{#DclModule},!*{#Int},!{!*ExplImpInfo},!*CheckState)
+ -> (!.SolvedImports,!(!v:{#DclModule},!.{#Int},!{!.ExplImpInfo},!.CheckState))
solveExplicitImports expl_imp_indices_ikh modules_in_component_set importing_mod (dcl_modules, visited_modules, expl_imp_info, cs)
# import_indices
= ikhSearch` importing_mod expl_imp_indices_ikh
@@ -42,22 +163,18 @@ solveExplicitImports expl_imp_indices_ikh modules_in_component_set importing_mod
where
solve_expl_imp_from_module expl_imp_indices_ikh modules_in_component_set importing_mod
(imported_mod, position, imported_symbols) (dcl_modules, visited_modules, expl_imp_info, cs)
- # (decl_infos, (visited_modules, expl_imp_info))
+ # (successes, (decl_accu, unsolved_belonging, visited_modules, expl_imp_info))
= mapSt (search_expl_imp_symbol expl_imp_indices_ikh modules_in_component_set importing_mod imported_mod)
imported_symbols
- (visited_modules, expl_imp_info)
+ ([], [], visited_modules, expl_imp_info)
(expl_imp_info, cs_error)
- = (switch_import_syntax check_triples check_singles position) decl_infos imported_symbols
+ = (switch_import_syntax check_triples check_singles position) successes imported_symbols
(expl_imp_info, cs.cs_error)
- belonging_to_solve
- = [ (di_decl, ini, imported_mod) \\ Yes ({di_decl}, ini=:{ini_belonging=Yes _}, imported_mod) <- decl_infos]
- (belonging_decls, dcl_modules, visited_modules, expl_imp_info, cs)
+ (decl_accu, dcl_modules, visited_modules, expl_imp_info, cs)
= foldSt (solve_belonging position expl_imp_indices_ikh modules_in_component_set importing_mod)
- belonging_to_solve
- ([], dcl_modules, visited_modules, expl_imp_info, { cs & cs_error = cs_error })
-// XXX alles Scheisse
- = ((flatten [[di_decl:di_instances] \\ Yes ({di_decl,di_instances}, _, _) <- decl_infos]++belonging_decls, position),
- (dcl_modules, visited_modules, expl_imp_info, cs))
+ unsolved_belonging
+ (decl_accu, dcl_modules, visited_modules, expl_imp_info, { cs & cs_error = cs_error })
+ = ((decl_accu, position), (dcl_modules, visited_modules, expl_imp_info, cs))
solve_belonging position expl_imp_indices_ikh modules_in_component_set importing_mod
(decl, {ini_symbol_nr, ini_belonging=Yes belongs}, imported_mod)
@@ -97,7 +214,7 @@ solveExplicitImports expl_imp_indices_ikh modules_in_component_set importing_mod
# (found, path, eii_declaring_modules, visited_modules)
= depth_first_search expl_imp_indices_ikh modules_in_component_set
imported_mod ini_symbol_nr belong_nr belong_ident [importing_mod]
- eii_declaring_modules (bitvectReset visited_modules)
+ eii_declaring_modules (bitvectResetAll visited_modules)
= case found of
Yes _
# eii_declaring_modules
@@ -188,26 +305,33 @@ solveExplicitImports expl_imp_indices_ikh modules_in_component_set importing_mod
-> (No, (popErrorAdmin cs_error, cs_symbol_table))
search_expl_imp_symbol expl_imp_indices_ikh modules_in_component_set importing_mod imported_mod
- ini=:{ini_symbol_nr} (visited_modules, expl_imp_info)
+ ini=:{ini_symbol_nr} (decls_accu, belonging_accu, visited_modules, expl_imp_info)
# (ExplImpInfo eii_ident eii_declaring_modules, expl_imp_info)
= replace expl_imp_info ini_symbol_nr TemporarilyFetchedAway
(opt_decl, path, eii_declaring_modules, visited_modules)
= depth_first_search expl_imp_indices_ikh modules_in_component_set imported_mod
ini_symbol_nr cUndef stupid_ident [importing_mod]
- eii_declaring_modules (bitvectReset visited_modules)
+ eii_declaring_modules (bitvectResetAll visited_modules)
= case opt_decl of
- Yes di=:{di_decl}
+ Yes di=:{di_decl, di_instances}
# new_eii_declaring_modules
= foldSt (\mod_index eei_dm->ikhInsert` False mod_index
{di_decl = di_decl, di_instances = [], di_belonging=EndNumbers} eei_dm)
path eii_declaring_modules
+ new_belonging_accu
+ = case ini.ini_belonging of
+ No
+ -> belonging_accu
+ Yes _
+ -> [(di_decl, ini, imported_mod):belonging_accu]
new_eii
- = ExplImpInfo eii_ident new_eii_declaring_modules
- -> (Yes (di, ini, imported_mod), (visited_modules, { expl_imp_info & [ini_symbol_nr] = new_eii }))
+ = ExplImpInfo eii_ident new_eii_declaring_modules
+ -> (True, ([di_decl:di_instances++decls_accu], new_belonging_accu, visited_modules,
+ { expl_imp_info & [ini_symbol_nr] = new_eii }))
No
# eii
= ExplImpInfo eii_ident eii_declaring_modules
- -> (No, (visited_modules, { expl_imp_info & [ini_symbol_nr] = eii }))
+ -> (False, (decls_accu, belonging_accu, visited_modules, { expl_imp_info & [ini_symbol_nr] = eii }))
depth_first_search expl_imp_indices_ikh modules_in_component_set
imported_mod imported_symbol belong_nr belong_ident path eii_declaring_modules visited_modules
@@ -295,8 +419,7 @@ solveExplicitImports expl_imp_indices_ikh modules_in_component_set importing_mod
= True
= is_member belong_ident t
- // No, No, No!
- check_triples position [No, No, No: t1] [imported_symbol, _, _: t2] (expl_imp_info, cs_error)
+ check_triples position [False, False, False: t1] [imported_symbol, _, _: t2] (expl_imp_info, cs_error)
# (expl_imp_info, cs_error)
= give_error position imported_symbol (expl_imp_info, cs_error)
= check_triples position t1 t2 (expl_imp_info, cs_error)
@@ -305,7 +428,7 @@ solveExplicitImports expl_imp_indices_ikh modules_in_component_set importing_mod
check_triples position [] [] (expl_imp_info, cs_error)
= (expl_imp_info, cs_error)
- check_singles position [No: t1] [imported_symbol: t2] (expl_imp_info, cs_error)
+ check_singles position [False: t1] [imported_symbol: t2] (expl_imp_info, cs_error)
# (expl_imp_info, cs_error)
= give_error position imported_symbol (expl_imp_info, cs_error)
= check_singles position t1 t2 (expl_imp_info, cs_error)
@@ -331,7 +454,7 @@ solveExplicitImports expl_imp_indices_ikh modules_in_component_set importing_mod
= get_eei_ident eii
= (eii_ident, { expl_imp_info & [i] = eii })
- get_eei_ident (eii=:ExplImpInfo eii_ident _) = (eii_ident, eii)
+get_eei_ident (eii=:ExplImpInfo eii_ident _) = (eii_ident, eii)
:: CheckCompletenessState =
{ ccs_dcl_modules :: !.{#DclModule}
@@ -352,7 +475,7 @@ solveExplicitImports expl_imp_indices_ikh modules_in_component_set importing_mod
:: CheckCompletenessInputBox = { box_cci :: !CheckCompletenessInput }
-checkExplicitImportCompleteness :: ![(Declaration, Position)] !*{#DclModule} !*{#FunDef} !*ExpressionHeap !*CheckState
+checkExplicitImportCompleteness :: ![([Declaration], Position)] !*{#DclModule} !*{#FunDef} !*ExpressionHeap !*CheckState
-> (!.{#DclModule},!.{#FunDef},!.ExpressionHeap,!.CheckState)
checkExplicitImportCompleteness dcls_explicit dcl_modules icl_functions expr_heap
cs=:{cs_symbol_table, cs_error}
@@ -363,7 +486,11 @@ checkExplicitImportCompleteness dcls_explicit dcl_modules icl_functions expr_hea
ccs_error = cs_error, ccs_heap_changes_accu = [] }
main_dcl_module_n
= cs.cs_x.x_main_dcl_module_n
- ccs = foldSt (checkCompleteness main_dcl_module_n) dcls_explicit { box_ccs = box_ccs }
+// ccs = foldSt (checkCompleteness main_dcl_module_n) dcls_explicit { box_ccs = box_ccs }
+ ccs = foldSt (\(dcls, position) ccs
+ -> foldSt (checkCompleteness main_dcl_module_n position) dcls ccs)
+ dcls_explicit
+ { box_ccs = box_ccs }
{ ccs_dcl_modules, ccs_icl_functions, ccs_expr_heap, ccs_symbol_table, ccs_error, ccs_heap_changes_accu }
= ccs.box_ccs
// repair heap contents
@@ -371,12 +498,12 @@ checkExplicitImportCompleteness dcls_explicit dcl_modules icl_functions expr_hea
cs = { cs & cs_symbol_table = ccs_symbol_table, cs_error = ccs_error }
= (ccs_dcl_modules, ccs_icl_functions, ccs_expr_heap, cs)
where
- checkCompleteness :: !Int !(Declaration, Position) !*CheckCompletenessStateBox -> *CheckCompletenessStateBox
- checkCompleteness main_dcl_module_n ({dcl_ident, dcl_index, dcl_kind=STE_FunctionOrMacro _}, import_position) ccs
+ checkCompleteness :: !Int !Position !Declaration !*CheckCompletenessStateBox -> *CheckCompletenessStateBox
+ checkCompleteness main_dcl_module_n import_position {dcl_ident, dcl_index, dcl_kind=STE_FunctionOrMacro _} ccs
= checkCompletenessOfMacro dcl_ident dcl_index main_dcl_module_n import_position ccs
- checkCompleteness main_dcl_module_n ({dcl_ident, dcl_index, dcl_kind=STE_Imported (STE_FunctionOrMacro _) mod_index}, import_position) ccs
+ checkCompleteness main_dcl_module_n import_position {dcl_ident, dcl_index, dcl_kind=STE_Imported (STE_FunctionOrMacro _) mod_index} ccs
= checkCompletenessOfMacro dcl_ident dcl_index main_dcl_module_n import_position ccs
- checkCompleteness main_dcl_module_n ({dcl_ident, dcl_index, dcl_kind=STE_Imported expl_imp_kind mod_index}, import_position) ccs
+ checkCompleteness main_dcl_module_n import_position {dcl_ident, dcl_index, dcl_kind=STE_Imported expl_imp_kind mod_index} ccs
#! ({dcl_common,dcl_functions}, ccs) = ccs!box_ccs.ccs_dcl_modules.[mod_index]
cci = { box_cci = { cci_import_position = import_position, cci_main_dcl_module_n=main_dcl_module_n }}
= continuation expl_imp_kind dcl_common dcl_functions cci ccs
diff --git a/frontend/utilities.icl b/frontend/utilities.icl
index 055f387..6b5f09c 100644
--- a/frontend/utilities.icl
+++ b/frontend/utilities.icl
@@ -1,4 +1,5 @@
implementation module utilities
+// compile using the "reuse unique nodes option"
import StdEnv, general