diff options
author | johnvg | 2013-04-04 12:50:44 +0000 |
---|---|---|
committer | johnvg | 2013-04-04 12:50:44 +0000 |
commit | 96024ccb40adc7d5467ecb000378af784aac738e (patch) | |
tree | 42b90973414908b7133995c6b3b51fb0d7202364 /frontend | |
parent | add type constraints in dynamic types (diff) |
renumber functions after checking imported modules (from iTask branch)
git-svn-id: https://svn.cs.ru.nl/repos/clean-compiler/trunk@2222 1f8540f1-abd5-4d5b-9d24-4c5ce8603e2d
Diffstat (limited to 'frontend')
-rw-r--r-- | frontend/check.icl | 667 | ||||
-rw-r--r-- | frontend/checkgenerics.dcl | 5 | ||||
-rw-r--r-- | frontend/checkgenerics.icl | 57 | ||||
-rw-r--r-- | frontend/generics1.icl | 6 | ||||
-rw-r--r-- | frontend/typereify.dcl | 13 | ||||
-rw-r--r-- | frontend/typereify.icl | 155 |
6 files changed, 509 insertions, 394 deletions
diff --git a/frontend/check.icl b/frontend/check.icl index 5c193be..4e2ae52 100644 --- a/frontend/check.icl +++ b/frontend/check.icl @@ -1069,28 +1069,21 @@ where createStrictArray :: !Int !a -> *{!a} createStrictArray n e = createArray n e -create_icl_to_dcl_index_table :: !ModuleKind !{#Int} !Int !(Optional {#{#Int}}) !*{#DclModule} !*{#FunDef} - -> (!Optional {#{#Int}},!Optional {#Int},!Optional {#{#Int}}, !.{#DclModule},!*{#FunDef}) -create_icl_to_dcl_index_table MK_Main icl_sizes main_dcl_module_n dcl_conversions modules fun_defs - = (No,No,No,modules,fun_defs) -create_icl_to_dcl_index_table _ icl_sizes main_dcl_module_n old_conversions modules fun_defs - #! (size_icl_functions,fun_defs) = usize fun_defs - #! icl_sizes = make_icl_sizes - with - make_icl_sizes :: *{#Int} - make_icl_sizes => {{icl_sizes.[i] \\ i<-[0..cMacroDefs-1]} & [cFunctionDefs]=size_icl_functions} +create_icl_to_dcl_index_table_except_functions :: !ModuleKind !{#Int} !Int !(Optional {#{#Int}}) !*{#DclModule} -> (!Optional {#{#Int}}, !*{#DclModule}) +create_icl_to_dcl_index_table_except_functions MK_Main icl_sizes main_dcl_module_n dcl_conversions modules + = (No,modules) +create_icl_to_dcl_index_table_except_functions _ icl_sizes main_dcl_module_n (Yes conversion_table) modules #! (dcl_mod,modules) = modules![main_dcl_module_n] - #! dictionary_info=dcl_mod.dcl_dictionary_info - # (Yes conversion_table) = old_conversions - #! icl_to_dcl_index_table = {create_icl_to_dcl_index_table_for_kind table_size dcl_to_icl_table table_kind dictionary_info \\ table_kind<-[0..] & table_size <-: icl_sizes & dcl_to_icl_table <-: conversion_table } - = (Yes icl_to_dcl_index_table,Yes conversion_table.[cMacroDefs],old_conversions,modules,fun_defs) + #! dictionary_info=dcl_mod.dcl_dictionary_info + #! icl_to_dcl_index_table = {create_icl_to_dcl_index_table_for_kind table_size dcl_to_icl_table table_kind dictionary_info + \\ table_kind<-[0..cFunctionDefs-1] & table_size <-: icl_sizes & dcl_to_icl_table <-: conversion_table } + = (Yes icl_to_dcl_index_table,modules) -recompute_icl_to_dcl_index_table_for_functions No dcl_icl_conversions n_functions +compute_icl_to_dcl_index_table_for_functions No n_functions = No -recompute_icl_to_dcl_index_table_for_functions (Yes icl_to_dcl_index_table) (Yes dcl_icl_conversions) n_functions +compute_icl_to_dcl_index_table_for_functions (Yes dcl_icl_conversions) n_functions # icl_to_dcl_index_table_for_functions = create_icl_to_dcl_index_table_for_kind n_functions dcl_icl_conversions cFunctionDefs {n_dictionary_types=0, n_dictionary_constructors=0, n_dictionary_selectors=0} - # icl_to_dcl_index_table = {{t\\t<-:icl_to_dcl_index_table} & [cFunctionDefs] = icl_to_dcl_index_table_for_functions} - = Yes icl_to_dcl_index_table + = Yes icl_to_dcl_index_table_for_functions create_icl_to_dcl_index_table_for_kind :: !Int !{#Int} Int DictionaryInfo -> {#Int} create_icl_to_dcl_index_table_for_kind table_size dcl_to_icl_table table_kind dcl_dictionary_info @@ -1111,39 +1104,83 @@ create_icl_to_dcl_index_table_for_kind table_size dcl_to_icl_table table_kind dc = icl_to_dcl_index_table_for_kind = icl_to_dcl_index_table_for_kind -renumber_type_fun_indices :: (Optional {{#Int}}) *{#CheckedTypeDef} -> *{#CheckedTypeDef} -renumber_type_fun_indices No type_defs - = type_defs -renumber_type_fun_indices (Yes conversion_table) type_defs - # (n, type_defs) = usize type_defs - = renumber 0 n conversion_table.[cFunctionDefs] type_defs +set_td_fun_index_for_icl_types [dcl_type_funs,not_exported_type_fun_range] icl_common=:{com_type_defs} + # (type_index,com_type_defs) = set_td_fun_index_for_type_defs 0 dcl_type_funs.ir_from dcl_type_funs.ir_to com_type_defs + # (_,com_type_defs) = set_td_fun_index_for_type_defs type_index not_exported_type_fun_range.ir_from not_exported_type_fun_range.ir_to com_type_defs + = {icl_common & com_type_defs=com_type_defs} where - renumber :: Int Int {# Int} *{#CheckedTypeDef} -> *{#CheckedTypeDef} - renumber i n conversion type_defs - | i < n - # (type_def, type_defs) = type_defs![i] - # icl_index = type_def.td_fun_index - | icl_index <> NoIndex && icl_index < size conversion - # dcl_index = conversion.[icl_index] - # type_def = { type_def & td_fun_index = dcl_index } - # type_defs = { type_defs & [i] = type_def } - = renumber (inc i) n conversion type_defs - // otherwise - = renumber (inc i) n conversion type_defs - // otherwise - = type_defs - -renumber_icl_definitions_as_dcl_definitions :: !(Optional {{#Int}}) !{#Int} IndexRange !Int ![Declaration] ![Declaration] !*{#DclModule} !*CommonDefs !*{#FunDef} - -> (![Declaration],![Declaration],!.{#DclModule},!.CommonDefs,!*{#FunDef}) -renumber_icl_definitions_as_dcl_definitions No icl_sizes icl_global_function_range main_dcl_module_n icl_decl_symbols macro_and_function_local_defs modules cdefs fun_defs - = (icl_decl_symbols,macro_and_function_local_defs,modules,cdefs,fun_defs) -renumber_icl_definitions_as_dcl_definitions (Yes icl_to_dcl_index_table) icl_sizes icl_global_function_range main_dcl_module_n icl_decl_symbols macro_and_function_local_defs modules cdefs fun_defs - # (size_icl_functions,fun_defs) = usize fun_defs - # icl_sizes = {{icl_sizes.[i] \\ i<-[0..cMacroDefs-1]} & [cFunctionDefs]=size_icl_functions} + set_td_fun_index_for_type_defs type_index type_fun_index end_type_fun_index type_defs + | type_fun_index<end_type_fun_index + # type_defs = {type_defs & [type_index].td_fun_index=type_fun_index} + = set_td_fun_index_for_type_defs (type_index+1) (type_fun_index+1) end_type_fun_index type_defs + = (type_index,type_defs) + +renumber_icl_definitions_without_functions_as_dcl_definitions :: !(Optional {#{#Int}}) !DictionaryInfo ![Declaration] !*CommonDefs + -> (![Declaration],!*CommonDefs) +renumber_icl_definitions_without_functions_as_dcl_definitions No dcl_dictionary_info icl_decl_symbols cdefs + = (icl_decl_symbols,cdefs) +renumber_icl_definitions_without_functions_as_dcl_definitions (Yes icl_to_dcl_index_table) dcl_dictionary_info icl_decl_symbols cdefs # (icl_decl_symbols,cdefs) = renumber_icl_decl_symbols icl_decl_symbols cdefs - # (macro_and_function_local_defs,cdefs) = renumber_icl_decl_symbols macro_and_function_local_defs cdefs - # (dcl_mod,modules) = modules![main_dcl_module_n] - # {n_dictionary_types,n_dictionary_selectors,n_dictionary_constructors}=dcl_mod.dcl_dictionary_info + with + renumber_icl_decl_symbols [] cdefs + = ([],cdefs) + renumber_icl_decl_symbols [icl_decl_symbol : icl_decl_symbols] cdefs + # (icl_decl_symbol,cdefs) = renumber_icl_decl_symbol icl_decl_symbol cdefs + # (icl_decl_symbols,cdefs) = renumber_icl_decl_symbols icl_decl_symbols cdefs + = ([icl_decl_symbol : icl_decl_symbols],cdefs) + where + renumber_icl_decl_symbol (Declaration icl_decl_symbol=:{decl_kind = STE_Type, decl_index}) cdefs + # (type_def,cdefs) = cdefs!com_type_defs.[decl_index] + # type_def = renumber_type_def type_def + # cdefs={cdefs & com_type_defs.[decl_index]=type_def} + = (Declaration {icl_decl_symbol & decl_index=icl_to_dcl_index_table.[cTypeDefs,decl_index]},cdefs) + where + renumber_type_def td=:{td_rhs = AlgType conses} + # conses = [{cons & ds_index=icl_to_dcl_index_table.[cConstructorDefs,cons.ds_index]} \\ cons <- conses] + = { td & td_rhs = AlgType conses} + renumber_type_def td=:{td_rhs = RecordType rt=:{rt_constructor,rt_fields,rt_is_boxed_record}} + # rt_constructor = {rt_constructor & ds_index=icl_to_dcl_index_table.[cConstructorDefs,rt_constructor.ds_index]} + # rt_fields = {{field & fs_index=icl_to_dcl_index_table.[cSelectorDefs,field.fs_index]} \\ field <-: rt_fields} + = {td & td_rhs=RecordType {rt_constructor=rt_constructor,rt_fields=rt_fields,rt_is_boxed_record=rt_is_boxed_record}} + renumber_type_def td=:{td_rhs = NewType cons} + = { td & td_rhs = NewType {cons & ds_index=icl_to_dcl_index_table.[cConstructorDefs,cons.ds_index]} } + renumber_type_def td + = td + renumber_icl_decl_symbol (Declaration icl_decl_symbol=:{decl_kind = STE_TypeExtension, decl_index}) cdefs + # (type_def,cdefs) = cdefs!com_type_defs.[decl_index] + # type_def = renumber_type_extension_def type_def + # cdefs={cdefs & com_type_defs.[decl_index]=type_def} + = (Declaration {icl_decl_symbol & decl_index=icl_to_dcl_index_table.[cTypeDefs,decl_index]},cdefs) + where + renumber_type_extension_def td=:{td_rhs = UncheckedAlgConses type_ext_ident conses} + # conses = [{cons & ds_index=icl_to_dcl_index_table.[cConstructorDefs,cons.ds_index]} \\ cons <- conses] + = {td & td_rhs = UncheckedAlgConses type_ext_ident conses} + renumber_type_extension_def td=:{td_rhs = AlgConses conses type_ext_ident} + # conses = [{cons & ds_index=icl_to_dcl_index_table.[cConstructorDefs,cons.ds_index]} \\ cons <- conses] + = {td & td_rhs = AlgConses conses type_ext_ident} + renumber_type_extension_def td + = td + renumber_icl_decl_symbol (Declaration icl_decl_symbol=:{decl_kind = STE_Constructor, decl_index}) cdefs + = (Declaration {icl_decl_symbol & decl_index=icl_to_dcl_index_table.[cConstructorDefs,decl_index]},cdefs) + renumber_icl_decl_symbol (Declaration icl_decl_symbol=:{decl_kind = STE_Field _, decl_index}) cdefs + = (Declaration {icl_decl_symbol & decl_index=icl_to_dcl_index_table.[cSelectorDefs,decl_index]},cdefs) + renumber_icl_decl_symbol (Declaration icl_decl_symbol=:{decl_kind = STE_Member, decl_index}) cdefs + = (Declaration {icl_decl_symbol & decl_index=icl_to_dcl_index_table.[cMemberDefs,decl_index]},cdefs) + renumber_icl_decl_symbol (Declaration icl_decl_symbol=:{decl_kind = STE_Class, decl_index}) cdefs + # (class_def,cdefs) = cdefs!com_class_defs.[decl_index] + # class_members = {{class_member & ds_index=icl_to_dcl_index_table.[cMemberDefs,class_member.ds_index]} \\ class_member <-: class_def.class_members} + # class_def = {class_def & class_members=class_members} + # cdefs = {cdefs & com_class_defs.[decl_index] =class_def} + = (Declaration {icl_decl_symbol & decl_index=icl_to_dcl_index_table.[cClassDefs,decl_index]},cdefs) + renumber_icl_decl_symbol (Declaration icl_decl_symbol=:{decl_kind = STE_Instance, decl_index}) cdefs + = (Declaration {icl_decl_symbol & decl_index=icl_to_dcl_index_table.[cInstanceDefs,decl_index]},cdefs) + renumber_icl_decl_symbol (Declaration icl_decl_symbol=:{decl_kind = STE_Generic, decl_index}) cdefs + = (Declaration {icl_decl_symbol & decl_index=icl_to_dcl_index_table.[cGenericDefs,decl_index]},cdefs) + renumber_icl_decl_symbol (Declaration icl_decl_symbol=:{decl_kind = STE_GenericCase, decl_index}) cdefs + = (Declaration {icl_decl_symbol & decl_index=icl_to_dcl_index_table.[cGenericCaseDefs,decl_index]},cdefs) + renumber_icl_decl_symbol icl_decl_symbol cdefs + = (icl_decl_symbol,cdefs) + # {n_dictionary_types,n_dictionary_selectors,n_dictionary_constructors}=dcl_dictionary_info # cdefs=reorder_common_definitions cdefs with reorder_common_definitions {com_type_defs,com_cons_defs,com_selector_defs,com_class_defs,com_member_defs,com_instance_defs,com_generic_defs,com_gencase_defs} @@ -1166,94 +1203,49 @@ renumber_icl_definitions_as_dcl_definitions (Yes icl_to_dcl_index_table) icl_siz com_class_defs=com_class_defs,com_member_defs=com_member_defs,com_instance_defs=com_instance_defs, com_generic_defs=com_generic_defs,com_gencase_defs=com_gencase_defs } - # fun_defs = reorder_array fun_defs icl_to_dcl_index_table.[cFunctionDefs] - = (icl_decl_symbols,macro_and_function_local_defs,modules,cdefs,fun_defs) + = (icl_decl_symbols,cdefs) where - renumber_icl_decl_symbols [] cdefs - = ([],cdefs) - renumber_icl_decl_symbols [icl_decl_symbol : icl_decl_symbols] cdefs - # (icl_decl_symbol,cdefs) = renumber_icl_decl_symbol icl_decl_symbol cdefs - # (icl_decl_symbols,cdefs) = renumber_icl_decl_symbols icl_decl_symbols cdefs - = ([icl_decl_symbol : icl_decl_symbols],cdefs) - where - renumber_icl_decl_symbol (Declaration icl_decl_symbol=:{decl_kind = STE_Type, decl_index}) cdefs - # (type_def,cdefs) = cdefs!com_type_defs.[decl_index] - # type_def = renumber_type_def type_def - # cdefs={cdefs & com_type_defs.[decl_index]=type_def} - = (Declaration {icl_decl_symbol & decl_index=icl_to_dcl_index_table.[cTypeDefs,decl_index]},cdefs) - where - renumber_type_def td=:{td_rhs = AlgType conses} - # conses = [{cons & ds_index=icl_to_dcl_index_table.[cConstructorDefs,cons.ds_index]} \\ cons <- conses] - = { td & td_rhs = AlgType conses} - renumber_type_def td=:{td_rhs = RecordType rt=:{rt_constructor,rt_fields,rt_is_boxed_record}} - # rt_constructor = {rt_constructor & ds_index=icl_to_dcl_index_table.[cConstructorDefs,rt_constructor.ds_index]} - # rt_fields = {{field & fs_index=icl_to_dcl_index_table.[cSelectorDefs,field.fs_index]} \\ field <-: rt_fields} - = {td & td_rhs=RecordType {rt_constructor=rt_constructor,rt_fields=rt_fields,rt_is_boxed_record=rt_is_boxed_record}} - renumber_type_def td=:{td_rhs = NewType cons} - = { td & td_rhs = NewType {cons & ds_index=icl_to_dcl_index_table.[cConstructorDefs,cons.ds_index]} } - renumber_type_def td - = td - renumber_icl_decl_symbol (Declaration icl_decl_symbol=:{decl_kind = STE_TypeExtension, decl_index}) cdefs - # (type_def,cdefs) = cdefs!com_type_defs.[decl_index] - # type_def = renumber_type_extension_def type_def - # cdefs={cdefs & com_type_defs.[decl_index]=type_def} - = (Declaration {icl_decl_symbol & decl_index=icl_to_dcl_index_table.[cTypeDefs,decl_index]},cdefs) - where - renumber_type_extension_def td=:{td_rhs = UncheckedAlgConses type_ext_ident conses} - # conses = [{cons & ds_index=icl_to_dcl_index_table.[cConstructorDefs,cons.ds_index]} \\ cons <- conses] - = {td & td_rhs = UncheckedAlgConses type_ext_ident conses} - renumber_type_extension_def td=:{td_rhs = AlgConses conses type_ext_ident} - # conses = [{cons & ds_index=icl_to_dcl_index_table.[cConstructorDefs,cons.ds_index]} \\ cons <- conses] - = {td & td_rhs = AlgConses conses type_ext_ident} - renumber_type_extension_def td - = td - renumber_icl_decl_symbol (Declaration icl_decl_symbol=:{decl_kind = STE_Constructor, decl_index}) cdefs - = (Declaration {icl_decl_symbol & decl_index=icl_to_dcl_index_table.[cConstructorDefs,decl_index]},cdefs) - renumber_icl_decl_symbol (Declaration icl_decl_symbol=:{decl_kind = STE_Field _, decl_index}) cdefs - = (Declaration {icl_decl_symbol & decl_index=icl_to_dcl_index_table.[cSelectorDefs,decl_index]},cdefs) - renumber_icl_decl_symbol (Declaration icl_decl_symbol=:{decl_kind = STE_Member, decl_index}) cdefs - = (Declaration {icl_decl_symbol & decl_index=icl_to_dcl_index_table.[cMemberDefs,decl_index]},cdefs) - renumber_icl_decl_symbol (Declaration icl_decl_symbol=:{decl_kind = STE_Class, decl_index}) cdefs - # (class_def,cdefs) = cdefs!com_class_defs.[decl_index] - # class_members = {{class_member & ds_index=icl_to_dcl_index_table.[cMemberDefs,class_member.ds_index]} \\ class_member <-: class_def.class_members} - # class_def = {class_def & class_members=class_members} - # cdefs = {cdefs & com_class_defs.[decl_index] =class_def} - = (Declaration {icl_decl_symbol & decl_index=icl_to_dcl_index_table.[cClassDefs,decl_index]},cdefs) - renumber_icl_decl_symbol (Declaration icl_decl_symbol=:{decl_kind = STE_Instance, decl_index}) cdefs - = (Declaration {icl_decl_symbol & decl_index=icl_to_dcl_index_table.[cInstanceDefs,decl_index]},cdefs) - renumber_icl_decl_symbol (Declaration icl_decl_symbol=:{decl_kind = STE_Generic, decl_index}) cdefs - = (Declaration {icl_decl_symbol & decl_index=icl_to_dcl_index_table.[cGenericDefs,decl_index]},cdefs) - renumber_icl_decl_symbol (Declaration icl_decl_symbol=:{decl_kind = STE_GenericCase, decl_index}) cdefs - = (Declaration {icl_decl_symbol & decl_index=icl_to_dcl_index_table.[cGenericCaseDefs,decl_index]},cdefs) - renumber_icl_decl_symbol icl_decl=:(Declaration icl_decl_symbol=:{decl_kind=STE_FunctionOrMacro _, decl_index}) cdefs -// | decl_index>=icl_global_function_range.ir_from && decl_index<icl_global_function_range.ir_to - = (Declaration {icl_decl_symbol & decl_index=icl_to_dcl_index_table.[cFunctionDefs,decl_index]},cdefs) -// = (icl_decl,cdefs) - renumber_icl_decl_symbol icl_decl_symbol cdefs - = (icl_decl_symbol,cdefs) - - reorder_array array index_array - # new_array={e\\e<-:array} - = {new_array & [index_array.[i]]=e \\ e<-:array & i<-[0..]} - reorder_and_enlarge_array array n_extra_elements index_array dummy_element # new_array=createArray (size array+n_extra_elements) dummy_element = {new_array & [index_array.[i]] = e \\ e<-:array & i<-[0..]} -combineDclAndIclModule :: ModuleKind IndexRange *{#DclModule} [Declaration] [Declaration] (CollectedDefinitions a) *{#Int} *CheckState - -> (!CopiedDefinitions,!Optional {#{#Int}},!*{#DclModule},![Declaration],![Declaration],!CollectedDefinitions a, !*{#Int}, !*CheckState); -combineDclAndIclModule MK_Main icl_macro_indices modules icl_decl_symbols macro_and_function_local_defs icl_definitions icl_sizes cs - = ({ copied_type_defs = {}, copied_class_defs = {}, copied_generic_defs = {}}, No, modules, icl_decl_symbols, macro_and_function_local_defs, icl_definitions, icl_sizes, cs) -combineDclAndIclModule _ icl_macro_indices modules icl_decl_symbols macro_and_function_local_defs icl_definitions icl_sizes cs +renumber_icl_function_definitions_as_dcl_definitions :: !(Optional {#Int}) ![Declaration] !*{#FunDef} -> (![Declaration],!*{#FunDef}) +renumber_icl_function_definitions_as_dcl_definitions No icl_decl_symbols fun_defs + = (icl_decl_symbols,fun_defs) +renumber_icl_function_definitions_as_dcl_definitions (Yes icl_to_dcl_index_table_for_functions) icl_decl_symbols fun_defs + # icl_decl_symbols = renumber_icl_decl_symbols icl_decl_symbols + with + renumber_icl_decl_symbols [] + = [] + renumber_icl_decl_symbols [icl_decl_symbol : icl_decl_symbols] + # icl_decl_symbol = renumber_icl_decl_symbol icl_decl_symbol + # icl_decl_symbols = renumber_icl_decl_symbols icl_decl_symbols + = [icl_decl_symbol : icl_decl_symbols] + where + renumber_icl_decl_symbol icl_decl=:(Declaration icl_decl_symbol=:{decl_kind=STE_FunctionOrMacro _, decl_index}) + = Declaration {icl_decl_symbol & decl_index=icl_to_dcl_index_table_for_functions.[decl_index]} + renumber_icl_decl_symbol icl_decl_symbol + = icl_decl_symbol + # fun_defs = reorder_array fun_defs icl_to_dcl_index_table_for_functions + = (icl_decl_symbols,fun_defs) + +reorder_array array index_array + # new_array={e\\e<-:array} + = {new_array & [index_array.[i]]=e \\ e<-:array & i<-[0..]} + +combineDclAndIclModule :: ModuleKind *{#DclModule} [Declaration] (CollectedDefinitions a) *{#Int} *CheckState + -> (!CopiedDefinitions,!*Optional *{#*{#Int}},!*{#DclModule},![Declaration],!CollectedDefinitions a, !*{#Int}, !*CheckState); +combineDclAndIclModule MK_Main modules icl_decl_symbols icl_definitions icl_sizes cs + = ({ copied_type_defs = {}, copied_class_defs = {}, copied_generic_defs = {}}, No, modules, icl_decl_symbols, icl_definitions, icl_sizes, cs) +combineDclAndIclModule _ modules icl_decl_symbols icl_definitions icl_sizes cs #! main_dcl_module_n=cs.cs_x.x_main_dcl_module_n - # ({dcl_declared={dcls_local},dcl_macros, dcl_sizes, dcl_common}, modules) = modules![main_dcl_module_n] + # ({dcl_declared={dcls_local}, dcl_sizes, dcl_common}, modules) = modules![main_dcl_module_n] cs = addGlobalDefinitionsToSymbolTable icl_decl_symbols cs - cs = addGlobalDefinitionsToSymbolTable macro_and_function_local_defs cs - (moved_dcl_defs,dcl_cons_and_member_defs,conversion_table,icl_sizes,icl_decl_symbols,macro_and_function_local_defs,cs) - = foldSt (add_to_conversion_table icl_macro_indices dcl_macros.ir_from dcl_common) dcls_local - ([],[],{createArray size NoIndex \\ size <-: dcl_sizes}, icl_sizes, icl_decl_symbols, macro_and_function_local_defs, cs) + conversion_table = { createArray size NoIndex \\ size <-: dcl_sizes } + (moved_dcl_defs,dcl_cons_and_member_defs,conversion_table, icl_sizes, icl_decl_symbols, cs) + = foldSt (add_to_conversion_table dcl_common) dcls_local ([],[], conversion_table, icl_sizes, icl_decl_symbols, cs) (new_type_defs, new_class_defs, new_cons_defs, new_selector_defs, new_member_defs, new_generic_defs, (cop_td_indexes, cop_cd_indexes, cop_gd_indexes), conversion_table, icl_sizes, icl_decl_symbols, cs) = foldSt (add_dcl_definition dcl_common) moved_dcl_defs ([], [], [], [], [], [], ([], [],[]), conversion_table, icl_sizes, icl_decl_symbols, cs) (new_cons_defs,new_member_defs,conversion_table,icl_sizes,icl_decl_symbols,symbol_table,errors) @@ -1263,7 +1255,6 @@ combineDclAndIclModule _ icl_macro_indices modules icl_decl_symbols macro_and_fu new_member_defs = reverse new_member_defs symbol_table = removeDeclarationsFromSymbolTable icl_decl_symbols cGlobalScope symbol_table - symbol_table = removeDeclarationsFromSymbolTable macro_and_function_local_defs cGlobalScope symbol_table # n_dcl_classes = dcl_sizes.[cClassDefs] n_dcl_types = dcl_sizes.[cTypeDefs] @@ -1277,7 +1268,7 @@ combineDclAndIclModule _ icl_macro_indices modules icl_decl_symbols macro_and_fu } , Yes conversion_table , {modules & [main_dcl_module_n].dcl_has_macro_conversions = True} - , icl_decl_symbols, macro_and_function_local_defs + , icl_decl_symbols , { icl_definitions & def_types = my_append icl_definitions.def_types new_type_defs , def_constructors = my_append icl_definitions.def_constructors new_cons_defs @@ -1297,43 +1288,31 @@ where where mark_def index marks = { marks & [index] = True } - add_to_conversion_table icl_macro_indices first_macro_index dcl_common - decl=:(Declaration {decl_ident=decl_ident=:{id_info},decl_kind,decl_index,decl_pos}) - (moved_dcl_defs,dcl_cons_and_member_defs,conversion_table,icl_sizes,icl_defs,macro_and_function_local_defs,cs) + add_to_conversion_table dcl_common (Declaration {decl_kind=STE_DclFunction}) + (moved_dcl_defs, dcl_cons_and_member_defs, conversion_table, icl_sizes, icl_defs, cs) + = (moved_dcl_defs, dcl_cons_and_member_defs, conversion_table, icl_sizes, icl_defs, cs) + add_to_conversion_table dcl_common (Declaration {decl_kind=STE_DclMacroOrLocalMacroFunction _}) + (moved_dcl_defs, dcl_cons_and_member_defs, conversion_table, icl_sizes, icl_defs, cs) + = (moved_dcl_defs, dcl_cons_and_member_defs, conversion_table, icl_sizes, icl_defs, cs) + add_to_conversion_table dcl_common decl=:(Declaration {decl_ident=decl_ident=:{id_info},decl_kind,decl_index,decl_pos}) + (moved_dcl_defs,dcl_cons_and_member_defs, conversion_table, icl_sizes, icl_defs, cs) # (entry=:{ste_kind,ste_index,ste_def_level}, cs_symbol_table) = readPtr id_info cs.cs_symbol_table | ste_kind == STE_Empty # def_index = toInt decl_kind | def_index == cConstructorDefs || def_index == cMemberDefs - = (moved_dcl_defs,[decl:dcl_cons_and_member_defs],conversion_table,icl_sizes,icl_defs,macro_and_function_local_defs,{cs & cs_symbol_table = cs_symbol_table}) + = (moved_dcl_defs,[decl:dcl_cons_and_member_defs],conversion_table, icl_sizes, icl_defs, { cs & cs_symbol_table = cs_symbol_table }) | can_be_only_in_dcl def_index && not (def_index==cTypeDefs && is_abstract_type dcl_common.com_type_defs decl_index) # (conversion_table, icl_sizes, icl_defs, cs_symbol_table) = add_dcl_declaration id_info entry decl def_index decl_index (conversion_table, icl_sizes, icl_defs, cs_symbol_table) - = ([decl : moved_dcl_defs],dcl_cons_and_member_defs,conversion_table,icl_sizes,icl_defs,macro_and_function_local_defs,{cs & cs_symbol_table = cs_symbol_table}) - | def_index == cMacroDefs - # (conversion_table, macro_and_function_local_defs, cs_symbol_table) - = add_macro_declaration id_info entry decl (decl_index - first_macro_index) (conversion_table, macro_and_function_local_defs, cs_symbol_table) - = (moved_dcl_defs,dcl_cons_and_member_defs,conversion_table,icl_sizes,icl_defs,macro_and_function_local_defs,{cs & cs_symbol_table = cs_symbol_table}) + = ([ decl : moved_dcl_defs ],dcl_cons_and_member_defs,conversion_table, icl_sizes, icl_defs, { cs & cs_symbol_table = cs_symbol_table }) # cs_error = checkError "undefined in implementation module" "" (setErrorAdmin (newPosition decl_ident decl_pos) cs.cs_error) - = (moved_dcl_defs,dcl_cons_and_member_defs,conversion_table,icl_sizes,icl_defs,macro_and_function_local_defs,{cs & cs_error = cs_error, cs_symbol_table = cs_symbol_table}) - | ste_def_level == cGlobalScope - = case (ste_kind,decl_kind) of - (STE_FunctionOrMacro _,STE_DclFunction) - | ste_index>=icl_macro_indices.ir_from && ste_index<icl_macro_indices.ir_to - # cs = {cs & cs_symbol_table = cs_symbol_table} - -> conflictingind_definition decl_ident decl_pos moved_dcl_defs dcl_cons_and_member_defs conversion_table icl_sizes icl_defs macro_and_function_local_defs cs - _ - | ste_kind == decl_kind - # def_index = toInt decl_kind - # decl_index = if (def_index == cMacroDefs) (decl_index - first_macro_index) decl_index - -> (moved_dcl_defs,dcl_cons_and_member_defs,{conversion_table & [def_index].[decl_index] = ste_index},icl_sizes,icl_defs,macro_and_function_local_defs,{cs & cs_symbol_table = cs_symbol_table}) - # cs = {cs & cs_symbol_table = cs_symbol_table} - -> conflictingind_definition decl_ident decl_pos moved_dcl_defs dcl_cons_and_member_defs conversion_table icl_sizes icl_defs macro_and_function_local_defs cs - # cs = {cs & cs_symbol_table = cs_symbol_table} - = conflictingind_definition decl_ident decl_pos moved_dcl_defs dcl_cons_and_member_defs conversion_table icl_sizes icl_defs macro_and_function_local_defs cs - - conflictingind_definition decl_ident decl_pos moved_dcl_defs dcl_cons_and_member_defs conversion_table icl_sizes icl_defs macro_and_function_local_defs cs - # cs_error = checkError "conflicting definition in implementation module" "" (setErrorAdmin (newPosition decl_ident decl_pos) cs.cs_error) - = (moved_dcl_defs,dcl_cons_and_member_defs,conversion_table,icl_sizes,icl_defs,macro_and_function_local_defs,{cs & cs_error = cs_error}) + = (moved_dcl_defs,dcl_cons_and_member_defs,conversion_table, icl_sizes, icl_defs, { cs & cs_error = cs_error, cs_symbol_table = cs_symbol_table }) + | ste_def_level == cGlobalScope && ste_kind == decl_kind + # def_index = toInt decl_kind + conversion_table = {conversion_table & [def_index].[decl_index] = ste_index} + = (moved_dcl_defs,dcl_cons_and_member_defs, conversion_table, icl_sizes, icl_defs, { cs & cs_symbol_table = cs_symbol_table }) + # cs_error = checkError "conflicting definition in implementation module" "" (setErrorAdmin (newPosition decl_ident decl_pos) cs.cs_error) + = (moved_dcl_defs,dcl_cons_and_member_defs,conversion_table, icl_sizes, icl_defs, { cs & cs_error = cs_error, cs_symbol_table = cs_symbol_table }) can_be_only_in_dcl def_kind = def_kind == cTypeDefs || def_kind == cSelectorDefs || def_kind == cClassDefs || def_kind == cGenericDefs @@ -1349,12 +1328,6 @@ where , NewEntry symbol_table info_ptr dcl.decl_kind icl_index cGlobalScope entry ) - add_macro_declaration info_ptr entry decl=:(Declaration dcl) decl_index (conversion_table, icl_defs, symbol_table) - = ( { conversion_table & [cMacroDefs].[decl_index] = -1 } - , [ decl : icl_defs ] - , NewEntry symbol_table info_ptr dcl.decl_kind dcl.decl_index cGlobalScope entry - ) - add_dcl_definition {com_type_defs,com_cons_defs} dcl=:(Declaration {decl_kind = STE_Type, decl_index}) (new_type_defs, new_class_defs, new_cons_defs, new_selector_defs, new_member_defs, new_generic_defs, (cop_td_indexes, cop_cd_indexes, cop_gd_indexes), conversion_table, icl_sizes, icl_decl_symbols, cs) # type_def = com_type_defs.[decl_index] @@ -1488,6 +1461,67 @@ where my_append front back = front ++ back +make_dcl_macro_and_function_conversions :: !ModuleKind ![Declaration] !Int !Int !Int !IndexRange [Declaration] *CheckState + -> (!Optional {#Int},!{#Int},![Declaration],!*CheckState); +make_dcl_macro_and_function_conversions MK_Main main_dcls_local n_dcl_functions n_dcl_macros first_dcl_macro_index icl_macro_indices macro_and_function_local_defs cs + = (No, {}, macro_and_function_local_defs, cs) +make_dcl_macro_and_function_conversions _ main_dcls_local n_dcl_functions n_dcl_macros first_dcl_macro_index icl_macro_indices macro_and_function_local_defs cs + # cs = addGlobalDefinitionsToSymbolTable macro_and_function_local_defs cs + + function_conversion_table = createArray n_dcl_functions NoIndex + macro_conversion_table = createArray n_dcl_macros NoIndex + + (function_conversion_table,macro_conversion_table,macro_and_function_local_defs,cs) + = foldSt (add_to_conversion_table first_dcl_macro_index) main_dcls_local (function_conversion_table,macro_conversion_table,macro_and_function_local_defs,cs) + + symbol_table = removeDeclarationsFromSymbolTable macro_and_function_local_defs cGlobalScope cs.cs_symbol_table + + = (Yes macro_conversion_table, function_conversion_table, macro_and_function_local_defs, {cs & cs_symbol_table = symbol_table}) +where + add_to_conversion_table first_macro_index decl=:(Declaration {decl_kind=STE_DclFunction,decl_ident=decl_ident=:{id_info},decl_index,decl_pos}) + (function_conversion_table,macro_conversion_table,icl_defs,cs) + # (entry=:{ste_kind,ste_index,ste_def_level}, cs_symbol_table) = readPtr id_info cs.cs_symbol_table + | ste_kind == STE_Empty + # cs_error = checkError "undefined in implementation module" "" (setErrorAdmin (newPosition decl_ident decl_pos) cs.cs_error) + = (function_conversion_table,macro_conversion_table,icl_defs,{cs & cs_error = cs_error, cs_symbol_table = cs_symbol_table}) + | ste_def_level == cGlobalScope && case ste_kind of + STE_FunctionOrMacro _ + | ste_index>=icl_macro_indices.ir_from && ste_index<icl_macro_indices.ir_to + -> False + -> True + _ -> False + # function_conversion_table = {function_conversion_table & [decl_index] = ste_index} + = (function_conversion_table,macro_conversion_table,icl_defs,{cs & cs_symbol_table = cs_symbol_table}) + # cs_error = checkError "conflicting definition in implementation module" "" (setErrorAdmin (newPosition decl_ident decl_pos) cs.cs_error) + = (function_conversion_table,macro_conversion_table,icl_defs,{cs & cs_error = cs_error, cs_symbol_table = cs_symbol_table}) + add_to_conversion_table first_macro_index decl=:(Declaration {decl_kind=decl_kind=:STE_DclMacroOrLocalMacroFunction _,decl_ident=decl_ident=:{id_info},decl_index,decl_pos}) + (function_conversion_table,macro_conversion_table,icl_defs,cs) + # (entry=:{ste_kind,ste_index,ste_def_level}, cs_symbol_table) = readPtr id_info cs.cs_symbol_table + | ste_kind == STE_Empty + || + ste_def_level == cModuleScope && case ste_kind of + STE_Imported (STE_DclMacroOrLocalMacroFunction _) module_n + -> module_n==cs.cs_x.x_main_dcl_module_n // possible if dcl module on a cycle + _ -> + False + + # (macro_conversion_table,icl_defs,cs_symbol_table) + = add_macro_declaration id_info entry decl (decl_index - first_macro_index) (macro_conversion_table,icl_defs,cs_symbol_table) + = (function_conversion_table,macro_conversion_table,icl_defs,{cs & cs_symbol_table = cs_symbol_table}) + | ste_def_level == cGlobalScope && ste_kind == decl_kind + # macro_conversion_table = {macro_conversion_table & [decl_index - first_macro_index] = ste_index} + = (function_conversion_table,macro_conversion_table,icl_defs,{cs & cs_symbol_table = cs_symbol_table}) + # cs_error = checkError "conflicting definition in implementation module" "" (setErrorAdmin (newPosition decl_ident decl_pos) cs.cs_error) + = (function_conversion_table,macro_conversion_table,icl_defs,{cs & cs_error = cs_error, cs_symbol_table = cs_symbol_table}) + add_to_conversion_table first_macro_index decl (function_conversion_table,macro_conversion_table,icl_defs,cs) + = (function_conversion_table,macro_conversion_table,icl_defs,cs) + + add_macro_declaration info_ptr entry decl=:(Declaration dcl) decl_index (macro_conversion_table, icl_defs, symbol_table) + = ( { macro_conversion_table & [decl_index] = -1 } + , [ decl : icl_defs ] + , NewEntry symbol_table info_ptr dcl.decl_kind dcl.decl_index cGlobalScope entry + ) + replace_icl_macros_by_dcl_macros :: ModuleKind IndexRange (Optional {#Int}) [Declaration] *{#DclModule} *CheckState -> (![Declaration],!*{#DclModule},!*CheckState); replace_icl_macros_by_dcl_macros MK_Main icl_macro_index_range optional_macro_conversions decls dcl_modules cs = (decls,dcl_modules,cs) @@ -1844,51 +1878,63 @@ checkDclModuleWithinComponent dcl_imported_module_numbers component_nr is_on_cyc = checkDclModule2 dcl_imported_module_numbers components_importing_module_a.[mod_index] imports_ikh component_nr is_on_cycle modules_in_component_set False mod_ident dcl_common def_macro_indices def_funtypes ste_index expl_imp_infos dcl_modules macro_defs heaps cs -renumber_icl_module :: ModuleKind IndexRange IndexRange IndexRange IndexRange Index Int {#Int} (Optional {#{#Int}}) IndexRange - *{#FunDef} *CommonDefs [Declaration] [Declaration] *{#DclModule} *ErrorAdmin - -> (![IndexRange],![IndexRange],![IndexRange], ![IndexRange], !Int,!Index,!IndexRange,Optional {#Index}, - !*{#FunDef},!*CommonDefs,![Declaration],![Declaration],!*{#DclModule}, *ErrorAdmin); -renumber_icl_module mod_type icl_global_function_range icl_instance_range icl_generic_range icl_type_fun_range nr_of_functions main_dcl_module_n icl_sizes dcl_conversions def_macro_indices - icl_functions icl_common local_defs macro_and_function_local_defs dcl_modules error - # (optional_icl_to_dcl_index_table,optional_macro_conversions,optional_old_conversion_table,dcl_modules,icl_functions) - = create_icl_to_dcl_index_table mod_type icl_sizes main_dcl_module_n dcl_conversions dcl_modules icl_functions +renumber_icl_common_defs :: ModuleKind Index {#Int} (Optional {#{#Int}}) *CommonDefs [Declaration] *{#DclModule} + -> (!*CommonDefs,![Declaration],!*{#DclModule}) +renumber_icl_common_defs mod_type main_dcl_module_n icl_sizes dcl_conversions icl_common local_defs dcl_modules + # (optional_icl_to_dcl_index_table,dcl_modules) + = create_icl_to_dcl_index_table_except_functions mod_type icl_sizes main_dcl_module_n dcl_conversions dcl_modules # (dcl_mod, dcl_modules) = dcl_modules![main_dcl_module_n] - # icl_functions = add_dummy_specialized_functions mod_type dcl_mod.dcl_specials icl_functions + # (local_defs,icl_common) + = renumber_icl_definitions_without_functions_as_dcl_definitions optional_icl_to_dcl_index_table dcl_mod.dcl_dictionary_info local_defs icl_common + = (icl_common,local_defs,dcl_modules) + +renumber_icl_module_functions :: ModuleKind IndexRange IndexRange IndexRange IndexRange Int !{#Int} !Int !Int IndexRange DclModule + !(Optional {#Index}) *{#FunDef} *CommonDefs [Declaration] *ErrorAdmin + -> (![IndexRange],![IndexRange],![IndexRange],![IndexRange],!Int,!Index,!IndexRange, + Optional {#Index},!*{#FunDef},!*CommonDefs,![Declaration], *ErrorAdmin) +renumber_icl_module_functions mod_type icl_global_function_range icl_instance_range icl_generic_range icl_type_fun_range nr_of_functions + dcl_function_table instances_conversion_table_size gencase_conversion_table_size def_macro_indices dcl_mod + optional_macro_conversions icl_functions icl_common macro_and_function_local_defs error + #! dcl_specials = dcl_mod.dcl_specials + # icl_functions = add_dummy_specialized_functions mod_type dcl_specials icl_functions # class_instances = icl_common.com_instance_defs # gencase_defs = icl_common.com_gencase_defs # type_defs = icl_common.com_type_defs + + # n_dcl_specials = dcl_specials.ir_to-dcl_specials.ir_from + dcl_type_funs = dcl_mod.dcl_type_funs + n_dcl_type_funs = dcl_type_funs.ir_to-dcl_type_funs.ir_from + not_exported_generic_range_to = icl_generic_range.ir_to + n_dcl_specials + n_dcl_type_funs + n_not_exported_type_funs = (icl_type_fun_range.ir_to - icl_type_fun_range.ir_from) - n_dcl_type_funs + not_exported_type_fun_range = { ir_from = not_exported_generic_range_to + , ir_to = not_exported_generic_range_to + n_not_exported_type_funs + } + # (dcl_icl_conversions, class_instances, gencase_defs, type_defs, error) - = add_dcl_instances_to_conversion_table - optional_old_conversion_table nr_of_functions dcl_mod class_instances gencase_defs type_defs error + = add_dcl_instances_generic_cases_and_type_funs_to_conversion_table dcl_function_table instances_conversion_table_size gencase_conversion_table_size + nr_of_functions icl_type_fun_range /*not_exported_type_fun_range*/ dcl_mod class_instances gencase_defs type_defs error | not error.ea_ok = ([],[],[],[], 0,0,def_macro_indices,optional_macro_conversions,icl_functions, {icl_common & com_instance_defs=class_instances, com_gencase_defs=gencase_defs, com_type_defs=type_defs}, - local_defs,macro_and_function_local_defs,dcl_modules,error) + macro_and_function_local_defs,error) # (n_functions,icl_functions) = usize icl_functions - # optional_icl_to_dcl_index_table = recompute_icl_to_dcl_index_table_for_functions optional_icl_to_dcl_index_table dcl_icl_conversions n_functions - # class_instances = renumber_member_indexes_of_class_instances optional_icl_to_dcl_index_table class_instances - # gencase_defs = renumber_members_of_gencases optional_icl_to_dcl_index_table gencase_defs - # type_defs = renumber_type_fun_indices optional_icl_to_dcl_index_table type_defs + # optional_icl_to_dcl_index_table_for_functions = compute_icl_to_dcl_index_table_for_functions dcl_icl_conversions n_functions + # class_instances = renumber_member_indexes_of_class_instances optional_icl_to_dcl_index_table_for_functions class_instances + # gencase_defs = renumber_members_of_gencases optional_icl_to_dcl_index_table_for_functions gencase_defs # icl_common = {icl_common & com_instance_defs = class_instances, com_gencase_defs = gencase_defs, com_type_defs = type_defs} - # (local_defs,macro_and_function_local_defs,dcl_modules,icl_common,icl_functions) - = renumber_icl_definitions_as_dcl_definitions optional_icl_to_dcl_index_table icl_sizes icl_global_function_range main_dcl_module_n local_defs macro_and_function_local_defs dcl_modules icl_common icl_functions - # (dcl_mod, dcl_modules) = dcl_modules![main_dcl_module_n] + # (macro_and_function_local_defs,icl_functions) + = renumber_icl_function_definitions_as_dcl_definitions optional_icl_to_dcl_index_table_for_functions macro_and_function_local_defs icl_functions #! dcl_instances = dcl_mod.dcl_instances #! n_exported_global_functions=dcl_mod.dcl_sizes.[cFunctionDefs] #! first_not_exported_global_function_index = size dcl_mod.dcl_functions # n_dcl_instances = dcl_instances.ir_to-dcl_instances.ir_from - #! dcl_specials = dcl_mod.dcl_specials - # n_dcl_specials = dcl_specials.ir_to-dcl_specials.ir_from # dcl_gencases = dcl_mod.dcl_gencases # n_dcl_gencases = dcl_gencases.ir_to-dcl_gencases.ir_from - # dcl_type_funs = dcl_mod.dcl_type_funs - # n_dcl_type_funs = dcl_type_funs.ir_to-dcl_type_funs.ir_from - # local_functions_index_offset = n_dcl_instances + n_dcl_gencases + n_dcl_specials + n_dcl_type_funs # optional_macro_conversions @@ -1918,17 +1964,10 @@ renumber_icl_module mod_type icl_global_function_range icl_instance_range icl_ge # not_exported_generic_range = { ir_from = icl_generic_range.ir_from + n_dcl_specials_and_gencases + n_dcl_type_funs - , ir_to = icl_generic_range.ir_to + n_dcl_specials + n_dcl_type_funs + , ir_to = not_exported_generic_range_to } # icl_generic_ranges = [dcl_gencases, not_exported_generic_range] - # n_not_exported_type_funs - = (icl_type_fun_range.ir_to - icl_type_fun_range.ir_from) - n_dcl_type_funs - # not_exported_type_fun_range = - { ir_from = not_exported_generic_range.ir_to - , ir_to = not_exported_generic_range.ir_to + n_not_exported_type_funs - } - # icl_type_fun_ranges = [dcl_type_funs, not_exported_type_fun_range] # dcl_global = {ir_from=icl_global_function_range.ir_from,ir_to=n_exported_global_functions} @@ -1939,7 +1978,7 @@ renumber_icl_module mod_type icl_global_function_range icl_instance_range icl_ge [icl_global, not_exported_instance_range, not_exported_generic_range] = (icl_global_functions_ranges, icl_instances_ranges, icl_generic_ranges, icl_type_fun_ranges, n_exported_global_functions,local_functions_index_offset,def_macro_indices, - optional_macro_conversions,icl_functions,icl_common,local_defs,macro_and_function_local_defs,dcl_modules,error) + optional_macro_conversions,icl_functions,icl_common,macro_and_function_local_defs,error) where add_dummy_specialized_functions MK_Main dcl_mod icl_functions = icl_functions @@ -1950,47 +1989,45 @@ renumber_icl_module mod_type icl_global_function_range icl_instance_range icl_ge # dummy_function = {fun_ident={id_name="",id_info=nilPtr},fun_arity= -1,fun_priority=NoPrio,fun_body=NoBody,fun_type=No,fun_pos=NoPos,fun_kind=FK_Unknown,fun_lifted=0,fun_info=EmptyFunInfo} = arrayPlusList icl_functions [dummy_function \\ i<-[0..n_specials-1]] - add_dcl_instances_to_conversion_table :: (Optional {#{#Int}}) !Index !DclModule !*{# ClassInstance} !*{# GenericCaseDef} !*{# CheckedTypeDef} *ErrorAdmin - -> (!*Optional *{#Index},!*{# ClassInstance}, !*{# GenericCaseDef}, !*{# CheckedTypeDef},*ErrorAdmin) - add_dcl_instances_to_conversion_table optional_old_conversion_table first_free_index - {dcl_specials,dcl_functions,dcl_common,dcl_has_macro_conversions,dcl_type_funs} + add_dcl_instances_generic_cases_and_type_funs_to_conversion_table :: !{#Int} !Int !Int !Index IndexRange /*IndexRange*/ !DclModule + !*{# ClassInstance} !*{# GenericCaseDef} !*{# CheckedTypeDef} *ErrorAdmin + -> (!*Optional *{#Index},!*{# ClassInstance},!*{# GenericCaseDef},!*{# CheckedTypeDef},*ErrorAdmin) + add_dcl_instances_generic_cases_and_type_funs_to_conversion_table + dcl_function_table instances_conversion_table_size gencase_conversion_table_size first_free_index icl_type_fun_range /*not_exported_type_fun_range*/ + dcl_mod=:{dcl_specials,dcl_functions,dcl_common,dcl_has_macro_conversions,dcl_type_funs} icl_instances icl_gencases icl_type_defs error | dcl_has_macro_conversions # (new_conversion_table, icl_instances, icl_gencases, icl_type_defs, error) - = build_conversion_table_for_instances_of_dcl_mod dcl_specials first_free_index optional_old_conversion_table + = build_conversion_table_for_instances_generic_cases_and_type_funs_of_dcl_mod dcl_specials first_free_index + dcl_function_table instances_conversion_table_size gencase_conversion_table_size dcl_functions dcl_common.com_instance_defs icl_instances dcl_common.com_gencase_defs icl_gencases dcl_common.com_type_defs icl_type_defs error = (Yes new_conversion_table,icl_instances, icl_gencases, icl_type_defs, error) = (No, icl_instances, icl_gencases, icl_type_defs, error) where - build_conversion_table_for_instances_of_dcl_mod dcl_specials=:{ir_from,ir_to} first_free_index optional_old_conversion_table dcl_functions - dcl_instances icl_instances dcl_gencases icl_gencases dcl_types icl_type_defs error + build_conversion_table_for_instances_generic_cases_and_type_funs_of_dcl_mod dcl_specials=:{ir_from,ir_to} first_free_index + dcl_function_table instances_conversion_table_size gencase_conversion_table_size + dcl_functions dcl_instances icl_instances dcl_gencases icl_gencases dcl_types icl_type_defs error #! nr_of_dcl_functions = size dcl_functions - # (Yes old_conversion_table) = optional_old_conversion_table - #! dcl_instances_table = old_conversion_table.[cInstanceDefs] - #! dcl_gencase_table = old_conversion_table.[cGenericCaseDefs] - #! dcl_function_table = old_conversion_table.[cFunctionDefs] - #! dcl_type_table = old_conversion_table.[cTypeDefs] #! new_table = { createArray nr_of_dcl_functions NoIndex & [i] = icl_index \\ icl_index <-: dcl_function_table & i <- [0..] } #! index_diff = first_free_index - ir_from #! new_table = { new_table & [i] = i + index_diff \\ i <- [ir_from .. ir_to - 1] } #! (new_table, icl_instances, error) - = build_conversion_table_for_instances 0 dcl_instances dcl_instances_table icl_instances new_table error + = build_conversion_table_for_instances 0 dcl_instances instances_conversion_table_size icl_instances new_table error #! (new_table, icl_gencases, error) - = build_conversion_table_for_generic_cases 0 dcl_gencases dcl_gencase_table icl_gencases new_table error - #! (new_table, icl_type_defs) - = fill_conversion_table_for_type_funs 0 dcl_types icl_type_defs dcl_type_table new_table + = build_conversion_table_for_generic_cases 0 dcl_gencases gencase_conversion_table_size icl_gencases new_table error + #! new_table = fill_conversion_table_for_type_funs icl_type_fun_range dcl_type_funs new_table = (new_table, icl_instances, icl_gencases, icl_type_defs, error) - build_conversion_table_for_generic_cases dcl_index dcl_gencases gencase_table icl_gencases new_table error - | dcl_index < size gencase_table + build_conversion_table_for_generic_cases dcl_index gencase_table gencase_conversion_table_size icl_gencases new_table error + | dcl_index < gencase_conversion_table_size #! (new_table, icl_gencases, error) - = build_conversion_table_for_generic_case dcl_index dcl_gencases gencase_table icl_gencases new_table error - = build_conversion_table_for_generic_cases (inc dcl_index) dcl_gencases gencase_table icl_gencases new_table error - = (new_table, icl_gencases, error) + = build_conversion_table_for_generic_case dcl_index gencase_table icl_gencases new_table error + = build_conversion_table_for_generic_cases (inc dcl_index) gencase_table gencase_conversion_table_size icl_gencases new_table error + = (new_table, icl_gencases, error) - build_conversion_table_for_generic_case dcl_index dcl_gencases gencase_table icl_gencases new_table error - #! icl_index = gencase_table.[dcl_index] + build_conversion_table_for_generic_case dcl_index dcl_gencases icl_gencases new_table error + #! icl_index = dcl_index #! (icl_gencase, icl_gencases) = icl_gencases ! [icl_index] #! dcl_gencase = dcl_gencases.[dcl_index] # (GCB_FunIndex icl_fun) = icl_gencase.gc_body @@ -1998,17 +2035,17 @@ renumber_icl_module mod_type icl_global_function_range icl_instance_range icl_ge #! new_table = { new_table & [dcl_fun] = icl_fun } = (new_table, icl_gencases, error) - build_conversion_table_for_instances dcl_class_inst_index dcl_instances class_instances_table icl_instances new_table error - | dcl_class_inst_index < size class_instances_table - # icl_index = class_instances_table.[dcl_class_inst_index] + build_conversion_table_for_instances dcl_class_inst_index dcl_instances instances_conversion_table_size icl_instances new_table error + | dcl_class_inst_index < instances_conversion_table_size + # icl_index = dcl_class_inst_index # (icl_instance, icl_instances) = icl_instances![icl_index] dcl_members = dcl_instances.[dcl_class_inst_index].ins_members icl_members = icl_instance.ins_members | size dcl_members == size icl_members # new_table = build_conversion_table_for_instances_of_members 0 dcl_members icl_members new_table - = build_conversion_table_for_instances (inc dcl_class_inst_index) dcl_instances class_instances_table icl_instances new_table error + = build_conversion_table_for_instances (inc dcl_class_inst_index) dcl_instances instances_conversion_table_size icl_instances new_table error # error = checkErrorWithIdentPos (newPosition icl_instance.ins_ident icl_instance.ins_pos) "incorrect number of members specified" error - = build_conversion_table_for_instances (inc dcl_class_inst_index) dcl_instances class_instances_table icl_instances new_table error + = build_conversion_table_for_instances (inc dcl_class_inst_index) dcl_instances instances_conversion_table_size icl_instances new_table error = (new_table, icl_instances,error) build_conversion_table_for_instances_of_members mem_index dcl_members icl_members new_table @@ -2019,26 +2056,17 @@ renumber_icl_module mod_type icl_global_function_range icl_instance_range icl_ge = build_conversion_table_for_instances_of_members (inc mem_index) dcl_members icl_members new_table = new_table - fill_conversion_table_for_type_funs dcl_type_index dcl_types icl_type_defs type_conversions new_table - | dcl_type_index >= size dcl_types - = (new_table, icl_type_defs) - # dcl_type_fun_index = dcl_types.[dcl_type_index].td_fun_index - | dcl_type_fun_index == NoIndex || dcl_types.[dcl_type_index].td_fun_index == NoIndex - = fill_conversion_table_for_type_funs (inc dcl_type_index) dcl_types icl_type_defs type_conversions new_table - # icl_type_index = type_conversions.[dcl_type_index] - # (icl_type_fun_index,icl_type_defs) = icl_type_defs![icl_type_index].td_fun_index - | dcl_type_fun_index == NoIndex - = fill_conversion_table_for_type_funs (inc dcl_type_index) dcl_types icl_type_defs type_conversions new_table - # new_table = {new_table & [dcl_type_fun_index] = icl_type_fun_index} - = fill_conversion_table_for_type_funs (inc dcl_type_index) dcl_types icl_type_defs type_conversions new_table + fill_conversion_table_for_type_funs icl_type_fun_range dcl_type_funs /*not_exported_type_fun_range*/ new_table + #! first_dcl_index = dcl_type_funs.ir_from + #! end_dcl_index = dcl_type_funs.ir_to + #! dcl_to_icl_index_diff = icl_type_fun_range.ir_from-first_dcl_index + = {new_table & [dcl_index] = dcl_index + dcl_to_icl_index_diff \\ dcl_index <- [first_dcl_index..end_dcl_index-1]} renumber_member_indexes_of_class_instances No class_instances = class_instances - renumber_member_indexes_of_class_instances (Yes icl_to_dcl_index_table) class_instances + renumber_member_indexes_of_class_instances (Yes function_conversion_table) class_instances = renumber_member_indexes_of_class_instances 0 class_instances where - function_conversion_table = icl_to_dcl_index_table.[cFunctionDefs] - renumber_member_indexes_of_class_instances class_inst_index class_instances | class_inst_index < size class_instances # (class_instance,class_instances) = class_instances![class_inst_index] @@ -2049,11 +2077,9 @@ renumber_icl_module mod_type icl_global_function_range icl_instance_range icl_ge renumber_members_of_gencases No gencases = gencases - renumber_members_of_gencases (Yes icl_to_dcl_index_table) gencases + renumber_members_of_gencases (Yes function_conversion_table) gencases = renumber 0 gencases - where - function_conversion_table = icl_to_dcl_index_table.[cFunctionDefs] - + where renumber gencase_index gencases | gencase_index < size gencases # (gencase=:{gc_body = GCB_FunIndex icl_index}, gencases) = gencases ! [gencase_index] @@ -2063,37 +2089,35 @@ renumber_icl_module mod_type icl_global_function_range icl_instance_range icl_ge = renumber (inc gencase_index) gencases = gencases -checkModule :: !ScannedModule !IndexRange ![FunDef] !Bool !Bool !Int !(Optional ScannedModule) ![ScannedModule] !{#DclModule} !*{#*{#FunDef}} !*PredefinedSymbols !*SymbolTable !*File !*Heaps +checkModule :: !ScannedModule !IndexRange ![FunDef] !Bool !Bool !Int !(Optional ScannedModule) ![ScannedModule] + !{#DclModule} !*{#*{#FunDef}} !*PredefinedSymbols !*SymbolTable !*File !*Heaps -> (!Bool, *IclModule, *{#DclModule}, *{!Group}, !*{#*{#FunDef}},!Int, !*Heaps, !*PredefinedSymbols, !*SymbolTable, *File, [String]) -checkModule {mod_defs,mod_ident,mod_type,mod_imports,mod_imported_objects,mod_foreign_exports,mod_modification_time} icl_global_function_range fun_defs support_dynamics dynamic_type_used dcl_module_n_in_cache - optional_dcl_mod scanned_modules dcl_modules cached_dcl_macros predef_symbols symbol_table err_file heaps +checkModule {mod_defs,mod_ident,mod_type,mod_imports,mod_imported_objects,mod_foreign_exports,mod_modification_time} + icl_global_function_range fun_defs support_dynamics dynamic_type_used dcl_module_n_in_cache optional_dcl_mod scanned_modules + dcl_modules cached_dcl_macros predef_symbols symbol_table err_file heaps # nr_of_cached_modules = size dcl_modules # (optional_pre_def_mod,predef_symbols) = case nr_of_cached_modules of 0 # (predef_mod,predef_symbols) = buildPredefinedModule support_dynamics predef_symbols -> (Yes predef_mod,predef_symbols) _ -> (No,predef_symbols) - # (nr_of_functions,first_inst_index,first_gen_inst_index,local_defs,macro_and_function_local_defs,icl_functions,macro_defs,init_dcl_modules,main_dcl_module_n,cdefs,sizes,cs) + + # (local_defs,macro_and_function_local_defs,icl_functions,inst_fun_defs,macro_defs,init_dcl_modules,main_dcl_module_n,cdefs,sizes,cs) = check_module1 mod_defs icl_global_function_range fun_defs optional_dcl_mod optional_pre_def_mod scanned_modules dcl_modules cached_dcl_macros dcl_module_n_in_cache predef_symbols symbol_table err_file - # icl_instance_range = {ir_from = first_inst_index, ir_to = first_gen_inst_index} - # icl_generic_range = {ir_from = first_gen_inst_index, ir_to = nr_of_functions} - = check_module2 mod_ident mod_modification_time mod_imported_objects mod_imports mod_foreign_exports mod_type icl_global_function_range icl_instance_range icl_generic_range nr_of_cached_modules - optional_pre_def_mod local_defs macro_and_function_local_defs support_dynamics dynamic_type_used icl_functions macro_defs init_dcl_modules cdefs sizes heaps cs + + = check_module2 mod_ident mod_modification_time mod_imported_objects mod_imports mod_foreign_exports mod_type icl_global_function_range nr_of_cached_modules + optional_pre_def_mod local_defs macro_and_function_local_defs support_dynamics dynamic_type_used icl_functions inst_fun_defs macro_defs init_dcl_modules cdefs sizes heaps cs check_module1 cdefs icl_global_function_range fun_defs optional_dcl_mod optional_pre_def_mod scanned_modules dcl_modules cached_dcl_macros dcl_module_n_in_cache predef_symbols symbol_table err_file # error = {ea_file = err_file, ea_loc = [], ea_ok = True } - first_inst_index = length fun_defs - (inst_fun_defs, def_instances) = convert_icl_class_instances cdefs.def_instances first_inst_index + # icl_functions = { next_fun \\ next_fun <- fun_defs} + #! first_inst_index = size icl_functions + # (inst_fun_defs, def_instances) = convert_icl_class_instances cdefs.def_instances first_inst_index first_gen_inst_index = first_inst_index + length inst_fun_defs - (gen_inst_fun_defs, def_generic_cases) = convert_generic_instances cdefs.def_generic_cases first_gen_inst_index - - icl_functions = { next_fun \\ next_fun <- fun_defs ++ inst_fun_defs ++ gen_inst_fun_defs} - - cdefs = { cdefs & def_instances = def_instances, def_generic_cases = def_generic_cases } - #! nr_of_functions = size icl_functions + cdefs = { cdefs & def_instances = def_instances } # (sizes,local_defs) = collectCommonDefinitions cdefs (icl_functions, sizes_and_macro_and_function_local_defs) = collectGlobalFunctions cFunctionDefs icl_global_function_range.ir_from icl_global_function_range.ir_to icl_functions (sizes,[]) @@ -2115,7 +2139,7 @@ check_module1 cdefs icl_global_function_range fun_defs optional_dcl_mod optional dcl_modules.[i] init_new_dcl_modules.[i-size dcl_modules] \\ i<-[0..size dcl_modules+size init_new_dcl_modules-1]} - = (nr_of_functions,first_inst_index,first_gen_inst_index,local_defs,macro_and_function_local_defs,icl_functions,macro_defs,init_dcl_modules,main_dcl_module_n,cdefs,sizes,cs) + = (local_defs,macro_and_function_local_defs,icl_functions,inst_fun_defs,macro_defs,init_dcl_modules,main_dcl_module_n,cdefs,sizes,cs) where add_dcl_module_predef_module_and_modules_to_symbol_table (Yes dcl_mod) optional_predef_mod modules mod_index cs @@ -2150,7 +2174,7 @@ check_module1 cdefs icl_global_function_range fun_defs optional_dcl_mod optional # (mod_entry, symbol_table) = readPtr predefined_idents.[predef_index].id_info symbol_table = case mod_entry.ste_kind of STE_Module _ - -> ({ pre_def_symbols & [predef_index] = { mod_symb & pds_module = cs_x.x_main_dcl_module_n, pds_def = mod_entry.ste_index }}, symbol_table) + -> ({pre_def_symbols & [predef_index] = {mod_symb & pds_module = cs_x.x_main_dcl_module_n, pds_def = mod_entry.ste_index}}, symbol_table) _ -> (pre_def_symbols, symbol_table) @@ -2214,20 +2238,30 @@ check_module1 cdefs icl_global_function_range fun_defs optional_dcl_mod optional fill_macro_def_array i [dcl_macro_defs:macro_defs] a = fill_macro_def_array (i+1) macro_defs {a & [i]=dcl_macro_defs} -check_module2 :: Ident {#Char} [.ImportedObject] [Import] [ParsedForeignExport] .ModuleKind !.IndexRange !.IndexRange !.IndexRange !Int - (Optional (Module a)) [Declaration] [Declaration] Bool Bool *{#FunDef} *{#*{#FunDef}} *{#DclModule} (CollectedDefinitions ClassInstance) +check_module2 :: Ident {#Char} [.ImportedObject] .[Import] [ParsedForeignExport] .ModuleKind !.IndexRange !Int + (Optional (Module a)) [Declaration] [Declaration] Bool Bool *{#FunDef} [FunDef] *{#*{#FunDef}} *{#DclModule} (CollectedDefinitions ClassInstance) *{#.Int} *Heaps *CheckState -> (!Bool,.IclModule,!.{#DclModule},.{!Group},!*{#*{#FunDef}},!Int,!.Heaps,!.{#PredefinedSymbol},!.Heap SymbolTableEntry,!.File,[String]); -check_module2 mod_ident mod_modification_time mod_imported_objects mod_imports mod_foreign_exports mod_type icl_global_function_range icl_instance_range icl_generic_range nr_of_cached_modules - optional_pre_def_mod local_defs macro_and_function_local_defs support_dynamics dynamic_type_used icl_functions macro_defs init_dcl_modules cdefs sizes heaps cs +check_module2 mod_ident mod_modification_time mod_imported_objects mod_imports mod_foreign_exports mod_type icl_global_function_range nr_of_cached_modules + optional_pre_def_mod local_defs macro_and_function_local_defs support_dynamics dynamic_type_used icl_functions inst_fun_defs macro_defs init_dcl_modules cdefs sizes heaps cs # (main_dcl_module_n,cs)=cs!cs_x.x_main_dcl_module_n - def_macro_indices=cdefs.def_macro_indices - (copied_dcl_defs, dcl_conversions, dcl_modules, local_defs, macro_and_function_local_defs, cdefs, icl_sizes, cs) - = combineDclAndIclModule mod_type def_macro_indices init_dcl_modules local_defs macro_and_function_local_defs cdefs sizes cs + (copied_dcl_defs, dcl_conversions, dcl_modules, local_defs, cdefs, icl_sizes, cs) + = combineDclAndIclModule mod_type init_dcl_modules local_defs cdefs sizes cs + + # (instances_conversion_table_size,gencase_conversion_table_size,dcl_conversions) + = case dcl_conversions of + Yes conversion_table + #! instances_conversion_table_size = size conversion_table.[cInstanceDefs] + #! gencase_conversion_table_size = size conversion_table.[cGenericCaseDefs] + -> (instances_conversion_table_size,gencase_conversion_table_size,Yes conversion_table) + No + -> (0,0,No) + | not cs.cs_error.ea_ok = (False, abort "evaluated error 1 (check.icl)", {}, {}, {}, cs.cs_x.x_main_dcl_module_n,heaps, cs.cs_predef_symbols, cs.cs_symbol_table, cs.cs_error.ea_file, []) + #! def_macro_indices=cdefs.def_macro_indices # icl_common = createCommonDefinitions cdefs (dcl_modules, macro_defs, heaps, cs) @@ -2242,25 +2276,17 @@ check_module2 mod_ident mod_modification_time mod_imported_objects mod_imports m # cs_symbol_table = cs.cs_symbol_table cs_predef_symbols = cs.cs_predef_symbols hp_var_heap = heaps.hp_var_heap - # (icl_type_fun_range, dcl_modules, icl_functions, icl_common, cs_predef_symbols, hp_var_heap, cs_symbol_table) + # (dcl_modules,cs_predef_symbols,hp_var_heap,cs_symbol_table) = if support_dynamics - (addTypeFunctions nr_of_cached_modules dcl_modules icl_functions icl_common cs_predef_symbols hp_var_heap cs_symbol_table) - ({ir_from=0,ir_to=0}, dcl_modules, icl_functions, icl_common, cs_predef_symbols, hp_var_heap, cs_symbol_table) - # cs = {cs & cs_symbol_table=cs_symbol_table, cs_predef_symbols=cs_predef_symbols} - # heaps = {heaps & hp_var_heap=hp_var_heap} + (addDclTypeFunctions nr_of_cached_modules dcl_modules cs_predef_symbols hp_var_heap cs_symbol_table) + (dcl_modules,cs_predef_symbols,hp_var_heap,cs_symbol_table) + # cs = {cs & cs_symbol_table = cs_symbol_table, cs_predef_symbols = cs_predef_symbols} + heaps = {heaps & hp_var_heap=hp_var_heap} - # (nr_of_functions, icl_functions) = usize icl_functions - - # (icl_global_functions_ranges,icl_instances_ranges,icl_generic_ranges,icl_type_fun_ranges,n_exported_global_functions,local_functions_index_offset,def_macro_indices,optional_macro_conversions, - icl_functions,icl_common,local_defs,macro_and_function_local_defs,dcl_modules, error) - = renumber_icl_module mod_type icl_global_function_range icl_instance_range icl_generic_range icl_type_fun_range nr_of_functions main_dcl_module_n icl_sizes dcl_conversions def_macro_indices - icl_functions icl_common local_defs macro_and_function_local_defs dcl_modules cs.cs_error - | not error.ea_ok - = (False, abort "evaluated error 3 (check.icl)", {}, {}, {}, cs.cs_x.x_main_dcl_module_n,heaps, cs.cs_predef_symbols, cs.cs_symbol_table, error.ea_file, []) + # (icl_common,local_defs,dcl_modules) + = renumber_icl_common_defs mod_type main_dcl_module_n icl_sizes dcl_conversions icl_common local_defs dcl_modules # (imported_module_numbers, dcl_modules) = determine_imported_module_numbers expl_imp_indices main_dcl_module_n dcl_modules - - cs = { cs & cs_error=error,cs_x.x_needed_modules = if dynamic_type_used cNeedStdDynamic 0 } (nr_of_modules, dcl_modules) = usize dcl_modules (dcl_macros, dcl_modules) = dcl_modules![main_dcl_module_n].dcl_macros @@ -2273,11 +2299,7 @@ check_module2 mod_ident mod_modification_time mod_imported_objects mod_imports m imports_ikh = ikhInsert` False nr_of_modules imports ikhEmpty // maps the module indices of all modules in the actual component to all explicit imports of that module - (macro_and_function_local_defs,dcl_modules,cs) - = replace_icl_macros_by_dcl_macros mod_type def_macro_indices optional_macro_conversions macro_and_function_local_defs dcl_modules cs - cs = addGlobalDefinitionsToSymbolTable local_defs cs - cs = addGlobalDefinitionsToSymbolTable macro_and_function_local_defs cs (dcls_import_list, dcl_modules, cs) = addImportedSymbolsToSymbolTable nr_of_modules (Yes dcl_macros) modules_in_component_set imports_ikh dcl_modules cs @@ -2285,17 +2307,80 @@ check_module2 mod_ident mod_modification_time mod_imported_objects mod_imports m qualified_explicit_imports = (ikhSearch` nr_of_modules imports_ikh).si_qualified_explicit (dcl_modules, macro_defs,hp_expression_heap, cs) = checkExplicitImportCompleteness imports.si_explicit qualified_explicit_imports dcl_modules macro_defs heaps.hp_expression_heap cs + heaps = { heaps & hp_expression_heap=hp_expression_heap } + (modified_ste_kinds,symbol_table,dcl_modules) = store_qualified_explicit_imports_in_symbol_table qualified_explicit_imports [] cs.cs_symbol_table dcl_modules - cs = {cs & cs_symbol_table=symbol_table} - heaps = { heaps & hp_expression_heap=hp_expression_heap } + #! first_inst_index = size icl_functions + first_gen_inst_index = first_inst_index + length inst_fun_defs + + # (gen_inst_fun_defs,gencase_defs,class_defs,symbol_table,error,dcl_modules) + = convert_generic_instances 0 first_gen_inst_index icl_common.com_gencase_defs icl_common.com_class_defs symbol_table cs.cs_error dcl_modules + icl_common = {icl_common & com_gencase_defs = gencase_defs, com_class_defs = class_defs} + cs = {cs & cs_symbol_table=symbol_table,cs_error=error} + + # icl_functions = array_plus_list icl_functions (inst_fun_defs ++ gen_inst_fun_defs) + #! nr_of_functions = size icl_functions + # icl_instance_range = {ir_from = first_inst_index, ir_to = first_gen_inst_index} + # icl_generic_range = {ir_from = first_gen_inst_index, ir_to = nr_of_functions} + + # ({dcl_declared={dcls_local},dcl_macros,dcl_sizes}, dcl_modules) = dcl_modules![main_dcl_module_n] + #! n_dcl_functions = dcl_sizes.[cFunctionDefs] + #! n_dcl_macros = dcl_sizes.[cMacroDefs] + # (optional_macro_conversions, dcl_function_table, macro_and_function_local_defs, cs) + = make_dcl_macro_and_function_conversions mod_type dcls_local n_dcl_functions n_dcl_macros dcl_macros.ir_from def_macro_indices macro_and_function_local_defs cs + + # (n_dcl_type_defs,n_dcl_class_defs) + = case mod_type of + MK_Main + -> (0,0) + _ + #! n_dcl_type_defs = dcl_sizes.[cTypeDefs] + #! n_class_defs = dcl_sizes.[cClassDefs] + -> (n_dcl_type_defs,n_class_defs) + + # {cs_symbol_table,cs_predef_symbols} = cs + {com_type_defs,com_class_defs} = icl_common + hp_var_heap = heaps.hp_var_heap + (icl_type_fun_range,icl_functions,com_type_defs,com_class_defs,cs_predef_symbols,hp_var_heap,cs_symbol_table) + = if support_dynamics + (addIclTypeFunctions n_dcl_type_defs n_dcl_class_defs icl_functions com_type_defs com_class_defs cs_predef_symbols hp_var_heap cs_symbol_table) + ({ir_from=0,ir_to=0},icl_functions,com_type_defs,com_class_defs,cs_predef_symbols,hp_var_heap,cs_symbol_table) + icl_common = {icl_common & com_type_defs=com_type_defs,com_class_defs=com_class_defs} + cs = {cs & cs_symbol_table=cs_symbol_table, cs_predef_symbols=cs_predef_symbols} + heaps = {heaps & hp_var_heap=hp_var_heap} + + # (nr_of_functions, icl_functions) = usize icl_functions + # (dcl_mod, dcl_modules) = dcl_modules![main_dcl_module_n] + + # (icl_global_functions_ranges,icl_instances_ranges,icl_generic_ranges,icl_type_fun_ranges,n_exported_global_functions,local_functions_index_offset,def_macro_indices, + optional_macro_conversions,icl_functions,icl_common,macro_and_function_local_defs,error) + = renumber_icl_module_functions mod_type icl_global_function_range icl_instance_range icl_generic_range icl_type_fun_range nr_of_functions + dcl_function_table instances_conversion_table_size gencase_conversion_table_size def_macro_indices dcl_mod + optional_macro_conversions icl_functions icl_common macro_and_function_local_defs cs.cs_error + + | not error.ea_ok + = (False, abort "evaluated error 3 (check.icl)", {}, {}, {}, cs.cs_x.x_main_dcl_module_n,heaps, cs.cs_predef_symbols, cs.cs_symbol_table, error.ea_file, []) + + # cs = { cs & cs_error=error,cs_x.x_needed_modules = if dynamic_type_used cNeedStdDynamic 0 } + + # (macro_and_function_local_defs,dcl_modules,cs) + = replace_icl_macros_by_dcl_macros mod_type def_macro_indices optional_macro_conversions macro_and_function_local_defs dcl_modules cs + + cs = addGlobalDefinitionsToSymbolTable macro_and_function_local_defs cs icl_imported = { el \\ el<-dcls_import_list } (_,icl_common, dcl_modules, heaps=:{hp_var_heap, hp_type_heaps}, cs) = checkCommonDefinitions (Yes (copied_dcl_defs, nr_of_cached_modules)) main_dcl_module_n icl_common dcl_modules heaps cs + (no_errors,cs) = cs!cs_error.ea_ok + icl_common + = if (no_errors && support_dynamics) + (set_td_fun_index_for_icl_types icl_type_fun_ranges icl_common) + icl_common + (instance_types, icl_common, dcl_modules, hp_var_heap, hp_type_heaps, cs) = checkIclInstances main_dcl_module_n icl_common dcl_modules hp_var_heap hp_type_heaps cs diff --git a/frontend/checkgenerics.dcl b/frontend/checkgenerics.dcl index 18c0281..62c594e 100644 --- a/frontend/checkgenerics.dcl +++ b/frontend/checkgenerics.dcl @@ -1,7 +1,7 @@ definition module checkgenerics import syntax -from checksupport import ::Heaps,::CheckState +from checksupport import ::Heaps,::CheckState,::ErrorAdmin checkGenericDefs :: !Index !(Optional (CopiedDefinitions, Int)) !*{#GenericDef} !*{#CheckedTypeDef} !*{#ClassDef} !*{#DclModule} !*Heaps !*CheckState @@ -10,7 +10,8 @@ checkGenericDefs :: !Index !(Optional (CopiedDefinitions, Int)) checkGenericCaseDefs :: !Index !*{#GenericCaseDef} !*{#GenericDef} !u:{#CheckedTypeDef} !*{#DclModule} !*Heaps !*CheckState -> (!*{#GenericCaseDef},!*{#GenericDef},!u:{#CheckedTypeDef},!*{#DclModule},!.Heaps,!.CheckState) -convert_generic_instances :: !.[GenericCaseDef] !Int -> (!.[FunDef], !.[GenericCaseDef]) +convert_generic_instances :: !Int !Int !*{#GenericCaseDef} !*{#ClassDef} !*SymbolTable !*ErrorAdmin !*{#DclModule} + -> (!.[FunDef],!*{#GenericCaseDef},!*{#ClassDef},!*SymbolTable,!*ErrorAdmin,!*{#DclModule}) create_gencase_funtypes :: !Index !*{#GenericCaseDef} !*Heaps -> (!Index, ![FunType], !*{#GenericCaseDef},!*Heaps) diff --git a/frontend/checkgenerics.icl b/frontend/checkgenerics.icl index ddc2305..16a039a 100644 --- a/frontend/checkgenerics.icl +++ b/frontend/checkgenerics.icl @@ -190,7 +190,7 @@ where = getTypeDef module_index {glob_module=type_module, glob_object=type_index} type_defs modules # type_cons = { type_cons & type_index = { glob_object = type_index, glob_module = type_module }} | type_synonym_with_arguments type_def.td_rhs type_def.td_arity - # cs = {cs & cs_error = checkError type_def.td_ident "synonym type not allowed" cs.cs_error} + # cs = {cs & cs_error = checkError type_def.td_ident "type synonym not allowed" cs.cs_error} = (TA type_cons [], TypeConsSymb type_cons, type_defs, modules,{heaps&hp_type_heaps = hp_type_heaps}, cs) = (TA type_cons [], TypeConsSymb type_cons, type_defs, modules,{heaps&hp_type_heaps = hp_type_heaps}, cs) where @@ -225,30 +225,37 @@ where _ -> ( {gi_module=NoIndex,gi_index = NoIndex} , {cs & cs_error = checkError id_name "generic undefined" cs.cs_error}) -convert_generic_instances :: !.[GenericCaseDef] !Int -> (!.[FunDef], !.[GenericCaseDef]) -convert_generic_instances [gc=:{gc_ident, gc_body=GCB_FunDef fun_def} : gcs] next_fun_index - # (fun_defs, gcs) = convert_generic_instances gcs (inc next_fun_index) - # gc = { gc & gc_body = GCB_FunIndex next_fun_index } - = ([fun_def : fun_defs], [gc:gcs]) - //---> ("convert generic case: user defined function", gc.gc_ident, gc.gc_type_cons, next_fun_index) -convert_generic_instances [gc=:{gc_ident,gc_pos, gc_type_cons, gc_body=GCB_None} : gcs] next_fun_index - # (fun_defs, gcs) = convert_generic_instances gcs (inc next_fun_index) - # fun_def = - { fun_ident = genericIdentToFunIdent gc_ident.id_name gc_type_cons - , fun_arity = 0 - , fun_priority = NoPrio - , fun_body = GeneratedBody - , fun_type = No - , fun_pos = gc_pos - , fun_kind = FK_Unknown - , fun_lifted = 0 - , fun_info = EmptyFunInfo - } - # gc = { gc & gc_body = GCB_FunIndex next_fun_index } - = ([fun_def:fun_defs], [gc:gcs]) - //---> ("convert generic case: function to derive ", gc.gc_ident, gc.gc_type_cons, next_fun_index) -convert_generic_instances [] next_fun_index - = ([], []) +convert_generic_instances :: !Int !Int !*{#GenericCaseDef} !*{#ClassDef} !*SymbolTable !*ErrorAdmin !*{#DclModule} + -> (!.[FunDef],!*{#GenericCaseDef},!*{#ClassDef},!*SymbolTable,!*ErrorAdmin,!*{#DclModule}) + +convert_generic_instances gci next_fun_index gencase_defs class_defs symbol_table error dcl_modules + | gci<size gencase_defs + # (gencase_def,gencase_defs)=gencase_defs![gci] + = case gencase_def of + gc=:{gc_ident, gc_body=GCB_FunDef fun_def} + # gc = { gc & gc_body = GCB_FunIndex next_fun_index } + gencase_defs = {gencase_defs & [gci]=gc} + (fun_defs,gencase_defs,class_defs,symbol_table,error,dcl_modules) + = convert_generic_instances (gci+1) (next_fun_index+1) gencase_defs class_defs symbol_table error dcl_modules + -> ([fun_def : fun_defs],gencase_defs,class_defs,symbol_table,error,dcl_modules) + gc=:{gc_ident,gc_pos, gc_type_cons, gc_body=GCB_None} + # fun_def = + { fun_ident = genericIdentToFunIdent gc_ident.id_name gc_type_cons + , fun_arity = 0 + , fun_priority = NoPrio + , fun_body = GeneratedBody + , fun_type = No + , fun_pos = gc_pos + , fun_kind = FK_Unknown + , fun_lifted = 0 + , fun_info = EmptyFunInfo + } + # gc = { gc & gc_body = GCB_FunIndex next_fun_index } + gencase_defs = {gencase_defs & [gci]=gc} + (fun_defs,gencase_defs,class_defs,symbol_table,error,dcl_modules) + = convert_generic_instances (gci+1) (next_fun_index+1) gencase_defs class_defs symbol_table error dcl_modules + -> ([fun_def : fun_defs],gencase_defs,class_defs,symbol_table,error,dcl_modules) + = ([],gencase_defs,class_defs,symbol_table,error,dcl_modules) create_gencase_funtypes :: !Index !*{#GenericCaseDef} !*Heaps -> (!Index,![FunType],!*{#GenericCaseDef},!*Heaps) diff --git a/frontend/generics1.icl b/frontend/generics1.icl index 0fcacfe..44d017f 100644 --- a/frontend/generics1.icl +++ b/frontend/generics1.icl @@ -886,6 +886,9 @@ where make_expr (TFA _ _) heaps // error is reported in convertATypeToGenTypeStruct = make_error_type_cons heaps + make_expr (TFAC _ _ _) heaps + // error is reported in convertATypeToGenTypeStruct + = make_error_type_cons heaps make_expr _ heaps = abort "type does not match\n" @@ -4230,7 +4233,8 @@ buildFunAndGroup2 ident arg_vars body_expr main_dcl_module_n funs_and_groups=:{f // Primitive expressions makeIntExpr :: Int -> Expression -makeIntExpr value = BasicExpr (BVI (toString value)) +makeIntExpr value + = BasicExpr (BVInt value) makeStringExpr :: String -> Expression makeStringExpr str diff --git a/frontend/typereify.dcl b/frontend/typereify.dcl index cc5b5d5..d2ea06c 100644 --- a/frontend/typereify.dcl +++ b/frontend/typereify.dcl @@ -1,17 +1,18 @@ -/* - module owner: Ronny Wichers Schreur -*/ definition module typereify +from general import ::Optional from syntax import ::Ident, ::FunDef, ::IndexRange, ::TypeHeaps, ::SymbolTable, ::SymbolTableEntry, ::Heap, - ::DclModule, ::CommonDefs, ::VarHeap, ::VarInfo + ::DclModule, ::CommonDefs, ::CheckedTypeDef, ::TypeDef, ::TypeRhs, ::ClassDef, ::VarHeap, ::VarInfo from predef import ::PredefinedSymbols, ::PredefinedSymbol -addTypeFunctions :: Int *{#DclModule} *{#FunDef} *CommonDefs *PredefinedSymbols *VarHeap *SymbolTable - -> (IndexRange, *{#DclModule},*{#FunDef},*CommonDefs,*PredefinedSymbols,*VarHeap,*SymbolTable) +addDclTypeFunctions :: !Int !*{#DclModule} !*PredefinedSymbols !*VarHeap !*SymbolTable + -> (!*{#DclModule},!*PredefinedSymbols,!*VarHeap,!*SymbolTable) + +addIclTypeFunctions :: !Int !Int !*{#FunDef} !*{#CheckedTypeDef} !*{#ClassDef} !*PredefinedSymbols !*VarHeap !*SymbolTable + -> (!IndexRange,!*{#FunDef},!*{#CheckedTypeDef},!*{#ClassDef},!*PredefinedSymbols,!*VarHeap,!*SymbolTable) buildTypeFunctions :: !Int !*{#FunDef} !{#CommonDefs} !*PredefinedSymbols !*VarHeap !*TypeHeaps -> (!*{#FunDef},!*PredefinedSymbols,!*VarHeap,!*TypeHeaps) diff --git a/frontend/typereify.icl b/frontend/typereify.icl index c19b8bf..75e420f 100644 --- a/frontend/typereify.icl +++ b/frontend/typereify.icl @@ -1,6 +1,3 @@ -/* - module owner: Ronny Wichers Schreur -*/ implementation module typereify import syntax @@ -43,28 +40,6 @@ instance makeTypeFun FunType where , ft_specials = FSP_None , ft_type_ptr = ft_type_ptr }, var_heap, symbol_table) - -class isTypeSynonym a :: a -> Bool - -instance isTypeSynonym (TypeDef a) | isTypeSynonym a where - isTypeSynonym {td_rhs} - = isTypeSynonym td_rhs - -// Currently type functions are generated for all types, including type -// synonyms. This should be changed to only type synonyms that are abstract. -instance isTypeSynonym TypeRhs where - isTypeSynonym (AlgType _) - = False - isTypeSynonym (RecordType _) - = False - isTypeSynonym (AbstractType _) - = False - isTypeSynonym (SynType _) - = False - isTypeSynonym (AbstractSynType _ _) - = False - isTypeSynonym (NewType _) - = False add_dcl_type_fun_types :: TypeSymbIdent Int *{#DclModule} *VarHeap *SymbolTable -> (*{#DclModule},*VarHeap,*SymbolTable) @@ -112,28 +87,83 @@ getNilSymb predefs symbol = { symb_ident = pds_ident, symb_kind = SK_Constructor { glob_module = pds_module, glob_object = pds_def} } = (symbol, predefs) -addTypeFunctions :: Int *{#DclModule} *{#FunDef} *CommonDefs *PredefinedSymbols *VarHeap *SymbolTable - -> (IndexRange, *{#DclModule},*{#FunDef},*CommonDefs,*PredefinedSymbols,*VarHeap,*SymbolTable) -addTypeFunctions nr_cached_dcls dcl_modules icl_functions icl_common predefs var_heap symbols +addDclTypeFunctions :: !Int !*{#DclModule} !*PredefinedSymbols !*VarHeap !*SymbolTable + -> (!*{#DclModule},!*PredefinedSymbols,!*VarHeap,!*SymbolTable) +addDclTypeFunctions nr_cached_dcls dcl_modules predefs var_heap symbols # (ctListDefSymb, predefs) = getListTypeSymb predefs # (dcl_modules, var_heap, symbols) = add_dcl_type_fun_types ctListDefSymb nr_cached_dcls dcl_modules var_heap symbols - # (icl_type_fun_range, icl_functions, icl_common, var_heap, symbols) - = add_icl_type_functions icl_functions ctListDefSymb icl_common var_heap symbols - with - add_icl_type_functions :: *{#FunDef} TypeSymbIdent *CommonDefs *VarHeap *SymbolTable - -> (IndexRange, *{#FunDef}, *CommonDefs, *VarHeap, *SymbolTable) - add_icl_type_functions icl_functions ctListDefSymb icl_common=:{com_type_defs} var_heap symbols - # (n_functions_before, icl_functions) = usize icl_functions - # (type_funs, com_type_defs, var_heap, symbols) - = addTypeFunctionsA n_functions_before ctListDefSymb com_type_defs var_heap symbols - # icl_common = {icl_common & com_type_defs=com_type_defs} - # icl_functions = {function \\ function <- [e \\ e <-: icl_functions] ++ type_funs} - # (n_functions_after, icl_functions) = usize icl_functions - # type_fun_range = {ir_from=n_functions_before,ir_to=n_functions_after} - = (type_fun_range, icl_functions, icl_common, var_heap, symbols) - # (nr_of_functions, icl_functions) = usize icl_functions - = (icl_type_fun_range, dcl_modules, icl_functions, icl_common, predefs, var_heap, symbols) + = (dcl_modules, predefs, var_heap, symbols) + +addIclTypeFunctions :: !Int !Int !*{#FunDef} !*{#CheckedTypeDef} !*{#ClassDef} !*PredefinedSymbols !*VarHeap !*SymbolTable + -> (!IndexRange,!*{#FunDef},!*{#CheckedTypeDef},!*{#ClassDef},!*PredefinedSymbols,!*VarHeap,!*SymbolTable) +addIclTypeFunctions n_dcl_type_defs n_dcl_class_defs icl_functions icl_type_defs icl_class_defs predefs var_heap symbol_table + # (ctListDefSymb, predefs) = getListTypeSymb predefs + (n_functions_before, icl_functions) = usize icl_functions + + # (type_fun_index,rev_type_funs,icl_type_defs,var_heap,symbol_table) + = add_td_funs_for_exported_types 0 n_functions_before ctListDefSymb n_dcl_type_defs [] icl_type_defs var_heap symbol_table + (type_fun_index,rev_type_funs,icl_class_defs,var_heap,symbol_table) + = add_td_funs_for_exported_classes 0 type_fun_index ctListDefSymb n_dcl_class_defs rev_type_funs icl_class_defs var_heap symbol_table + (type_fun_index,rev_type_funs,icl_type_defs,var_heap,symbol_table) + = add_td_funs_for_not_exported_types (n_dcl_type_defs+n_dcl_class_defs) type_fun_index ctListDefSymb rev_type_funs icl_type_defs var_heap symbol_table + (type_fun_index,rev_type_funs,icl_class_defs,var_heap,symbol_table) + = add_td_funs_for_not_exported_classes n_dcl_class_defs type_fun_index ctListDefSymb rev_type_funs icl_class_defs var_heap symbol_table + + icl_functions = {function \\ function <- [e \\ e <-: icl_functions] ++ reverse rev_type_funs} + (n_functions_after, icl_functions) = usize icl_functions + type_fun_range = {ir_from=n_functions_before,ir_to=n_functions_after} + = (type_fun_range,icl_functions,icl_type_defs,icl_class_defs,predefs,var_heap,symbol_table) +where + add_td_funs_for_exported_types :: Int Int TypeSymbIdent Int [FunDef] *{#CheckedTypeDef} *VarHeap *SymbolTable + -> (!Int,![FunDef],!*{#CheckedTypeDef},!*VarHeap,!*SymbolTable) + add_td_funs_for_exported_types dcl_type_index type_fun_index ct_type_def n_dcl_type_defs rev_type_fun_defs icl_type_defs var_heap symbol_table + | dcl_type_index<n_dcl_type_defs + # icl_type_index = dcl_type_index + (type_def,icl_type_defs) = icl_type_defs![icl_type_index] + (type_fun_def, var_heap, symbol_table) + = add_td_fun_def type_fun_index type_def.td_ident.id_name type_def.td_pos ct_type_def var_heap symbol_table + icl_type_defs = {icl_type_defs & [icl_type_index].td_fun_index = type_fun_index} + rev_type_fun_defs = [type_fun_def : rev_type_fun_defs] + = add_td_funs_for_exported_types (dcl_type_index+1) (type_fun_index+1) ct_type_def n_dcl_type_defs rev_type_fun_defs icl_type_defs var_heap symbol_table + = (type_fun_index,rev_type_fun_defs,icl_type_defs,var_heap,symbol_table) + + add_td_funs_for_exported_classes :: Int Int TypeSymbIdent Int [FunDef] *{#ClassDef} *VarHeap *SymbolTable + -> (!Int,![FunDef],!*{#ClassDef},!*VarHeap,!*SymbolTable) + add_td_funs_for_exported_classes dcl_class_index type_fun_index ct_type_def n_dcl_class_defs rev_type_fun_defs icl_class_defs var_heap symbol_table + | dcl_class_index<n_dcl_class_defs + # icl_type_index = dcl_class_index + (class_def,icl_class_defs) = icl_class_defs![icl_type_index] + (type_fun_def, var_heap, symbol_table) + = add_td_fun_def type_fun_index (class_def.class_ident.id_name+++";") class_def.class_pos ct_type_def var_heap symbol_table + rev_type_fun_defs = [type_fun_def : rev_type_fun_defs] + = add_td_funs_for_exported_classes (dcl_class_index+1) (type_fun_index+1) ct_type_def n_dcl_class_defs rev_type_fun_defs icl_class_defs var_heap symbol_table + = (type_fun_index,rev_type_fun_defs,icl_class_defs,var_heap,symbol_table) + + add_td_funs_for_not_exported_types :: Int Int TypeSymbIdent [FunDef] *{#CheckedTypeDef} *VarHeap *SymbolTable + -> (!Int,![FunDef],!*{#CheckedTypeDef},!*VarHeap,!*SymbolTable) + add_td_funs_for_not_exported_types icl_type_index type_fun_index ct_type_def rev_type_fun_defs icl_type_defs var_heap symbol_table + | icl_type_index<size icl_type_defs + # (type_def,icl_type_defs) = icl_type_defs![icl_type_index] + | type_def.td_fun_index==NoIndex + # (type_fun_def, var_heap, symbol_table) + = add_td_fun_def type_fun_index type_def.td_ident.id_name type_def.td_pos ct_type_def var_heap symbol_table + icl_type_defs = {icl_type_defs & [icl_type_index].td_fun_index = type_fun_index} + rev_type_fun_defs = [type_fun_def : rev_type_fun_defs] + = add_td_funs_for_not_exported_types (icl_type_index+1) (type_fun_index+1) ct_type_def rev_type_fun_defs icl_type_defs var_heap symbol_table + = add_td_funs_for_not_exported_types (icl_type_index+1) type_fun_index ct_type_def rev_type_fun_defs icl_type_defs var_heap symbol_table + = (type_fun_index,rev_type_fun_defs,icl_type_defs,var_heap,symbol_table) + + add_td_funs_for_not_exported_classes :: Int Int TypeSymbIdent [FunDef] *{#ClassDef} *VarHeap *SymbolTable + -> (!Int,![FunDef],!*{#ClassDef},!*VarHeap,!*SymbolTable) + add_td_funs_for_not_exported_classes icl_class_index type_fun_index ct_type_def rev_type_fun_defs icl_class_defs var_heap symbol_table + | icl_class_index<size icl_class_defs + # (class_def,icl_class_defs) = icl_class_defs![icl_class_index] + # (type_fun_def, var_heap, symbol_table) + = add_td_fun_def type_fun_index (class_def.class_ident.id_name+++";") class_def.class_pos ct_type_def var_heap symbol_table + rev_type_fun_defs = [type_fun_def : rev_type_fun_defs] + = add_td_funs_for_not_exported_classes (icl_class_index+1) (type_fun_index+1) ct_type_def rev_type_fun_defs icl_class_defs var_heap symbol_table + = (type_fun_index,rev_type_fun_defs,icl_class_defs,var_heap,symbol_table) :: BuildTypeFunState = !{ bs_predefs :: !.PredefinedSymbols @@ -183,35 +213,22 @@ buildTypeFunction type_def=:{td_fun_index, td_args} functions info bs_state = (functions, bs_state) addTypeFunctionsA :: Int TypeSymbIdent *{#CheckedTypeDef} *VarHeap *SymbolTable - -> ([a], *{#CheckedTypeDef}, *VarHeap, *SymbolTable) | makeTypeFun a -addTypeFunctionsA first_td_fun_index ct_type_def type_defs var_heap symbol_table - = add_td_fun_defs first_td_fun_index ct_type_def type_defs var_heap symbol_table + -> ([FunType], *{#CheckedTypeDef},*VarHeap,*SymbolTable) +addTypeFunctionsA type_fun_index ct_type_def type_defs var_heap symbol_table + # (n, type_defs) = usize type_defs + = add_td_funs_acc 0 n type_fun_index ct_type_def type_defs [] var_heap symbol_table where - add_td_fun_defs :: Int TypeSymbIdent *{#CheckedTypeDef} *VarHeap *SymbolTable - -> ([a], *{#CheckedTypeDef}, *VarHeap, *SymbolTable) | makeTypeFun a - add_td_fun_defs type_fun_index ct_type_def type_defs var_heap symbol_table - # (n, type_defs) - = usize type_defs - = add_td_funs_acc 0 n type_fun_index ct_type_def type_defs [] var_heap symbol_table - - add_td_funs_acc :: Int Int Int TypeSymbIdent *{#CheckedTypeDef} [a] *VarHeap *SymbolTable - -> ([a], *{#CheckedTypeDef}, *VarHeap, *SymbolTable) | makeTypeFun a - add_td_funs_acc i n index ct_type_def type_defs rev_type_fun_defs var_heap symbol_table + add_td_funs_acc :: Int Int Int TypeSymbIdent *{#CheckedTypeDef} [FunType] *VarHeap *SymbolTable + -> ([FunType], *{#CheckedTypeDef}, *VarHeap,*SymbolTable) + add_td_funs_acc i n type_fun_index ct_type_def type_defs rev_type_fun_defs var_heap symbol_table | i >= n = (reverse rev_type_fun_defs, type_defs, var_heap, symbol_table) # (type_def, type_defs) = type_defs![i] - | isTypeSynonym type_def || is_dictionary type_def - = add_td_funs_acc (i+1) n index ct_type_def type_defs rev_type_fun_defs var_heap symbol_table - # (type_fun_def, var_heap, symbol_table) - = add_td_fun_def index type_def.td_ident.id_name type_def.td_pos ct_type_def var_heap symbol_table - # type_defs = {type_defs & [i].td_fun_index = index} - # rev_type_fun_defs = [type_fun_def : rev_type_fun_defs] - = add_td_funs_acc (i+1) n (index+1) ct_type_def type_defs rev_type_fun_defs var_heap symbol_table - - is_dictionary {td_ident} // FIXME, fragile - = name.[size name - 1] == ';' - where - name = td_ident.id_name + (type_fun_def, var_heap, symbol_table) + = add_td_fun_def type_fun_index type_def.td_ident.id_name type_def.td_pos ct_type_def var_heap symbol_table + type_defs = {type_defs & [i].td_fun_index = type_fun_index} + rev_type_fun_defs = [type_fun_def : rev_type_fun_defs] + = add_td_funs_acc (i+1) n (type_fun_index+1) ct_type_def type_defs rev_type_fun_defs var_heap symbol_table add_td_fun_def :: Int {#Char} Position TypeSymbIdent *VarHeap *SymbolTable -> (!a,!*VarHeap,!*SymbolTable) | makeTypeFun a |