Commit 30bb9fae authored by Martin Wierich's avatar Martin Wierich
Browse files

delaying "determineTypesOfInstances" and "checkSpecialsOfInstances" after

checking of a whole dcl module component --> now cyclic module dependencies
should work
parent d9b30d60
......@@ -5,7 +5,7 @@ import syntax, transform, checksupport, typesupport, predef
cPredefinedModuleIndex :== 1
checkModule :: !ScannedModule !IndexRange ![FunDef] !Int !Int !(Optional ScannedModule) ![ScannedModule] !{#DclModule} !{#FunDef} !*PredefinedSymbols !*SymbolTable !*File !*Heaps
-> (!Bool, !*IclModule, *{# DclModule}, *{! Group}, !(Optional {# Index}), !.{#FunDef},!Int, !*Heaps, !*PredefinedSymbols, !*SymbolTable, *File)
-> (!Bool, *IclModule, *{# DclModule}, *{! Group}, !(Optional {# Index}), !.{#FunDef},!Int, !*Heaps, !*PredefinedSymbols, !*SymbolTable, *File)
checkFunctions :: !Index !Level !Index !Index !*{#FunDef} !*ExpressionInfo !*Heaps !*CheckState -> (!*{#FunDef}, !*ExpressionInfo, !*Heaps, !*CheckState)
......
This diff is collapsed.
......@@ -1630,7 +1630,6 @@ checkFields mod_index field_ass opt_type e_info=:{ef_selector_defs,ef_type_defs,
-> (No, e_info, cs)
= (No, e_info, cs)
where
check_fields [ bind=:{bind_dst} : field_ass ] cs=:{cs_symbol_table,cs_error}
# (entry, cs_symbol_table) = readPtr bind_dst.id_info cs_symbol_table
# fields = retrieveSelectorIndexes mod_index entry
......@@ -1667,13 +1666,13 @@ where
(type_def, type_defs) = type_defs![selector_def.sd_type_index]
-> (Yes (type_def, glob_module), selector_defs, type_defs, modules, cs)
# ({dcl_common={com_selector_defs,com_type_defs}}, modules) = modules![glob_module]
# selector_def = com_selector_defs.[glob_object]
type_def = com_type_defs.[selector_def.sd_type_index]
{sd_type_index} = com_selector_defs.[glob_object]
type_def = com_type_defs.[sd_type_index]
-> (Yes (type_def,glob_module), selector_defs, type_defs, modules, cs)
No
-> (No, selector_defs, type_defs, modules, { cs & cs_error = checkError "" " could not determine the type of this record" cs.cs_error })
check_and_rearrange_fields :: Int Int {#FieldSymbol} ![Bind ParsedExpr (Ident,[Global .Int])] *ErrorAdmin -> ([Bind ParsedExpr .(Global FieldSymbol)],!.ErrorAdmin);
check_and_rearrange_fields :: !Int !Int !{#FieldSymbol} ![Bind ParsedExpr (Ident,[Global .Int])] !*ErrorAdmin -> (![Bind ParsedExpr .(Global FieldSymbol)],!.ErrorAdmin);
check_and_rearrange_fields mod_index field_index fields field_ass cs_error
| field_index < size fields
# (field_expr, field_ass) = look_up_field mod_index fields.[field_index] field_ass
......
......@@ -94,7 +94,6 @@ cConversionTableSize :== 8
, dcl_functions :: !{# FunType }
, dcl_instances :: !IndexRange
, dcl_macros :: !IndexRange
, dcl_class_specials :: !IndexRange
, dcl_specials :: !IndexRange
, dcl_common :: !CommonDefs
, dcl_sizes :: !{# Int}
......@@ -154,6 +153,7 @@ addDeclarationsOfDclModToSymbolTable :: .Int !{!Declaration} !{!Declaration} !*C
addGlobalDefinitionsToSymbolTable :: ![Declaration] !*CheckState -> .CheckState;
addSymbol :: !(Optional a) !Ident !Position !STE_Kind !STE_Kind !.Int !.Int !Int !*CheckState -> (!Bool, !.CheckState)
addImportedFunctionOrMacro :: !(Optional IndexRange) !Ident !Int !*CheckState -> (!Bool, !.CheckState)
removeImportedSymbolsFromSymbolTable :: Declaration !*SymbolTable -> .SymbolTable
removeFieldFromSelectorDefinition :: !Ident .Int .Int !*(Heap SymbolTableEntry) -> .Heap SymbolTableEntry;
removeDeclarationsFromSymbolTable :: ![Declaration] !Int !*SymbolTable -> *SymbolTable
removeLocalIdentsFromSymbolTable :: .Int !.[Ident] !*(Heap SymbolTableEntry) -> .Heap SymbolTableEntry;
......@@ -180,5 +180,3 @@ nrOfBelongingSymbols :: !BelongingSymbols -> Int
import_ident :: Ident
restoreHeap :: !Ident !*SymbolTable -> .SymbolTable
expand_syn_types_late_XXX yes no :== no
......@@ -106,7 +106,6 @@ where
, dcl_functions :: !{# FunType }
, dcl_instances :: !IndexRange
, dcl_macros :: !IndexRange
, dcl_class_specials :: !IndexRange
, dcl_specials :: !IndexRange
, dcl_common :: !CommonDefs
, dcl_sizes :: !{# Int}
......@@ -428,6 +427,18 @@ where
-> cs
= { cs & cs_error = checkErrorWithIdentPos (newPosition ident dcl_pos) " multiply defined" cs.cs_error}
removeImportedSymbolsFromSymbolTable :: Declaration !*SymbolTable -> .SymbolTable
removeImportedSymbolsFromSymbolTable {dcl_ident=dcl_ident=:{id_info}, dcl_index} symbol_table
# ({ste_kind,ste_def_level,ste_previous}, symbol_table)
= readPtr id_info symbol_table
symbol_table
= symbol_table <:= (id_info, ste_previous)
= case ste_kind of
STE_Imported (STE_Field selector_id) def_mod
-> removeFieldFromSelectorDefinition selector_id def_mod dcl_index symbol_table
_
-> symbol_table
removeFieldFromSelectorDefinition :: !Ident .Int .Int !*(Heap SymbolTableEntry) -> .Heap SymbolTableEntry;
removeFieldFromSelectorDefinition {id_info} field_mod field_index symbol_table
# (entry, symbol_table) = readPtr id_info symbol_table
......@@ -620,5 +631,3 @@ restoreHeap {id_info} cs_symbol_table
# ({ste_previous}, cs_symbol_table)
= readPtr id_info cs_symbol_table
= writePtr id_info ste_previous cs_symbol_table
expand_syn_types_late_XXX yes no :== no
......@@ -416,12 +416,6 @@ checkTypeDefs is_main_dcl type_defs module_index cons_defs selector_defs module
where
check_type_defs is_main_dcl type_index nr_of_types module_index ts ti=:{ti_type_heaps,ti_var_heap} cs
| type_index == nr_of_types
| cs.cs_error.ea_ok && not is_main_dcl
# marks = createArray nr_of_types CS_NotChecked
{exp_type_defs,exp_modules,exp_type_heaps,exp_error} = (expand_syn_types_late_XXX id (expand_syn_types module_index 0 nr_of_types))
{ exp_type_defs = ts.ts_type_defs, exp_modules = ts.ts_modules, exp_marks = marks,
exp_type_heaps = ti_type_heaps, exp_error = cs.cs_error }
= (exp_type_defs, ts.ts_cons_defs, ts.ts_selector_defs, exp_modules, ti_var_heap, exp_type_heaps, { cs & cs_error = exp_error })
= (ts.ts_type_defs, ts.ts_cons_defs, ts.ts_selector_defs, ts.ts_modules, ti_var_heap, ti_type_heaps, cs)
# (ts, ti, cs) = checkTypeDef type_index module_index ts ti cs
= check_type_defs is_main_dcl (inc type_index) nr_of_types module_index ts ti cs
......@@ -437,8 +431,6 @@ expand_syn_types module_index type_index nr_of_types expst
expandSynonymTypes :: !.Index !*{#CheckedTypeDef} !*{#.DclModule} !*TypeHeaps !*ErrorAdmin
-> (!.{#CheckedTypeDef},!.{#DclModule},!.TypeHeaps,!.ErrorAdmin)
expandSynonymTypes module_index exp_type_defs exp_modules exp_type_heaps exp_error
| expand_syn_types_late_XXX False True
= abort "expandSynonymTypes"
#! nr_of_types
= size exp_type_defs
# marks
......
......@@ -4,6 +4,6 @@ import syntax, checksupport
// compare definition and implementation module
compareDefImp :: !{#Int} !{!FunctionBody} !Int {#CheckedTypeDef} !*{# DclModule} !*IclModule !*Heaps !*ErrorAdmin
-> (!.{# DclModule}, !.IclModule,!.Heaps,!.ErrorAdmin)
compareDefImp :: !{#Int} !{!FunctionBody} !Int !{#CheckedTypeDef} !DclModule !*IclModule !*Heaps !*ErrorAdmin
-> (!.IclModule,!.Heaps,!.ErrorAdmin)
......@@ -26,17 +26,6 @@ import syntax, checksupport, compare_constructor, utilities, StdCompare
:: !.HeapWithNumber TypeVarInfo
, tc_attr_vars
:: !.HeapWithNumber AttrVarInfo
, tc_dcl_modules
:: !.{#DclModule}
, tc_icl_type_defs
:: !{#CheckedTypeDef}
, tc_type_conversions
:: !Conversions
, tc_visited_syn_types // to detect cycles in type synonyms
// only for no in expand_syn_types_late_XXX
:: !.{#Bool}
, tc_main_dcl_module_n
:: !Int
}
:: TypesCorrespondMonad
......@@ -59,6 +48,8 @@ import syntax, checksupport, compare_constructor, utilities, StdCompare
:: !{! FunctionBody }
, ec_function_conversions
:: !Conversions
, ec_main_dcl_module_n
:: !Int
}
:: ExpressionsCorrespondMonad
......@@ -73,8 +64,7 @@ import syntax, checksupport, compare_constructor, utilities, StdCompare
:: !Int
}
:: OptionalCorrespondenceNumber = CorrespondenceNumber !Int | Bound | Unbound
// Bound is only used for no case in expand_syn_types_late_XXX
:: OptionalCorrespondenceNumber = CorrespondenceNumber !Int | Unbound
class t_corresponds a :: !a !a -> *TypesCorrespondMonad
// whether two types correspond
......@@ -89,40 +79,29 @@ class CorrespondenceNumber a where
initial_hwn hwn_heap = { hwn_heap = hwn_heap, hwn_number = 0 }
compareDefImp :: !{#Int} !{!FunctionBody} !Int {#CheckedTypeDef} !*{# DclModule} !*IclModule !*Heaps !*ErrorAdmin
-> (!.{# DclModule}, !.IclModule,!.Heaps,!.ErrorAdmin)
compareDefImp size_uncopied_icl_defs untransformed main_dcl_module_n type_defs_of_icl_mod dcl_modules
compareDefImp :: !{#Int} !{!FunctionBody} !Int !{#CheckedTypeDef} !DclModule !*IclModule !*Heaps !*ErrorAdmin
-> (!.IclModule,!.Heaps,!.ErrorAdmin)
compareDefImp size_uncopied_icl_defs untransformed main_dcl_module_n icl_com_type_defs main_dcl_module
icl_module heaps error_admin
// icl definitions with indices >= size_uncopied_icl_defs.[def_type] don't have to be compared,
// because they are copies of definitions that appear exclusively in the dcl module
# (main_dcl_module, dcl_modules) = dcl_modules![main_dcl_module_n]
= case main_dcl_module.dcl_conversions of
No -> (dcl_modules, icl_module, heaps, error_admin)
No -> (icl_module, heaps, error_admin)
Yes conversion_table
# {dcl_functions, dcl_macros, dcl_common} = main_dcl_module
{icl_common, icl_functions}
= icl_module
{hp_var_heap, hp_expression_heap, hp_type_heaps={th_vars, th_attrs}}
= heaps
{ com_type_defs, com_cons_defs=icl_com_cons_defs,
{ com_cons_defs=icl_com_cons_defs,
com_selector_defs=icl_com_selector_defs, com_class_defs=icl_com_class_defs,
com_member_defs=icl_com_member_defs, com_instance_defs = icl_com_instance_defs }
= icl_common
icl_com_type_defs
= expand_syn_types_late_XXX type_defs_of_icl_mod com_type_defs
(icl_type_defs, icl_com_type_defs)
= expand_syn_types_late_XXX (icl_com_type_defs, icl_com_type_defs)
(memcpy icl_com_type_defs)
tc_state
= { tc_type_vars = initial_hwn th_vars
, tc_attr_vars = initial_hwn th_attrs
, tc_dcl_modules = dcl_modules
, tc_icl_type_defs = icl_type_defs
, tc_type_conversions = conversion_table.[cTypeDefs]
, tc_visited_syn_types = createArray (size dcl_common.com_type_defs) False
, tc_main_dcl_module_n = main_dcl_module_n
}
(icl_com_type_defs, tc_state, error_admin)
(_, tc_state, error_admin)
= compareWithConversions
size_uncopied_icl_defs.[cTypeDefs] conversion_table.[cTypeDefs]
dcl_common.com_type_defs icl_com_type_defs tc_state error_admin
......@@ -147,23 +126,23 @@ compareDefImp size_uncopied_icl_defs untransformed main_dcl_module_n type_defs_o
size_uncopied_icl_defs.[cInstanceDefs] conversion_table.[cInstanceDefs]
dcl_common.com_instance_defs icl_com_instance_defs tc_state error_admin
(icl_functions, hp_var_heap, hp_expression_heap, tc_state, error_admin)
= compareMacrosWithConversion conversion_table.[cMacroDefs] conversion_table.[cFunctionDefs]
dcl_macros untransformed
icl_functions hp_var_heap hp_expression_heap tc_state error_admin
= compareMacrosWithConversion main_dcl_module_n
conversion_table.[cMacroDefs] conversion_table.[cFunctionDefs]
dcl_macros untransformed
icl_functions hp_var_heap hp_expression_heap tc_state error_admin
(icl_functions, tc_state, error_admin)
= compareFunctionTypesWithConversions conversion_table.[cFunctionDefs]
dcl_functions icl_functions tc_state error_admin
{ tc_type_vars, tc_attr_vars, tc_dcl_modules }
= tc_state
{ tc_type_vars, tc_attr_vars }
= tc_state
icl_common
= { icl_common & com_type_defs=expand_syn_types_late_XXX com_type_defs icl_com_type_defs,
com_cons_defs=icl_com_cons_defs,
= { icl_common & com_cons_defs=icl_com_cons_defs,
com_selector_defs=icl_com_selector_defs, com_class_defs=icl_com_class_defs,
com_member_defs=icl_com_member_defs, com_instance_defs = icl_com_instance_defs }
heaps
= { hp_var_heap = hp_var_heap, hp_expression_heap = hp_expression_heap,
hp_type_heaps = { th_vars = tc_type_vars.hwn_heap, th_attrs = tc_attr_vars.hwn_heap}}
-> ( tc_dcl_modules, { icl_module & icl_common = icl_common, icl_functions = icl_functions },
-> ({ icl_module & icl_common = icl_common, icl_functions = icl_functions },
heaps, error_admin )
where
memcpy :: !u:{#CheckedTypeDef} -> (!.{#CheckedTypeDef}, !u:{#CheckedTypeDef})
......@@ -237,14 +216,16 @@ generate_error message iclDef iclDefs tc_state error_admin
error_admin = checkError ident_pos.ip_ident message error_admin
= (iclDefs, tc_state, popErrorAdmin error_admin)
compareMacrosWithConversion conversions function_conversions macro_range untransformed icl_functions var_heap expr_heap tc_state error_admin
compareMacrosWithConversion main_dcl_module_n conversions function_conversions macro_range untransformed
icl_functions var_heap expr_heap tc_state error_admin
#! nr_of_functions = size icl_functions
# correspondences = createArray nr_of_functions cNoCorrespondence
ec_state = { ec_correspondences = correspondences, ec_var_heap = initial_hwn var_heap,
ec_expr_heap = expr_heap, ec_icl_functions = icl_functions,
ec_error_admin = error_admin, ec_tc_state = tc_state,
ec_untransformed = untransformed,
ec_function_conversions = function_conversions }
ec_function_conversions = function_conversions,
ec_main_dcl_module_n = main_dcl_module_n }
ec_state = iFoldSt (compareMacroWithConversion conversions macro_range.ir_from) macro_range.ir_from macro_range.ir_to
ec_state
{ec_icl_functions, ec_var_heap, ec_expr_heap, ec_error_admin, ec_tc_state} = ec_state
......@@ -326,8 +307,6 @@ instance CorrespondenceNumber TypeVarInfo where
= CorrespondenceNumber number
toCorrespondenceNumber TVI_Empty
= Unbound
toCorrespondenceNumber (TVI_AType _)
= expand_syn_types_late_XXX (abort "not used!!!") Bound
fromCorrespondenceNumber number
= TVI_CorrespondenceNumber number
......@@ -415,50 +394,10 @@ instance t_corresponds (Global DefinedSymbol) where
instance t_corresponds (TypeDef TypeRhs) where
t_corresponds dclDef iclDef
= (expand_syn_types_late_XXX t_corresponds_TypeDef` t_corresponds_TypeDef) dclDef iclDef
= t_corresponds_TypeDef dclDef iclDef
where
t_corresponds_TypeDef dclDef iclDef tc_state
// | False--->("comparing:", dclDef, iclDef)
// = undef
# tc_state = { tc_state & tc_visited_syn_types.[dclDef.td_index] = True }
tc_state = init_attr_vars dclDef.td_attrs tc_state
tc_state = init_attr_vars iclDef.td_attrs tc_state
tc_state = init_atype_vars dclDef.td_args tc_state
tc_state = init_atype_vars iclDef.td_args tc_state
(corresponds, tc_state) = t_corresponds dclDef.td_args iclDef.td_args tc_state
| not corresponds
= (corresponds, tc_state)
# icl_root_has_anonymous_attr = root_has_anonymous_attr iclDef.td_attribute iclDef.td_rhs
| icl_root_has_anonymous_attr<>root_has_anonymous_attr dclDef.td_attribute dclDef.td_rhs
&& isnt_abstract dclDef.td_rhs
= (False, tc_state)
# coerced_icl_rhs = if icl_root_has_anonymous_attr (coerce iclDef.td_rhs) iclDef.td_rhs
(corresponds, tc_state) = t_corresponds dclDef.td_rhs coerced_icl_rhs tc_state
tc_state = { tc_state & tc_visited_syn_types.[dclDef.td_index] = False }
| not corresponds
= (corresponds, tc_state)
# (corresponds, tc_state) = t_corresponds dclDef.td_context iclDef.td_context tc_state
| not corresponds
= (corresponds, tc_state)
# attributes_correspond = (is_TA_Unique dclDef.td_attribute)==(is_TA_Unique iclDef.td_attribute)
= (attributes_correspond, tc_state)
where
root_has_anonymous_attr (TA_Var lhs_attr_var) syn_type=:(SynType a_type=:{at_attribute=TA_Var rhs_attr_var})
= rhs_attr_var.av_info_ptr==lhs_attr_var.av_info_ptr
root_has_anonymous_attr _ _
= False
coerce (SynType atype)
= SynType { atype & at_attribute = TA_Anonymous }
isnt_abstract (AbstractType _) = False
isnt_abstract _ = True
is_TA_Unique TA_Unique = True
is_TA_Unique _ = False
t_corresponds_TypeDef` dclDef iclDef tc_state
// | False--->("comparing:", dclDef, iclDef)
// = undef
# tc_state = init_attr_vars dclDef.td_attrs tc_state
tc_state = init_attr_vars iclDef.td_attrs tc_state
......@@ -484,106 +423,10 @@ instance t_corresponds ATypeVar where
instance t_corresponds AType where
t_corresponds dclDef iclDef
= (expand_syn_types_late_XXX t_corresponds_at_type` t_corresponds_at_type) dclDef iclDef
where
t_corresponds_at_type` dclDef iclDef
| dclDef.at_annotation<>iclDef.at_annotation
= return False
= t_corresponds dclDef.at_attribute iclDef.at_attribute
&&& t_corresponds dclDef.at_type iclDef.at_type
t_corresponds_at_type dclDef iclDef tc_state
| dclDef.at_annotation<>iclDef.at_annotation
= (False, tc_state)
# (corresponds, tc_state) = simple_corresponds dclDef iclDef tc_state
| corresponds
= (corresponds, tc_state)
= case dclDef.at_type of
TA dcl_type_symb dcl_args
-> corresponds_with_expanded_syn_type dcl_type_symb.type_index dcl_args iclDef tc_state
TV {tv_info_ptr}
#! x = sreadPtr tv_info_ptr tc_state.tc_type_vars.hwn_heap
-> case x of
TVI_AType dcl_atype
-> t_corresponds { dcl_atype & at_annotation = dclDef.at_annotation } iclDef tc_state
_ -> (False, tc_state)
_ -> (False, tc_state)
where
simple_corresponds dclDef iclDef
= t_corresponds dclDef.at_attribute iclDef.at_attribute
&&& t_corresponds dclDef.at_type iclDef.at_type
corresponds_with_expanded_syn_type {glob_module, glob_object} dclArgs icl_atype
tc_state
// # is_defined_in_main_dcl = glob_module==cIclModIndex
# is_defined_in_main_dcl = glob_module==tc_state.tc_main_dcl_module_n
| is_defined_in_main_dcl && tc_state.tc_visited_syn_types.[glob_object]
= (False, tc_state) // cycle in synonym types in main dcl
# ({dcl_common}, tc_state) = tc_state!tc_dcl_modules.[glob_module]
type_def = dcl_common.com_type_defs.[glob_object]
= case type_def.td_rhs of
SynType {at_type=TV type_var, at_attribute}
// a "projection" type. attributes are treated in a special way
# arg_pos = get_arg_pos type_var type_def.td_args 0
dcl_arg = dclArgs!!arg_pos
coerced_dcl_arg = { dcl_arg & at_attribute = determine_type_attribute type_def.td_attribute }
-> t_corresponds coerced_dcl_arg icl_atype tc_state
SynType atype
# tc_state = { tc_state & tc_type_vars
= bind_type_vars type_def.td_args dclArgs tc_state.tc_type_vars }
tc_state = init_attr_vars type_def.td_attrs tc_state
tc_state = opt_set_visited_bit is_defined_in_main_dcl glob_object True tc_state
atype = { atype & at_attribute = determine_type_attribute type_def.td_attribute }
(corresponds, tc_state) = t_corresponds atype icl_atype tc_state
tc_state = opt_set_visited_bit is_defined_in_main_dcl glob_object False tc_state
-> (corresponds, tc_state)
AbstractType _
| not is_defined_in_main_dcl
-> (False, tc_state)
#! icl_type_def = tc_state.tc_icl_type_defs.[tc_state.tc_type_conversions.[glob_object]]
# tc_state = { tc_state & tc_type_vars
= bind_type_vars icl_type_def.td_args dclArgs tc_state.tc_type_vars }
tc_state = init_attr_vars icl_type_def.td_attrs tc_state
-> case icl_type_def.td_rhs of
SynType atype
# atype = { atype & at_attribute = determine_type_attribute type_def.td_attribute }
-> t_corresponds atype icl_atype tc_state
_ -> (False, tc_state)
_ -> (False, tc_state)
where
bind_type_vars formal_args actual_args tc_type_vars
# hwn_heap = bind_type_vars` formal_args actual_args tc_type_vars.hwn_heap
= { tc_type_vars & hwn_heap = hwn_heap }
bind_type_vars` [{atv_variable}:formal_args] [actual_arg:actual_args] type_var_heap
# (actual_arg, type_var_heap) = possibly_dereference actual_arg type_var_heap
= bind_type_vars` formal_args actual_args
(writePtr atv_variable.tv_info_ptr (TVI_AType actual_arg) type_var_heap)
// --->("binding", atv_variable.tv_name,"to",actual_arg)
bind_type_vars` _ _ type_var_heap
= type_var_heap
possibly_dereference atype=:{at_type=TV {tv_info_ptr}} type_var_heap
#! dereferenced = sreadPtr tv_info_ptr type_var_heap
= case dereferenced of
TVI_AType atype2
-> (atype2, type_var_heap)
_ -> (atype, type_var_heap)
possibly_dereference atype type_var_heap
= (atype, type_var_heap)
opt_set_visited_bit True glob_object bit tc_state
= { tc_state & tc_visited_syn_types.[glob_object] = bit }
opt_set_visited_bit False _ _ tc_state
= tc_state
determine_type_attribute TA_Unique = TA_Unique
determine_type_attribute _ = TA_Multi
get_arg_pos x [h:t] count
| x==h.atv_variable = count
= get_arg_pos x t (inc count)
| dclDef.at_annotation<>iclDef.at_annotation
= return False
= t_corresponds dclDef.at_attribute iclDef.at_attribute
&&& t_corresponds dclDef.at_type iclDef.at_type
instance t_corresponds TypeAttribute where
t_corresponds TA_Unique TA_Unique
......@@ -594,9 +437,6 @@ instance t_corresponds TypeAttribute where
= t_corresponds dclDef iclDef
t_corresponds (TA_RootVar dclDef) (TA_RootVar iclDef)
= PA_BUG (return True) (t_corresponds dclDef iclDef)
t_corresponds _ TA_Anonymous
| expand_syn_types_late_XXX False True
= return True
t_corresponds TA_None icl
= case icl of
TA_Multi-> return True
......@@ -975,7 +815,7 @@ e_corresponds_VarInfoPtr ident dclPtr iclPtr ec_state=:{ec_var_heap}
e_corresponds_app_symb dcl_app_symb=:{symb_name, symb_kind=SK_Function dcl_glob_index}
icl_app_symb=:{symb_kind=SK_Function icl_glob_index}
ec_state
#! main_dcl_module_n = ec_state.ec_tc_state.tc_main_dcl_module_n
#! main_dcl_module_n = ec_state.ec_main_dcl_module_n
| dcl_glob_index.glob_module==main_dcl_module_n && icl_glob_index.glob_module==main_dcl_module_n
| ec_state.ec_function_conversions.[dcl_glob_index.glob_object]<>icl_glob_index.glob_object
= give_error symb_name ec_state
......
......@@ -4,7 +4,7 @@ import syntax, checksupport
:: ImportNrAndIdents =
{ ini_symbol_nr :: !Index
, ini_belonging :: !Optional [ImportedIdent]
, ini_imp_decl :: !ImportDeclaration
}
:: SolvedImports =
......@@ -16,7 +16,7 @@ import syntax, checksupport
markExplImpSymbols :: !Int !*(!*{!*{!u:ExplImpInfo}}, !*SymbolTable)
-> (!.[Ident],!(!{!{!u:ExplImpInfo}},!.SymbolTable))
updateExplImpForMarkedSymbol :: !Index Declaration !SymbolTableEntry !u:{#DclModule} !{!{!*ExplImpInfo}} !*SymbolTable
updateExplImpForMarkedSymbol :: !Index !Declaration !SymbolTableEntry !u:{#DclModule} !{!{!*ExplImpInfo}} !*SymbolTable
-> (!u:{#DclModule}, !{!{!.ExplImpInfo}}, !.SymbolTable)
solveExplicitImports :: !(IntKeyHashtable [(Int,Position,[ImportNrAndIdents])]) !{#Int} !Index
......
......@@ -17,7 +17,7 @@ implies a b :== not a || b
:: ImportNrAndIdents =
{ ini_symbol_nr :: !Index
, ini_belonging :: !Optional [ImportedIdent]
, ini_imp_decl :: !ImportDeclaration
}
:: SolvedImports =
......@@ -64,7 +64,7 @@ markExplImpSymbols component_nr (expl_imp_info, cs_symbol_table)
updateExplImpForMarkedSymbol :: !Index Declaration !SymbolTableEntry !u:{#DclModule} !{!{!*ExplImpInfo}} !*SymbolTable
updateExplImpForMarkedSymbol :: !Index !Declaration !SymbolTableEntry !u:{#DclModule} !{!{!*ExplImpInfo}} !*SymbolTable
-> (!u:{#DclModule}, !{!{!.ExplImpInfo}}, !.SymbolTable)
updateExplImpForMarkedSymbol mod_index decl {ste_kind=STE_ExplImpComponentNrs component_numbers inst_indices}
dcl_modules expl_imp_infos cs_symbol_table
......@@ -177,9 +177,11 @@ solveExplicitImports expl_imp_indices_ikh modules_in_component_set importing_mod
= ((decl_accu, position), (dcl_modules, visited_modules, expl_imp_info, cs))
solve_belonging position expl_imp_indices_ikh modules_in_component_set importing_mod
(decl, {ini_symbol_nr, ini_belonging=Yes belongs}, imported_mod)
(decl, {ini_symbol_nr, ini_imp_decl}, imported_mod)
(decls_accu, dcl_modules, visited_modules, expl_imp_info, cs=:{cs_error, cs_symbol_table})
# (all_belongs, dcl_modules)
# (Yes belongs)
= getBelongingSymbolsFromID ini_imp_decl
(all_belongs, dcl_modules)
= get_all_belongs decl dcl_modules
(ExplImpInfo eii_ident eii_declaring_modules, expl_imp_info)
= replace expl_imp_info ini_symbol_nr TemporarilyFetchedAway
......@@ -319,7 +321,7 @@ solveExplicitImports expl_imp_indices_ikh modules_in_component_set importing_mod
{di_decl = di_decl, di_instances = [], di_belonging=EndNumbers} eei_dm)
path eii_declaring_modules
new_belonging_accu
= case ini.ini_belonging of
= case getBelongingSymbolsFromID ini.ini_imp_decl of
No
-> belonging_accu
Yes _
......@@ -365,9 +367,9 @@ solveExplicitImports expl_imp_indices_ikh modules_in_component_set importing_mod
belong_nr belong_ident path eii_declaring_modules visited_modules
| not (isEmpty imp_imp_symbols)
// follow the path trough an explicit import only if the symbol is listed there
# (found, ini_belonging)
# (found, opt_belongs)
= search_imported_symbol imported_symbol imp_imp_symbols
| not (found && implies (belong_nr<>cUndef) (belong_ident_found belong_ident ini_belonging))
| not (found && implies (belong_nr<>cUndef) (belong_ident_found belong_ident opt_belongs))
= try_children imports expl_imp_indices_ikh modules_in_component_set imported_symbol
belong_nr belong_ident path eii_declaring_modules visited_modules
= continue imp_imp_mod imports expl_imp_indices_ikh modules_in_component_set imported_symbol
......@@ -394,9 +396,9 @@ solveExplicitImports expl_imp_indices_ikh modules_in_component_set importing_mod
search_imported_symbol :: !Int ![ImportNrAndIdents] -> (!Bool, !Optional [ImportedIdent])
search_imported_symbol imported_symbol []
= (False, No)
search_imported_symbol imported_symbol [{ini_symbol_nr, ini_belonging}:t]
search_imported_symbol imported_symbol [{ini_symbol_nr, ini_imp_decl}:t]
| imported_symbol==ini_symbol_nr
= (True, ini_belonging)
= (True, getBelongingSymbolsFromID ini_imp_decl)
= search_imported_symbol imported_symbol t
......@@ -437,14 +439,18 @@ solveExplicitImports expl_imp_indices_ikh modules_in_component_set importing_mod
check_singles position [] [] (expl_imp_info, cs_error)
= (expl_imp_info, cs_error)
give_error position {ini_symbol_nr} (expl_imp_info, cs_error)
give_error position {ini_symbol_nr, ini_imp_decl} (expl_imp_info, cs_error)
# (eii_ident, expl_imp_info)
= do_a_lot_just_to_read_an_array_2 ini_symbol_nr expl_imp_info
cs_error
= pushErrorAdmin (newPosition import_ident position) cs_error
cs_error
// XXX it should be also printed to which namespace eii_ident belongs
= checkError eii_ident "not exported by the specified module" cs_error
= checkError eii_ident
(switch_import_syntax
"not exported by the specified module"
("not exported as a "+++impDeclToNameSpaceString ini_imp_decl
+++" by the specified module"))
cs_error
= (expl_imp_info, popErrorAdmin cs_error)
do_a_lot_just_to_read_an_array_2 i expl_imp_info
......@@ -454,6 +460,13 @@ solveExplicitImports expl_imp_indices_ikh modules_in_component_set importing_mod
= get_eei_ident eii
= (eii_ident, { expl_imp_info & [i] = eii })
impDeclToNameSpaceString (ID_Function _) = "function/macro"
impDeclToNameSpaceString (ID_Class _ _) = "class"
impDeclToNameSpaceString (ID_Type _ _) = "type"
impDeclToNameSpaceString (ID_Record _ _) = "type"
impDeclToNameSpaceString (ID_Instance _ _ _)= "instance"
get_eei_ident (eii=:ExplImpInfo eii_ident _) = (eii_ident, eii)
:: CheckCompletenessState =
......@@ -811,7 +824,7 @@ instance check_completeness TypeContext where
(check_whether_ident_is_imported tc_class.glob_object.ds_ident STE_Class cci ccs)
instance check_completeness (TypeDef TypeRhs) where