Commit 4d6e56c7 authored by John van Groningen's avatar John van Groningen

refactor, remove copying of the dcl_modules and modules(CommonDefs) arrays in convertGenenerics

parent 160a29ce
...@@ -53,7 +53,7 @@ frontEndInterface opt_file_dir_time options mod_ident search_paths cached_dcl_mo ...@@ -53,7 +53,7 @@ frontEndInterface opt_file_dir_time options mod_ident search_paths cached_dcl_mo
# (ok, icl_mod, dcl_mods, groups, cached_dcl_macros,main_dcl_module_n,heaps, predef_symbols, symbol_table, error, directly_imported_dcl_modules) # (ok, icl_mod, dcl_mods, groups, cached_dcl_macros,main_dcl_module_n,heaps, predef_symbols, symbol_table, error, directly_imported_dcl_modules)
= checkModule mod global_fun_range mod_functions support_dynamics dynamic_type_used dcl_module_n_in_cache optional_dcl_mod modules cached_dcl_modules cached_dcl_macros predef_symbols symbol_table error heaps = checkModule mod global_fun_range mod_functions support_dynamics dynamic_type_used dcl_module_n_in_cache optional_dcl_mod modules cached_dcl_modules cached_dcl_macros predef_symbols symbol_table error heaps
hash_table = { hash_table & hte_symbol_heap = symbol_table} hash_table & hte_symbol_heap = symbol_table
| not ok | not ok
= (No,{},dcl_mods,main_dcl_module_n,predef_symbols, hash_table, files, error, io, out, tcl_file, heaps) = (No,{},dcl_mods,main_dcl_module_n,predef_symbols, hash_table, files, error, io, out, tcl_file, heaps)
...@@ -123,14 +123,15 @@ frontEndInterface opt_file_dir_time options mod_ident search_paths cached_dcl_mo ...@@ -123,14 +123,15 @@ frontEndInterface opt_file_dir_time options mod_ident search_paths cached_dcl_mo
type_heaps = { type_heaps & th_vars = th_vars } type_heaps = { type_heaps & th_vars = th_vars }
# heaps = { heaps & hp_type_heaps = type_heaps, hp_expression_heap = hp_expression_heap, hp_generic_heap = gen_heap, hp_var_heap=hp_var_heap } # heaps & hp_type_heaps = type_heaps, hp_expression_heap = hp_expression_heap, hp_generic_heap = gen_heap, hp_var_heap=hp_var_heap
| not error_admin.ea_ok | not error_admin.ea_ok
= (No,{},dcl_mods,main_dcl_module_n,predef_symbols, hash_table, files, error_admin.ea_file, io, out, tcl_file, heaps) = (No,{},dcl_mods,main_dcl_module_n,predef_symbols, hash_table, files, error_admin.ea_file, io, out, tcl_file, heaps)
#! start_index_generic_classes = size icl_common.com_class_defs; #! start_index_generic_classes = size icl_common.com_class_defs;
# (saved_main_dcl_common, ti_common_defs) = replace {#dcl_common \\ {dcl_common}<-:dcl_mods} main_dcl_module_n icl_common # (ti_common_defs,dcl_mods) = copy_common_defs_from_dcl_modules dcl_mods
# (saved_main_dcl_common, ti_common_defs) = replace ti_common_defs main_dcl_module_n icl_common
#! (ti_common_defs, groups, fun_defs, td_infos, heaps, hash_table, predef_symbols, dcl_mods, cached_dcl_macros, error_admin) #! (ti_common_defs, groups, fun_defs, td_infos, heaps, hash_table, predef_symbols, dcl_mods, cached_dcl_macros, error_admin)
= case options.feo_generics of = case options.feo_generics of
...@@ -140,9 +141,9 @@ frontEndInterface opt_file_dir_time options mod_ident search_paths cached_dcl_mo ...@@ -140,9 +141,9 @@ frontEndInterface opt_file_dir_time options mod_ident search_paths cached_dcl_mo
False False
-> (ti_common_defs, groups, fun_defs, td_infos, heaps, hash_table, predef_symbols, dcl_mods, cached_dcl_macros, error_admin) -> (ti_common_defs, groups, fun_defs, td_infos, heaps, hash_table, predef_symbols, dcl_mods, cached_dcl_macros, error_admin)
# (icl_common, ti_common_defs) = replace {#x \\ x<-:ti_common_defs} main_dcl_module_n saved_main_dcl_common # (icl_common, ti_common_defs) = replace ti_common_defs main_dcl_module_n saved_main_dcl_common
# dcl_mods = { {dcl_mod & dcl_common = common} \\ dcl_mod <-: dcl_mods & common <-: ti_common_defs } # dcl_mods & [module_n].dcl_common = common \\ common <-: ti_common_defs & module_n<-[0..]
# icl_mod = {icl_mod & icl_common = icl_common} # icl_mod = {icl_mod & icl_common = icl_common}
...@@ -306,6 +307,22 @@ frontEndInterface opt_file_dir_time options mod_ident search_paths cached_dcl_mo ...@@ -306,6 +307,22 @@ frontEndInterface opt_file_dir_time options mod_ident search_paths cached_dcl_mo
#! nr_of_dcl_mods = size dcl_mods #! nr_of_dcl_mods = size dcl_mods
= arrayCopyBegin dcl_mods nr_of_dcl_mods = arrayCopyBegin dcl_mods nr_of_dcl_mods
copy_common_defs_from_dcl_modules :: !*{#DclModule} -> (!*{#CommonDefs},!*{#DclModule})
copy_common_defs_from_dcl_modules dcl_mods
# (n_dcl_mods,dcl_mods) = usize dcl_mods
| n_dcl_mods==0
= ({#},dcl_mods)
# (common_defs_0,dcl_mods) = dcl_mods![0].dcl_common
= copy_common_defs 1 (createArray n_dcl_mods common_defs_0) dcl_mods
copy_common_defs :: !Int !*{#CommonDefs} !*{#DclModule} -> (!*{#CommonDefs},!*{#DclModule})
copy_common_defs module_n common_defs dcl_mods
| module_n<size dcl_mods
# (common_def,dcl_mods) = dcl_mods![module_n].dcl_common
# common_defs & [module_n] = common_def
= copy_common_defs (module_n+1) common_defs dcl_mods
= (common_defs,dcl_mods)
clear_group_indices_of_macros :: !*{#*{#FunDef}} -> *{#*{#FunDef}} clear_group_indices_of_macros :: !*{#*{#FunDef}} -> *{#*{#FunDef}}
clear_group_indices_of_macros cached_dcl_macros clear_group_indices_of_macros cached_dcl_macros
= clear_group_indices1 0 cached_dcl_macros = clear_group_indices1 0 cached_dcl_macros
......
...@@ -6,24 +6,24 @@ from transform import ::Group ...@@ -6,24 +6,24 @@ from transform import ::Group
convertGenerics :: convertGenerics ::
!Int !Int
!NumberSet !NumberSet
!{#CommonDefs} !*{#CommonDefs}
!{!Group} !{!Group}
!*{# FunDef} !*{# FunDef}
!*TypeDefInfos !*TypeDefInfos
!*Heaps !*Heaps
!*HashTable !*HashTable
!*PredefinedSymbols !*PredefinedSymbols
!u:{# DclModule} !*{# DclModule}
!*{#*{#FunDef}} !*{#*{#FunDef}}
!*ErrorAdmin !*ErrorAdmin
-> ( !{#CommonDefs} -> ( !*{#CommonDefs}
, !{!Group} , !{!Group}
, !*{# FunDef} , !*{# FunDef}
, !*TypeDefInfos , !*TypeDefInfos
, !*Heaps , !*Heaps
, !*HashTable , !*HashTable
, !*PredefinedSymbols , !*PredefinedSymbols
, !u:{# DclModule} , !*{# DclModule}
, !*{#*{#FunDef}} , !*{#*{#FunDef}}
, !*ErrorAdmin , !*ErrorAdmin
) )
...@@ -106,30 +106,28 @@ FIELD_NewType_Mask:==8; ...@@ -106,30 +106,28 @@ FIELD_NewType_Mask:==8;
convertGenerics :: convertGenerics ::
!Int // index of the main dcl module !Int // index of the main dcl module
!NumberSet // set of used modules !NumberSet // set of used modules
!{#CommonDefs} // common definitions of all modules !*{#CommonDefs} // common definitions of all modules
!{!Group} // groups of functions !{!Group} // groups of functions
!*{# FunDef} // functions !*{# FunDef} // functions
!*TypeDefInfos // type definition information of all modules !*TypeDefInfos // type definition information of all modules
!*Heaps // all heaps !*Heaps // all heaps
!*HashTable // needed for what creating class dictionaries !*HashTable // needed for what creating class dictionaries
!*PredefinedSymbols // predefined symbols !*PredefinedSymbols // predefined symbols
!u:{# DclModule} // dcl modules !*{# DclModule} // dcl modules
!*{#*{#FunDef}} // dcl macros !*{#*{#FunDef}} // dcl macros
!*ErrorAdmin // to report errors !*ErrorAdmin // to report errors
-> ( !{#CommonDefs} // common definitions of all modules -> ( !*{#CommonDefs} // common definitions of all modules
, !{!Group} // groups of functions , !{!Group} // groups of functions
, !*{# FunDef} // function definitions , !*{# FunDef} // function definitions
, !*TypeDefInfos // type definition infos , !*TypeDefInfos // type definition infos
, !*Heaps // all heaps , !*Heaps // all heaps
, !*HashTable // needed for creating class dictinaries , !*HashTable // needed for creating class dictinaries
, !*PredefinedSymbols // predefined symbols , !*PredefinedSymbols // predefined symbols
, !u:{# DclModule} // dcl modules , !*{# DclModule} // dcl modules
, !*{#*{#FunDef}} // dcl macros , !*{#*{#FunDef}} // dcl macros
, !*ErrorAdmin // to report errors , !*ErrorAdmin // to report errors
) )
convertGenerics main_dcl_module_n used_module_numbers modules groups funs td_infos heaps hash_table u_predefs dcl_modules dcl_macros error convertGenerics main_dcl_module_n used_module_numbers modules groups funs td_infos heaps hash_table u_predefs dcl_modules dcl_macros error
#! modules = {x \\ x <-: modules} // unique copy
#! dcl_modules = { x \\ x <-: dcl_modules } // unique copy
#! size_predefs = size u_predefs #! size_predefs = size u_predefs
#! (predefs, u_predefs) = arrayCopyBegin u_predefs size_predefs // non-unique copy #! (predefs, u_predefs) = arrayCopyBegin u_predefs size_predefs // non-unique copy
...@@ -2006,8 +2004,7 @@ where ...@@ -2006,8 +2004,7 @@ where
, ds_arity = 0 , ds_arity = 0
, ds_index = NoIndex/*index in the type def table, filled in later*/ , ds_index = NoIndex/*index in the type def table, filled in later*/
} }
#! class_def = { = { class_ident = class_ident,
class_ident = class_ident,
class_arity = 1, class_arity = 1,
class_args = [class_var], class_args = [class_var],
class_context = [], class_context = [],
...@@ -2017,7 +2014,6 @@ where ...@@ -2017,7 +2014,6 @@ where
class_cons_vars = 0, // dotted class variables class_cons_vars = 0, // dotted class variables
class_dictionary = class_dictionary class_dictionary = class_dictionary
} }
= class_def
// Convert generic cases // Convert generic cases
...@@ -5104,8 +5100,7 @@ where ...@@ -5104,8 +5100,7 @@ where
clear_type (CV tv :@: _) th = clear_type_var tv th clear_type (CV tv :@: _) th = clear_type_var tv th
clear_type (TFA atvs type) th clear_type (TFA atvs type) th
#! th = foldSt clear_attr [atv_attribute \\ {atv_attribute} <- atvs] th #! th = foldSt clear_attr [atv_attribute \\ {atv_attribute} <- atvs] th
#! th = foldSt clear_type_var [atv_variable \\ {atv_variable} <- atvs] th = foldSt clear_type_var [atv_variable \\ {atv_variable} <- atvs] th
= th
clear_type _ th = th clear_type _ th = th
clear_atype {at_attribute} th clear_atype {at_attribute} th
...@@ -5114,7 +5109,7 @@ where ...@@ -5114,7 +5109,7 @@ where
clear_attr (TA_Var av) th = clear_attr_var av th clear_attr (TA_Var av) th = clear_attr_var av th
clear_attr (TA_RootVar av) th = clear_attr_var av th clear_attr (TA_RootVar av) th = clear_attr_var av th
clear_attr _ th = th clear_attr _ th = th
clear_type_var {tv_info_ptr} th=:{th_vars} clear_type_var {tv_info_ptr} th=:{th_vars}
= {th & th_vars = writePtr tv_info_ptr TVI_Empty th_vars} = {th & th_vars = writePtr tv_info_ptr TVI_Empty th_vars}
......
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