aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--frontend/check.icl257
-rw-r--r--frontend/comparedefimp.dcl10
-rw-r--r--frontend/comparedefimp.icl216
-rw-r--r--frontend/containers.dcl7
-rw-r--r--frontend/containers.icl26
-rw-r--r--frontend/generics1.icl8
-rw-r--r--frontend/hashtable.dcl1
-rw-r--r--frontend/hashtable.icl27
-rw-r--r--frontend/parse.icl134
-rw-r--r--frontend/postparse.icl42
-rw-r--r--frontend/syntax.dcl29
11 files changed, 528 insertions, 229 deletions
diff --git a/frontend/check.icl b/frontend/check.icl
index 1c99f9c..bb8e6c3 100644
--- a/frontend/check.icl
+++ b/frontend/check.icl
@@ -10,7 +10,7 @@ from checkgenerics import checkGenericDefs,checkGenericCaseDefs,convert_generic_
cUndef :== (-1)
cDummyArray :== {}
-
+
checkTypeClasses :: !Index !(Optional (CopiedDefinitions, Int)) !*{#ClassDef} !*{#MemberDef} !*{#CheckedTypeDef} !*{#DclModule} !*Heaps !*CheckState
-> (!*{#ClassDef}, !*{#MemberDef}, !*{#CheckedTypeDef}, !*{#DclModule}, !*Heaps, !*CheckState)
checkTypeClasses module_index opt_icl_info class_defs member_defs type_defs modules heaps=:{hp_type_heaps} cs
@@ -83,7 +83,7 @@ where
collected_instances type_defs class_defs modules { heaps & hp_var_heap = hp_var_heap } { cs & cs_predef_symbols=cs_predef_symbols,cs_error = cs_error }
check_specials :: !Index !FunType !Index !FunSpecials !Index ![FunType] !*Heaps !*PredefinedSymbols !*ErrorAdmin
- -> (!FunSpecials, !Index,![FunType],!*Heaps,!*PredefinedSymbols,!*ErrorAdmin)
+ -> (!FunSpecials,!Index,![FunType],!*Heaps,!*PredefinedSymbols,!*ErrorAdmin)
check_specials mod_index fun_type fun_index (FSP_Substitutions substs) next_inst_index all_instances heaps predef_symbols error
# (list_of_specials, (next_inst_index, all_instances, heaps, cs_predef_symbols,cs_error))
= mapSt (checkSpecial mod_index fun_type fun_index) substs (next_inst_index, all_instances, heaps, predef_symbols,error)
@@ -91,6 +91,38 @@ where
check_specials mod_index fun_type fun_index FSP_None next_inst_index all_instances heaps predef_symbols error
= (FSP_None, next_inst_index, all_instances, heaps, predef_symbols,error)
+checkDclInstanceMemberTypes :: !*{#ClassInstance} !ModuleIndex !v:{#CheckedTypeDef} !w:{#ClassDef} !v:{#DclModule} !*Heaps !*CheckState
+ -> (!*{#ClassInstance},!v:{#CheckedTypeDef},!w:{#ClassDef},!v:{#DclModule},!*Heaps,!*CheckState)
+checkDclInstanceMemberTypes instance_defs mod_index type_defs class_defs modules heaps cs
+ = check_instance_member_types 0 instance_defs mod_index type_defs class_defs modules heaps cs
+where
+ check_instance_member_types :: !Index !*{#ClassInstance} !ModuleIndex !v:{#CheckedTypeDef} !w:{#ClassDef} !v:{#DclModule} !*Heaps !*CheckState
+ -> (!*{#ClassInstance},!v:{#CheckedTypeDef},!w:{#ClassDef},!v:{#DclModule},!*Heaps,!*CheckState)
+ check_instance_member_types inst_index instance_defs module_index type_defs class_defs modules heaps cs
+ | inst_index < size instance_defs
+ # (instance_def, instance_defs) = instance_defs![inst_index]
+ (ins_member_types, type_defs, class_defs, modules, heaps, cs)
+ = check_function_types instance_def.ins_member_types module_index type_defs class_defs modules heaps cs
+ instance_defs = {instance_defs & [inst_index].ins_member_types = sort ins_member_types }
+ = check_instance_member_types (inc inst_index) instance_defs module_index type_defs class_defs modules heaps cs
+ = (instance_defs,type_defs,class_defs,modules,heaps,cs)
+
+ check_function_types :: ![FunType] !ModuleIndex !v:{#CheckedTypeDef} !w:{#ClassDef} !v:{#DclModule} !*Heaps !*CheckState
+ -> (![FunType],!v:{#CheckedTypeDef},!w:{#ClassDef},!v:{#DclModule},!*Heaps,!*CheckState)
+ check_function_types [fun_type=:{ft_ident,ft_type,ft_pos,ft_specials} : fun_types] module_index type_defs class_defs modules heaps cs
+ # position = newPosition ft_ident ft_pos
+ cs = { cs & cs_error = setErrorAdmin position cs.cs_error }
+ (ft_type, ft_specials, type_defs, class_defs, modules, hp_type_heaps, cs)
+ = checkFunctionType module_index ft_type ft_specials type_defs class_defs modules heaps.hp_type_heaps cs
+ (new_info_ptr, hp_var_heap) = newPtr VI_Empty heaps.hp_var_heap
+ heaps = { heaps & hp_type_heaps = hp_type_heaps, hp_var_heap = hp_var_heap }
+ fun_type = { fun_type & ft_type = ft_type, ft_specials = ft_specials, ft_type_ptr = new_info_ptr }
+ (fun_types, type_defs, class_defs, modules, heaps, cs)
+ = check_function_types fun_types module_index type_defs class_defs modules heaps cs
+ = ([fun_type:fun_types], type_defs, class_defs, modules, heaps, cs)
+ check_function_types [] module_index type_defs class_defs modules heaps cs
+ = ( [], type_defs, class_defs, modules, heaps, cs)
+
checkSpecialsOfInstances :: !Index !Index ![ClassInstance] !Index ![ClassInstance] ![FunType] {# FunType} *{! [Special] } !*Heaps !*PredefinedSymbols !*ErrorAdmin
-> (!Index, ![ClassInstance], ![FunType], !*{! [Special]}, !*Heaps, !*PredefinedSymbols,!*ErrorAdmin)
checkSpecialsOfInstances mod_index first_mem_index [class_inst=:{ins_members,ins_specials} : class_insts] next_inst_index all_class_instances all_specials
@@ -224,19 +256,19 @@ where
# cs = {cs & cs_error = checkError id_name ("wrong arity: expected "+++toString class_def.class_arity+++" found "+++toString ci_arity) cs.cs_error}
= (ins, is, type_heaps, cs)
-checkIclInstances :: !Index !*CommonDefs !u:{# DclModule} !*VarHeap !*TypeHeaps !*CheckState
- -> (![(Index,SymbolType)], !*CommonDefs, !u:{# DclModule}, !*VarHeap , !*TypeHeaps, !*CheckState)
+checkIclInstances :: !Index !*CommonDefs !u:{# DclModule} !*VarHeap !*TypeHeaps !*CheckState
+ -> (![(Index,SymbolType)], !*CommonDefs,!u:{# DclModule},!*VarHeap,!*TypeHeaps,!*CheckState)
checkIclInstances mod_index icl_common=:{com_instance_defs,com_class_defs,com_member_defs,com_generic_defs,com_type_defs} modules var_heap type_heaps cs=:{cs_error}
| cs_error.ea_ok
# (instance_types, com_instance_defs, com_class_defs, com_member_defs, com_generic_defs, com_type_defs, modules, var_heap, type_heaps, cs)
- = check_icl_instances 0 mod_index [] com_instance_defs com_class_defs com_member_defs /*AA*/com_generic_defs com_type_defs modules var_heap type_heaps cs
+ = check_icl_instances 0 mod_index [] com_instance_defs com_class_defs com_member_defs com_generic_defs com_type_defs modules var_heap type_heaps cs
= (instance_types, { icl_common & com_instance_defs = com_instance_defs,com_class_defs = com_class_defs,com_member_defs = com_member_defs, com_generic_defs = com_generic_defs, com_type_defs = com_type_defs },
modules, var_heap, type_heaps, cs)
= ([], icl_common, modules, var_heap, type_heaps, cs)
where
- check_icl_instances :: !Index !Index ![(Index,SymbolType)] !x:{# ClassInstance} !w:{# ClassDef} !v:{# MemberDef} /*AA*/!w:{# GenericDef} !nerd:{# CheckedTypeDef} !u:{# DclModule}
- !*VarHeap !*TypeHeaps !*CheckState
- -> (![(Index,SymbolType)], !x:{# ClassInstance}, !w:{# ClassDef}, !v:{# MemberDef}, /*AA*/!w:{# GenericDef}, !nerd:{# CheckedTypeDef}, !u:{# DclModule}, !*VarHeap, !*TypeHeaps, !*CheckState)
+ check_icl_instances :: !Index !Index ![(Index,SymbolType)]
+ !x:{#ClassInstance} !w:{#ClassDef} !v:{#MemberDef} !w:{#GenericDef} !z:{#CheckedTypeDef} !u:{#DclModule} !*VarHeap !*TypeHeaps !*CheckState
+ -> (![(Index,SymbolType)], !x:{#ClassInstance},!w:{#ClassDef},!v:{#MemberDef},!w:{#GenericDef},!z:{#CheckedTypeDef},!u:{#DclModule},!*VarHeap,!*TypeHeaps,!*CheckState)
check_icl_instances inst_index mod_index instance_types instance_defs class_defs member_defs generic_defs type_defs modules var_heap type_heaps cs
| inst_index < size instance_defs
# (instance_def=:{ins_ident, ins_pos}, instance_defs) = instance_defs![inst_index]
@@ -250,15 +282,15 @@ where
class_size = size class_members
| class_size == size ins_members
# (instance_types, member_defs, type_defs, modules, var_heap, type_heaps, cs)
- = check_icl_instance_members mod_index ins_class_index.gi_module
- 0 class_size ins_members class_members class_ident ins_pos ins_type instance_types member_defs type_defs modules var_heap type_heaps cs
+ = check_icl_instance_members mod_index ins_class_index.gi_module
+ 0 class_size ins_members class_members class_ident ins_pos ins_type instance_types member_defs type_defs modules var_heap type_heaps cs
= (instance_types, class_defs, member_defs, generic_defs, type_defs, modules, var_heap, type_heaps, cs)
# cs = { cs & cs_error = checkErrorWithIdentPos (newPosition class_ident ins_pos) "different number of members specified" cs.cs_error }
= (instance_types, class_defs, member_defs, generic_defs, type_defs, modules, var_heap, type_heaps, cs)
- check_icl_instance_members :: !Index !Index !Int !Int !{#ClassInstanceMember} !{#DefinedSymbol} Ident !Position !InstanceType ![(Index,SymbolType)]
- !v:{# MemberDef} !blah:{# CheckedTypeDef} !u:{# DclModule} !*VarHeap !*TypeHeaps !*CheckState
- -> (![(Index,SymbolType)], !v:{# MemberDef}, !blah:{# CheckedTypeDef}, !u:{# DclModule},!*VarHeap, !*TypeHeaps, !*CheckState)
+ check_icl_instance_members :: !Index !Index !Int !Int !{#ClassInstanceMember} !{#DefinedSymbol} Ident !Position !InstanceType
+ ![(Index,SymbolType)] !v:{# MemberDef} !z:{#CheckedTypeDef} !u:{#DclModule} !*VarHeap !*TypeHeaps !*CheckState
+ -> (![(Index,SymbolType)],!v:{# MemberDef},!z:{#CheckedTypeDef},!u:{#DclModule},!*VarHeap,!*TypeHeaps,!*CheckState)
check_icl_instance_members module_index member_mod_index mem_offset class_size ins_members class_members
class_ident ins_pos ins_type instance_types member_defs type_defs modules var_heap type_heaps cs=:{cs_x={x_main_dcl_module_n}}
| mem_offset == class_size
@@ -278,8 +310,9 @@ where
(instance_type, _, type_heaps, Yes (modules, type_defs), cs_error)
= determineTypeOfMemberInstance me_type me_class_vars ins_type SP_None type_heaps (Yes (modules, type_defs, x_main_dcl_module_n)) cs.cs_error
(st_context, var_heap) = initializeContextVariables instance_type.st_context var_heap
+ instance_type = { instance_type & st_context = st_context }
= check_icl_instance_members module_index member_mod_index (inc mem_offset) class_size ins_members class_members class_ident ins_pos ins_type
- [ (ins_member.cim_index, { instance_type & st_context = st_context }) : instance_types ] member_defs type_defs modules var_heap type_heaps { cs & cs_error = cs_error }
+ [ (ins_member.cim_index, instance_type) : instance_types ] member_defs type_defs modules var_heap type_heaps { cs & cs_error = cs_error }
getClassDef :: !GlobalIndex !Int !u:{#ClassDef} !v:{#DclModule} -> (!ClassDef,!u:{#ClassDef},!v:{#DclModule})
getClassDef {gi_module,gi_index} mod_index class_defs modules
@@ -468,7 +501,7 @@ getTypeDef x_main_dcl_module_n {glob_module,glob_object} type_defs modules
= (type_def, type_defs, modules)
# (type_def, modules) = modules![glob_module].dcl_common.com_type_defs.[glob_object]
= (type_def, type_defs, modules)
-
+
determineTypesOfDclInstances :: !Index !Index !*{#ClassInstance} !*{# ClassDef} !*{# MemberDef}
!*{#DclModule} !*TypeHeaps !*VarHeap !*CheckState
-> (![FunType], !Index, ![ClassInstance], !*{#ClassInstance}, !*{# ClassDef}, !*{# MemberDef}, !*{#DclModule}, !*TypeHeaps, !*VarHeap, !*CheckState)
@@ -483,17 +516,17 @@ determineTypesOfDclInstances first_memb_inst_index mod_index com_instance_defs c
com_member_defs, modules, type_heaps, var_heap, { cs & cs_predef_symbols=cs_predef_symbols,cs_error = cs_error })
= ([], first_memb_inst_index, [], com_instance_defs, com_class_defs, com_member_defs, modules, type_heaps, var_heap, cs)
where
- determine_types_of_dcl_instances :: !Index !Index !Index !Index !Index ![ClassInstance] !v:{#ClassDef} !w:{#MemberDef}
- !x:{#DclModule} !*{#ClassInstance} !*TypeHeaps !*VarHeap !*PredefinedSymbols !*ErrorAdmin
- -> (![FunType], !Index, ![ClassInstance], !v:{#ClassDef}, !w:{#MemberDef}, !x:{#DclModule}, !*{#ClassInstance}, !*TypeHeaps, !*VarHeap, !*PredefinedSymbols,!*ErrorAdmin)
+ determine_types_of_dcl_instances :: !Index !Index !Index !Index !Index ![ClassInstance]
+ !v:{#ClassDef} !w:{#MemberDef} !x:{#DclModule} !*{#ClassInstance} !*TypeHeaps !*VarHeap !*PredefinedSymbols !*ErrorAdmin
+ -> (![FunType], !Index, ![ClassInstance], !v:{#ClassDef},!w:{#MemberDef},!x:{#DclModule},!*{#ClassInstance},!*TypeHeaps,!*VarHeap,!*PredefinedSymbols,!*ErrorAdmin)
determine_types_of_dcl_instances x_main_dcl_module_n inst_index next_class_inst_index next_mem_inst_index mod_index all_class_specials
class_defs member_defs modules instance_defs type_heaps var_heap predef_symbols error
| inst_index < size instance_defs
- # (instance_def=:{ins_class_index,ins_pos,ins_type,ins_specials}, instance_defs) = instance_defs![inst_index]
+ # (instance_def=:{ins_class_index,ins_pos,ins_type,ins_member_types,ins_specials}, instance_defs) = instance_defs![inst_index]
# ({class_ident, class_members}, class_defs, modules) = getClassDef ins_class_index mod_index class_defs modules
class_size = size class_members
(ins_members, memb_inst_defs1, member_defs, modules, type_heaps, var_heap, error)
- = determine_dcl_instance_symbols_and_types x_main_dcl_module_n next_mem_inst_index 0 mod_index ins_class_index.gi_module class_size class_members
+ = determine_dcl_instance_symbols_and_types 0 ins_member_types x_main_dcl_module_n next_mem_inst_index mod_index ins_class_index.gi_module class_size class_members
ins_type ins_specials class_ident ins_pos member_defs modules type_heaps var_heap error
instance_def = { instance_def & ins_members = { member \\ member <- ins_members }}
(ins_specials, next_class_inst_index, all_class_specials, type_heaps, predef_symbols,error)
@@ -505,26 +538,46 @@ where
= (memb_inst_defs1 ++ memb_inst_defs2, next_mem_inst_index, all_class_specials, class_defs, member_defs, modules, instance_defs, type_heaps, var_heap, predef_symbols,error)
= ([], next_mem_inst_index, all_class_specials, class_defs, member_defs, modules, instance_defs, type_heaps, var_heap, predef_symbols,error)
- determine_dcl_instance_symbols_and_types :: !Index !Index !Index !Index !Index !Int !{#DefinedSymbol} !InstanceType !Specials Ident !Position
- !w:{#MemberDef} !u:{#DclModule} !*TypeHeaps !*VarHeap !*ErrorAdmin
- -> (![ClassInstanceMember], ![FunType], !w:{#MemberDef}, !u:{#DclModule}, !*TypeHeaps, !*VarHeap, !.ErrorAdmin)
- determine_dcl_instance_symbols_and_types x_main_dcl_module_n first_inst_index mem_offset module_index member_mod_index class_size class_members
+ determine_dcl_instance_symbols_and_types :: !Index ![FunType] !Index !Index !Index !Index !Int !{#DefinedSymbol} !InstanceType !Specials Ident !Position
+ !w:{#MemberDef} !u:{#DclModule} !*TypeHeaps !*VarHeap !*ErrorAdmin
+ -> (![ClassInstanceMember], ![FunType], !w:{#MemberDef},!u:{#DclModule},!*TypeHeaps,!*VarHeap,!.ErrorAdmin)
+ determine_dcl_instance_symbols_and_types mem_offset member_types x_main_dcl_module_n first_inst_index module_index member_mod_index class_size class_members
ins_type ins_specials class_ident ins_pos member_defs modules type_heaps var_heap cs_error
| mem_offset == class_size
= ([], [], member_defs, modules, type_heaps, var_heap, cs_error)
# class_member = class_members.[mem_offset]
- class_instance_member = {cim_ident=class_member.ds_ident, cim_arity=class_member.ds_arity, cim_index = first_inst_index + mem_offset}
({me_ident,me_type,me_priority,me_class_vars}, member_defs, modules) = getMemberDef member_mod_index class_member.ds_index module_index member_defs modules
cs_error = pushErrorAdmin (newPosition class_ident ins_pos) cs_error
(instance_type, new_ins_specials, type_heaps, Yes (modules, _), cs_error)
= determineTypeOfMemberInstance me_type me_class_vars ins_type ins_specials type_heaps (Yes (modules, {}, cUndef)) cs_error
+ (instance_type, new_ins_specials, member_types, modules, type_heaps, cs_error)
+ = if_instance_member_type_specified_compare_and_use member_types instance_type new_ins_specials me_ident modules type_heaps cs_error
cs_error = popErrorAdmin cs_error
(new_info_ptr, var_heap) = newPtr VI_Empty var_heap
inst_def = MakeNewFunctionType me_ident me_type.st_arity me_priority instance_type ins_pos new_ins_specials new_info_ptr
(inst_symbols, memb_inst_defs, member_defs, modules, type_heaps, var_heap, cs_error)
- = determine_dcl_instance_symbols_and_types x_main_dcl_module_n first_inst_index (inc mem_offset) module_index member_mod_index
- class_size class_members ins_type ins_specials class_ident ins_pos member_defs modules type_heaps var_heap cs_error
- = ([class_instance_member : inst_symbols], [inst_def : memb_inst_defs], member_defs, modules, type_heaps, var_heap, cs_error)
+ = determine_dcl_instance_symbols_and_types (inc mem_offset) member_types x_main_dcl_module_n first_inst_index module_index member_mod_index
+ class_size class_members ins_type ins_specials class_ident ins_pos member_defs modules type_heaps var_heap cs_error
+ class_member = {cim_ident=class_member.ds_ident, cim_arity=class_member.ds_arity, cim_index = first_inst_index + mem_offset}
+ = ([class_member : inst_symbols], [inst_def : memb_inst_defs], member_defs, modules, type_heaps, var_heap, cs_error)
+ where
+ if_instance_member_type_specified_compare_and_use :: [FunType] SymbolType FunSpecials Ident !u:{#DclModule} !*TypeHeaps !*ErrorAdmin
+ -> (!SymbolType,!FunSpecials,![FunType],!u:{#DclModule},!*TypeHeaps,!*ErrorAdmin)
+ if_instance_member_type_specified_compare_and_use member_types=:[] instance_type specials me_ident modules type_heaps cs_error
+ = (instance_type, specials, member_types, modules, type_heaps, cs_error)
+ if_instance_member_type_specified_compare_and_use member_types=:[{ft_ident,ft_type,ft_arity}:tl_member_types] instance_type specials me_ident modules type_heaps cs_error
+ | ft_ident.id_name<me_ident.id_name
+ = if_instance_member_type_specified_compare_and_use tl_member_types instance_type specials me_ident modules type_heaps cs_error
+ | ft_ident.id_name<>me_ident.id_name
+ = (instance_type, specials, member_types, modules, type_heaps, cs_error)
+ | ft_arity<>instance_type.st_arity
+ # cs_error = specified_member_type_incorrect_error CEC_NrArgsNotOk cs_error
+ = (instance_type, specials, member_types, modules, type_heaps, cs_error)
+ # (error_code,type_heaps) = compare_specified_and_derived_instance_types ft_type instance_type type_heaps
+ | error_code==CEC_Ok || error_code==CEC_OkWithFirstMoreStrictness
+ = (ft_type, specials, member_types, modules, type_heaps, cs_error)
+ # cs_error = specified_member_type_incorrect_error error_code cs_error
+ = (instance_type, specials, member_types, modules, type_heaps, cs_error)
check_instance_specials :: !Index !ClassInstance !Index !Specials !Index ![ClassInstance] !*TypeHeaps !*PredefinedSymbols !*ErrorAdmin
-> (!Specials, !Index, ![ClassInstance], !*TypeHeaps, !*PredefinedSymbols,!*ErrorAdmin)
@@ -896,6 +949,10 @@ instance < FunDef
where
(<) fd1 fd2 = fd1.fun_ident.id_name < fd2.fun_ident.id_name
+instance < FunType
+where
+ (<) fd1 fd2 = fd1.ft_ident.id_name < fd2.ft_ident.id_name
+
collectCommonDefinitions :: !(CollectedDefinitions ClassInstance) -> (!*{# Int}, ![Declaration])
collectCommonDefinitions {def_types,def_constructors,def_selectors,def_classes,def_members,def_instances, def_generic_cases, def_generics}
// MW: the order in which the declarations appear in the returned list is essential (explicit imports)
@@ -982,15 +1039,15 @@ checkCommonDefinitions opt_icl_info module_index common modules heaps cs
com_selector_defs = array_plus_list com_selector_defs new_selector_defs
com_cons_defs = array_plus_list com_cons_defs new_cons_defs
- common = {common & com_type_defs = com_type_defs, com_cons_defs = com_cons_defs, com_selector_defs = com_selector_defs, com_class_defs = com_class_defs,
- com_member_defs = com_member_defs, com_instance_defs = com_instance_defs,
+ common = {common & com_type_defs = com_type_defs, com_cons_defs = com_cons_defs, com_selector_defs = com_selector_defs,
+ 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}
heaps = {heaps & hp_var_heap=hp_var_heap,hp_type_heaps={hp_type_heaps & th_vars=th_vars}}
= (dictionary_info,common, modules, heaps, { cs & cs_symbol_table = cs_symbol_table })
# dictionary_info = { n_dictionary_types=0, n_dictionary_constructors=0, n_dictionary_selectors=0 }
- common = {common & com_type_defs = com_type_defs, com_cons_defs = com_cons_defs, com_selector_defs = com_selector_defs, com_class_defs = com_class_defs,
- com_member_defs = com_member_defs, com_instance_defs = com_instance_defs,
+ common = {common & com_type_defs = com_type_defs, com_cons_defs = com_cons_defs, com_selector_defs = com_selector_defs,
+ 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}
= (dictionary_info,common, modules, heaps, cs)
@@ -1020,8 +1077,8 @@ where
# ({fun_ident, fun_pos}, fun_defs) = fun_defs![decl_index]
= ([Declaration { decl_ident = fun_ident, decl_pos = fun_pos, decl_kind = STE_DclMacroOrLocalMacroFunction [], decl_index = decl_index } : defs], fun_defs)
-gimme_a_strict_array_type :: !u:{!.a} -> v:{!.a}, [u<=v]
-gimme_a_strict_array_type a = a
+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})
@@ -1483,8 +1540,7 @@ checkDclModules imports_of_icl_mod dcl_modules macro_defs heaps cs=:{cs_symbol_t
#! nr_of_dcl_modules = size dcl_modules
# (bitvect, dependencies, dcl_modules, cs_symbol_table)
= iFoldSt add_dependencies 0 nr_of_dcl_modules
- (bitvectCreate (nr_of_dcl_modules+1), gimme_a_strict_array_type (createArray (nr_of_dcl_modules+1) []),
- dcl_modules, cs_symbol_table)
+ (bitvectCreate (nr_of_dcl_modules+1), createStrictArray (nr_of_dcl_modules+1) [], dcl_modules, cs_symbol_table)
index_of_icl_module = nr_of_dcl_modules
(dependencies_of_icl_mod, (_, cs_symbol_table))
= mapFilterYesSt get_opt_dependency imports_of_icl_mod (bitvect, cs_symbol_table)
@@ -1502,7 +1558,7 @@ checkDclModules imports_of_icl_mod dcl_modules macro_defs heaps cs=:{cs_symbol_t
reversed_dag = { module_dag & dag_get_children = select reversed_dag1 }
components_importing_module_a = groupify reversed_dag component_numbers nr_of_components
// module i is imported by components with _component_ numbers components_importing_module_a.[i]
- components_array = gimme_a_strict_array_type { component \\ component <- components }
+ components_array = {! component \\ component <- components }
(expl_imp_symbols_in_components, expl_imp_indices, (dcl_modules, cs_symbol_table))
= mapY2St (get_expl_imp_symbols_of_component imports_of_icl_mod) components (dcl_modules, cs_symbol_table)
@@ -2019,7 +2075,7 @@ check_module1 cdefs icl_global_function_range fun_defs optional_dcl_mod optional
# error = {ea_file = err_file, ea_loc = [], ea_ok = True }
first_inst_index = length fun_defs
- (inst_fun_defs, def_instances) = convert_class_instances cdefs.def_instances first_inst_index
+ (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
@@ -2043,7 +2099,7 @@ check_module1 cdefs icl_global_function_range fun_defs optional_dcl_mod optional
(scanned_modules,macro_defs,cs) = add_dcl_module_predef_module_and_modules_to_symbol_table optional_dcl_mod optional_pre_def_mod scanned_modules nr_of_cached_modules cs
macro_defs = make_macro_def_array cached_dcl_macros macro_defs
- init_new_dcl_modules = gimme_a_strict_array_type { initialDclModule scanned_module module_n \\ scanned_module <- scanned_modules & module_n<-[nr_of_cached_modules..]}
+ init_new_dcl_modules = {! initialDclModule scanned_module module_n \\ scanned_module <- scanned_modules & module_n<-[nr_of_cached_modules..]}
init_dcl_modules = { if (i<size dcl_modules)
dcl_modules.[i]
@@ -2095,7 +2151,7 @@ check_module1 cdefs icl_global_function_range fun_defs optional_dcl_mod optional
= ([mod_sizes_and_defs:mods],[dcl_macro_defs:macro_defs], cs)
add_module_to_symbol_table mod=:{mod_defs} mod_index cs=:{cs_symbol_table, cs_error}
- # def_instances = convert_class_instances mod_defs.def_instances
+ # def_instances = convert_dcl_class_instances mod_defs.def_instances
# def_generic_cases = convert_generic_instances mod_defs.def_generic_cases
mod_defs = { mod_defs & def_instances = def_instances, def_generic_cases = def_generic_cases }
sizes_and_defs = collectFunctionTypes mod_defs.def_funtypes (collectCommonDefinitions mod_defs)
@@ -2107,10 +2163,10 @@ check_module1 cdefs icl_global_function_range fun_defs optional_dcl_mod optional
(cs_symbol_table, cs_error) = addDefToSymbolTable cGlobalScope mod_index mod.mod_ident (STE_Module mod) cs_symbol_table cs_error
= ((mod,sizes,defs),dcl_macro_defs,{ cs & cs_symbol_table = cs_symbol_table, cs_error = cs_error })
where
- convert_class_instances :: ![ParsedInstance a] -> [ClassInstance]
- convert_class_instances [pi : pins]
- = [ParsedInstanceToClassInstance pi {} : convert_class_instances pins]
- convert_class_instances []
+ convert_dcl_class_instances :: ![ScannedInstanceAndMembersR a] -> [ClassInstance]
+ convert_dcl_class_instances [{sim_pi,sim_member_types} : pins]
+ = [ParsedInstanceToClassInstance sim_pi {} sim_member_types : convert_dcl_class_instances pins]
+ convert_dcl_class_instances []
= []
convert_generic_instances :: ![GenericCaseDef] -> [GenericCaseDef]
@@ -2118,13 +2174,13 @@ check_module1 cdefs icl_global_function_range fun_defs optional_dcl_mod optional
// TODO: check what to do here
= gcs //[{ gc & gc_body = gc.gc_body } \\ gc <- gcs]
- convert_class_instances :: .[ParsedInstance FunDef] Int -> (!.[FunDef],!.[ClassInstance]);
- convert_class_instances [pi=:{pi_members} : pins] next_fun_index
- # ins_members = sort pi_members
+ convert_icl_class_instances :: .[ScannedInstanceAndMembersR FunDef] Int -> (!.[FunDef],!.[ClassInstance]);
+ convert_icl_class_instances [{sim_pi,sim_members} : pins] next_fun_index
+ # ins_members = sort sim_members
(member_symbols, next_fun_index) = determine_indexes_of_members ins_members next_fun_index
- (next_fun_defs, cins) = convert_class_instances pins next_fun_index
- = (ins_members ++ next_fun_defs, [ParsedInstanceToClassInstance pi { member \\ member <- member_symbols} : cins])
- convert_class_instances [] next_fun_index
+ (next_fun_defs, cins) = convert_icl_class_instances pins next_fun_index
+ = (ins_members ++ next_fun_defs, [ParsedInstanceToClassInstance sim_pi {member \\ member <- member_symbols} [] : cins])
+ convert_icl_class_instances [] next_fun_index
= ([], [])
determine_indexes_of_members [{fun_ident,fun_arity}:members] next_fun_index
@@ -2273,7 +2329,7 @@ check_module2 mod_ident mod_modification_time mod_imported_objects mod_imports m
{cs_symbol_table, cs_predef_symbols, cs_error,cs_x } = cs
(icl_functions, hp_type_heaps, cs_error)
- = foldSt checkSpecifiedInstanceType instance_types (icl_functions, heaps.hp_type_heaps, cs_error)
+ = foldSt copyInstanceTypeAndCheckSpecifiedInstanceType instance_types (icl_functions, heaps.hp_type_heaps, cs_error)
heaps = { heaps & hp_type_heaps = hp_type_heaps }
@@ -2292,8 +2348,6 @@ check_module2 mod_ident mod_modification_time mod_imported_objects mod_imports m
(icl_specials,dcl_modules, icl_functions, var_heap, th_vars, expr_heap)
= collect_specialized_functions_in_dcl_module mod_type nr_of_functions main_dcl_module_n dcl_modules icl_functions hp_var_heap th_vars hp_expression_heap
- icl_functions = copy_instance_types instance_types icl_functions
-
(dcl_modules, class_instances, icl_functions, cs_predef_symbols)
= adjust_instance_types_of_array_functions_in_std_array_icl dcl_modules class_instances icl_functions main_dcl_module_n cs_predef_symbols
@@ -2392,7 +2446,6 @@ check_module2 mod_ident mod_modification_time mod_imported_objects mod_imports m
# (icl_functions, (var_heap, type_var_heap, expr_heap))
= collect_specialized_functions ir_from ir_to dcl_functions (icl_functions, (var_heap, type_var_heap, expr_heap))
= (dcl_specials,modules, icl_functions, var_heap, type_var_heap, expr_heap)
-
where
collect_specialized_functions spec_index last_index dcl_fun_types (icl_functions, heaps)
| spec_index < last_index
@@ -2428,14 +2481,6 @@ check_module2 mod_ident mod_modification_time mod_imported_objects mod_imports m
new_free_var fv var_heap
# (fv_info_ptr, var_heap) = newPtr VI_Empty var_heap
= ({ fv & fv_info_ptr = fv_info_ptr, fv_def_level = NotALevel, fv_count = 0}, var_heap)
-
- copy_instance_types :: [(Index,SymbolType)] !*{# FunDef} -> *{# FunDef}
- copy_instance_types types fun_defs
- = foldl copy_instance_type fun_defs types
-
- copy_instance_type fun_defs (index, symbol_type)
- # (inst_def, fun_defs) = fun_defs![index]
- = { fun_defs & [index] = { inst_def & fun_type = Yes symbol_type }}
adjust_instance_types_of_array_functions_in_std_array_icl dcl_modules class_instances fun_defs main_dcl_module_n predef_symbols
# ({pds_def}, predef_symbols) = predef_symbols![PD_StdArray]
@@ -2466,34 +2511,54 @@ check_module2 mod_ident mod_modification_time mod_imported_objects mod_imports m
(Yes symbol_type) = inst_def.fun_type
= { instance_defs & [cim_index] = { inst_def & fun_type = Yes (makeElemTypeOfArrayFunctionStrict symbol_type ins_offset offset_table) } }
- checkSpecifiedInstanceType (index_of_member_fun, derived_symbol_type) (icl_functions, type_heaps, cs_error)
- # ({fun_type, fun_pos, fun_ident}, icl_functions) = icl_functions![index_of_member_fun]
- # (cs_error, type_heaps)
- = case fun_type of
- No
- -> (cs_error, type_heaps)
+ copyInstanceTypeAndCheckSpecifiedInstanceType :: (Int,SymbolType) *(*{#FunDef},*TypeHeaps,*ErrorAdmin) -> (!*{#FunDef},!*TypeHeaps,!*ErrorAdmin)
+ copyInstanceTypeAndCheckSpecifiedInstanceType (index_of_member_fun, derived_symbol_type) (icl_functions, type_heaps, cs_error)
+ # (fun_type,icl_functions) = icl_functions![index_of_member_fun].fun_type
+ # (icl_functions, type_heaps, cs_error)
+ = case fun_type of
+ No
+ # icl_functions = {icl_functions & [index_of_member_fun].fun_type = Yes derived_symbol_type}
+ -> (icl_functions, type_heaps, cs_error)
Yes specified_symbol_type
| not cs_error.ea_ok
- -> (cs_error, type_heaps)
+ # icl_functions = {icl_functions & [index_of_member_fun].fun_type = Yes derived_symbol_type}
+ -> (icl_functions, type_heaps, cs_error)
# (err_code, type_heaps)
- = symbolTypesCorrespond specified_symbol_type derived_symbol_type type_heaps
+ = compare_specified_and_derived_instance_types specified_symbol_type derived_symbol_type type_heaps
| err_code==CEC_Ok
- -> (cs_error, type_heaps)
- # cs_error = pushErrorAdmin (newPosition fun_ident fun_pos) cs_error
- luxurious_explanation
- = case err_code of
- CEC_ResultNotOK -> "result type"
- CEC_ArgNrNotOk -> "nr or arguments"
- CEC_ContextNotOK -> "context"
- CEC_AttrEnvNotOK -> "attribute environment"
- 1 -> "first argument"
- 2 -> "second argument"
- 3 -> "third argument"
- _ -> toString err_code+++"th argument"
- cs_error = checkError "the specified member type is incorrect (" (luxurious_explanation+++" not ok)") cs_error
- -> ( popErrorAdmin cs_error, type_heaps)
+ # icl_functions = {icl_functions & [index_of_member_fun].fun_type = Yes derived_symbol_type}
+ -> (icl_functions, type_heaps, cs_error)
+ | err_code==CEC_OkWithFirstMoreStrictness
+ # (function,icl_functions) = icl_functions![index_of_member_fun]
+ # function = {function & fun_type = Yes specified_symbol_type,
+ fun_info.fi_properties = function.fun_info.fi_properties bitor FI_MemberInstanceRequiresTypeInDefMod}
+ # icl_functions = {icl_functions & [index_of_member_fun] = function}
+ -> (icl_functions, type_heaps, cs_error)
+ # ({fun_ident,fun_pos},icl_functions) = icl_functions![index_of_member_fun]
+ cs_error = pushErrorAdmin (newPosition fun_ident fun_pos) cs_error
+ cs_error = specified_member_type_incorrect_error err_code cs_error
+ cs_error = popErrorAdmin cs_error
+ icl_functions = {icl_functions & [index_of_member_fun].fun_type = Yes derived_symbol_type}
+ -> (icl_functions, type_heaps, cs_error)
= (icl_functions, type_heaps, cs_error)
+specified_member_type_incorrect_error error_code cs_error
+ = specified_type_incorrect_error "the specified member type is incorrect (" error_code cs_error
+
+specified_type_incorrect_error error_s error_code cs_error
+ # luxurious_explanation
+ = case error_code of
+ CEC_ResultNotOK -> "result type"
+ CEC_NrArgsNotOk -> "nr of arguments"
+ CEC_StrictnessOfArgsNotOk -> "! before argument"
+ CEC_ContextNotOK -> "context"
+ CEC_AttrEnvNotOK -> "attribute environment"
+ 1 -> "first argument"
+ 2 -> "second argument"
+ 3 -> "third argument"
+ _ -> toString error_code+++"th argument"
+ = checkError error_s (luxurious_explanation+++" not ok)") cs_error
+
checkForeignExports :: [ParsedForeignExport] [IndexRange] *{#FunDef} *CheckState -> (![ForeignExport],!*{#FunDef},!*CheckState)
checkForeignExports [{pfe_ident=pfe_ident=:{id_name,id_info},pfe_line,pfe_file,pfe_stdcall}:foreign_exports] icl_global_functions_ranges fun_defs cs
# ({ste_kind,ste_index},cs_symbol_table) = readPtr id_info cs.cs_symbol_table
@@ -2928,21 +2993,16 @@ checkInstancesOfDclModule mod_index (nr_of_dcl_functions_and_instances, nr_of_dc
True
-> adjust_instance_types_of_array_functions_in_std_array_dcl mod_index
com_member_defs com_instance_defs dcl_functions cs
- #! dcl_mod = { dcl_mod & dcl_functions = dcl_functions,
+ #! dcl_mod = {dcl_mod & dcl_functions = dcl_functions,
dcl_specials = { ir_from = nr_of_dcl_functions_and_instances,
ir_to = nr_of_dcl_funs_insts_and_specs },
dcl_gencases = { ir_from = nr_of_dcl_funs_insts_and_specs
, ir_to = nr_of_dcl_funs_insts_specs_and_gencases},
- dcl_common =
- { dcl_common
- & com_instance_defs = array_plus_list com_instance_defs new_class_instances
- , com_class_defs = com_class_defs
- , com_member_defs = com_member_defs
- , com_gencase_defs = com_gencase_defs
- }}
-
- // TODO: update the instance range or create another, generic function range
-
+ dcl_common = {dcl_common & com_instance_defs = array_plus_list com_instance_defs new_class_instances
+ , com_class_defs = com_class_defs
+ , com_member_defs = com_member_defs
+ , com_gencase_defs = com_gencase_defs
+ }}
dcl_modules = { dcl_modules & [mod_index] = dcl_mod }
= (dcl_modules, heaps, cs)
where
@@ -3019,11 +3079,13 @@ checkDclModule2 dcl_imported_module_numbers components_importing_module imports_
#!nr_of_members = count_members mod_index dcl_common.com_instance_defs dcl_common.com_class_defs modules
# nr_of_dcl_functions_and_instances = nr_of_dcl_functions+nr_of_members
-
(nr_of_dcl_funs_insts_and_specs, rev_function_list, rev_special_defs, com_type_defs, com_class_defs, modules, heaps, cs)
= checkDclFunctions mod_index nr_of_dcl_functions_and_instances dcl_funtypes
dcl_common.com_type_defs dcl_common.com_class_defs modules heaps cs
+ (com_instance_defs, com_type_defs, com_class_defs, modules, heaps, cs)
+ = checkDclInstanceMemberTypes dcl_common.com_instance_defs mod_index com_type_defs com_class_defs modules heaps cs
+
dcl_functions = { function \\ function <- reverse rev_function_list }
com_member_defs = dcl_common.com_member_defs
e_info = { ef_type_defs = com_type_defs, ef_selector_defs = dcl_common.com_selector_defs, ef_class_defs = com_class_defs,
@@ -3035,8 +3097,6 @@ checkDclModule2 dcl_imported_module_numbers components_importing_module imports_
cs = check_needed_modules_are_imported mod_ident ".dcl" cs
- com_instance_defs = dcl_common.com_instance_defs
-
(ef_member_defs, com_instance_defs, dcl_functions, cs)
= adjust_predefined_symbols mod_index e_info.ef_member_defs com_instance_defs dcl_functions cs
@@ -3240,7 +3300,6 @@ instance <<< Special
where
(<<<) file {spec_types} = file <<< spec_types
-
instance <<< SpecialSubstitution
where
(<<<) file {ss_environ} = file <<< ss_environ
diff --git a/frontend/comparedefimp.dcl b/frontend/comparedefimp.dcl
index 0897570..4a58c15 100644
--- a/frontend/comparedefimp.dcl
+++ b/frontend/comparedefimp.dcl
@@ -7,12 +7,14 @@ import syntax, checksupport
compareDefImp :: !Int !DclModule !(Optional {#Index}) !CopiedDefinitions !Int !*IclModule !*{#*{#FunDef}} !*Heaps !*ErrorAdmin
-> (!.IclModule,!.{#.{#FunDef}},!.Heaps,!.ErrorAdmin)
-symbolTypesCorrespond :: !SymbolType !SymbolType !*TypeHeaps -> (!ComparisionErrorCode, !.TypeHeaps)
+compare_specified_and_derived_instance_types :: !SymbolType !SymbolType !*TypeHeaps -> (!ComparisionErrorCode, !*TypeHeaps)
:: ComparisionErrorCode :== Int
// arg n not ok: n
CEC_ResultNotOK :== 0
CEC_Ok :== -1
-CEC_ArgNrNotOk :== -2
-CEC_ContextNotOK :== -3
-CEC_AttrEnvNotOK :== -4
+CEC_NrArgsNotOk :== -2
+CEC_StrictnessOfArgsNotOk :== -3
+CEC_ContextNotOK :== -4
+CEC_AttrEnvNotOK :== -5
+CEC_OkWithFirstMoreStrictness :== -6 // only for compare_specified_and_derived_instance_types
diff --git a/frontend/comparedefimp.icl b/frontend/comparedefimp.icl
index 5a70a1c..7124bab 100644
--- a/frontend/comparedefimp.icl
+++ b/frontend/comparedefimp.icl
@@ -36,7 +36,6 @@ where
= (icl_type_defs, icl_cons_defs, comp_st)
# comp_error = compareError type_def_error (newPosition icl_type_def.td_ident icl_type_def.td_pos) comp_st.comp_error
= (icl_type_defs, icl_cons_defs, { comp_st & comp_error = comp_error })
-// ---> ("compare_type_defs", dcl_type_def.td_ident, dcl_type_def.td_rhs, icl_type_def.td_ident, icl_type_def.td_rhs)
= (icl_type_defs, icl_cons_defs, comp_st)
compare_rhs_of_types (AlgType dclConstructors) (AlgType iclConstructors) dcl_cons_defs icl_cons_defs comp_st
@@ -120,7 +119,7 @@ where
| not copied_from_dcl.[class_index]
# dcl_class_def = dcl_class_defs.[class_index]
(icl_class_def, icl_class_defs) = icl_class_defs![class_index]
- # (ok, icl_member_defs, comp_st) = compare_classes dcl_class_def dcl_member_defs icl_class_def icl_member_defs comp_st
+ (ok, icl_member_defs, comp_st) = compare_classes dcl_class_def dcl_member_defs icl_class_def icl_member_defs comp_st
| ok
= (icl_class_defs, icl_member_defs, comp_st)
# comp_error = compareError class_def_error (newPosition icl_class_def.class_ident icl_class_def.class_pos) comp_st.comp_error
@@ -154,20 +153,69 @@ where
= (False, icl_member_defs, comp_st)
= (False, icl_member_defs, comp_st)
-compareInstanceDefs :: !{# Int} !{# ClassInstance} !u:{# ClassInstance} !*CompareState -> (!u:{# ClassInstance}, !*CompareState)
-compareInstanceDefs dcl_sizes dcl_instance_defs icl_instance_defs comp_st
+compareInstanceDefs :: !{# Int} !{# ClassInstance} !u:{# ClassInstance} !*{#FunDef} !*CompareState
+ -> (!u:{# ClassInstance},!*{#FunDef},!*CompareState)
+compareInstanceDefs dcl_sizes dcl_instance_defs icl_instance_defs icl_functions comp_st
# nr_of_dcl_instances = dcl_sizes.[cInstanceDefs]
- = iFoldSt (compare_instance_defs dcl_instance_defs) 0 nr_of_dcl_instances (icl_instance_defs, comp_st)
+ = iFoldSt (compare_instance_defs dcl_instance_defs) 0 nr_of_dcl_instances (icl_instance_defs,icl_functions,comp_st)
where
- compare_instance_defs :: !{# ClassInstance} !Index (!u:{# ClassInstance}, !*CompareState) -> (!u:{# ClassInstance}, !*CompareState)
- compare_instance_defs dcl_instance_defs instance_index (icl_instance_defs, comp_st)
+ compare_instance_defs :: !{# ClassInstance} !Index !(!u:{# ClassInstance},!*{#FunDef},!*CompareState)
+ -> (!u:{# ClassInstance},!*{#FunDef},!*CompareState)
+ compare_instance_defs dcl_instance_defs instance_index (icl_instance_defs,icl_functions,comp_st)
# dcl_instance_def = dcl_instance_defs.[instance_index]
(icl_instance_def, icl_instance_defs) = icl_instance_defs![instance_index]
(ok, comp_st) = compare dcl_instance_def.ins_type icl_instance_def.ins_type comp_st
- | ok
- = (icl_instance_defs, comp_st)
- # comp_error = compareError instance_def_error (newPosition icl_instance_def.ins_ident icl_instance_def.ins_pos) comp_st.comp_error
- = (icl_instance_defs, { comp_st & comp_error = comp_error })
+ | not ok
+ # comp_st = instance_def_conflicts_error icl_instance_def.ins_ident icl_instance_def.ins_pos comp_st
+ = (icl_instance_defs,icl_functions, comp_st)
+ # (icl_functions,comp_st)
+ = member_types_equal dcl_instance_def.ins_member_types icl_instance_def.ins_members 0 icl_functions comp_st
+ = (icl_instance_defs,icl_functions,comp_st)
+
+ member_types_equal :: [FunType] {#ClassInstanceMember} Int *{#FunDef} *CompareState -> (!*{#FunDef},!*CompareState)
+ member_types_equal [] icl_instance_members icl_member_n icl_functions comp_st
+ | icl_member_n<size icl_instance_members
+ # function_index = icl_instance_members.[icl_member_n].cim_index
+ | icl_functions.[function_index].fun_info.fi_properties bitand FI_MemberInstanceRequiresTypeInDefMod<>0
+ # ({fun_ident,fun_pos},icl_functions) = icl_functions![function_index]
+ # comp_st = instance_def_conflicts_error fun_ident fun_pos comp_st
+ = member_types_equal [] icl_instance_members (icl_member_n+1) icl_functions comp_st
+ = member_types_equal [] icl_instance_members (icl_member_n+1) icl_functions comp_st
+ = (icl_functions,comp_st)
+ member_types_equal [instance_member_type:instance_member_types] icl_instance_members icl_member_n icl_functions comp_st
+ = member_type_and_types_equal instance_member_type instance_member_types icl_instance_members icl_member_n icl_functions comp_st
+ where
+ member_type_and_types_equal instance_member_type=:{ft_ident,ft_type,ft_pos} instance_member_types icl_instance_members icl_member_n icl_functions comp_st
+ | icl_member_n<size icl_instance_members
+ # {cim_ident,cim_index} = icl_instance_members.[icl_member_n]
+ | ft_ident.id_name<>cim_ident.id_name
+ | icl_functions.[cim_index].fun_info.fi_properties bitand FI_MemberInstanceRequiresTypeInDefMod<>0
+ # ({fun_ident,fun_pos},icl_functions) = icl_functions![cim_index]
+ # comp_st = instance_def_conflicts_error fun_ident fun_pos comp_st
+ = member_type_and_types_equal instance_member_type instance_member_types icl_instance_members (icl_member_n+1) icl_functions comp_st
+ = member_type_and_types_equal instance_member_type instance_member_types icl_instance_members (icl_member_n+1) icl_functions comp_st
+
+ # ({fun_type},icl_functions) = icl_functions![cim_index]
+ # (Yes icl_instance_member_type) = fun_type
+
+ # tc_state = { tc_type_vars = initial_hwn comp_st.comp_type_var_heap
+ , tc_attr_vars = initial_hwn comp_st.comp_attr_var_heap
+ , tc_strictness_flags = 0
+ }
+ # tc_state = init_symbol_type_vars ft_type icl_instance_member_type tc_state
+
+ # (corresponds, tc_state) = t_corresponds ft_type icl_instance_member_type tc_state
+ # comp_st = {comp_st & comp_type_var_heap=tc_state.tc_type_vars.hwn_heap,
+ comp_attr_var_heap=tc_state.tc_attr_vars.hwn_heap }
+ # comp_st = if (not corresponds)
+ (instance_def_conflicts_error ft_ident ft_pos comp_st)
+ comp_st
+ = member_types_equal instance_member_types icl_instance_members (icl_member_n+1) icl_functions comp_st
+ # comp_st = instance_def_conflicts_error ft_ident ft_pos comp_st
+ = member_types_equal instance_member_types icl_instance_members icl_member_n icl_functions comp_st
+
+ instance_def_conflicts_error ident pos comp_st
+ = {comp_st & comp_error = compareError instance_def_error (newPosition ident pos) comp_st.comp_error }
compareGenericDefs :: !{# Int} !{#Bool} !{# GenericDef} !u:{# GenericDef} !*CompareState -> (!u:{# GenericDef}, !*CompareState)
compareGenericDefs dcl_sizes copied_from_dcl dcl_generic_defs icl_generic_defs comp_st
@@ -188,11 +236,9 @@ where
= (icl_generic_defs, { comp_st & comp_error = comp_error })
| otherwise
= (icl_generic_defs, comp_st)
-
class compare a :: !a !a !*CompareState -> (!Bool, !*CompareState)
-
instance compare (a,b) | compare a & compare b
where
compare (x1, y1) (x2, y2) comp_st
@@ -376,13 +422,16 @@ initialyseAttributeVars [] [{av_info_ptr}:icl_type_vars] type_var_heap
= initialyseAttributeVars [] icl_type_vars (type_var_heap <:= (av_info_ptr, AVI_Empty));
initialyseAttributeVars [] [] type_var_heap
= type_var_heap
-
+
:: TypesCorrespondState =
{ tc_type_vars :: !.HeapWithNumber TypeVarInfo
, tc_attr_vars :: !.HeapWithNumber AttrVarInfo
- , tc_ignore_strictness :: !Bool
+ , tc_strictness_flags :: !Int
}
+AllowFirstMoreStrictness:==1;
+FirstHasMoreStrictness:==2;
+
:: TypesCorrespondMonad
:== *TypesCorrespondState -> *(!Bool, !*TypesCorrespondState)
@@ -414,9 +463,10 @@ initialyseAttributeVars [] [] type_var_heap
// arg n not ok: n
CEC_ResultNotOK :== 0
CEC_Ok :== -1
-CEC_ArgNrNotOk :== -2
-CEC_ContextNotOK :== -3
-CEC_AttrEnvNotOK :== -4
+CEC_NrArgsNotOk :== -2
+CEC_StrictnessOfArgsNotOk :== -3
+CEC_ContextNotOK :== -4
+CEC_AttrEnvNotOK :== -5
class t_corresponds a :: !a !a -> *TypesCorrespondMonad
// whether two types correspond
@@ -460,8 +510,8 @@ compareDefImp main_dcl_module_n main_dcl_module (Yes macro_conversion_table) {co
= compareClassDefs main_dcl_module.dcl_sizes copied_class_defs dcl_common.com_class_defs dcl_common.com_member_defs
icl_com_class_defs icl_com_member_defs comp_st
- (icl_com_instance_defs, comp_st)
- = compareInstanceDefs main_dcl_module.dcl_sizes dcl_common.com_instance_defs icl_com_instance_defs comp_st
+ (icl_com_instance_defs, icl_functions, comp_st)
+ = compareInstanceDefs main_dcl_module.dcl_sizes dcl_common.com_instance_defs icl_com_instance_defs icl_functions comp_st
(icl_com_generic_defs, comp_st)
= compareGenericDefs
@@ -473,7 +523,7 @@ compareDefImp main_dcl_module_n main_dcl_module (Yes macro_conversion_table) {co
tc_state
= { tc_type_vars = initial_hwn th_vars
, tc_attr_vars = initial_hwn th_attrs
- , tc_ignore_strictness = False
+ , tc_strictness_flags = 0
}
(icl_functions, macro_defs, hp_var_heap, hp_expression_heap, tc_state, error_admin)
= compareMacrosWithConversion main_dcl_module_n macro_conversion_table dcl_macros icl_functions macro_defs hp_var_heap hp_expression_heap tc_state error_admin
@@ -494,9 +544,9 @@ compareDefImp main_dcl_module_n main_dcl_module (Yes macro_conversion_table) {co
compareFunctionTypes n_exported_global_functions dcl_fun_types icl_functions tc_state error_admin
= iFoldSt (compareTwoFunctionTypes dcl_fun_types) 0 n_exported_global_functions (icl_functions, tc_state, error_admin)
-compareTwoFunctionTypes :: /*!{#Int}*/ !{#FunType} !Int !*(!u:{#FunDef},!*TypesCorrespondState,!*ErrorAdmin)
- -> (!v:{#FunDef},!.TypesCorrespondState,!.ErrorAdmin) , [u <= v]
-compareTwoFunctionTypes /*conversions*/ dcl_fun_types dclIndex (icl_functions, tc_state, error_admin)
+compareTwoFunctionTypes :: !{#FunType} !Int !*(!u:{#FunDef},!*TypesCorrespondState,!*ErrorAdmin)
+ -> (!v:{#FunDef},!.TypesCorrespondState,!.ErrorAdmin) , [u <= v]
+compareTwoFunctionTypes dcl_fun_types dclIndex (icl_functions, tc_state, error_admin)
# (fun_def=:{fun_type, fun_priority}, icl_functions) = icl_functions![dclIndex]
= case fun_type of
No -> generate_error "type of exported function is missing" fun_def icl_functions tc_state error_admin
@@ -504,40 +554,43 @@ compareTwoFunctionTypes /*conversions*/ dcl_fun_types dclIndex (icl_functions, t
# {ft_type=dcl_symbol_type, ft_priority,ft_ident} = dcl_fun_types.[dclIndex]
# tc_state = init_symbol_type_vars dcl_symbol_type icl_symbol_type tc_state
(corresponds, tc_state)
- = t_corresponds dcl_symbol_type icl_symbol_type tc_state // --->("comparing:", dcl_symbol_type ,icl_symbol_type)
+ = t_corresponds dcl_symbol_type icl_symbol_type tc_state
| corresponds && fun_priority==ft_priority
-> (icl_functions, tc_state, error_admin)
-> generate_error ErrorMessage fun_def icl_functions tc_state error_admin
-symbolTypesCorrespond :: !SymbolType !SymbolType !*TypeHeaps -> (!ComparisionErrorCode, !.TypeHeaps)
-symbolTypesCorrespond symbol_type_1 symbol_type_2 type_heaps=:{th_vars, th_attrs}
- | length symbol_type_1.st_args<>length symbol_type_2.st_args
- = (CEC_ArgNrNotOk, type_heaps)
- # tc_state
- = { tc_type_vars = initial_hwn th_vars
- , tc_attr_vars = initial_hwn th_attrs
- , tc_ignore_strictness = True
- }
- tc_state
- = init_symbol_type_vars symbol_type_1 symbol_type_2 tc_state
+compare_specified_and_derived_instance_types :: !SymbolType !SymbolType !*TypeHeaps -> (!ComparisionErrorCode, !*TypeHeaps)
+compare_specified_and_derived_instance_types specified_instance_type derived_symbol_type type_heaps=:{th_vars, th_attrs}
+ | length specified_instance_type.st_args<>length derived_symbol_type.st_args
+ = (CEC_NrArgsNotOk, type_heaps)
+ # tc_state = { tc_type_vars = initial_hwn th_vars
+ , tc_attr_vars = initial_hwn th_attrs
+ , tc_strictness_flags = AllowFirstMoreStrictness
+ }
+ tc_state = init_symbol_type_vars specified_instance_type derived_symbol_type tc_state
(correspond_list, tc_state)
= map2St t_corresponds
- [symbol_type_1.st_result:symbol_type_1.st_args]
- [symbol_type_2.st_result:symbol_type_2.st_args]
+ [specified_instance_type.st_result:specified_instance_type.st_args]
+ [derived_symbol_type.st_result:derived_symbol_type.st_args]
tc_state
- err_code
- = firstIndex not correspond_list
+ err_code = firstIndex not correspond_list
| err_code<>CEC_Ok
= (err_code, tc_state_to_type_heaps tc_state)
+ # (arg_strictness_corresponds, tc_state)
+ = t_corresponds specified_instance_type.st_args_strictness derived_symbol_type.st_args_strictness tc_state
+ | not arg_strictness_corresponds
+ = (CEC_StrictnessOfArgsNotOk, tc_state_to_type_heaps tc_state)
# (context_corresponds, tc_state)
- = t_corresponds symbol_type_1.st_context symbol_type_2.st_context tc_state
+ = t_corresponds specified_instance_type.st_context derived_symbol_type.st_context tc_state
| not context_corresponds
= (CEC_ContextNotOK, tc_state_to_type_heaps tc_state)
# (attr_env_corresponds, tc_state)
- = t_corresponds symbol_type_1.st_attr_env symbol_type_2.st_attr_env tc_state
+ = t_corresponds specified_instance_type.st_attr_env derived_symbol_type.st_attr_env tc_state
| not attr_env_corresponds
= (CEC_AttrEnvNotOK, tc_state_to_type_heaps tc_state)
- = (CEC_Ok, tc_state_to_type_heaps tc_state)
+ | tc_state.tc_strictness_flags bitand FirstHasMoreStrictness<>0
+ = (CEC_OkWithFirstMoreStrictness, tc_state_to_type_heaps tc_state)
+ = (CEC_Ok, tc_state_to_type_heaps tc_state)
where
tc_state_to_type_heaps {tc_type_vars, tc_attr_vars}
= { th_vars = tc_type_vars.hwn_heap, th_attrs = tc_attr_vars.hwn_heap}
@@ -760,16 +813,36 @@ instance t_corresponds Annotation where
t_corresponds dcl_annotation icl_annotation
= t_corresponds` dcl_annotation icl_annotation
where
- t_corresponds` dcl_annotation icl_annotation tc_state=:{tc_ignore_strictness}
- = (tc_ignore_strictness || dcl_annotation==icl_annotation, tc_state)
+ t_corresponds` AN_Strict AN_Strict tc_state
+ = (True, tc_state)
+ t_corresponds` AN_Strict AN_None tc_state=:{tc_strictness_flags}
+ | tc_strictness_flags bitand AllowFirstMoreStrictness==0
+ = (False,tc_state)
+ | tc_strictness_flags bitand FirstHasMoreStrictness<>0
+ = (True,tc_state)
+ # tc_state = {tc_state & tc_strictness_flags = tc_strictness_flags bitor FirstHasMoreStrictness}
+ = (True,tc_state)
+ t_corresponds` AN_None AN_None tc_state
+ = (True, tc_state)
+ t_corresponds` AN_None AN_Strict tc_state
+ = (False, tc_state)
instance t_corresponds StrictnessList where
t_corresponds dcl_strictness icl_strictness
= t_corresponds` dcl_strictness icl_strictness
where
- t_corresponds` dcl_strictness icl_strictness tc_state=:{tc_ignore_strictness}
- = (tc_ignore_strictness || equal_strictness_lists dcl_strictness icl_strictness, tc_state)
-
+ t_corresponds` dcl_strictness icl_strictness tc_state=:{tc_strictness_flags}
+ | tc_strictness_flags bitand AllowFirstMoreStrictness==0
+ = (equal_strictness_lists dcl_strictness icl_strictness, tc_state)
+ | tc_strictness_flags bitand FirstHasMoreStrictness<>0
+ = (more_or_equal_strictness_lists dcl_strictness icl_strictness, tc_state)
+ | equal_strictness_lists dcl_strictness icl_strictness
+ = (True,tc_state)
+ | more_or_equal_strictness_lists dcl_strictness icl_strictness
+ # tc_state = {tc_state & tc_strictness_flags = tc_strictness_flags bitor FirstHasMoreStrictness}
+ = (True,tc_state)
+ = (False,tc_state)
+
instance t_corresponds AType where
t_corresponds dclDef iclDef
= t_corresponds dclDef.at_attribute iclDef.at_attribute
@@ -804,25 +877,45 @@ instance t_corresponds AttributeVar where
= (unifiable, { tc_state & tc_attr_vars = tc_attr_vars })
instance t_corresponds Type where
- t_corresponds (TA dclIdent dclArgs) icl_type=:(TA iclIdent iclArgs)
+ t_corresponds (TA dclIdent dclArgs) (TA iclIdent iclArgs)
= equal dclIdent.type_ident iclIdent.type_ident
&&& equal dclIdent.type_index.glob_module iclIdent.type_index.glob_module
&&& t_corresponds dclArgs iclArgs
- t_corresponds (TA dclIdent dclArgs) icl_type=:(TAS iclIdent iclArgs iclStrictness)
+ t_corresponds (TA dclIdent dclArgs) (TAS iclIdent iclArgs iclStrictness)
= equal dclIdent.type_ident iclIdent.type_ident
&&& equal dclIdent.type_index.glob_module iclIdent.type_index.glob_module
- &&& return (equal_strictness_lists NotStrict iclStrictness)
+ &&& return (is_not_strict iclStrictness)
&&& t_corresponds dclArgs iclArgs
- t_corresponds (TAS dclIdent dclArgs dclStrictness) icl_type=:(TA iclIdent iclArgs)
+ t_corresponds (TAS dclIdent dclArgs dclStrictness) (TA iclIdent iclArgs)
= equal dclIdent.type_ident iclIdent.type_ident
&&& equal dclIdent.type_index.glob_module iclIdent.type_index.glob_module
- &&& return (equal_strictness_lists dclStrictness NotStrict)
+ &&& compare_strictness dclStrictness
&&& t_corresponds dclArgs iclArgs
- t_corresponds (TAS dclIdent dclArgs dclStrictness) icl_type=:(TAS iclIdent iclArgs iclStrictness)
+ where
+ compare_strictness dclStrictness tc_state=:{tc_strictness_flags}
+ | tc_strictness_flags bitand AllowFirstMoreStrictness==0
+ = (equal_strictness_lists dclStrictness NotStrict, tc_state)
+ | tc_strictness_flags bitand FirstHasMoreStrictness<>0 || equal_strictness_lists dclStrictness NotStrict
+ = (True, tc_state)
+ # tc_state = {tc_state & tc_strictness_flags = tc_strictness_flags bitor FirstHasMoreStrictness}
+ = (True, tc_state)
+ t_corresponds (TAS dclIdent dclArgs dclStrictness) (TAS iclIdent iclArgs iclStrictness)
= equal dclIdent.type_ident iclIdent.type_ident
&&& equal dclIdent.type_index.glob_module iclIdent.type_index.glob_module
- &&& return (equal_strictness_lists dclStrictness iclStrictness)
+ &&& compare_strictness dclStrictness iclStrictness
&&& t_corresponds dclArgs iclArgs
+ where
+ compare_strictness dclStrictness iclStrictness tc_state=:{tc_strictness_flags}
+ | tc_strictness_flags bitand AllowFirstMoreStrictness==0
+ = (equal_strictness_lists dclStrictness iclStrictness, tc_state)
+ | tc_strictness_flags bitand FirstHasMoreStrictness<>0
+ = (more_or_equal_strictness_lists dclStrictness iclStrictness, tc_state)
+ | equal_strictness_lists dclStrictness iclStrictness
+ = (True, tc_state)
+ | more_or_equal_strictness_lists dclStrictness iclStrictness
+ # tc_state = {tc_state & tc_strictness_flags = tc_strictness_flags bitor FirstHasMoreStrictness}
+ = (True, tc_state)
+ = (False, tc_state)
t_corresponds (dclFun --> dclArg) (iclFun --> iclArg)
= t_corresponds dclFun iclFun
&&& t_corresponds dclArg iclArg
@@ -941,19 +1034,6 @@ instance t_corresponds MemberDef where
&&& equal dclDef.me_priority iclDef.me_priority
&&& t_corresponds dclDef.me_type iclDef.me_type
-instance t_corresponds ClassInstance where
- t_corresponds dclDef iclDef
- = t_corresponds` dclDef.ins_type iclDef.ins_type
- where
- t_corresponds` dclDef iclDef tc_state
- # tc_state = init_attr_vars dclDef.it_attr_vars iclDef.it_attr_vars tc_state
- tc_state = init_type_vars dclDef.it_vars iclDef.it_vars tc_state
- (corresponds, tc_state)
- = t_corresponds dclDef.it_types iclDef.it_types tc_state
- | not corresponds
- = (corresponds, tc_state)
- = t_corresponds dclDef.it_context iclDef.it_context tc_state
-
instance t_corresponds DynamicType where
t_corresponds dclDef iclDef
= t_corresponds dclDef.dt_type iclDef.dt_type
diff --git a/frontend/containers.dcl b/frontend/containers.dcl
index f0da996..e277237 100644
--- a/frontend/containers.dcl
+++ b/frontend/containers.dcl
@@ -33,6 +33,7 @@ arg_strictness_annotation :: !Int !StrictnessList -> Annotation;
arg_is_strict :: !Int !StrictnessList -> Bool;
is_not_strict :: !StrictnessList -> Bool
equal_strictness_lists :: !StrictnessList !StrictnessList -> Bool
+more_or_equal_strictness_lists :: !StrictnessList !StrictnessList -> Bool
add_next_strict :: !Int !Int !StrictnessList -> (!Int,!Int,!StrictnessList)
add_next_not_strict :: !Int !Int !StrictnessList -> (!Int,!Int,!StrictnessList)
append_strictness :: !Int !StrictnessList -> StrictnessList
@@ -46,15 +47,15 @@ remove_first_n :: !Int !StrictnessList -> StrictnessList
:: IntKeyTree a = IKT_Leaf | IKT_Node !IntKey a !.(IntKeyTree a) !.(IntKeyTree a)
ikhEmpty :: .(IntKeyHashtable a)
-ikhInsert :: !Bool !IntKey a !*(IntKeyHashtable a) -> (!Bool, !.IntKeyHashtable a)
+ikhInsert :: !Bool !IntKey !a !*(IntKeyHashtable a) -> (!Bool, !.IntKeyHashtable a)
// input bool: overide old value, output bool: a new element was inserted
-ikhInsert` :: !Bool !IntKey a !*(IntKeyHashtable a) -> .IntKeyHashtable a
+ikhInsert` :: !Bool !IntKey !a !*(IntKeyHashtable a) -> .IntKeyHashtable a
// bool: overide old value
ikhSearch :: !IntKey !(IntKeyHashtable a) -> .Optional a
ikhSearch` :: !IntKey !(IntKeyHashtable a) -> a
ikhUSearch :: !IntKey !*(IntKeyHashtable a) -> (!.Optional a, !*IntKeyHashtable a)
-iktUInsert :: !Bool !IntKey a !*(IntKeyTree a) -> (!Bool, !.IntKeyTree a)
+iktUInsert :: !Bool !IntKey !a !*(IntKeyTree a) -> (!Bool, !.IntKeyTree a)
// input bool: overide old value, output bool: a new element was inserted
iktFlatten :: !(IntKeyTree a) -> [(IntKey, a)]
iktSearch :: !IntKey !(IntKeyTree a) -> .Optional a
diff --git a/frontend/containers.icl b/frontend/containers.icl
index 2b2bd8b..59fdb69 100644
--- a/frontend/containers.icl
+++ b/frontend/containers.icl
@@ -313,6 +313,22 @@ equal_strictness_lists (StrictList s1 l) (Strict s2)
equal_strictness_lists (StrictList s1 l1) (StrictList s2 l2)
= s1==s2 && equal_strictness_lists l1 l2
+more_or_equal_strictness_lists :: !StrictnessList !StrictnessList -> Bool
+more_or_equal_strictness_lists NotStrict s2
+ = is_not_strict s2
+more_or_equal_strictness_lists (Strict s) NotStrict
+ = True
+more_or_equal_strictness_lists (Strict s1) (Strict s2)
+ = (bitnot s1) bitand s2==0
+more_or_equal_strictness_lists (Strict s1) (StrictList s2 l)
+ = (bitnot s1) bitand s2==0 && is_not_strict l
+more_or_equal_strictness_lists (StrictList s l) NotStrict
+ = True
+more_or_equal_strictness_lists (StrictList s1 l) (Strict s2)
+ = (bitnot s1) bitand s2==0
+more_or_equal_strictness_lists (StrictList s1 l1) (StrictList s2 l2)
+ = (bitnot s1) bitand s2==0 && more_or_equal_strictness_lists l1 l2
+
add_next_strict :: !Int !Int !StrictnessList -> (!Int,!Int,!StrictnessList)
add_next_strict strictness_index strictness strictness_list
| strictness_index<32
@@ -383,7 +399,7 @@ screw :== 80
ikhEmpty :: .(IntKeyHashtable a)
ikhEmpty = IntKeyHashtable 0 0 0 {}
-ikhInsert :: !Bool !IntKey a !*(IntKeyHashtable a) -> (!Bool, !.IntKeyHashtable a)
+ikhInsert :: !Bool !IntKey !a !*(IntKeyHashtable a) -> (!Bool, !.IntKeyHashtable a)
ikhInsert overide int_key value (IntKeyHashtable ikh_rehash_threshold ikh_nr_of_entries ikh_bitmask ikh_entries)
| ikh_rehash_threshold<=ikh_nr_of_entries
= ikhInsert overide int_key value (grow ikh_entries)
@@ -391,7 +407,7 @@ ikhInsert overide int_key value (IntKeyHashtable ikh_rehash_threshold ikh_nr_of_
(tree, ikh_entries) = ikh_entries![hash_value]
(is_new, tree)
= iktUInsert overide int_key value tree
- ikh_entries = { ikh_entries & [hash_value] = tree }
+ ikh_entries = {ikh_entries & [hash_value] = tree}
| is_new
= (is_new, (IntKeyHashtable ikh_rehash_threshold (ikh_nr_of_entries+1) ikh_bitmask ikh_entries))
= (is_new, (IntKeyHashtable ikh_rehash_threshold ikh_nr_of_entries ikh_bitmask ikh_entries))
@@ -421,7 +437,7 @@ grow old_entries
= foldSt (\(key, value) ikh -> snd (ikhInsert False key value ikh)) list ikh
= (old_entries, ikh)
-ikhInsert` :: !Bool !IntKey a !*(IntKeyHashtable a) -> .IntKeyHashtable a
+ikhInsert` :: !Bool !IntKey !a !*(IntKeyHashtable a) -> .IntKeyHashtable a
ikhInsert` overide int_key value ikh
= snd (ikhInsert overide int_key value ikh)
@@ -445,10 +461,10 @@ ikhUSearch int_key (IntKeyHashtable ikh_rehash_threshold ikh_nr_of_entries ikh_b
(ikt, ikh_entries) = ikh_entries![hash_value]
(opt_result, ikt)
= iktUSearch int_key ikt
- ikh_entries = { ikh_entries & [hash_value] = ikt }
+ ikh_entries = {ikh_entries & [hash_value] = ikt}
= (opt_result, (IntKeyHashtable ikh_rehash_threshold ikh_nr_of_entries ikh_bitmask ikh_entries))
-iktUInsert :: !Bool !IntKey a !*(IntKeyTree a) -> (!Bool, !.IntKeyTree a)
+iktUInsert :: !Bool !IntKey !a !*(IntKeyTree a) -> (!Bool, !.IntKeyTree a)
iktUInsert overide int_key value IKT_Leaf
= (True, IKT_Node int_key value IKT_Leaf IKT_Leaf)
iktUInsert overide int_key value (IKT_Node key2 value2 left right)
diff --git a/frontend/generics1.icl b/frontend/generics1.icl
index 2468b76..5daddc9 100644
--- a/frontend/generics1.icl
+++ b/frontend/generics1.icl
@@ -945,7 +945,7 @@ buildConversionTo
| not error.ea_ok
# (def_sym, funs_and_groups)
= (buildFunAndGroup fun_name [] EE No main_module_index td_pos funs_and_groups)
- = (def_sym, funs_and_groups, heaps, error)
+ = (def_sym, funs_and_groups, heaps, error)
# (def_sym, funs_and_groups)
= (buildFunAndGroup fun_name [arg_var] body_expr No main_module_index td_pos funs_and_groups)
= (def_sym, funs_and_groups, heaps, error)
@@ -1370,7 +1370,7 @@ where
, gs_varh = gs_varh
, gs_dcl_modules = gs_dcl_modules
, gs_symtab = gs_symtab }
- = (common_defs, gs)
+ = (common_defs, gs)
// limitations:
// - context restrictions on generic variables are not allowed
@@ -1420,7 +1420,7 @@ where
# glob_def_sym =
{ glob_module = pds_module
, glob_object = {ds_ident=pds_ident, ds_index=pds_def, ds_arity = 1}
- }
+ }
# tc_class = TCGeneric
{ gtc_generic=glob_def_sym
, gtc_kind = kind
@@ -1844,6 +1844,7 @@ where
, ins_class_ident = {ci_ident=Ident class_ident, ci_arity=1}
, ins_ident = class_ident
, ins_type = ins_type
+ , ins_member_types = []
, ins_members = {{cim_ident=ds_ident,cim_arity=ds_arity,cim_index=ds_index}}
, ins_specials = SP_None
, ins_pos = gc_pos
@@ -1923,6 +1924,7 @@ where
, ins_class_ident = {ci_ident=Ident class_ident, ci_arity=1}
, ins_ident = class_ident
, ins_type = ins_type
+ , ins_member_types = []
, ins_members = {class_instance_member}
, ins_specials = SP_None
, ins_pos = gc_pos
diff --git a/frontend/hashtable.dcl b/frontend/hashtable.dcl
index 45b3bac..088d5ae 100644
--- a/frontend/hashtable.dcl
+++ b/frontend/hashtable.dcl
@@ -22,6 +22,7 @@ set_hte_mark :: !Int !*HashTable -> *HashTable
| IC_Field !Ident
| IC_Selector
| IC_Instance ![Type]
+ | IC_InstanceMember ![Type]
| IC_Generic
| IC_GenericCase !Type
| IC_Unknown
diff --git a/frontend/hashtable.icl b/frontend/hashtable.icl
index 934bbfc..78c2767 100644
--- a/frontend/hashtable.icl
+++ b/frontend/hashtable.icl
@@ -20,6 +20,7 @@ import predef, syntax, StdCompare, compare_constructor
| IC_Field !Ident
| IC_Selector
| IC_Instance ![Type]
+ | IC_InstanceMember ![Type]
| IC_Generic
| IC_GenericCase !Type
| IC_Unknown
@@ -39,18 +40,8 @@ instance =< IdentClass
where
(=<) (IC_Instance types1) (IC_Instance types2)
= compare_types types1 types2
- where
- compare_types [t1 : t1s] [t2 : t2s]
- # cmp = t1 =< t2
- | cmp == Equal
- = t1s =< t2s
- = cmp
- compare_types [] []
- = Equal
- compare_types [] _
- = Smaller
- compare_types _ []
- = Greater
+ (=<) (IC_InstanceMember types1) (IC_InstanceMember types2)
+ = compare_types types1 types2
(=<) (IC_GenericCase type1) (IC_GenericCase type2)
= type1 =< type2
(=<) (IC_Field typ_id1) (IC_Field typ_id2)
@@ -62,6 +53,18 @@ where
= Smaller
= Greater
+compare_types [t1 : t1s] [t2 : t2s]
+ # cmp = t1 =< t2
+ | cmp == Equal
+ = t1s =< t2s
+ = cmp
+compare_types [] []
+ = Equal
+compare_types [] _
+ = Smaller
+compare_types _ []
+ = Greater
+
instance =< (!a,!b) | =< a & =< b
where
(=<) (x1,y1) (x2,y2)
diff --git a/frontend/parse.icl b/frontend/parse.icl
index 6c0b1ec..1da098f 100644
--- a/frontend/parse.icl
+++ b/frontend/parse.icl
@@ -475,7 +475,7 @@ where
try_function_symbol OpenToken pState
# (token, pState) = nextToken FunctionContext pState
= case token of
- (IdentToken name)
+ IdentToken name
# (token, pState) = nextToken FunctionContext pState
| CloseToken == token
# (id, pState) = stringToIdent name IC_Expression pState
@@ -686,6 +686,81 @@ where
foreign_export_error s pState
= (True,PD_Erroneous,tokenBack (parseError "foreign export" No s pState))
+want_instance_type_definitions :: ![Type] !ParseState -> (![ParsedDefinition], !ParseState)
+want_instance_type_definitions instance_type pState
+ = parseList want_instance_type_definition pState
+where
+ want_instance_type_definition :: !ParseState -> (!Bool, ParsedDefinition, !ParseState)
+ want_instance_type_definition pState
+ # (token, pState) = nextToken GeneralContext pState
+ (fname, linenr, pState) = getFileAndLineNr pState
+ pos = LinePos fname linenr
+ | isLhsStartToken token
+ # (lhs, pState) = want_lhs_of_def token pState
+ (token, pState) = nextToken FunctionContext pState
+ (def, pState) = want_rhs_of_instance_member_def lhs token (determine_position lhs pos) pState
+ = (True, def, pState)
+ = (False, abort "no def(1)", tokenBack pState)
+ where
+ determine_position (Yes (name, _)) (LinePos f l) = FunPos f l name.id_name
+ determine_position lhs pos = pos
+
+ want_lhs_of_def :: !Token !ParseState -> (!Optional (Ident, Bool), !ParseState)
+ want_lhs_of_def token pState
+ # (succ, fname, is_infix, pState) = try_function_symbol token pState
+ | succ
+ # (function_ident, pState) = stringToIdent fname (IC_InstanceMember instance_type) pState
+ = (Yes (function_ident, is_infix), pState)
+ = (No, pState)
+ where
+ try_function_symbol :: !Token !ParseState -> (!Bool, {#Char}, !Bool, !ParseState)
+ try_function_symbol (IdentToken name) pState
+ = (True, name, False, pState)
+ try_function_symbol OpenToken pState
+ # (token, pState) = nextToken FunctionContext pState
+ = case token of
+ IdentToken name
+ # (token, pState) = nextToken FunctionContext pState
+ | CloseToken == token
+ -> (True, name, True, pState)
+ -> (False, abort "no name", False, tokenBack (tokenBack (tokenBack pState)))
+ _
+ -> (False, abort "no name", False, tokenBack (tokenBack pState))
+ try_function_symbol token pState
+ = (False, abort "name", False, tokenBack pState)
+
+ check_name No pState
+ = (erroneousIdent, NoPrio, parseError "Definition" No "identifier" pState)
+ check_name (Yes (name,False)) pState
+ = (name, NoPrio, pState)
+ check_name (Yes (name,is_infix)) pState
+// = (name, DefaultPriority, pState)
+ = (name, Prio NoAssoc 9, pState)
+
+ want_rhs_of_instance_member_def :: !(Optional (Ident, Bool)) !Token !Position !ParseState -> (ParsedDefinition, !ParseState)
+ want_rhs_of_instance_member_def opt_name DoubleColonToken pos pState
+ # (name, priority, pState) = check_name opt_name pState
+ (tspec, pState) = want pState // SymbolType
+ = (PD_TypeSpec pos name priority (Yes tspec) FSP_None, wantEndOfDefinition "type definition" pState)
+ want_rhs_of_instance_member_def opt_name (PriorityToken prio) pos pState
+ # (name,_,pState) = check_name_and_fixity opt_name cHasPriority pState
+ (token, pState) = nextToken TypeContext pState
+ | token == DoubleColonToken
+ # (tspec, pState) = want pState // SymbolType
+ = (PD_TypeSpec pos name prio (Yes tspec) FSP_None, wantEndOfDefinition "type definition" pState)
+ # pState = parseError "type definition" (Yes token) "::" pState
+ = (PD_TypeSpec pos name prio No FSP_None, wantEndOfDefinition "type defenition" pState)
+ want_rhs_of_instance_member_def opt_name token pos pState
+ # pState = parseError "type definition" (Yes token) "::" pState
+ = (PD_Erroneous, wantEndOfDefinition "type defenition" pState)
+
+check_name_and_fixity No hasprio pState
+ = (erroneousIdent, False, parseError "Definition" No "identifier" pState)
+check_name_and_fixity (Yes (name,is_infix)) hasprio pState
+ | not is_infix && hasprio
+ = (name, False, parseError "Definition" No "Infix operator should be inside parentheses; no infix" pState)
+ = (name, is_infix, pState)
+
optionalSpecials :: !ParseState -> (!Specials, !ParseState)
optionalSpecials pState
# (token, pState) = nextToken TypeContext pState
@@ -1186,8 +1261,6 @@ wantImportDeclarationT token pState
-> (ID_Class class_id No, tokenBack pState)
InstanceToken
# (class_name, pState) = want pState
-// (ii_extended, pState) = optional_extension pState // MW: removed but still not ok
- ii_extended = False
(types, pState) = wantList "instance types" tryBrackType pState
(class_id, pState) = stringToIdent class_name IC_Class pState
(inst_id, pState) = stringToIdent class_name (IC_Instance types) pState
@@ -1362,15 +1435,17 @@ wantInstanceDeclaration parseContext pi_pos pState
# pState = want_begin_group token pState
(pi_members, pState) = wantDefinitions (SetClassOrInstanceDefsContext parseContext) pState
pState = wantEndGroup "instance" pState
- = (PD_Instance {pi_class = pi_class, pi_ident = pi_ident, pi_types = pi_types, pi_context = pi_context,
- pi_members = pi_members, pi_specials = SP_None, pi_pos = pi_pos}, pState)
+ = (PD_Instance {pim_pi = {pi_class = pi_class, pi_ident = pi_ident, pi_types = pi_types, pi_context = pi_context,
+ pi_specials = SP_None, pi_pos = pi_pos},
+ pim_members = pi_members}, pState)
// otherwise // ~ (isIclContext parseContext)
| token == CommaToken
# (pi_types_and_contexts, pState) = want_instance_types pState
(idents, pState) = seqList [stringToIdent class_name (IC_Instance type) \\ (type,context) <- pi_types_and_contexts] pState
= (PD_Instances
- [ { pi_class = pi_class, pi_ident = ident, pi_types = type, pi_context = context
- , pi_members = [], pi_specials = SP_None, pi_pos = pi_pos}
+ [ { pim_pi = { pi_class = pi_class, pi_ident = ident, pi_types = type, pi_context = context
+ , pi_specials = SP_None, pi_pos = pi_pos},
+ pim_members = [] }
\\ (type,context) <- [ (pi_types, pi_context) : pi_types_and_contexts ]
& ident <- [ pi_ident : idents ]
]
@@ -1378,9 +1453,9 @@ wantInstanceDeclaration parseContext pi_pos pState
)
// otherwise // token <> CommaToken
# (specials, pState) = optionalSpecials (tokenBack pState)
- pState = wantEndOfDefinition "instance declaration" pState
- = (PD_Instance {pi_class = pi_class, pi_ident = pi_ident, pi_types = pi_types, pi_context = pi_context,
- pi_members = [], pi_specials = specials, pi_pos = pi_pos}, pState)
+ # pim_pi = {pi_class = pi_class, pi_ident = pi_ident, pi_types = pi_types,
+ pi_context = pi_context, pi_specials = specials, pi_pos = pi_pos}
+ = want_optional_member_types pim_pi pState
want_begin_group token pState // For JvG layout
# // (token, pState) = nextToken TypeContext pState PK
@@ -1400,6 +1475,16 @@ wantInstanceDeclaration parseContext pi_pos pState
-> parseError "instance declaration" (Yes token) "where" pState
-> parseError "instance declaration" (Yes token) "where or {" pState
+ want_optional_member_types pim_pi pState
+ # (token, pState) = nextToken TypeContext pState
+ # (begin_members, pState) = begin_member_group token pState
+ | begin_members
+ # (instance_member_types, pState) = want_instance_type_definitions pim_pi.pi_types pState
+ pState = wantEndGroup "instance" pState
+ = (PD_Instance {pim_pi = pim_pi, pim_members = instance_member_types}, pState)
+ # pState = wantEndOfDefinition "instance declaration" (tokenBack pState)
+ = (PD_Instance {pim_pi = pim_pi, pim_members = []}, pState)
+
want_instance_type pState
# (pi_types, pState) = wantList "instance types" tryBrackType pState
(pi_context, pState) = optionalContext pState
@@ -1413,6 +1498,35 @@ wantInstanceDeclaration parseContext pi_pos pState
// otherwise // token <> CommaToken
= ([type_and_context], pState)
+ begin_member_group SemicolonToken pState
+ # (token, pState) = nextToken TypeContext pState
+ | token == WhereToken
+ = begin_member_group_where pState
+ | token == CurlyOpenToken
+ = begin_member_group_curly_open pState
+ = (False, tokenBack pState)
+ begin_member_group token pState
+ | token == WhereToken
+ = begin_member_group_where pState
+ | token == CurlyOpenToken
+ = begin_member_group_curly_open pState
+ = (False, pState)
+
+ begin_member_group_where pState
+ # (ss_useLayout, pState) = accScanState UseLayout pState
+ # (token, pState) = nextToken TypeContext pState
+ | token == CurlyOpenToken
+ | ss_useLayout
+ = (True, parseError "instance definition" No "No { in layout mode" pState)
+ = (True, pState)
+ = (True, tokenBack pState)
+
+ begin_member_group_curly_open pState
+ # (ss_useLayout, pState) = accScanState UseLayout pState
+ | ss_useLayout
+ = (True, parseError "instance definition" (Yes CurlyOpenToken) "in layout mode the keyword where is" pState)
+ = (True, pState)
+
optionalContext :: !ParseState -> ([TypeContext],ParseState)
optionalContext pState
# (token, pState) = nextToken TypeContext pState
diff --git a/frontend/postparse.icl b/frontend/postparse.icl
index 5218737..f47db38 100644
--- a/frontend/postparse.icl
+++ b/frontend/postparse.icl
@@ -3,8 +3,6 @@ implementation module postparse
import StdEnv
import syntax, parse, utilities, containers, StdCompare
import genericsupport
-//import RWSDebug
-
:: *CollectAdmin =
{ ca_error :: !*ParseErrorAdmin
@@ -354,10 +352,10 @@ where
collectFunctions e icl_module ca
= (e, ca)
-instance collectFunctions (ParsedInstance a) | collectFunctions a where
- collectFunctions inst=:{pi_members} icl_module ca
- # (pi_members, ca) = collectFunctions pi_members icl_module ca
- = ({inst & pi_members = pi_members }, ca)
+instance collectFunctions (ScannedInstanceAndMembersR FunDef) where
+ collectFunctions inst=:{sim_members} icl_module ca
+ # (sim_members, ca) = collectFunctions sim_members icl_module ca
+ = ({inst & sim_members = sim_members }, ca)
instance collectFunctions GenericCaseDef where
collectFunctions gc=:{gc_body=GCB_FunDef fun_def} icl_module ca
@@ -1108,7 +1106,7 @@ scanModule mod=:{mod_ident,mod_type,mod_defs = pdefs} cached_modules support_gen
= (reorganise_icl_ok && pea_ok && import_dcl_ok && import_dcls_ok, mod, fun_range, fun_defs, optional_dcl_mod, modules, dcl_module_n,hash_table, err_file, files)
where
- scan_main_dcl_module :: Ident ModuleKind (ModTimeFunction *Files) *Files *CollectAdmin -> (!Bool,!Optional (Module (CollectedDefinitions (ParsedInstance FunDef))),!Int,![ScannedModule],![Ident],!*Files,!*CollectAdmin)
+ scan_main_dcl_module :: Ident ModuleKind (ModTimeFunction *Files) *Files *CollectAdmin -> (!Bool,!Optional (Module (CollectedDefinitions (ScannedInstanceAndMembersR FunDef))),!Int,![ScannedModule],![Ident],!*Files,!*CollectAdmin)
scan_main_dcl_module mod_ident MK_Main _ files ca
= (True, No,NoIndex,[MakeEmptyModule mod_ident MK_NoMainDcl], cached_modules,files, ca)
scan_main_dcl_module mod_ident MK_None _ files ca
@@ -1179,7 +1177,7 @@ collectFunctionBodies fun_name fun_arity fun_prio fun_kind defs ca
= ([], fun_kind, defs, ca)
collectGenericBodies :: !GenericCaseDef ![ParsedDefinition] !*CollectAdmin
- -> (![ParsedBody], ![ParsedDefinition], !*CollectAdmin)
+ -> (![ParsedBody], ![ParsedDefinition],!*CollectAdmin)
collectGenericBodies first_case all_defs=:[PD_GenericCase gc : defs] ca
| first_case.gc_ident == gc.gc_ident && first_case.gc_type_cons == gc.gc_type_cons
#! (bodies, rest_defs, ca) = collectGenericBodies first_case defs ca
@@ -1215,7 +1213,7 @@ where
# (strictness_index,strictness,strictness_list) = add_next_not_strict strictness_index strictness strictness_list
= add_strictness_for_arguments fields strictness_index strictness strictness_list
-reorganiseDefinitions :: Bool [ParsedDefinition] Index Index Index Index *CollectAdmin -> (![FunDef],!CollectedDefinitions (ParsedInstance FunDef), ![ParsedImport], ![ImportedObject],![ParsedForeignExport],!*CollectAdmin)
+reorganiseDefinitions :: Bool [ParsedDefinition] Index Index Index Index *CollectAdmin -> (![FunDef],!CollectedDefinitions (ScannedInstanceAndMembersR FunDef), ![ParsedImport], ![ImportedObject],![ParsedForeignExport],!*CollectAdmin)
reorganiseDefinitions icl_module [PD_Function pos name is_infix args rhs fun_kind : defs] cons_count sel_count mem_count type_count ca
# prio = if is_infix (Prio NoAssoc 9) NoPrio
fun_arity = length args
@@ -1373,13 +1371,13 @@ where
determine_indexes_of_class_members [] first_mem_index last_mem_offset
= ([], [], last_mem_offset)
-reorganiseDefinitions icl_module [PD_Instance class_instance=:{pi_members,pi_pos} : defs] cons_count sel_count mem_count type_count ca
+reorganiseDefinitions icl_module [PD_Instance class_instance=:{pim_members,pim_pi} : defs] cons_count sel_count mem_count type_count ca
# (fun_defs, c_defs, imports, imported_objects,foreign_exports, ca) = reorganiseDefinitions icl_module defs cons_count sel_count mem_count type_count ca
- (mem_defs, ca) = collect_member_instances pi_members ca
- | icl_module || isEmpty mem_defs
- = (fun_defs, { c_defs & def_instances = [{class_instance & pi_members = mem_defs} : c_defs.def_instances] }, imports, imported_objects,foreign_exports, ca)
- = (fun_defs, { c_defs & def_instances = [{class_instance & pi_members = []} : c_defs.def_instances] }, imports, imported_objects,foreign_exports,
- postParseError pi_pos "instance specifications of members not allowed" ca)
+ | icl_module || isEmpty pim_members
+ # (mem_defs, ca) = collect_member_instances pim_members ca
+ = (fun_defs, { c_defs & def_instances = [{sim_pi=class_instance.pim_pi, sim_members = mem_defs, sim_member_types=[]} : c_defs.def_instances] }, imports, imported_objects,foreign_exports, ca)
+ # (mem_types, ca) = collect_member_instance_types pim_members ca
+ = (fun_defs, { c_defs & def_instances = [{sim_pi=class_instance.pim_pi, sim_members = [], sim_member_types=mem_types} : c_defs.def_instances] }, imports, imported_objects,foreign_exports, ca)
where
collect_member_instances :: [ParsedDefinition] *CollectAdmin -> ([FunDef], *CollectAdmin)
collect_member_instances [PD_Function pos name is_infix args rhs fun_kind : defs] ca
@@ -1402,6 +1400,18 @@ where
-> collect_member_instances defs (postParseError fun_pos "function body expected" ca)
collect_member_instances [] ca
= ([], ca)
+
+ collect_member_instance_types :: [ParsedDefinition] *CollectAdmin -> (![FunType], !*CollectAdmin)
+ collect_member_instance_types [PD_TypeSpec fun_pos fun_name prio type specials : defs] ca
+ = case type of
+ Yes fun_type=:{st_arity}
+ # fun_type = MakeNewFunctionType fun_name st_arity prio fun_type fun_pos specials nilPtr
+ (fun_types, ca) = collect_member_instance_types defs ca
+ -> ([fun_type : fun_types], ca)
+ No
+ -> collect_member_instance_types defs (postParseError fun_pos "function body expected" ca)
+ collect_member_instance_types [] ca
+ = ([], ca)
reorganiseDefinitions icl_module [PD_Instances class_instances : defs] cons_count sel_count mem_count type_count ca
= reorganiseDefinitions icl_module ([PD_Instance class_instance \\ class_instance <- class_instances] ++ defs) cons_count sel_count mem_count type_count ca
reorganiseDefinitions icl_module [PD_Generic gen : defs] cons_count sel_count mem_count type_count ca
@@ -1440,7 +1450,7 @@ reorganiseDefinitions icl_module [PD_ForeignExport new_foreign_export file_name
# (fun_defs, c_defs, imports, imported_objects,foreign_exports, ca) = reorganiseDefinitions icl_module defs cons_count sel_count mem_count type_count ca
= (fun_defs, c_defs, imports, imported_objects,[{pfe_ident=new_foreign_export,pfe_file=file_name,pfe_line=line_n,pfe_stdcall=stdcall}:foreign_exports], ca)
reorganiseDefinitions icl_module [def:defs] _ _ _ _ ca
- = abort ("reorganiseDefinitions does not match" ---> def)
+ = abort "reorganiseDefinitions does not match"
reorganiseDefinitions icl_module [] _ _ _ _ ca
= ([], { def_types = [], def_constructors = [], def_selectors = [], def_macros = [],def_macro_indices={ir_from=0,ir_to=0},def_classes = [], def_members = [],
def_instances = [], def_funtypes = [],
diff --git a/frontend/syntax.dcl b/frontend/syntax.dcl
index 6bf9923..ca9cc1f 100644
--- a/frontend/syntax.dcl
+++ b/frontend/syntax.dcl
@@ -14,7 +14,6 @@ from containers import ::NumberSet
instance toString Ident
-
/* Each Identifier is equipped with a pointer to a SymbolTableEntry that is
used for binding the identifier with its definition.
*/
@@ -118,7 +117,7 @@ instance == FunctionOrMacroIndex
}
:: ParsedModule :== Module [ParsedDefinition]
-:: ScannedModule :== Module (CollectedDefinitions (ParsedInstance FunDef))
+:: ScannedModule :== Module (CollectedDefinitions (ScannedInstanceAndMembersR FunDef))
:: ModuleKind = MK_Main | MK_Module | MK_System | MK_None | MK_NoMainDcl
@@ -258,8 +257,8 @@ cIsNotAFunction :== False
| PD_Type ParsedTypeDef
| PD_TypeSpec Position Ident Priority (Optional SymbolType) FunSpecials
| PD_Class ClassDef [ParsedDefinition]
- | PD_Instance (ParsedInstance ParsedDefinition)
- | PD_Instances [ParsedInstance ParsedDefinition]
+ | PD_Instance ParsedInstanceAndMembers
+ | PD_Instances [ParsedInstanceAndMembers]
| PD_Import [ParsedImport]
| PD_ImportedObjects [ImportedObject]
| PD_ForeignExport !Ident !{#Char} !Int !Bool /* if stdcall */
@@ -293,17 +292,27 @@ cNameLocationDependent :== True
, pc_cons_prio :: !Priority
, pc_cons_pos :: !Position
}
-
-:: ParsedInstance member =
+
+:: ParsedInstance =
{ pi_class :: !IdentOrQualifiedIdent
, pi_ident :: !Ident
, pi_types :: ![Type]
, pi_context :: ![TypeContext]
, pi_pos :: !Position
- , pi_members :: ![member]
, pi_specials :: !Specials
}
+:: ParsedInstanceAndMembers =
+ { pim_pi :: !ParsedInstance
+ , pim_members :: ![ParsedDefinition]
+ }
+
+:: ScannedInstanceAndMembersR icl_member =
+ { sim_pi :: !ParsedInstance
+ , sim_members :: ![icl_member] // for .icl
+ , sim_member_types :: ![FunType] // for .dcl
+ }
+
:: IdentOrQualifiedIdent
= Ident !Ident
| QualifiedIdent /*module*/!Ident !String
@@ -447,6 +456,7 @@ cNameLocationDependent :== True
, ins_class_ident :: !ClassIdent
, ins_ident :: !Ident
, ins_type :: !InstanceType
+ , ins_member_types :: ![FunType] // for .dcl
, ins_members :: !{#ClassInstanceMember}
, ins_specials :: !Specials
, ins_pos :: !Position
@@ -604,6 +614,7 @@ FI_IsMacroFun :== 1 // whether the function is a local function of a macro
FI_HasTypeSpec :== 2 // whether the function has u user defined type
FI_IsNonRecursive :== 4 // used in trans.icl and partition.icl
FI_IsUnboxedListOfRecordsConsOrNil :== 8
+FI_MemberInstanceRequiresTypeInDefMod :== 16
:: FunInfo =
{ fi_calls :: ![FunCall]
@@ -1500,12 +1511,12 @@ ParsedConstructorToConsDef pc :==
st_arity = pc.pc_cons_arity, st_context = [], st_attr_env = [], st_attr_vars = []},
cons_exi_vars = pc.pc_exi_vars, cons_type_ptr = nilPtr }
-ParsedInstanceToClassInstance pi members :==
+ParsedInstanceToClassInstance pi members member_types :==
{ ins_class_index = {gi_module=NoIndex, gi_index=NoIndex},
ins_class_ident = {ci_ident=pi.pi_class, ci_arity=length pi.pi_types}, ins_ident = pi.pi_ident,
ins_type = { it_vars = [], it_types = pi.pi_types, it_attr_vars = [],
it_context = pi.pi_context },
- ins_members = members, ins_specials = pi.pi_specials, ins_pos = pi.pi_pos}
+ ins_members = members, ins_member_types = member_types, ins_specials = pi.pi_specials, ins_pos = pi.pi_pos}
MakeTypeDef name lhs rhs attr pos :==
{ td_ident = name, td_index = -1, td_arity = length lhs, td_args = lhs, td_attrs = [], td_attribute = attr,