aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjohnvg2011-04-15 13:27:17 +0000
committerjohnvg2011-04-15 13:27:17 +0000
commit07421cdc9f40418c2896a0a77f5e038904ac6059 (patch)
tree465d9c9e9003b51c915d11fa570d44910c63c3c9
parentremove field icl_copied_from_dcl from type IclModule (diff)
git-svn-id: https://svn.cs.ru.nl/repos/clean-compiler/trunk@1926 1f8540f1-abd5-4d5b-9d24-4c5ce8603e2d
-rw-r--r--backend/backendconvert.icl4
-rw-r--r--frontend/analtypes.icl5
-rw-r--r--frontend/check.icl82
-rw-r--r--frontend/checktypes.dcl4
-rw-r--r--frontend/checktypes.icl16
-rw-r--r--frontend/explicitimports.icl4
-rw-r--r--frontend/generics1.icl27
-rw-r--r--frontend/overloading.icl95
-rw-r--r--frontend/syntax.dcl17
-rw-r--r--frontend/syntax.icl7
-rw-r--r--frontend/type.icl23
11 files changed, 138 insertions, 146 deletions
diff --git a/backend/backendconvert.icl b/backend/backendconvert.icl
index 962fabf..d549829 100644
--- a/backend/backendconvert.icl
+++ b/backend/backendconvert.icl
@@ -1155,8 +1155,8 @@ adjustArrayFunctions array_first_instance_indices predefs main_dcl_module_n func
= foldStateA (adjustStdArrayInstance arrayClassIndex arrayInfo) instances
where
adjustStdArrayInstance :: Index AdjustStdArrayInfo ClassInstance -> BackEnder
- adjustStdArrayInstance arrayClassIndex arrayInfo=:{asai_moduleIndex} instance`=:{ins_class}
- | ins_class.glob_object.ds_index == arrayClassIndex && ins_class.glob_module == asai_moduleIndex
+ adjustStdArrayInstance arrayClassIndex arrayInfo=:{asai_moduleIndex} instance`=:{ins_class_index}
+ | ins_class_index.gi_index == arrayClassIndex && ins_class_index.gi_module == asai_moduleIndex
= adjustArrayClassInstance arrayInfo instance`
// otherwise
= identity
diff --git a/frontend/analtypes.icl b/frontend/analtypes.icl
index 15bd4d1..7940696 100644
--- a/frontend/analtypes.icl
+++ b/frontend/analtypes.icl
@@ -615,7 +615,7 @@ emptyIdent name :== { id_name = name, id_info = nilPtr }
newKindVariables td_args (type_var_heap, as_kind_heap)
= mapSt new_kind td_args (type_var_heap, as_kind_heap)
where
- new_kind :: ATypeVar *(*Heap TypeVarInfo,*Heap KindInfo) -> (!.TypeKind,!(!.Heap TypeVarInfo,!.Heap KindInfo));
+ new_kind :: ATypeVar *(*TypeVarHeap,*KindHeap) -> (!.TypeKind,!(!*TypeVarHeap,!*KindHeap));
new_kind {atv_variable={tv_info_ptr}} (type_var_heap, kind_heap)
# (kind_info_ptr, kind_heap) = newPtr KI_Const kind_heap
= (KindVar kind_info_ptr, (type_var_heap <:= (tv_info_ptr, TVI_TypeKind kind_info_ptr), kind_heap <:= (kind_info_ptr, KI_Var kind_info_ptr)))
@@ -1018,11 +1018,12 @@ where
= check_kinds_of_class_instances common_defs (inc instance_index) instance_defs class_infos as
where
check_kinds_of_class_instance :: !{#CommonDefs} !ClassInstance !*ClassDefInfos !*AnalyseState -> (!*ClassDefInfos, !*AnalyseState)
- check_kinds_of_class_instance common_defs {ins_class,ins_ident,ins_pos,ins_type={it_vars,it_types,it_context}} class_infos
+ check_kinds_of_class_instance common_defs {ins_class_index,ins_class_ident={ci_ident,ci_arity},ins_ident,ins_pos,ins_type={it_vars,it_types,it_context}} class_infos
as=:{as_type_var_heap,as_kind_heap,as_error}
# as_error = pushErrorAdmin (newPosition ins_ident ins_pos) as_error
(as_type_var_heap, as_kind_heap) = bindFreshKindVariablesToTypeVars it_vars as_type_var_heap as_kind_heap
as = { as & as_type_var_heap = as_type_var_heap, as_kind_heap = as_kind_heap, as_error = as_error }
+ ins_class = {glob_module=ins_class_index.gi_module,glob_object={ds_index=ins_class_index.gi_index,ds_ident=ci_ident,ds_arity=ci_arity}}
context = {tc_class = TCClass ins_class, tc_types = it_types, tc_var = nilPtr}
(class_infos, as) = determine_kinds_of_type_contexts common_defs [context : it_context] class_infos as
= (class_infos, { as & as_error = popErrorAdmin as.as_error})
diff --git a/frontend/check.icl b/frontend/check.icl
index 6e5668c..cc35a74 100644
--- a/frontend/check.icl
+++ b/frontend/check.icl
@@ -175,14 +175,12 @@ where
check_instance_defs inst_index mod_index instance_defs is type_heaps cs
| inst_index < size instance_defs
# (instance_def, instance_defs) = instance_defs![inst_index]
- (instance_def, is, type_heaps, cs) = check_instance mod_index instance_def is type_heaps cs
+ (instance_def, is, type_heaps, cs) = check_instance instance_def mod_index is type_heaps cs
= check_instance_defs (inc inst_index) mod_index { instance_defs & [inst_index] = instance_def } is type_heaps cs
= (instance_defs, is, type_heaps, cs)
- check_instance :: !Index !ClassInstance !u:InstanceSymbols !*TypeHeaps !*CheckState -> (!ClassInstance, !u:InstanceSymbols, !*TypeHeaps, !*CheckState)
- check_instance module_index
- ins=:{ins_class={glob_object = class_ident =: {ds_ident = {id_name,id_info},ds_arity}},ins_type,ins_specials,ins_pos,ins_ident}
- is=:{is_class_defs,is_modules} type_heaps cs=:{cs_symbol_table}
+ check_instance :: !ClassInstance !Index !u:InstanceSymbols !*TypeHeaps !*CheckState -> (!ClassInstance, !u:InstanceSymbols, !*TypeHeaps, !*CheckState)
+ check_instance ins=:{ins_class_ident={ci_ident={id_name,id_info}},ins_pos,ins_ident} module_index is type_heaps cs=:{cs_symbol_table}
# (entry, cs_symbol_table) = readPtr id_info cs_symbol_table
# cs = pushErrorAdmin (newPosition ins_ident ins_pos) { cs & cs_symbol_table = cs_symbol_table }
# (ins, is, type_heaps, cs) = case entry.ste_kind of
@@ -198,19 +196,17 @@ where
check_class_instance :: ClassDef !Index !Index !Index !ClassInstance !u:InstanceSymbols !*TypeHeaps !*CheckState
-> (!ClassInstance, !u:InstanceSymbols, !*TypeHeaps, !*CheckState)
check_class_instance class_def module_index class_index class_mod_index
- ins=:{ins_class={glob_object = class_ident =: {ds_ident = {id_name,id_info},ds_arity}},ins_type,ins_specials,ins_pos,ins_ident}
+ ins=:{ins_class_ident=ins_class_ident=:{ci_ident={id_name,id_info},ci_arity},ins_type,ins_specials,ins_pos,ins_ident}
is=:{is_class_defs,is_modules} type_heaps cs=:{cs_symbol_table}
- | class_def.class_arity == ds_arity
- # ins_class = { glob_object = { class_ident & ds_index = class_index }, glob_module = class_mod_index}
+ | class_def.class_arity == ci_arity
+ # ins_class_index = {gi_index = class_index, gi_module = class_mod_index}
(ins_type, ins_specials, is_type_defs, is_class_defs, is_modules, type_heaps, cs)
- = checkInstanceType module_index ins_class ins_type ins_specials
+ = checkInstanceType module_index ins_class_index ins_class_ident ins_type ins_specials
is.is_type_defs is.is_class_defs is.is_modules type_heaps cs
is = { is & is_type_defs = is_type_defs, is_class_defs = is_class_defs, is_modules = is_modules }
- = ({ins & ins_class = ins_class, ins_type = ins_type, ins_specials = ins_specials}, is, type_heaps, cs)
- // otherwise
- = ( ins, is, type_heaps
- , { cs & cs_error = checkError id_name ("wrong arity: expected "+++toString class_def.class_arity+++" found "+++toString ds_arity) cs.cs_error }
- )
+ = ({ins & ins_class_index = ins_class_index, ins_type = ins_type, ins_specials = ins_specials}, is, type_heaps, cs)
+ # 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)
@@ -231,25 +227,22 @@ where
# (instance_types, class_defs, member_defs, generic_defs, type_defs, modules, var_heap, type_heaps, cs) =
check_class_instance instance_def mod_index instance_types class_defs member_defs generic_defs type_defs modules var_heap type_heaps cs
= check_icl_instances (inc inst_index) mod_index instance_types instance_defs class_defs member_defs generic_defs type_defs modules var_heap type_heaps cs
- // otherwise
= (instance_types, instance_defs, class_defs, member_defs, generic_defs, type_defs, modules, var_heap, type_heaps, cs)
- check_class_instance {ins_pos,ins_class,ins_members,ins_type} mod_index instance_types class_defs member_defs generic_defs type_defs modules var_heap type_heaps cs
- # ({class_members,class_ident}, class_defs, modules) = getClassDef ins_class mod_index class_defs modules
- 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.glob_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)
- // otherwise
- # 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_class_instance {ins_pos,ins_class_index,ins_members,ins_type} mod_index instance_types class_defs member_defs generic_defs type_defs modules var_heap type_heaps cs
+ # ({class_members,class_ident}, class_defs, modules) = getClassDef ins_class_index mod_index class_defs modules
+ 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
+ = (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 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
@@ -272,13 +265,13 @@ where
= 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 }
-getClassDef :: !(Global DefinedSymbol) !Int !u:{#ClassDef} !v:{#DclModule} -> (!ClassDef,!u:{#ClassDef},!v:{#DclModule})
-getClassDef {glob_module, glob_object={ds_ident, ds_index}} mod_index class_defs modules
- | glob_module == mod_index
- # (class_def, class_defs) = class_defs![ds_index]
+getClassDef :: !GlobalIndex !Int !u:{#ClassDef} !v:{#DclModule} -> (!ClassDef,!u:{#ClassDef},!v:{#DclModule})
+getClassDef {gi_module,gi_index} mod_index class_defs modules
+ | gi_module == mod_index
+ # (class_def, class_defs) = class_defs![gi_index]
= (class_def, class_defs, modules)
- # (dcl_mod, modules) = modules![glob_module]
- = (dcl_mod.dcl_common.com_class_defs.[ds_index], class_defs, modules)
+ # (dcl_mod, modules) = modules![gi_module]
+ = (dcl_mod.dcl_common.com_class_defs.[gi_index], class_defs, modules)
getMemberDef :: !Int Int !Int !u:{#MemberDef} !v:{#DclModule} -> (!MemberDef,!u:{#MemberDef},!v:{#DclModule})
getMemberDef mem_mod mem_index mod_index member_defs modules
@@ -480,11 +473,11 @@ where
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,ins_pos,ins_type,ins_specials}, instance_defs) = instance_defs![inst_index]
- # ({class_ident, class_members}, class_defs, modules) = getClassDef ins_class mod_index class_defs modules
+ # (instance_def=:{ins_class_index,ins_pos,ins_type,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.glob_module class_size class_members
+ = 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
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)
@@ -2444,8 +2437,8 @@ check_module2 mod_ident mod_modification_time mod_imported_objects mod_imports m
adjust_instance_types_of_array_functions :: !Index !{#.Index} !Int !*(!u:{# ClassInstance},!*{# FunDef},!v:{#PredefinedSymbol})
-> (!u:{# ClassInstance},!*{# FunDef},!v:{#PredefinedSymbol})
adjust_instance_types_of_array_functions array_class_index offset_table inst_index (class_instances, fun_defs, predef_symbols)
- # ({ins_class={glob_module,glob_object={ds_index}},ins_type,ins_members}, class_instances) = class_instances![inst_index]
- | glob_module == main_dcl_module_n && ds_index == array_class_index && elemTypeIsStrict ins_type.it_types predef_symbols
+ # ({ins_class_index={gi_module,gi_index},ins_type,ins_members}, class_instances) = class_instances![inst_index]
+ | gi_module == main_dcl_module_n && gi_index == array_class_index && elemTypeIsStrict ins_type.it_types predef_symbols
# fun_defs = iFoldSt (make_instance_strict ins_members offset_table) 0 (size ins_members) fun_defs
= (class_instances, fun_defs, predef_symbols)
= (class_instances, fun_defs, predef_symbols)
@@ -2455,7 +2448,7 @@ check_module2 mod_ident mod_modification_time mod_imported_objects mod_imports m
# {cim_index} = instances.[ins_offset]
(inst_def, instance_defs) = instance_defs![cim_index]
(Yes symbol_type) = inst_def.fun_type
- = {instance_defs & [cim_index] = {inst_def & fun_type = Yes (makeElemTypeOfArrayFunctionStrict symbol_type ins_offset offset_table)}}
+ = { 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]
@@ -2936,7 +2929,7 @@ checkInstancesOfDclModule mod_index (nr_of_dcl_functions_and_instances, nr_of_dc
dcl_modules = { dcl_modules & [mod_index] = dcl_mod }
= (dcl_modules, heaps, cs)
- where
+ where
adjust_instance_types_of_array_functions_in_std_array_dcl array_mod_index class_members class_instances fun_types cs=:{cs_predef_symbols}
#! nr_of_instances = size class_instances
# ({pds_def}, cs_predef_symbols) = cs_predef_symbols![PD_ArrayClass]
@@ -2949,8 +2942,8 @@ checkInstancesOfDclModule mod_index (nr_of_dcl_functions_and_instances, nr_of_dc
adjust_instance_types_of_array_functions :: .Index !Index !{#.Index} !Int !*(!u:{# ClassInstance},!*{# FunType},!v:{#PredefinedSymbol})
-> (!u:{# ClassInstance},!*{# FunType},!v:{#PredefinedSymbol})
adjust_instance_types_of_array_functions array_mod_index array_class_index offset_table inst_index (class_instances, fun_types, predef_symbols)
- # ({ins_class={glob_module,glob_object={ds_index}},ins_type,ins_members}, class_instances) = class_instances![inst_index]
- | glob_module == array_mod_index && ds_index == array_class_index && elemTypeIsStrict ins_type.it_types predef_symbols
+ # ({ins_class_index={gi_module,gi_index},ins_type,ins_members}, class_instances) = class_instances![inst_index]
+ | gi_module == array_mod_index && gi_index == array_class_index && elemTypeIsStrict ins_type.it_types predef_symbols
# fun_types = iFoldSt (make_instance_strict ins_members offset_table) 0 (size ins_members) fun_types
= (class_instances, fun_types, predef_symbols)
= (class_instances, fun_types, predef_symbols)
@@ -3153,9 +3146,8 @@ where
= foldlArraySt (count_members_of_instance mod_index) com_instance_defs (0, com_class_defs, modules)
= sum
- count_members_of_instance mod_index {ins_class} (sum, com_class_defs, modules)
- # ({class_members}, com_class_defs, modules)
- = getClassDef ins_class mod_index com_class_defs modules
+ count_members_of_instance mod_index {ins_class_index} (sum, com_class_defs, modules)
+ # ({class_members}, com_class_defs, modules) = getClassDef ins_class_index mod_index com_class_defs modules
= (size class_members + sum, com_class_defs, modules)
adjustPredefSymbol predef_index mod_index symb_kind cs=:{cs_symbol_table,cs_error}
diff --git a/frontend/checktypes.dcl b/frontend/checktypes.dcl
index 597f832..0bcbcfc 100644
--- a/frontend/checktypes.dcl
+++ b/frontend/checktypes.dcl
@@ -11,8 +11,8 @@ checkFunctionType :: !Index !SymbolType !FunSpecials !u:{#CheckedTypeDef} !v:{#C
checkMemberType :: !Index !SymbolType !u:{# CheckedTypeDef} !v:{# ClassDef} !u:{# DclModule} !*TypeHeaps !*CheckState
-> (!SymbolType, !u:{# CheckedTypeDef}, !v:{# ClassDef}, !u:{# DclModule}, !*TypeHeaps, !*CheckState)
-checkInstanceType :: !Index !(Global DefinedSymbol) !InstanceType !Specials !u:{# CheckedTypeDef} !v:{# ClassDef} !u:{# DclModule} !*TypeHeaps !*CheckState
- -> (!InstanceType, !Specials, !u:{# CheckedTypeDef}, !v:{# ClassDef}, !u:{# DclModule}, !*TypeHeaps, !*CheckState)
+checkInstanceType :: !Index !GlobalIndex !ClassIdent !InstanceType !Specials !u:{# CheckedTypeDef} !v:{# ClassDef} !u:{# DclModule} !*TypeHeaps !*CheckState
+ -> (!InstanceType,!Specials,!u:{# CheckedTypeDef},!v:{# ClassDef},!u:{# DclModule},!*TypeHeaps,!*CheckState)
checkSuperClasses :: ![TypeVar] ![TypeContext] !Index !u:{# CheckedTypeDef} !v:{# ClassDef} !u:{# DclModule} !*TypeHeaps !*CheckState
-> (![TypeVar], ![TypeContext], !u:{#CheckedTypeDef}, !v:{# ClassDef}, !u:{# DclModule}, !*TypeHeaps, !*CheckState)
diff --git a/frontend/checktypes.icl b/frontend/checktypes.icl
index b5e350d..a81e44c 100644
--- a/frontend/checktypes.icl
+++ b/frontend/checktypes.icl
@@ -772,9 +772,9 @@ checkOpenType mod_index scope dem_attr type cot_state
checkOpenATypes mod_index scope types cot_state
= mapSt (checkOpenAType mod_index scope DAK_None) types cot_state
-checkInstanceType :: !Index !(Global DefinedSymbol) !InstanceType !Specials !u:{# CheckedTypeDef} !v:{# ClassDef} !u:{# DclModule} !*TypeHeaps !*CheckState
- -> (!InstanceType, !Specials, !u:{# CheckedTypeDef}, !v:{# ClassDef}, !u:{# DclModule}, !*TypeHeaps, !*CheckState)
-checkInstanceType mod_index ins_class it=:{it_types,it_context} specials type_defs class_defs modules heaps cs
+checkInstanceType :: !Index !GlobalIndex !ClassIdent !InstanceType !Specials !u:{# CheckedTypeDef} !v:{# ClassDef} !u:{# DclModule} !*TypeHeaps !*CheckState
+ -> (!InstanceType,!Specials,!u:{# CheckedTypeDef},!v:{# ClassDef},!u:{# DclModule},!*TypeHeaps,!*CheckState)
+checkInstanceType mod_index ins_class_index ins_class_ident it=:{it_types,it_context} specials type_defs class_defs modules heaps cs
# cs_error = check_fully_polymorphity it_types it_context cs.cs_error
ots = { ots_type_defs = type_defs, ots_modules = modules }
oti = { oti_heaps = heaps, oti_all_vars = [], oti_all_attrs = [], oti_global_vars= [] }
@@ -783,7 +783,7 @@ checkInstanceType mod_index ins_class it=:{it_types,it_context} specials type_de
(heaps, cs) = check_linearity_of_type_vars it_vars oti.oti_heaps cs
oti = { oti & oti_all_vars = [], oti_all_attrs = [], oti_heaps = heaps }
(it_context, type_defs, class_defs, modules, heaps, cs) = checkTypeContexts it_context mod_index class_defs ots oti cs
- cs_error = foldSt (compare_context_and_instance_types ins_class it_types) it_context cs.cs_error
+ cs_error = foldSt (compare_context_and_instance_types ins_class_index ins_class_ident it_types) it_context cs.cs_error
(specials, cs) = checkSpecialTypeVars specials { cs & cs_error = cs_error }
cs_symbol_table = removeVariablesFromSymbolTable cGlobalScope it_vars cs.cs_symbol_table
cs_symbol_table = removeAttributesFromSymbolTable it_attr_vars cs_symbol_table
@@ -809,15 +809,15 @@ checkInstanceType mod_index ins_class it=:{it_types,it_context} specials type_de
= (th_vars, checkError tv_ident ": this type variable occurs more than once in an instance type" error)
= (th_vars, error)
- compare_context_and_instance_types ins_class it_types {tc_class=TCGeneric _, tc_types} cs_error
+ compare_context_and_instance_types ins_class_index ins_class_ident it_types {tc_class=TCGeneric _, tc_types} cs_error
= cs_error
- compare_context_and_instance_types ins_class it_types {tc_class=TCClass clazz, tc_types} cs_error
- | ins_class<>clazz
+ compare_context_and_instance_types ins_class_index ins_class_ident it_types {tc_class=TCClass clazz, tc_types} cs_error
+ | ins_class_index.gi_module<>clazz.glob_module || ins_class_index.gi_index<>clazz.glob_object.ds_index
= cs_error
# are_equal
= fold2St compare_context_and_instance_type it_types tc_types True
| are_equal
- = checkError ins_class.glob_object.ds_ident "context restriction equals instance type" cs_error
+ = checkError ins_class_ident.ci_ident "context restriction equals instance type" cs_error
= cs_error
where
compare_context_and_instance_type (TA {type_index=ti1} _) (TA {type_index=ti2} _) are_equal_accu
diff --git a/frontend/explicitimports.icl b/frontend/explicitimports.icl
index e8b973b..ad6f224 100644
--- a/frontend/explicitimports.icl
+++ b/frontend/explicitimports.icl
@@ -600,9 +600,9 @@ instance check_completeness ClassDef where
= check_completeness class_context cci ccs
instance check_completeness ClassInstance where
- check_completeness {ins_class={glob_module,glob_object={ds_ident,ds_index}}, ins_type} cci ccs
+ check_completeness {ins_class_index={gi_module,gi_index},ins_class_ident={ci_ident},ins_type} cci ccs
= check_completeness ins_type cci
- (check_whether_ident_is_imported ds_ident glob_module ds_index STE_Class cci ccs)
+ (check_whether_ident_is_imported ci_ident gi_module gi_index STE_Class cci ccs)
instance check_completeness ConsDef
where
diff --git a/frontend/generics1.icl b/frontend/generics1.icl
index 8e82e47..bdd297c 100644
--- a/frontend/generics1.icl
+++ b/frontend/generics1.icl
@@ -273,8 +273,8 @@ buildGenericTypeRep type_index funs_and_groups
, hp_var_heap = gs_varh
, hp_generic_heap = gs_genh
, hp_type_heaps = { th_vars = gs_tvarh, th_attrs = gs_avarh }
- }
-
+ }
+
# (type_def, gs_modules) = gs_modules![type_index.gi_module].com_type_defs.[type_index.gi_index]
# (type_info, cons_infos, funs_and_groups, gs_modules, heaps, gs_error)
@@ -1381,7 +1381,7 @@ buildMemberType gen_def=:{gen_ident,gen_pos,gen_type,gen_vars} kind class_var gs
#! th = {th_vars = gs.gs_tvarh, th_attrs = gs.gs_avarh}
#! (kind_indexed_st, gatvs, th, gs_error)
= buildKindIndexedType gen_type gen_vars kind gen_ident gen_pos th gs.gs_error
-
+
#! (member_st, th, gs_error)
= replace_generic_vars_with_class_var kind_indexed_st gatvs th gs_error
@@ -1839,9 +1839,9 @@ where
build_shorthand_class_instance :: TypeKind Int Ident Position DefinedSymbol InstanceType !(!Int,![ClassInstance]) -> (!Int,![ClassInstance])
build_shorthand_class_instance this_kind class_index gc_ident gc_pos {ds_ident,ds_arity,ds_index} ins_type (ins_index, instances)
#! class_ident = genericIdentToClassIdent gc_ident.id_name this_kind
- #! class_ds = {ds_index = class_index, ds_arity=1, ds_ident=class_ident}
#! ins =
- { ins_class = {glob_module=gs_main_module, glob_object=class_ds}
+ { ins_class_index = {gi_module=gs_main_module, gi_index=class_index}
+ , ins_class_ident = {ci_ident=class_ident, ci_arity=1}
, ins_ident = class_ident
, ins_type = ins_type
, ins_members = {{cim_ident=ds_ident,cim_arity=ds_arity,cim_index=ds_index}}
@@ -1919,7 +1919,8 @@ where
# class_ident = genericIdentToClassIdent gc_ident.id_name gc_kind
# class_ds = {ds_index = class_index, ds_arity=1, ds_ident=class_ident}
#! ins =
- { ins_class = {glob_module=gs_main_module, glob_object=class_ds}
+ { ins_class_index = {gi_module=gs_main_module, gi_index=class_index}
+ , ins_class_ident = {ci_ident=class_ident, ci_arity=1}
, ins_ident = class_ident
, ins_type = ins_type
, ins_members = {class_instance_member}
@@ -3836,15 +3837,8 @@ curryGenericArgType1 :: !SymbolType !String !*TypeHeaps
-> (!SymbolType, !*TypeHeaps)
curryGenericArgType1 st=:{st_args, st_result, st_attr_env, st_attr_vars} attr_var_name th=:{th_attrs}
# (atype, attr_vars, av_num, th_attrs) = curry st_args st_result 1 th_attrs
- # curried_st =
- { st
- & st_args = []
- , st_arity = 0
- , st_result = atype
- , st_attr_vars = attr_vars
- }
+ # curried_st = {st & st_args = [], st_arity = 0, st_result = atype, st_attr_vars = attr_vars}
= (curried_st, {th & th_attrs = th_attrs})
- //---> ("curryGenericArgType", st, curried_st)
where
// outermost closure gets TA_Multi attribute
curry [] res av_num th_attrs
@@ -3868,7 +3862,6 @@ where
clearType t th
= foldType clear_type clear_atype t th
where
-
clear_type (TV tv) th = clear_type_var tv th
clear_type (GTV tv) th = clear_type_var tv th
clear_type (CV tv :@: _) th = clear_type_var tv th
@@ -3876,7 +3869,6 @@ where
#! th = foldSt clear_attr [atv_attribute \\ {atv_attribute} <- atvs] th
#! th = foldSt clear_type_var [atv_variable \\ {atv_variable} <- atvs] th
= th
-
clear_type _ th = th
clear_atype {at_attribute} th
@@ -3888,6 +3880,7 @@ where
clear_type_var {tv_info_ptr} th=:{th_vars}
= {th & th_vars = writePtr tv_info_ptr TVI_Empty th_vars}
+
clear_attr_var {av_info_ptr} th=:{th_attrs}
= {th & th_attrs = writePtr av_info_ptr AVI_Empty th_attrs}
@@ -3953,7 +3946,6 @@ collectAttrVars type th
collectAttrsOfTypeVars :: ![TypeVar] type !*TypeHeaps -> (![ATypeVar], !*TypeHeaps) | foldType type
collectAttrsOfTypeVars tvs type th
#! (th=:{th_vars}) = clearType type th
- //---> ("collectAttrsOfTypeVars called for", tvs)
# th_vars = foldSt (\{tv_info_ptr} h->writePtr tv_info_ptr TVI_Used h) tvs th_vars
@@ -3963,7 +3955,6 @@ collectAttrsOfTypeVars tvs type th
#! th = clearType type {th & th_vars= th_vars}
= (atvs, th)
- //---> ("collectAttrsOfTypeVars returns", atvs)
where
on_type type st = st
diff --git a/frontend/overloading.icl b/frontend/overloading.icl
index 5d764fe..8a06f03 100644
--- a/frontend/overloading.icl
+++ b/frontend/overloading.icl
@@ -11,7 +11,7 @@ import genericsupport, type_io_common
}
:: ReducedContext =
- { rc_class :: !Global DefinedSymbol
+ { rc_class_index :: !GlobalIndex
, rc_types :: ![Type]
, rc_inst_module :: !Index
, rc_inst_members :: !{#ClassInstanceMember}
@@ -63,7 +63,7 @@ overloadingError op_symb err
abstractTypeInDynamicError td_ident err=:{ea_ok}
# err = errorHeading "Implementation restriction" err
= { err & ea_file = err.ea_file <<< (" derived abstract type '" +++ toString td_ident +++ "' not permitted in a dynamic") <<< '\n' }
-
+
typeCodeInDynamicError err=:{ea_ok}
# err = errorHeading "Overloading error (warning for now)" err
err = {err & ea_ok=ea_ok}
@@ -125,7 +125,7 @@ where
= (CA_Context tc, rs_state)
# {rs_var_heap, rs_new_contexts} = rs_state
# (tc_var, rs_var_heap) = newPtr VI_Empty rs_var_heap
- # rs_new_contexts = [{ tc & tc_var = tc_var } : rs_new_contexts]
+ # rs_new_contexts = [{tc & tc_var = tc_var} : rs_new_contexts]
= (CA_Context tc, {rs_state & rs_var_heap=rs_var_heap, rs_new_contexts=rs_new_contexts})
reduce_any_context :: !ReduceInfo !TypeContext !*ReduceState -> *(!ClassApplication, !*ReduceState)
@@ -157,29 +157,29 @@ where
# ({glob_module,glob_object}, contexts, uni_ok, rs_type_heaps, rs_coercions) = find_instance tc_types class_instances ri_defs rs_type_heaps rs_coercions
# rs_state = {rs_state & rs_coercions=rs_coercions, rs_type_heaps=rs_type_heaps}
| (glob_module <> NotFound) && uni_ok
- # {ins_members, ins_class} = ri_defs.[glob_module].com_instance_defs.[glob_object]
- | is_predefined_symbol ins_class.glob_module ins_class.glob_object.ds_index PD_ArrayClass rs_state.rs_predef_symbols &&
+ # {ins_members, ins_class_index} = ri_defs.[glob_module].com_instance_defs.[glob_object]
+ | is_predefined_global_symbol ins_class_index PD_ArrayClass rs_state.rs_predef_symbols &&
is_unboxed_array tc_types rs_state.rs_predef_symbols
# {rs_predef_symbols, rs_error,rs_special_instances, rs_type_heaps}
= rs_state
# (rcs_class_context, rs_special_instances, (rs_predef_symbols, rs_type_heaps), rs_error)
- = check_unboxed_array_type ri_main_dcl_module_n glob_module ins_class ins_members tc_types class_members ri_defs rs_special_instances (rs_predef_symbols, rs_type_heaps) rs_error
+ = check_unboxed_array_type ri_main_dcl_module_n glob_module ins_class_index ins_members tc_types class_members ri_defs rs_special_instances (rs_predef_symbols, rs_type_heaps) rs_error
# rs_state = {rs_state & rs_predef_symbols=rs_predef_symbols,
rs_special_instances=rs_special_instances,rs_type_heaps=rs_type_heaps, rs_error=rs_error}
= ({ rcs_class_context = rcs_class_context, rcs_constraints_contexts = []}, rs_state)
- | is_predefined_symbol ins_class.glob_module ins_class.glob_object.ds_index PD_UListClass rs_state.rs_predef_symbols
+ | is_predefined_global_symbol ins_class_index PD_UListClass rs_state.rs_predef_symbols
# {rs_predef_symbols, rs_error,rs_special_instances, rs_type_heaps}
= rs_state
# (rcs_class_context, rs_special_instances, (rs_predef_symbols, rs_type_heaps), rs_error)
- = check_unboxed_list_type ri_main_dcl_module_n glob_module ins_class ins_members tc_types class_members ri_defs rs_special_instances (rs_predef_symbols, rs_type_heaps) rs_error
+ = check_unboxed_list_type ri_main_dcl_module_n glob_module ins_class_index ins_members tc_types class_members ri_defs rs_special_instances (rs_predef_symbols, rs_type_heaps) rs_error
# rs_state = {rs_state & rs_predef_symbols=rs_predef_symbols,
rs_special_instances=rs_special_instances,rs_type_heaps=rs_type_heaps, rs_error=rs_error}
= ({ rcs_class_context = rcs_class_context, rcs_constraints_contexts = []}, rs_state)
- | is_predefined_symbol ins_class.glob_module ins_class.glob_object.ds_index PD_UTSListClass rs_state.rs_predef_symbols
+ | is_predefined_global_symbol ins_class_index PD_UTSListClass rs_state.rs_predef_symbols
# {rs_predef_symbols, rs_error,rs_special_instances, rs_type_heaps}
= rs_state
# (rcs_class_context, rs_special_instances, (rs_predef_symbols, rs_type_heaps), rs_error)
- = check_unboxed_tail_strict_list_type ri_main_dcl_module_n glob_module ins_class ins_members tc_types class_members ri_defs rs_special_instances (rs_predef_symbols, rs_type_heaps) rs_error
+ = check_unboxed_tail_strict_list_type ri_main_dcl_module_n glob_module ins_class_index ins_members tc_types class_members ri_defs rs_special_instances (rs_predef_symbols, rs_type_heaps) rs_error
# rs_state = {rs_state & rs_predef_symbols=rs_predef_symbols,
rs_special_instances=rs_special_instances,rs_type_heaps=rs_type_heaps, rs_error=rs_error}
= ({ rcs_class_context = rcs_class_context, rcs_constraints_contexts = []}, rs_state)
@@ -188,9 +188,9 @@ where
= reduceContexts info contexts rs_state
(constraints, rs_state)
= reduce_contexts_in_constraints info tc_types class_args class_context rs_state
- = ({ rcs_class_context = { rc_class = ins_class, rc_inst_module = glob_module, rc_inst_members = ins_members,
+ = ({ rcs_class_context = { rc_class_index = ins_class_index, rc_inst_module = glob_module, rc_inst_members = ins_members,
rc_types = tc_types, rc_red_contexts = appls }, rcs_constraints_contexts = constraints }, rs_state)
- # rcs_class_context = { rc_class = class_symb, rc_inst_module = NoIndex, rc_inst_members = {}, rc_types = tc_types, rc_red_contexts = [] }
+ # rcs_class_context = { rc_class_index = {gi_module=glob_module,gi_index=ds_index}, rc_inst_module = NoIndex, rc_inst_members = {}, rc_types = tc_types, rc_red_contexts = [] }
| glob_module <> NotFound
# rs_state = {rs_state & rs_error = uniqueError class_ident tc_types rs_state.rs_error}
= ({ rcs_class_context = rcs_class_context, rcs_constraints_contexts = []}, rs_state)
@@ -198,7 +198,7 @@ where
= ({ rcs_class_context = rcs_class_context, rcs_constraints_contexts = []}, rs_state)
# (constraints, rs_state)
= reduce_contexts_in_constraints info tc_types class_args class_context rs_state
- = ({ rcs_class_context = { rc_class = class_symb, rc_inst_module = NoIndex, rc_inst_members = {}, rc_types = tc_types, rc_red_contexts = [] },
+ = ({ rcs_class_context = { rc_class_index = {gi_module=glob_module,gi_index=ds_index}, rc_inst_module = NoIndex, rc_inst_members = {}, rc_types = tc_types, rc_red_contexts = [] },
rcs_constraints_contexts = constraints }, rs_state)
reduce_contexts_in_constraints :: !ReduceInfo ![Type] ![TypeVar] ![TypeContext] *ReduceState
@@ -400,20 +400,20 @@ where
is_unboxed_array _ predef_symbols
= False
- check_unboxed_array_type :: Int Int (Global DefinedSymbol) {#ClassInstanceMember} ![Type] {#DefinedSymbol} {#CommonDefs} *SpecialInstances *(*PredefinedSymbols,*TypeHeaps) *ErrorAdmin
+ check_unboxed_array_type :: Int Int GlobalIndex {#ClassInstanceMember} ![Type] {#DefinedSymbol} {#CommonDefs} *SpecialInstances *(*PredefinedSymbols,*TypeHeaps) *ErrorAdmin
-> (ReducedContext,*SpecialInstances,(*PredefinedSymbols,*TypeHeaps), *ErrorAdmin)
- check_unboxed_array_type main_dcl_module_n ins_module ins_class ins_members types=:[ _, elem_type :_] class_members defs special_instances predef_symbols_type_heaps error
+ check_unboxed_array_type main_dcl_module_n ins_module ins_class_index ins_members types=:[ _, elem_type :_] class_members defs special_instances predef_symbols_type_heaps error
# (unboxable, opt_record, predef_symbols_type_heaps) = try_to_unbox elem_type defs predef_symbols_type_heaps
| unboxable
= case opt_record of
Yes record
# (ins_members, special_instances) = add_record_to_array_instances record class_members special_instances
- -> ({ rc_class = ins_class, rc_inst_module = main_dcl_module_n, rc_inst_members = ins_members, rc_red_contexts = [], rc_types = types },
+ -> ({ rc_class_index = ins_class_index, rc_inst_module = main_dcl_module_n, rc_inst_members = ins_members, rc_red_contexts = [], rc_types = types },
special_instances, predef_symbols_type_heaps, error)
No
- -> ({ rc_class = ins_class, rc_inst_module = ins_module, rc_inst_members = ins_members, rc_red_contexts = [], rc_types = types },
+ -> ({ rc_class_index = ins_class_index, rc_inst_module = ins_module, rc_inst_members = ins_members, rc_red_contexts = [], rc_types = types },
special_instances, predef_symbols_type_heaps, error)
- = ({ rc_class = ins_class, rc_inst_module = ins_module, rc_inst_members = ins_members, rc_red_contexts = [], rc_types = types },
+ = ({ rc_class_index = ins_class_index, rc_inst_module = ins_module, rc_inst_members = ins_members, rc_red_contexts = [], rc_types = types },
special_instances, predef_symbols_type_heaps, unboxError "Array" elem_type error)
where
add_record_to_array_instances :: !TypeSymbIdent !{#DefinedSymbol} !*SpecialInstances -> (!{#ClassInstanceMember},!*SpecialInstances)
@@ -427,23 +427,23 @@ where
-> (inst.ai_members, { special_instances & si_next_array_member_index = si_next_array_member_index + size members,
si_array_instances = [ inst : si_array_instances ] })
- check_unboxed_list_type :: Int Int (Global DefinedSymbol) {#ClassInstanceMember} ![Type] {#DefinedSymbol} {#CommonDefs} *SpecialInstances *(*PredefinedSymbols,*TypeHeaps) *ErrorAdmin
+ check_unboxed_list_type :: Int Int GlobalIndex {#ClassInstanceMember} ![Type] {#DefinedSymbol} {#CommonDefs} *SpecialInstances *(*PredefinedSymbols,*TypeHeaps) *ErrorAdmin
-> (ReducedContext,*SpecialInstances,(*PredefinedSymbols,*TypeHeaps), *ErrorAdmin)
- check_unboxed_list_type main_dcl_module_n ins_module ins_class ins_members types=:[elem_type:_] class_members defs special_instances predef_symbols_type_heaps error
+ check_unboxed_list_type main_dcl_module_n ins_module ins_class_index ins_members types=:[elem_type:_] class_members defs special_instances predef_symbols_type_heaps error
# (unboxable, opt_record, predef_symbols_type_heaps) = try_to_unbox elem_type defs predef_symbols_type_heaps
| unboxable
= case opt_record of
Yes record
# (ins_members, special_instances) = add_record_to_list_instances record class_members special_instances
- -> ({ rc_class = ins_class, rc_inst_module = main_dcl_module_n, rc_inst_members = ins_members, rc_red_contexts = [], rc_types = types },
+ -> ({ rc_class_index = ins_class_index, rc_inst_module = main_dcl_module_n, rc_inst_members = ins_members, rc_red_contexts = [], rc_types = types },
special_instances, predef_symbols_type_heaps, error)
No
- -> ({ rc_class = ins_class, rc_inst_module = ins_module, rc_inst_members = ins_members, rc_red_contexts = [], rc_types = types },
+ -> ({ rc_class_index = ins_class_index, rc_inst_module = ins_module, rc_inst_members = ins_members, rc_red_contexts = [], rc_types = types },
special_instances, predef_symbols_type_heaps, error)
- = ({ rc_class = ins_class, rc_inst_module = ins_module, rc_inst_members = ins_members, rc_red_contexts = [], rc_types = types },
+ = ({ rc_class_index = ins_class_index, rc_inst_module = ins_module, rc_inst_members = ins_members, rc_red_contexts = [], rc_types = types },
special_instances, predef_symbols_type_heaps, unboxError "UList" elem_type error)
where
- add_record_to_list_instances :: !TypeSymbIdent !{#DefinedSymbol} !*SpecialInstances -> (!{#ClassInstanceMember},!*SpecialInstances)
+ add_record_to_list_instances :: !TypeSymbIdent !{# DefinedSymbol} !*SpecialInstances -> (!{#ClassInstanceMember},!*SpecialInstances)
add_record_to_list_instances record members special_instances=:{si_next_array_member_index,si_list_instances}
# may_be_there = look_up_array_or_list_instance record si_list_instances
= case may_be_there of
@@ -454,20 +454,20 @@ where
-> (inst.ai_members, { special_instances & si_next_array_member_index = si_next_array_member_index + size members,
si_list_instances = [ inst : si_list_instances ] })
- check_unboxed_tail_strict_list_type :: Int Int (Global DefinedSymbol) {#ClassInstanceMember} ![Type] {#DefinedSymbol} {#CommonDefs} *SpecialInstances *(*PredefinedSymbols,*TypeHeaps) *ErrorAdmin
+ check_unboxed_tail_strict_list_type :: Int Int GlobalIndex {#ClassInstanceMember} ![Type] {#DefinedSymbol} {#CommonDefs} *SpecialInstances *(*PredefinedSymbols,*TypeHeaps) *ErrorAdmin
-> (ReducedContext,*SpecialInstances,(*PredefinedSymbols,*TypeHeaps), *ErrorAdmin)
- check_unboxed_tail_strict_list_type main_dcl_module_n ins_module ins_class ins_members types=:[elem_type:_] class_members defs special_instances predef_symbols_type_heaps error
+ check_unboxed_tail_strict_list_type main_dcl_module_n ins_module ins_class_index ins_members types=:[elem_type:_] class_members defs special_instances predef_symbols_type_heaps error
# (unboxable, opt_record, predef_symbols_type_heaps) = try_to_unbox elem_type defs predef_symbols_type_heaps
| unboxable
= case opt_record of
Yes record
# (ins_members, special_instances) = add_record_to_tail_strict_list_instances record class_members special_instances
- -> ({ rc_class = ins_class, rc_inst_module = main_dcl_module_n, rc_inst_members = ins_members, rc_red_contexts = [], rc_types = types },
+ -> ({ rc_class_index = ins_class_index, rc_inst_module = main_dcl_module_n, rc_inst_members = ins_members, rc_red_contexts = [], rc_types = types },
special_instances, predef_symbols_type_heaps, error)
No
- -> ({ rc_class = ins_class, rc_inst_module = ins_module, rc_inst_members = ins_members, rc_red_contexts = [], rc_types = types },
+ -> ({ rc_class_index = ins_class_index, rc_inst_module = ins_module, rc_inst_members = ins_members, rc_red_contexts = [], rc_types = types },
special_instances, predef_symbols_type_heaps, error)
- = ({ rc_class = ins_class, rc_inst_module = ins_module, rc_inst_members = ins_members, rc_red_contexts = [], rc_types = types },
+ = ({ rc_class_index = ins_class_index, rc_inst_module = ins_module, rc_inst_members = ins_members, rc_red_contexts = [], rc_types = types },
special_instances, predef_symbols_type_heaps, unboxError "UTSList" elem_type error)
where
add_record_to_tail_strict_list_instances :: !TypeSymbIdent !{#DefinedSymbol} !*SpecialInstances -> (!{#ClassInstanceMember},!*SpecialInstances)
@@ -508,6 +508,11 @@ where
# {pds_def,pds_module} = predef_symbols.[predef_index]
= mod_index == pds_module && symb_index == pds_def
+ is_predefined_global_symbol :: !GlobalIndex !Int !PredefinedSymbols -> Bool
+ is_predefined_global_symbol {gi_module,gi_index} predef_index predef_symbols
+ # {pds_def,pds_module} = predef_symbols.[predef_index]
+ = gi_module == pds_module && gi_index == pds_def
+
look_up_array_or_list_instance :: !TypeSymbIdent ![ArrayInstance] -> Optional ArrayInstance
look_up_array_or_list_instance record []
= No
@@ -850,7 +855,7 @@ where
| containsContext super_class super_classes
= (super_classes, type_heaps)
= generate_super_classes super_class ([super_class : super_classes], type_heaps)
-
+
remove_doubles sub_classes tc context
| containsContext tc sub_classes
= context
@@ -875,10 +880,10 @@ selectFromDictionary dict_mod dict_index member_index defs
{ fs_ident, fs_index } = rt_fields.[member_index]
= { glob_module = dict_mod, glob_object = { ds_ident = fs_ident, ds_index = fs_index, ds_arity = 1 }}
-getDictionaryTypeAndConstructor :: !(Global DefinedSymbol) !{#CommonDefs} -> (!DefinedSymbol,!DefinedSymbol)
-getDictionaryTypeAndConstructor {glob_module, glob_object = {ds_ident,ds_index}} defs
- # {class_dictionary} = defs.[glob_module].com_class_defs.[ds_index]
- (RecordType {rt_constructor}) = defs.[glob_module].com_type_defs.[class_dictionary.ds_index].td_rhs
+getDictionaryTypeAndConstructor :: !GlobalIndex !{#CommonDefs} -> (!DefinedSymbol,!DefinedSymbol)
+getDictionaryTypeAndConstructor {gi_module,gi_index} defs
+ # {class_dictionary} = defs.[gi_module].com_class_defs.[gi_index]
+ (RecordType {rt_constructor}) = defs.[gi_module].com_type_defs.[class_dictionary.ds_index].td_rhs
= (class_dictionary, rt_constructor)
convertOverloadedCall :: !{#CommonDefs} ![TypeContext] !SymbIdent !ExprInfoPtr ![ClassApplication] !(!*Heaps, ![ExprInfoPtr],!*ErrorAdmin) -> (!*Heaps, ![ExprInfoPtr],!*ErrorAdmin)
@@ -907,8 +912,8 @@ where
= (EI_TypeCode (TCE_Var new_var_ptr), heaps_and_ptrs)
find_instance_of_member :: (Global Int) Int ReducedContexts -> ((Global Int),[ClassApplication])
- find_instance_of_member me_class me_offset { rcs_class_context = {rc_class, rc_inst_module, rc_inst_members, rc_red_contexts}, rcs_constraints_contexts}
- | rc_class.glob_module == me_class.glob_module && rc_class.glob_object.ds_index == me_class.glob_object
+ find_instance_of_member me_class me_offset { rcs_class_context = {rc_class_index, rc_inst_module, rc_inst_members, rc_red_contexts}, rcs_constraints_contexts}
+ | rc_class_index.gi_module == me_class.glob_module && rc_class_index.gi_index == me_class.glob_object
# {cim_index,cim_arity} = rc_inst_members.[me_offset]
| cim_index<0
= ({ glob_module = cim_arity, glob_object = -1 - cim_index }, rc_red_contexts)
@@ -925,7 +930,7 @@ convertOverloadedCall defs contexts symbol=:{symb_ident, symb_kind = SK_Generic
#! (opt_member_glob, hp_generic_heap) = getGenericMember gen_glob kind defs heaps.hp_generic_heap
#! heaps = { heaps & hp_generic_heap = hp_generic_heap }
= case opt_member_glob of
- No
+ No
# error = checkError ("no generic instances of " +++ toString symb_ident +++ " for kind") kind error
-> (heaps, expr_info_ptrs, error)
Yes member_glob -> convertOverloadedCall defs contexts {symbol & symb_kind = SK_OverloadedFunction member_glob} expr_ptr class_appls (heaps, expr_info_ptrs, error)
@@ -980,21 +985,21 @@ where
= convert_reduced_context_to_expression defs contexts rcs_class_context rcs_exprs heaps_and_ptrs
where
convert_reduced_context_to_expression :: {#CommonDefs} [TypeContext] ReducedContext [Expression] *(*Heaps,[Ptr ExprInfo]) -> *(Expression,*(*Heaps,[Ptr ExprInfo]))
- convert_reduced_context_to_expression defs contexts {rc_class, rc_inst_module, rc_inst_members, rc_red_contexts, rc_types} dictionary_args heaps_and_ptrs
+ convert_reduced_context_to_expression defs contexts {rc_class_index, rc_inst_module, rc_inst_members, rc_red_contexts, rc_types} dictionary_args heaps_and_ptrs
# (expressions, (heaps, class_ptrs)) = convertClassApplsToExpressions defs contexts rc_red_contexts heaps_and_ptrs
context_size = length expressions
| (size rc_inst_members > 2 && context_size > 0) || (size rc_inst_members==2 && (context_size>1 || not (is_small_context expressions)))
# (let_binds, let_types, rev_dicts, hp_var_heap, hp_expression_heap)
= foldSt (bind_shared_dictionary (size rc_inst_members)) expressions ([], [], [], heaps.hp_var_heap, heaps.hp_expression_heap)
dictionary_args = build_class_members (size rc_inst_members) rc_inst_members rc_inst_module (reverse rev_dicts) context_size dictionary_args
- (dict_expr, hp_expression_heap, class_ptrs) = build_dictionary rc_class rc_types dictionary_args defs hp_expression_heap class_ptrs
+ (dict_expr, hp_expression_heap, class_ptrs) = build_dictionary rc_class_index rc_types dictionary_args defs hp_expression_heap class_ptrs
| isEmpty let_binds
= (dict_expr, ({ heaps & hp_var_heap = hp_var_heap, hp_expression_heap = hp_expression_heap }, class_ptrs))
# (let_info_ptr, hp_expression_heap) = newPtr (EI_LetType let_types) hp_expression_heap
= (Let { let_strict_binds = [], let_lazy_binds = let_binds, let_expr = dict_expr, let_info_ptr = let_info_ptr, let_expr_position = NoPos },
({ heaps & hp_var_heap = hp_var_heap, hp_expression_heap = hp_expression_heap }, [let_info_ptr : class_ptrs]))
# dictionary_args = build_class_members (size rc_inst_members) rc_inst_members rc_inst_module expressions context_size dictionary_args
- (dict_expr, hp_expression_heap, class_ptrs) = build_dictionary rc_class rc_types dictionary_args defs heaps.hp_expression_heap class_ptrs
+ (dict_expr, hp_expression_heap, class_ptrs) = build_dictionary rc_class_index rc_types dictionary_args defs heaps.hp_expression_heap class_ptrs
= (dict_expr, ({ heaps & hp_expression_heap = hp_expression_heap }, class_ptrs))
is_small_context [] = True;
@@ -1025,12 +1030,12 @@ where
app_info_ptr = nilPtr }
= build_class_members mem_offset ins_members mod_index class_arguments arity [mem_expr : dictionary_args]
- build_dictionary class_symbol instance_types dictionary_args defs expr_heap ptrs
- # (dict_type, dict_cons) = getDictionaryTypeAndConstructor class_symbol defs
+ build_dictionary class_index instance_types dictionary_args defs expr_heap ptrs
+ # (dict_type, dict_cons) = getDictionaryTypeAndConstructor class_index defs
record_symbol = { symb_ident = dict_cons.ds_ident,
- symb_kind = SK_Constructor {glob_module = class_symbol.glob_module, glob_object = dict_cons.ds_index}
+ symb_kind = SK_Constructor {glob_module = class_index.gi_module, glob_object = dict_cons.ds_index}
}
- dict_type_symbol = MakeTypeSymbIdent {glob_module = class_symbol.glob_module, glob_object = dict_type.ds_index} dict_type.ds_ident dict_type.ds_arity
+ dict_type_symbol = MakeTypeSymbIdent {glob_module = class_index.gi_module, glob_object = dict_type.ds_index} dict_type.ds_ident dict_type.ds_arity
class_type = TA dict_type_symbol [ AttributedType type \\ type <- instance_types ]
(app_info_ptr, expr_heap) = newPtr (EI_DictionaryType class_type) expr_heap
rc_record = App { app_symb = record_symbol, app_args = dictionary_args, app_info_ptr = app_info_ptr }
@@ -1689,7 +1694,7 @@ where
{ ui & ui_var_heap = ui_var_heap, ui_error = ui_error })
updateExpression group_index selection ui
= (selection, ui)
-
+
instance updateExpression DynamicPattern
where
updateExpression group_index dp=:{dp_type,dp_rhs} ui
diff --git a/frontend/syntax.dcl b/frontend/syntax.dcl
index cc0b6e7..a689b8c 100644
--- a/frontend/syntax.dcl
+++ b/frontend/syntax.dcl
@@ -439,7 +439,8 @@ cNameLocationDependent :== True
}
:: ClassInstance =
- { ins_class :: !Global DefinedSymbol
+ { ins_class_index :: !GlobalIndex
+ , ins_class_ident :: !ClassIdent
, ins_ident :: !Ident
, ins_type :: !InstanceType
, ins_members :: !{#ClassInstanceMember}
@@ -447,6 +448,11 @@ cNameLocationDependent :== True
, ins_pos :: !Position
}
+:: ClassIdent =
+ { ci_ident :: !Ident
+ , ci_arity :: !Int
+ }
+
:: ClassInstanceMember =
{ cim_ident :: !Ident
, cim_arity :: !Int // module number if cim_index<0
@@ -1491,10 +1497,11 @@ ParsedConstructorToConsDef pc :==
cons_exi_vars = pc.pc_exi_vars, cons_type_ptr = nilPtr }
ParsedInstanceToClassInstance pi members :==
- { ins_class = {glob_object = MakeDefinedSymbol pi.pi_class NoIndex (length pi.pi_types), glob_module = NoIndex}, 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_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}
MakeTypeDef name lhs rhs attr pos :==
{ td_ident = name, td_index = -1, td_arity = length lhs, td_args = lhs, td_attrs = [], td_attribute = attr,
diff --git a/frontend/syntax.icl b/frontend/syntax.icl
index a05ef5e..b670b7e 100644
--- a/frontend/syntax.icl
+++ b/frontend/syntax.icl
@@ -1,8 +1,7 @@
implementation module syntax
-import StdEnv, compare_constructor // ,RWSDebug
-
-import scanner, general, Heap, typeproperties, utilities, compilerSwitches
+import StdEnv, compare_constructor
+import scanner, general, Heap, typeproperties, utilities
import syntax
instance toString Ident
@@ -722,7 +721,7 @@ where
instance <<< ClassInstance
where
- (<<<) file {ins_class,ins_type} = file <<< ins_class <<< " :: " <<< ins_type
+ (<<<) file {ins_class_ident,ins_type} = file <<< ins_class_ident.ci_ident <<< " :: " <<< ins_type
instance <<< (Optional a) | <<< a
where
diff --git a/frontend/type.icl b/frontend/type.icl
index fdbe390..7771fbd 100644
--- a/frontend/type.icl
+++ b/frontend/type.icl
@@ -2250,10 +2250,10 @@ typeProgram comps main_dcl_module_n fun_defs specials list_inferred_types icl_de
ti_functions = {dcl_functions \\ {dcl_functions} <-: dcl_modules }
class_instances = { { IT_Empty \\ i <- [0 .. dec (size com_class_defs)] } \\ {com_class_defs} <-: ti_common_defs }
- state = collect_imported_instances imports ti_common_defs {} ts_error class_instances hp_type_heaps.th_vars td_infos
+ state = collect_imported_instances imports ti_common_defs ts_error class_instances hp_type_heaps.th_vars td_infos
state = collect_qualified_imported_instances icl_qualified_imports ti_common_defs state
- (_, ts_error, class_instances, th_vars, td_infos) = collect_and_check_instances (size icl_defs.com_instance_defs) ti_common_defs state
+ (ts_error, class_instances, th_vars, td_infos) = collect_and_check_instances (size icl_defs.com_instance_defs) ti_common_defs state
ts = { ts_fun_env = InitFunEnv fun_env_size, ts_var_heap = hp_var_heap, ts_expr_heap = hp_expression_heap, ts_generic_heap = hp_generic_heap, ts_var_store = 0, ts_attr_store = FirstAttrVar, ts_cons_variables = [], ts_exis_variables = [],
ts_type_heaps = { hp_type_heaps & th_vars = th_vars }, ts_td_infos = td_infos, ts_error = ts_error, ts_fun_defs=fun_defs }
@@ -2276,10 +2276,9 @@ typeProgram comps main_dcl_module_n fun_defs specials list_inferred_types icl_de
= (not type_error, fun_defs, array_and_list_instances, ti_common_defs, ti_functions,
ts_td_infos, {hp_var_heap = ts_var_heap, hp_expression_heap = ts_expr_heap, hp_type_heaps = ts_type_heaps, hp_generic_heap=ts_generic_heap },
predef_symbols, ts_error.ea_file, out)
-// ---> ("typeProgram", array_inst_types)
where
- collect_imported_instances imports common_defs dummy error class_instances type_var_heap td_infos
- = foldlArraySt (collect_imported_instance common_defs) imports (dummy, error, class_instances, type_var_heap, td_infos)
+ collect_imported_instances imports common_defs error class_instances type_var_heap td_infos
+ = foldlArraySt (collect_imported_instance common_defs) imports (error, class_instances, type_var_heap, td_infos)
collect_qualified_imported_instances icl_qualified_imports common_defs state
= foldSt (\ (declarations,_,_) state -> foldSt (collect_imported_instance common_defs) declarations state)
@@ -2293,16 +2292,14 @@ where
collect_and_check_instances nr_of_instances common_defs state
= iFoldSt (update_instances_of_class common_defs main_dcl_module_n) 0 nr_of_instances state
- update_instances_of_class common_defs mod_index ins_index (dummy, error, class_instances, type_var_heap, td_infos)
- #!{ins_class={glob_object={ds_ident={id_name}, ds_index},glob_module},ins_type={it_types},ins_pos} = common_defs.[mod_index].com_instance_defs.[ins_index]
- (mod_instances, class_instances) = replace class_instances glob_module dummy
- (instances, mod_instances) = replace mod_instances ds_index IT_Empty
+ update_instances_of_class common_defs mod_index ins_index (error, class_instances, type_var_heap, td_infos)
+ #!{ins_class_index={gi_module,gi_index},ins_type={it_types},ins_pos} = common_defs.[mod_index].com_instance_defs.[ins_index]
+ (instances, class_instances) = class_instances![gi_module,gi_index]
(error, instances) = insert it_types ins_index mod_index common_defs error instances
- (_, mod_instances) = replace mod_instances ds_index instances
- (dummy, class_instances) = replace class_instances glob_module mod_instances
+ class_instances = {class_instances & [gi_module,gi_index]=instances}
(error, type_var_heap, td_infos)
- = check_types_of_instances ins_pos common_defs glob_module ds_index it_types (error, type_var_heap, td_infos)
- = (dummy, error, class_instances, type_var_heap, td_infos)
+ = check_types_of_instances ins_pos common_defs gi_module gi_index it_types (error, type_var_heap, td_infos)
+ = (error, class_instances, type_var_heap, td_infos)
where
insert :: ![Type] !Index !Index !{# CommonDefs } !*ErrorAdmin !*InstanceTree -> (!*ErrorAdmin, !*InstanceTree)
insert ins_types new_ins_index new_ins_module modules error IT_Empty