Commit 7578de7e authored by John van Groningen's avatar John van Groningen
Browse files

remove fun_index from FunDef

parent d3686b53
......@@ -796,7 +796,7 @@ checkFunction mod_index fun_index def_level fun_defs
fi_properties = (if ef_is_macro_fun FI_IsMacroFun 0) bitor (has_type fun_type)
fun_info = { fun_def.fun_info & fi_calls = es_calls, fi_def_level = def_level, fi_free_vars = free_vars, fi_dynamics = es_dynamics,
fi_properties = fi_properties }
fun_defs = { es_fun_defs & [fun_index] = { fun_def & fun_body = fun_body, fun_index = fun_index, fun_info = fun_info, fun_type = fun_type}}
fun_defs = { es_fun_defs & [fun_index] = { fun_def & fun_body = fun_body, fun_info = fun_info, fun_type = fun_type}}
(fun_defs, cs_symbol_table) = remove_calls_from_symbol_table fun_index def_level es_calls fun_defs cs.cs_symbol_table
= (fun_defs,
{ e_info & ef_type_defs = ef_type_defs, ef_modules = ef_modules },
......@@ -1367,23 +1367,15 @@ checkDclModules imports_of_icl_mod dcl_modules icl_functions heaps cs=:{cs_symbo
get_ident (ID_Instance class_ident instance_ident _) = instance_ident
get_symbol imp_decl ident=:{id_info} (expl_imp_symbols_accu, nr_of_expl_imp_symbols, expl_imp_indices_accu, cs_symbol_table)
# (ste, cs_symbol_table)
= readPtr id_info cs_symbol_table
# (ste, cs_symbol_table) = readPtr id_info cs_symbol_table
= case ste.ste_kind of
STE_ExplImpSymbol expl_imp_symbols_nr
# ini
= { ini_symbol_nr = expl_imp_symbols_nr, ini_imp_decl = imp_decl }
-> (expl_imp_symbols_accu, nr_of_expl_imp_symbols,
[ini:expl_imp_indices_accu], cs_symbol_table)
# ini = { ini_symbol_nr = expl_imp_symbols_nr, ini_imp_decl = imp_decl }
-> (expl_imp_symbols_accu, nr_of_expl_imp_symbols, [ini:expl_imp_indices_accu], cs_symbol_table)
STE_Empty
# cs_symbol_table
= writePtr id_info { ste & ste_kind = STE_ExplImpSymbol nr_of_expl_imp_symbols, ste_previous = ste }
cs_symbol_table
ini
= { ini_symbol_nr = nr_of_expl_imp_symbols, ini_imp_decl = imp_decl }
-> ([ident:expl_imp_symbols_accu], nr_of_expl_imp_symbols+1,
[ini:expl_imp_indices_accu], cs_symbol_table)
# cs_symbol_table = writePtr id_info { ste & ste_kind = STE_ExplImpSymbol nr_of_expl_imp_symbols, ste_previous = ste } cs_symbol_table
ini = { ini_symbol_nr = nr_of_expl_imp_symbols, ini_imp_decl = imp_decl }
-> ([ident:expl_imp_symbols_accu], nr_of_expl_imp_symbols+1,[ini:expl_imp_indices_accu], cs_symbol_table)
checkDclComponent :: !{![Int]} !{![Int]} ![[(Index, Position, [ImportNrAndIdents])]] ![Int]
!(!Int, !*ExplImpInfos, !*{# DclModule}, !*{# FunDef}, !*Heaps,!*CheckState)
......@@ -2020,13 +2012,13 @@ check_module2 mod_name mod_imported_objects mod_imports mod_type icl_global_func
# {ft_type,ft_specials = SP_FunIndex decl_index} = dcl_fun_types.[spec_index]
icl_index = conversion_table.[decl_index]
(icl_fun, icl_functions) = icl_functions![icl_index]
(new_fun_def, heaps) = build_function next_fun_index icl_fun ft_type heaps
(new_fun_def, heaps) = build_function next_fun_index icl_fun icl_index ft_type heaps
(new_fun_defs, funs_index_heaps)
= collect_specialized_functions (inc spec_index) last_index dcl_fun_types conversion_table (icl_functions, inc next_fun_index, heaps)
= ([new_fun_def : new_fun_defs], funs_index_heaps)
= ([], (icl_functions, next_fun_index, heaps))
build_function new_fun_index fun_def=:{fun_symb, fun_index, fun_arity, fun_body = CheckedBody {cb_args}, fun_info} fun_type
build_function new_fun_index fun_def=:{fun_symb, fun_arity, fun_body = CheckedBody {cb_args}, fun_info} fun_index fun_type
(var_heap, type_var_heap, expr_heap)
# (tb_args, var_heap) = mapSt new_free_var cb_args var_heap
(app_args, expr_heap) = mapSt new_bound_var tb_args expr_heap
......@@ -2035,7 +2027,7 @@ check_module2 mod_name mod_imported_objects mod_imports mod_type icl_global_func
symb_kind = SK_Function { glob_module = main_dcl_module_n, glob_object = fun_index }},
app_args = app_args,
app_info_ptr = app_info_ptr }
= ({ fun_def & fun_index=new_fun_index, fun_body = TransformedBody {tb_args = tb_args, tb_rhs = tb_rhs}, fun_type = Yes fun_type,
= ({ fun_def & fun_body = TransformedBody {tb_args = tb_args, tb_rhs = tb_rhs}, fun_type = Yes fun_type,
fun_info = { EmptyFunInfo & fi_calls = [ { fc_index = fun_index, fc_level = cGlobalScope }] }},
(var_heap, type_var_heap, expr_heap))
......@@ -2234,18 +2226,15 @@ initialDclModule ({mod_name, mod_defs=mod_defs=:{def_funtypes,def_macros}, mod_t
, dcl_is_cashed = False
}
addImportedSymbolsToSymbolTable importing_mod opt_macro_range modules_in_component_set imports_ikh
dcl_modules cs
addImportedSymbolsToSymbolTable importing_mod opt_macro_range modules_in_component_set imports_ikh dcl_modules cs
#! nr_of_dcl_modules
= size dcl_modules
# {si_explicit, si_implicit}
= ikhSearch` importing_mod imports_ikh
# {si_explicit, si_implicit} = ikhSearch` importing_mod imports_ikh
(decls_accu, visited_modules, dcl_modules, cs)
= foldSt (add_impl_imported_symbols_with_new_error_pos opt_macro_range importing_mod
modules_in_component_set imports_ikh)
si_implicit ([], bitvectCreate nr_of_dcl_modules, dcl_modules, cs)
= foldSt (add_expl_imported_symbols_with_new_error_pos opt_macro_range importing_mod) si_explicit
(decls_accu, dcl_modules, cs)
= foldSt (add_expl_imported_symbols_with_new_error_pos opt_macro_range importing_mod) si_explicit (decls_accu, dcl_modules, cs)
where
add_impl_imported_symbols_with_new_error_pos opt_macro_range importing_mod modules_in_component_set imports_ikh
(mod_index, position) (decls_accu, visited_modules, dcl_modules, cs)
......@@ -2287,14 +2276,9 @@ addImportedSymbolsToSymbolTable importing_mod opt_macro_range modules_in_compone
si_implicit
(decls_accu, visited_modules, dcl_modules, cs)
add_expl_imported_symbols_with_new_error_pos opt_macro_range importing_mod (decls, position)
(decls_accu, dcl_modules, cs)
# cs
= pushErrorAdmin (newPosition import_ident position) cs
(decls_accu, dcl_modules, cs)
= foldSt (add_expl_imp_declaration opt_macro_range importing_mod) decls
(decls_accu, dcl_modules, cs)
add_expl_imported_symbols_with_new_error_pos opt_macro_range importing_mod (decls, position) (decls_accu, dcl_modules, cs)
# cs = pushErrorAdmin (newPosition import_ident position) cs
(decls_accu, dcl_modules, cs) = foldSt (add_expl_imp_declaration opt_macro_range importing_mod) decls (decls_accu, dcl_modules, cs)
= (decls_accu, dcl_modules, popErrorAdmin cs)
add_declaration opt_dcl_macro_range importing_mod declaration (decls_accu, cs)
......@@ -2616,8 +2600,7 @@ checkDclModule dcl_imported_module_numbers super_components imports_ikh componen
dcl_macros = mod_defs.def_macros
cs = addGlobalDefinitionsToSymbolTable dcl_defined cs
(dcls_import_list, modules, cs)
= addImportedSymbolsToSymbolTable mod_index No modules_in_component_set
imports_ikh modules cs
= addImportedSymbolsToSymbolTable mod_index No modules_in_component_set imports_ikh modules cs
dcls_import
= { el \\ el<-dcls_import_list }
cs = { cs & cs_x.x_needed_modules = 0 }
......
implementation module convertcases
import syntax, transform, checksupport, StdCompare, check, utilities, trans, general, RWSDebug
import syntax, transform, checksupport, StdCompare, check, utilities, trans, general //, RWSDebug
// exactZip fails when its arguments are of unequal length
exactZip` :: ![.a] ![.b] -> [(.a,.b)]
......@@ -726,7 +726,6 @@ newFunctionWithType opt_id fun_bodies local_vars fun_type group_index (cs_next_f
, fun_body = fun_bodies
, fun_type = Yes fun_type
, fun_pos = NoPos
, fun_index = NoIndex
, fun_kind = FK_ImpFunction cNameNotLocationDependent
, fun_lifted = 0
, fun_info = { EmptyFunInfo & fi_group_index = group_index, fi_local_vars = local_vars }
......
......@@ -3303,7 +3303,6 @@ makeFunction {ds_index, ds_arity, ds_ident} group_index arg_vars body_expr opt_s
},
fun_type = opt_sym_type,
fun_pos = fun_pos,
fun_index = ds_index,
fun_kind = FK_ImpFunction cNameNotLocationDependent,
fun_lifted = 0,
fun_info = {
......
......@@ -1327,15 +1327,15 @@ where
get_recursive_fun_index :: !Index !SymbKind Int !{# FunDef} -> Index
get_recursive_fun_index group_index (SK_Function {glob_module,glob_object}) main_dcl_module_n fun_defs
| glob_module == main_dcl_module_n
# {fun_info,fun_index} = fun_defs.[glob_object]
# {fun_info} = fun_defs.[glob_object]
| fun_info.fi_group_index == group_index
= fun_index
= glob_object
= NoIndex
= NoIndex
get_recursive_fun_index group_index (SK_LocalMacroFunction glob_object) main_dcl_module_n fun_defs
# {fun_info,fun_index} = fun_defs.[glob_object]
# {fun_info} = fun_defs.[glob_object]
| fun_info.fi_group_index == group_index
= fun_index
= glob_object
= NoIndex
get_recursive_fun_index group_index _ main_dcl_module_n fun_defs
= NoIndex
......
......@@ -122,7 +122,7 @@ addFunctionsRange fun_defs ca
MakeNewImpOrDefFunction icl_module name arity body kind prio opt_type pos
:== { fun_symb = name, fun_arity = arity, fun_priority = prio, fun_type = opt_type, fun_kind = fun_kind_to_def_or_imp_fun_kind icl_module kind,
fun_body = ParsedBody body, fun_pos = pos, fun_lifted = 0, fun_index = NoIndex, fun_info = EmptyFunInfo }
fun_body = ParsedBody body, fun_pos = pos, fun_lifted = 0, fun_info = EmptyFunInfo }
class collectFunctions a :: a Bool !*CollectAdmin -> (a, !*CollectAdmin)
......
......@@ -490,7 +490,6 @@ FI_HasTypeSpec :== 2 // whether the function has u user defined type
, fun_body :: !FunctionBody
, fun_type :: !Optional SymbolType
, fun_pos :: !Position
, fun_index :: !Int
, fun_kind :: !DefOrImpFunKind
, fun_lifted :: !Int
, fun_info :: !FunInfo
......
......@@ -474,7 +474,6 @@ FI_HasTypeSpec :== 2 // whether the function has u user defined type
, fun_body :: !FunctionBody
, fun_type :: !Optional SymbolType
, fun_pos :: !Position
, fun_index :: !Int
, fun_kind :: !DefOrImpFunKind
, fun_lifted :: !Int
// , fun_type_ptr :: !TypeVarInfoPtr
......@@ -1709,13 +1708,13 @@ where
(<<<) file {fun_symb,fun_body=CheckedBody {cb_args,cb_rhs},fun_info={fi_free_vars,fi_def_level,fi_calls}} = file <<< fun_symb <<< '.'
<<< "C " <<< cb_args <<< " = " <<< cb_rhs <<< '\n'
// <<< '.' <<< fi_def_level <<< ' ' <<< '[' <<< fi_free_vars <<< ']' <<< cb_args <<< " = " <<< cb_rhs
(<<<) file {fun_symb,fun_index,fun_body=TransformedBody {tb_args,tb_rhs},fun_info={fi_free_vars,fi_local_vars,fi_def_level,fi_calls}}
= file <<< fun_symb <<< '@' <<< fun_index <<< '.' <<< "T "
(<<<) file {fun_symb,fun_body=TransformedBody {tb_args,tb_rhs},fun_info={fi_free_vars,fi_local_vars,fi_def_level,fi_calls}}
= file <<< fun_symb <<< '.' <<< "T "
// <<< '[' <<< fi_free_vars <<< "] [" <<< fi_local_vars <<< ']'
<<< tb_args <<< '[' <<< fi_calls <<< ']' <<< " = " <<< tb_rhs <<< '\n'
// <<< '.' <<< fi_def_level <<< ' ' <<< '[' <<< fi_free_vars <<< ']' <<< tb_args <<< " = " <<< tb_rhs
(<<<) file {fun_symb,fun_index,fun_body=BackendBody body,fun_type=Yes type} = file // <<< type <<< '\n'
<<< fun_symb <<< '@' <<< fun_index <<< '.' <<< body <<< '\n'
(<<<) file {fun_symb,fun_body=BackendBody body,fun_type=Yes type} = file // <<< type <<< '\n'
<<< fun_symb <<< '.' <<< body <<< '\n'
(<<<) file {fun_symb,fun_body=NoBody,fun_type=Yes type} = file // <<< type <<< '\n'
<<< fun_symb <<< '.' <<< "Array function\n"
......
......@@ -1114,7 +1114,6 @@ possibly_generate_case_function kees=:{case_info_ptr} aci=:{aci_free_vars} ro ti
, fun_body = TransformedBody { tb_args = form_vars, tb_rhs = copied_expr}
, fun_type = Yes fun_type
, fun_pos = NoPos
, fun_index = fun_index
, fun_kind = FK_ImpFunction cNameNotLocationDependent
, fun_lifted = undeff
, fun_info = { fi_calls = []
......@@ -1522,8 +1521,8 @@ generateFunction fd=:{fun_body = TransformedBody {tb_args,tb_rhs},fun_info = {fi
st_result = fresh_result_type, st_context = [], st_attr_vars = all_attr_vars,
st_attr_env = coercionsToAttrEnv fresh_attr_vars final_coercions }
new_fd_expanding
= { fd & fun_body = Expanding new_fun_args, fun_arity = fun_arity,fun_type=new_fun_type, fun_index = ti_next_fun_nr,
fun_info.fi_group_index = fi_group_index}
= { fd & fun_body = Expanding new_fun_args, fun_arity = fun_arity,fun_type=new_fun_type,
fun_info.fi_group_index = fi_group_index}
new_gen_fd
= { gf_fun_def = new_fd_expanding, gf_instance_info = II_Empty, gf_fun_index = ti_next_fun_nr,
gf_cons_args = {cc_args = new_cons_args, cc_size = length new_cons_args, cc_linear_bits=new_linear_bits} }
......@@ -2146,8 +2145,8 @@ where
= App app @ extra_args
is_cons_or_decons_of_UList_or_UTSList glob_object glob_module imported_funs
:== let { type = imported_funs.[glob_module].[glob_object].ft_type;
} in type.st_arity>0 && not (isEmpty type.st_context);
:== let type = imported_funs.[glob_module].[glob_object].ft_type;
in type.st_arity>0 && not (isEmpty type.st_context);
is_nil_cons_or_decons_of_UList_or_UTSList glob_object glob_module imported_funs
:== not (isEmpty imported_funs.[glob_module].[glob_object].ft_type.st_context);
......
......@@ -659,7 +659,6 @@ copy_local_functions_of_macro local_macro_functions is_def_macro local_functions
# function = {function & fun_info.fi_group_index=if (function_group_index<NoIndex) (-2-function_group_index) function_group_index}
# (function,local_macro_functions,es) = copy_macro_or_local_macro_function is_def_macro function local_macro_functions es
# function={function & fun_index=new_function_n}
# (new_functions,local_macro_functions,es) = copy_local_functions_of_macro local_macro_functions is_def_macro local_functions_to_be_copied es
-> ([(old_and_new_function_n,function):new_functions],local_macro_functions,es)
......@@ -1393,7 +1392,6 @@ where
# (macro,new_functions,local_macro_functions,es) = copy_macro_and_local_functions macro copied_local_functions es
// # new_function_index=trace ("new_function_index: "+++toString new_function_index+++"\n") new_function_index;
# macro={macro & fun_index=new_function_index}
# last_function_index = case local_macro_functions of (Yes {next_local_function_n}) -> next_local_function_n-1
# es = add_new_fun_defs [({old_function_n=glob_object,new_function_n=new_function_index},macro):new_functions] new_function_index last_function_index es
with
......
......@@ -2366,8 +2366,8 @@ where
add_extra_elements_to_fun_def_array n_new_elements fun_defs
| n_new_elements==0
= fun_defs
# dummy_fun_def = { fun_symb = {id_name="",id_info=nilPtr},fun_arity=0,fun_priority=NoPrio,fun_body=NoBody,fun_type=No,fun_pos=NoPos,fun_index= -1,fun_kind=FK_DefOrImpUnknown,fun_lifted=0,
fun_info = {fi_calls=[],fi_group_index=0,fi_def_level=NotALevel,fi_free_vars=[],fi_local_vars=[],fi_dynamics=[],fi_properties=0}}
# dummy_fun_def = { fun_symb = {id_name="",id_info=nilPtr},fun_arity=0,fun_priority=NoPrio,fun_body=NoBody,fun_type=No,fun_pos=NoPos,
fun_kind=FK_DefOrImpUnknown,fun_lifted=0,fun_info = {fi_calls=[],fi_group_index=0,fi_def_level=NotALevel,fi_free_vars=[],fi_local_vars=[],fi_dynamics=[],fi_properties=0}}
= {createArray (size fun_defs+n_new_elements) dummy_fun_def & [i]=fun_defs.[i] \\ i<-[0..size fun_defs-1]}
(array_first_instance_indices,fun_defs, predef_symbols, type_heaps) = convert_array_instances si_array_instances common_defs fun_defs predef_symbols type_heaps
(list_first_instance_indices,fun_defs, predef_symbols, type_heaps) = convert_list_instances si_list_instances PD_UListClass common_defs fun_defs predef_symbols type_heaps
......@@ -2415,8 +2415,6 @@ where
, fun_body = NoBody
, fun_type = Yes instance_type
, fun_pos = me_pos
// , fun_index = member_index
, fun_index = fun_index
, fun_kind = FK_DefOrImpUnknown
, fun_lifted = 0
, fun_info = EmptyFunInfo
......@@ -2458,8 +2456,6 @@ where
, fun_body = NoBody
, fun_type = Yes instance_type
, fun_pos = me_pos
// , fun_index = member_index
, fun_index = fun_index
, fun_kind = FK_DefOrImpUnknown
, fun_lifted = 0
, fun_info = EmptyFunInfo
......
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