We planned to upgrade GitLab and Mattermost to the latest version this Friday morning (early). You may experience some downtime!

Commit 5b8c6c29 authored by John van Groningen's avatar John van Groningen

refactor, add NoCollectedLocalDefs constructor

parent 62578c46
......@@ -476,7 +476,6 @@ where
cs & cs_symbol_table=symbol_table
arguments = [PE_Ident {id_name="_a"+++toString arg_n,id_info=argument_pointer}\\argument_pointer<-argument_pointers & arg_n<-[1..arity]]
empty_CollectedLocalDefs = CollectedLocalDefs {loc_functions={ir_from=0,ir_to=0},loc_nodes=[],loc_in_icl_module=True}
rhs = case me_priority of
NoPrio -> if (arity==0)
(PE_Ident default_class_member_ident)
......@@ -488,10 +487,10 @@ where
new_instance_body = ParsedBody
[{ pb_args = arguments,
pb_rhs = { rhs_alts=UnGuardedExpr
{ ewl_expr = rhs,
ewl_nodes = [], ewl_locals= empty_CollectedLocalDefs, ewl_position = ins_pos
},
rhs_locals=empty_CollectedLocalDefs},
{ ewl_expr = rhs,
ewl_nodes = [], ewl_locals = NoCollectedLocalDefs, ewl_position = ins_pos
},
rhs_locals=NoCollectedLocalDefs},
pb_position = ins_pos
}]
new_instance_member = { fun_ident = new_instance_ident, fun_arity = arity, fun_priority = me_priority,
......
......@@ -394,7 +394,9 @@ checkFunctionBodies _ function_ident_for_errors e_input=:{ei_expr_level,ei_mod_
removeLocalsFromSymbolTable :: !Index !Level ![Ident] !LocalDefs !Int !*{#FunDef} !*{#*{#FunDef}} !*(Heap SymbolTableEntry)
-> (!.{#FunDef},!.{#.{#FunDef}},!.Heap SymbolTableEntry)
removeLocalsFromSymbolTable module_index level loc_vars (CollectedLocalDefs {loc_functions,loc_in_icl_module}) local_functions_index_offset fun_defs macro_defs symbol_table
removeLocalsFromSymbolTable module_index level loc_vars NoCollectedLocalDefs local_functions_index_offset fun_defs macro_defs symbol_table
= (fun_defs,macro_defs,symbol_table)
removeLocalsFromSymbolTable module_index level loc_vars (CollectedLocalDefs {loc_functions,loc_in_icl_module}) local_functions_index_offset fun_defs macro_defs symbol_table
# loc_functions={ir_from=loc_functions.ir_from+local_functions_index_offset,ir_to=loc_functions.ir_to+local_functions_index_offset}
# symbol_table=removeLocalIdentsFromSymbolTable level loc_vars symbol_table
| loc_in_icl_module
......@@ -559,6 +561,8 @@ where
checkLocalFunctions :: !Index !Level !LocalDefs !Int !*{#FunDef} !*ExpressionInfo !*Heaps !*CheckState
-> (!.{#FunDef},!.ExpressionInfo,!.Heaps,!.CheckState);
checkLocalFunctions mod_index level NoCollectedLocalDefs local_functions_index_offset fun_defs e_info heaps cs
= (fun_defs,e_info,heaps,cs)
checkLocalFunctions mod_index level (CollectedLocalDefs {loc_functions={ir_from,ir_to},loc_in_icl_module}) local_functions_index_offset fun_defs e_info heaps cs
# ir_from=ir_from+local_functions_index_offset
# ir_to=ir_to+local_functions_index_offset
......@@ -1469,7 +1473,7 @@ where
determine_info_of_symbol entry=:{ste_kind=STE_FunctionOrMacro calls,ste_index,ste_def_level} symb_info
e_input=:{ei_fun_index} e_state=:{es_calls} e_info cs=:{cs_symbol_table,cs_x}
# (fun_def,e_state) = e_state!es_fun_defs.[ste_index]
# {fun_ident,fun_arity,fun_kind,fun_priority,fun_info={fi_properties}}=fun_def
# {fun_arity,fun_kind,fun_priority,fun_info={fi_properties}}=fun_def
# index = { glob_object = ste_index, glob_module = cs_x.x_main_dcl_module_n }
# symbol_kind = convert_DefOrImpFunKind_to_icl_SymbKind fun_kind index fi_properties
| is_called_before ei_fun_index calls
......@@ -1480,7 +1484,7 @@ where
determine_info_of_symbol entry=:{ste_kind=STE_DclMacroOrLocalMacroFunction calls,ste_index,ste_def_level} symb_info
e_input=:{ei_fun_index, ei_mod_index} e_state=:{es_calls} e_info cs=:{cs_symbol_table}
# (macro_def,e_info) = e_info!ef_macro_defs.[ei_mod_index,ste_index]
# {fun_ident,fun_arity,fun_kind,fun_priority,fun_info={fi_properties}}=macro_def
# {fun_arity,fun_kind,fun_priority,fun_info={fi_properties}}=macro_def
# index = { glob_object = ste_index, glob_module = ei_mod_index }
# symbol_kind = convert_DefOrImpFunKind_to_dcl_SymbKind fun_kind index fi_properties
| is_called_before ei_fun_index calls
......@@ -1491,7 +1495,7 @@ where
determine_info_of_symbol entry=:{ste_kind=STE_Imported (STE_DclMacroOrLocalMacroFunction calls) macro_mod_index,ste_index,ste_def_level} symb_info
e_input=:{ei_fun_index} e_state=:{es_calls} e_info cs=:{cs_symbol_table}
# (macro_def,e_info) = e_info!ef_macro_defs.[macro_mod_index,ste_index]
# {fun_ident,fun_arity,fun_kind,fun_priority,fun_info={fi_properties}}=macro_def
# {fun_arity,fun_kind,fun_priority,fun_info={fi_properties}}=macro_def
# index = { glob_object = ste_index, glob_module = macro_mod_index }
# symbol_kind = convert_DefOrImpFunKind_to_dcl_SymbKind fun_kind index fi_properties
| is_called_before ei_fun_index calls
......@@ -1601,7 +1605,7 @@ checkQualifiedIdentExpression free_vars module_id ident_name is_expr_list e_inpu
-> (app_expr, free_vars, e_state, e_info, cs)
STE_Imported (STE_DclMacroOrLocalMacroFunction _) mod_index
# (macro_def,e_info) = e_info!ef_macro_defs.[mod_index,decl_index]
# {fun_ident,fun_arity,fun_kind,fun_priority,fun_info={fi_properties}}=macro_def
# {fun_arity,fun_kind,fun_priority,fun_info={fi_properties}}=macro_def
# index = { glob_object = decl_index, glob_module = mod_index }
# symbol_kind = convert_DefOrImpFunKind_to_dcl_SymbKind fun_kind index fi_properties
# (e_state,cs) = add_call e_state decl_ident.id_info cs
......@@ -2746,6 +2750,8 @@ checkRhssAndTransformLocalDefs free_vars loc_defs rhs_expr e_input e_state e_inf
= (rhs_expr, free_vars, { e_state & es_expr_heap = es_expr_heap }, e_info, cs)
checkLhssOfLocalDefs :: .Int .Int LocalDefs Int *ExpressionState *ExpressionInfo *CheckState -> (!.[NodeDef AuxiliaryPattern],!(![Ident],![ArrayPattern]),!.ExpressionState,!.ExpressionInfo,!.CheckState);
checkLhssOfLocalDefs def_level mod_index NoCollectedLocalDefs local_functions_index_offset e_state e_info cs
= ([], ([],[]), e_state, e_info, cs)
checkLhssOfLocalDefs def_level mod_index (CollectedLocalDefs {loc_functions={ir_from,ir_to},loc_nodes,loc_in_icl_module}) local_functions_index_offset e_state=:{es_var_heap,es_fun_defs} e_info=:{ef_is_macro_fun} cs
# ir_from=ir_from+local_functions_index_offset
# ir_to=ir_to+local_functions_index_offset
......
......@@ -276,6 +276,8 @@ where
instance collectFunctions LocalDefs
where
collectFunctions (LocalParsedDefs []) icl_module ca
= (NoCollectedLocalDefs, ca)
collectFunctions (LocalParsedDefs locals) icl_module ca
# (fun_defs, node_defs, ca) = reorganiseLocalDefinitions locals ca
(node_defs, ca) = collect_functions_in_node_defs node_defs ca
......@@ -384,8 +386,6 @@ instance collectFunctions ParsedBody where
# (pb_rhs, ca) = collectFunctions pb_rhs icl_module ca
= ({ pb & pb_rhs = pb_rhs }, ca)
NoCollectedLocalDefs :== CollectedLocalDefs { loc_functions = { ir_from = 0, ir_to = 0 }, loc_nodes = [], loc_in_icl_module=True }
transformLambda :: Ident [ParsedExpr] Rhs Position -> FunDef
transformLambda lam_ident args rhs pos
# lam_body = [{pb_args = args, pb_rhs = rhs, pb_position = pos }]
......
......@@ -218,6 +218,7 @@ instance == FunctionOrMacroIndex
:: LocalDefs = LocalParsedDefs [ParsedDefinition]
| CollectedLocalDefs CollectedLocalDefs
| NoCollectedLocalDefs
:: IndexRange = { ir_from :: !Index, ir_to :: !Index }
......
......@@ -470,6 +470,7 @@ where
instance <<< LocalDefs
where
(<<<) file NoCollectedLocalDefs = file
(<<<) file (LocalParsedDefs defs) = file <<< defs
(<<<) file (CollectedLocalDefs defs) = file <<< defs
......
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