aboutsummaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'frontend')
-rw-r--r--frontend/check.icl139
-rw-r--r--frontend/explicitimports.icl40
-rw-r--r--frontend/syntax.dcl2
-rw-r--r--frontend/syntax.icl2
4 files changed, 138 insertions, 45 deletions
diff --git a/frontend/check.icl b/frontend/check.icl
index 6b0bdbf..5217fcc 100644
--- a/frontend/check.icl
+++ b/frontend/check.icl
@@ -1563,8 +1563,7 @@ checkDclComponent components_array super_components expl_imp_indices mod_indices
STE_ClosedModule
// this component has been already checked during the previous icl module's compilation
# (expl_imp_infos, dcl_modules, cs_symbol_table)
- = foldSt (just_update_expl_imp_info components_array super_components) mod_indices
- (expl_imp_infos, dcl_modules, cs.cs_symbol_table)
+ = foldSt (just_update_expl_imp_info components_array super_components) mod_indices (expl_imp_infos, dcl_modules, cs.cs_symbol_table)
-> (component_nr-1, expl_imp_infos, dcl_modules, icl_functions, macro_defs, heaps,
{ cs & cs_symbol_table = cs_symbol_table })
STE_Module _
@@ -1676,14 +1675,9 @@ checkDclComponent components_array super_components expl_imp_indices mod_indices
(dcl_modules, expl_imp_infos, cs_symbol_table)
= (expl_imp_infos, dcl_modules, cs_symbol_table)
- just_update_expl_imp_info components_array super_components mod_index
- (expl_imp_infos, dcl_modules, cs_symbol_table)
- # ({dcls_local_for_import, dcls_import}, dcl_modules)
- = dcl_modules![mod_index].dcl_declared
- # (dcl_modules, expl_imp_infos, cs_symbol_table)
- = updateExplImpInfo super_components.[mod_index] mod_index dcls_import dcls_local_for_import
- dcl_modules expl_imp_infos cs_symbol_table
- = (expl_imp_infos, dcl_modules, cs_symbol_table)
+ just_update_expl_imp_info components_array super_components mod_index (expl_imp_infos, dcl_modules, cs_symbol_table)
+ # ({dcls_local_for_import, dcls_import}, dcl_modules) = dcl_modules![mod_index].dcl_declared
+ = updateExplImpInfoForCachedModule super_components.[mod_index] mod_index dcls_import dcls_local_for_import expl_imp_infos dcl_modules cs_symbol_table
check_expl_imp_completeness_of_dcl_mod_within_non_trivial_component mod_index {si_explicit} (dcl_modules, icl_functions,macro_defs,hp_expression_heap, cs)
# ({dcl_declared}, dcl_modules) = dcl_modules![mod_index]
@@ -2502,16 +2496,122 @@ updateExplImpInfo super_components mod_index dcls_import dcls_local_for_import
cs_symbol_table
(dcl_modules, expl_imp_infos, cs_symbol_table)
- = foldlArraySt (update_expl_imp_for_marked_symbol mod_index) dcls_local_for_import
- (dcl_modules, expl_imp_infos, cs_symbol_table)
+ = update_expl_imp_for_marked_symbols mod_index dcls_local_for_import (dcl_modules, expl_imp_infos, cs_symbol_table)
(dcl_modules, expl_imp_infos, cs_symbol_table)
- = foldlArraySt (update_expl_imp_for_marked_symbol mod_index) dcls_import
- (dcl_modules, expl_imp_infos, cs_symbol_table)
+ = update_expl_imp_for_marked_symbols mod_index dcls_import (dcl_modules, expl_imp_infos, cs_symbol_table)
cs_symbol_table
= foldSt (\l cs_symbol_table->foldSt restoreHeap l cs_symbol_table)
changed_symbols cs_symbol_table
= (dcl_modules, expl_imp_infos, cs_symbol_table)
-
+
+updateExplImpInfoForCachedModule :: [Int] Index {!Declaration} {!Declaration} {!{!*ExplImpInfo}} u:{#DclModule} *SymbolTable
+ -> (!{!{!.ExplImpInfo}},u:{#DclModule},.SymbolTable)
+updateExplImpInfoForCachedModule super_components mod_index dcls_import dcls_local_for_import expl_imp_infos dcl_modules cs_symbol_table
+ # (changed_symbols, (expl_imp_infos, cs_symbol_table))
+ = mapSt markExplImpSymbols super_components (expl_imp_infos, cs_symbol_table)
+
+ dcl_modules13 = dcl_modules
+ cs_symbol_table13 = cs_symbol_table
+
+ dcl_modules__cs_symbol_table = mark_belongings_of_expl_imp_symbols dcls_local_for_import (dcl_modules, cs_symbol_table)
+ (dcl_modules, cs_symbol_table) = mark_belongings_of_expl_imp_symbols dcls_import dcl_modules__cs_symbol_table
+
+ cs_symbol_table = mark_belongings_of_expl_imp_symbols_as_exported dcls_local_for_import cs_symbol_table
+ cs_symbol_table = mark_belongings_of_expl_imp_symbols_as_exported dcls_import cs_symbol_table
+
+ cs_symbol_table = switch_import_syntax cs_symbol_table13 cs_symbol_table
+ dcl_modules = switch_import_syntax dcl_modules13 dcl_modules
+
+ cs_symbol_table
+ = switch_import_syntax
+ (foldlArraySt opt_store_instance_with_class_symbol dcls_local_for_import cs_symbol_table)
+ cs_symbol_table
+ cs_symbol_table
+ = switch_import_syntax
+ (foldlArraySt opt_store_instance_with_class_symbol dcls_import cs_symbol_table)
+ cs_symbol_table
+
+ (dcl_modules, expl_imp_infos, cs_symbol_table)
+ = update_expl_imp_for_marked_symbols mod_index dcls_local_for_import (dcl_modules, expl_imp_infos, cs_symbol_table)
+ (dcl_modules, expl_imp_infos, cs_symbol_table)
+ = update_expl_imp_for_marked_symbols mod_index dcls_import (dcl_modules, expl_imp_infos, cs_symbol_table)
+
+ dcl_modules__cs_symbol_table
+ = switch_import_syntax
+ (dcl_modules, cs_symbol_table)
+ (unmark_belongings_of_expl_imp_symbols dcls_local_for_import (dcl_modules, cs_symbol_table))
+ (dcl_modules, cs_symbol_table)
+ = switch_import_syntax
+ dcl_modules__cs_symbol_table
+ (unmark_belongings_of_expl_imp_symbols dcls_import dcl_modules__cs_symbol_table)
+
+ cs_symbol_table = foldSt (\l cs_symbol_table->foldSt restoreHeap l cs_symbol_table) changed_symbols cs_symbol_table
+ = (expl_imp_infos, dcl_modules, cs_symbol_table)
+where
+ mark_belongings_of_expl_imp_symbols decls (dcl_modules, cs_symbol_table)
+ = foldlArraySt mark_belongings_of_expl_imp_symbol decls (dcl_modules, cs_symbol_table)
+ where
+ mark_belongings_of_expl_imp_symbol decl=:(Declaration {decl_ident={id_info}}) (dcl_modules, cs_symbol_table)
+ # (ste, cs_symbol_table) = readPtr id_info cs_symbol_table
+ = case ste of
+ ({ste_kind=STE_ExplImpComponentNrs component_numbers inst_indices})
+ # (all_belonging_symbols, dcl_modules) = getBelongingSymbols decl dcl_modules
+ -> (dcl_modules, foldlBelongingSymbols mark_belonging_symbol all_belonging_symbols cs_symbol_table)
+ where
+ mark_belonging_symbol {id_info} cs_symbol_table
+ # (ste, cs_symbol_table) = readPtr id_info cs_symbol_table
+ = case ste.ste_kind of
+ STE_Empty
+ -> writePtr id_info {ste & ste_kind=STE_BelongingSymbolForExportedSymbol} cs_symbol_table
+ _
+ -> cs_symbol_table
+ _
+ -> (dcl_modules, cs_symbol_table)
+
+ mark_belongings_of_expl_imp_symbols_as_exported decls cs_symbol_table
+ = foldlArraySt mark_belonging_of_expl_imp_marked_symbol_as_exported decls cs_symbol_table
+ where
+ mark_belonging_of_expl_imp_marked_symbol_as_exported decl=:(Declaration {decl_ident={id_info}}) cs_symbol_table
+ # (ste, cs_symbol_table) = readPtr id_info cs_symbol_table
+ = case ste.ste_kind of
+ STE_BelongingSymbolForExportedSymbol
+ -> writePtr id_info {ste & ste_kind=STE_BelongingSymbolExported} cs_symbol_table
+ _
+ -> cs_symbol_table
+
+ unmark_belongings_of_expl_imp_symbols decls (dcl_modules, cs_symbol_table)
+ = foldlArraySt unmark_belongings_of_expl_imp_symbol decls (dcl_modules, cs_symbol_table)
+ where
+ unmark_belongings_of_expl_imp_symbol decl=:(Declaration {decl_ident={id_info}}) (dcl_modules, cs_symbol_table)
+ # (ste, cs_symbol_table) = readPtr id_info cs_symbol_table
+ = case ste of
+ ({ste_kind=STE_ExplImpComponentNrs component_numbers inst_indices})
+ # (all_belonging_symbols, dcl_modules) = getBelongingSymbols decl dcl_modules
+ -> (dcl_modules, foldlBelongingSymbols unmark_belonging_symbol all_belonging_symbols cs_symbol_table)
+ where
+ unmark_belonging_symbol {id_info} cs_symbol_table
+ # (ste, cs_symbol_table) = readPtr id_info cs_symbol_table
+ = case ste.ste_kind of
+ STE_BelongingSymbolExported
+ -> writePtr id_info {ste & ste_kind=STE_Empty} cs_symbol_table
+ STE_BelongingSymbolForExportedSymbol
+ -> writePtr id_info {ste & ste_kind=STE_Empty} cs_symbol_table
+ _
+ -> cs_symbol_table
+ _
+ -> (dcl_modules, 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
+
/*
ste_kind_to_string :: STE_Kind -> String
ste_kind_to_string ste_kind = case ste_kind of
@@ -2573,14 +2673,15 @@ opt_store_instance_with_class_symbol decl=:(Declaration {decl_kind=STE_Imported
opt_store_instance_with_class_symbol _ cs_symbol_table
= cs_symbol_table
+update_expl_imp_for_marked_symbols mod_index decls (dcl_modules, expl_imp_infos, cs_symbol_table)
+ = foldlArraySt (update_expl_imp_for_marked_symbol mod_index) decls (dcl_modules, expl_imp_infos, cs_symbol_table)
+
update_expl_imp_for_marked_symbol mod_index decl=:(Declaration {decl_ident}) (dcl_modules, expl_imp_infos, cs_symbol_table)
- # (ste, cs_symbol_table)
- = readPtr decl_ident.id_info cs_symbol_table
+ # (ste, cs_symbol_table) = readPtr decl_ident.id_info cs_symbol_table
= updateExplImpForMarkedSymbol mod_index decl ste dcl_modules expl_imp_infos cs_symbol_table
update_expl_imp_for_marked_local_symbol mod_index decl=:(Declaration {decl_ident}) (dcl_modules, expl_imp_infos, cs_symbol_table)
- # (ste, cs_symbol_table)
- = readPtr decl_ident.id_info cs_symbol_table
+ # (ste, cs_symbol_table) = readPtr decl_ident.id_info cs_symbol_table
= updateExplImpForMarkedLocalSymbol mod_index decl ste dcl_modules expl_imp_infos cs_symbol_table
updateExplImpForMarkedLocalSymbol :: !Index Declaration !SymbolTableEntry !u:{#DclModule} !{!{!*ExplImpInfo}} !*SymbolTable
diff --git a/frontend/explicitimports.icl b/frontend/explicitimports.icl
index 46b1ffd..a73c1d8 100644
--- a/frontend/explicitimports.icl
+++ b/frontend/explicitimports.icl
@@ -19,40 +19,28 @@ implies a b :== not a || b
, si_implicit :: ![(Index, Position)] // module indices
}
-markExplImpSymbols :: !Int !*(!*{!*{!u:ExplImpInfo}}, !*SymbolTable)
- -> (!.[Ident],!(!{!{!u:ExplImpInfo}},!.SymbolTable))
+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)
+ #! 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 }
+ 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
+ # 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 }
+ # 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, 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
@@ -89,11 +77,11 @@ addExplImpInfo mod_index decl instances { cai_component_nr, cai_index } (dcl_mod
= (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
+ # ({ste_kind}, cs_symbol_table) = readPtr id_info cs_symbol_table
= ( bit_nr+1
, case ste_kind of
STE_Empty -> bitvect
+ STE_BelongingSymbolForExportedSymbol -> bitvect
_ -> bitvectSet bit_nr bitvect
, cs_symbol_table
)
diff --git a/frontend/syntax.dcl b/frontend/syntax.dcl
index 1669b95..a0df396 100644
--- a/frontend/syntax.dcl
+++ b/frontend/syntax.dcl
@@ -66,6 +66,8 @@ instance == FunctionOrMacroIndex
| STE_UsedType !Index !STE_Kind
/* used during binding of types to mark types that have been applied. The first */
+ | STE_BelongingSymbolExported
+ | STE_BelongingSymbolForExportedSymbol
:: Declaration = Declaration !DeclarationRecord
diff --git a/frontend/syntax.icl b/frontend/syntax.icl
index 0d4957e..22bba06 100644
--- a/frontend/syntax.icl
+++ b/frontend/syntax.icl
@@ -67,6 +67,8 @@ instance == FunctionOrMacroIndex
| STE_ExplImpComponentNrs ![ComponentNrAndIndex] ![Declaration]
| STE_BelongingSymbol !Int
| STE_UsedType !Index !STE_Kind
+ | STE_BelongingSymbolExported
+ | STE_BelongingSymbolForExportedSymbol
:: Declaration = Declaration !DeclarationRecord