Commit 6984485f authored by Martin Wierich's avatar Martin Wierich
Browse files

improved code for explicit imports,

moved all switches to syntax module
parent 39575b1a
......@@ -614,12 +614,12 @@ collectCommonfinitions {def_types,def_constructors,def_selectors,def_macros,def_
sizes = { sizes & [cSelectorDefs] = size }
(size, defs) = foldSt type_def_to_dcl def_types (0, defs)
sizes = { sizes & [cTypeDefs] = size }
(size, defs) = foldSt member_def_to_dcl def_members (0, defs)
sizes = { sizes & [cMemberDefs] = size }
(size, defs) = foldSt class_def_to_dcl def_classes (0, defs)
sizes = { sizes & [cClassDefs] = size }
(size, defs) = foldSt instance_def_to_dcl def_instances (0, defs)
sizes = { sizes & [cInstanceDefs] = size }
(size, defs) = foldSt member_def_to_dcl def_members (0, defs)
sizes = { sizes & [cMemberDefs] = size }
= (sizes, defs)
where
type_def_to_dcl {td_name, td_pos} (dcl_index, decls)
......@@ -632,8 +632,8 @@ where
= (inc dcl_index, [{ dcl_ident = class_name, dcl_pos = class_pos, dcl_kind = STE_Class, dcl_index = dcl_index } : decls])
member_def_to_dcl {me_symb, me_pos} (dcl_index, decls)
= (inc dcl_index, [{ dcl_ident = me_symb, dcl_pos = me_pos, dcl_kind = STE_Member, dcl_index = dcl_index } : decls])
instance_def_to_dcl {ins_ident, ins_pos} (dcl_index, decls)
= (inc dcl_index, [{ dcl_ident = ins_ident, dcl_pos = ins_pos, dcl_kind = STE_Instance, dcl_index = dcl_index } : decls])
instance_def_to_dcl {ins_class, ins_ident, ins_pos} (dcl_index, decls)
= (inc dcl_index, [{ dcl_ident = ins_ident, dcl_pos = ins_pos, dcl_kind = STE_Instance ins_class.glob_object.ds_ident, dcl_index = dcl_index } : decls])
collectMacros {ir_from,ir_to} macro_defs sizes_defs
= collectGlobalFunctions cMacroDefs ir_from ir_to macro_defs sizes_defs
......@@ -1108,7 +1108,7 @@ check_module2 mod_name mod_imported_objects mod_imports mod_type icl_global_func
cs = addGlobalDefinitionsToSymbolTable local_defs cs
(dcl_modules, icl_functions, hp_expression_heap, cs)
= checkExplicitImportCompleteness (mod_name.id_name+++".icl") main_dcl_module_n dcls_explicit dcl_modules icl_functions hp_expression_heap cs
= checkExplicitImportCompleteness main_dcl_module_n dcls_explicit dcl_modules icl_functions hp_expression_heap cs
heaps = { heaps & hp_expression_heap=hp_expression_heap }
......@@ -1238,8 +1238,8 @@ check_module2 mod_name mod_imported_objects mod_imports mod_type icl_global_func
where
build_conversion_table_for_instances_of_dcl_mod {ir_from,ir_to} first_free_index dcl_functions dcl_instances conversion_table icl_instances
#! nr_of_dcl_functions = size dcl_functions
# dcl_instances_table = conversion_table.[toInt STE_Instance]
dcl_function_table = conversion_table.[toInt STE_DclFunction]
# dcl_instances_table = conversion_table.[cInstanceDefs]
dcl_function_table = conversion_table.[cFunctionDefs]
new_table = { createArray nr_of_dcl_functions NoIndex & [i] = icl_index \\ icl_index <-: dcl_function_table & i <- [0..] }
index_diff = first_free_index - ir_from
new_table = { new_table & [i] = i + index_diff \\ i <- [ir_from .. ir_to - 1] }
......@@ -1521,12 +1521,12 @@ checkImport module_id_info entry=:{ste_kind = STE_Module mod, ste_index} iinfo=:
= check_component [ste_index:component] lowest_mod_info ds modules macro_and_fun_defs heaps cs
check_explicit_import_completeness mod_index (modules, macro_and_fun_defs, hp_expression_heap, cs=:{cs_x})
# ({dcl_name, dcl_declared}, modules) = modules![mod_index]
# ({dcl_declared}, modules) = modules![mod_index]
({dcls_local, dcls_import, dcls_explicit}) = dcl_declared
cs = addDeclaredSymbolsToSymbolTable cIsADclModule mod_index dcls_local dcls_import cs
dcls_explicit = [dcl_explicit \\ dcl_explicit <-:dcls_explicit]
(modules, macro_and_fun_defs, hp_expression_heap, cs=:{cs_symbol_table})
= checkExplicitImportCompleteness (dcl_name.id_name+++".dcl") cs_x.x_main_dcl_module_n dcls_explicit modules macro_and_fun_defs hp_expression_heap cs
= checkExplicitImportCompleteness cs_x.x_main_dcl_module_n dcls_explicit modules macro_and_fun_defs hp_expression_heap cs
cs_symbol_table = removeImportsAndLocalsOfModuleFromSymbolTable dcl_declared cs.cs_symbol_table
// XXX optimise by using version that does not allocate the first result value
= (modules, macro_and_fun_defs, hp_expression_heap, { cs & cs_symbol_table = cs_symbol_table })
......@@ -1555,13 +1555,6 @@ initialDclModule ({mod_name, mod_defs=mod_defs=:{def_funtypes,def_macros}, mod_t
, dcl_imported_module_numbers = EndModuleNumbers
}
local_declaration_for_import decl=:{dcl_kind=STE_FunctionOrMacro _} module_n
= decl
local_declaration_for_import decl=:{dcl_kind=STE_Imported _ _} module_n
= abort "local_declaration_for_import"
local_declaration_for_import decl=:{dcl_kind} module_n
= {decl & dcl_kind = STE_Imported dcl_kind module_n}
checkDclModule :: !Bool !(Module (CollectedDefinitions ClassInstance IndexRange)) !Index !*{#DclModule} !*{#FunDef} !*Heaps !*CheckState
-> (!*{#DclModule}, !*{#FunDef}, !*Heaps, !*CheckState)
checkDclModule is_on_cycle {mod_name,mod_imports,mod_defs} mod_index modules icl_functions heaps=:{hp_var_heap, hp_type_heaps,hp_expression_heap} cs
......@@ -1575,8 +1568,6 @@ checkDclModule is_on_cycle {mod_name,mod_imports,mod_defs} mod_index modules icl
cs = { cs & cs_x.x_needed_modules = 0 }
nr_of_dcl_functions = size dcl_mod.dcl_functions
dcls_explicit = flatten [[dcls_explicit\\dcls_explicit<-:dcls_explicit] \\ (_,{dcls_explicit})<-imports]
#! main_dcl_module_n = cs.cs_x.x_main_dcl_module_n
# (dcl_common, modules, hp_type_heaps, hp_var_heap, cs)
......@@ -1621,7 +1612,7 @@ checkDclModule is_on_cycle {mod_name,mod_imports,mod_defs} mod_index modules icl
dcls_explicit = flatten [[dcls_explicit\\dcls_explicit<-:dcls_explicit] \\ (_,{dcls_explicit})<-imports]
(modules, icl_functions, hp_expression_heap, cs)
= case is_on_cycle of
False -> checkExplicitImportCompleteness (mod_name.id_name+++".dcl") main_dcl_module_n dcls_explicit modules icl_functions hp_expression_heap cs
False -> checkExplicitImportCompleteness main_dcl_module_n dcls_explicit modules icl_functions hp_expression_heap cs
True -> (modules, icl_functions, hp_expression_heap, cs)
heaps = { heaps & hp_expression_heap = hp_expression_heap }
......@@ -1632,7 +1623,7 @@ checkDclModule is_on_cycle {mod_name,mod_imports,mod_defs} mod_index modules icl
com_instance_defs = com_instance_defs, com_cons_defs = e_info.ef_cons_defs, com_member_defs = e_info.ef_member_defs }
(dcl_imported, cs_symbol_table) = retrieveAndRemoveImportsFromSymbolTable imports [] cs.cs_symbol_table
dcl_imported = {dcl_import\\dcl_import<-dcl_imported}
cs_symbol_table = removeDeclarationsFromSymbolTable dcl_defined cModuleScope cs_symbol_table
......@@ -1647,11 +1638,11 @@ checkDclModule is_on_cycle {mod_name,mod_imports,mod_defs} mod_index modules icl
dcl_class_specials = { ir_from = first_special_class_index, ir_to = last_special_class_index }}
= ({ modules & [ mod_index ] = dcl_mod }, icl_functions, heaps, { cs & cs_symbol_table = cs_symbol_table })
where
collect_imported_symbols [{import_module={id_info},import_symbols,import_file_position=LinePos filename line_nr} : mods ] all_decls modules cs=:{cs_symbol_table}
collect_imported_symbols [{import_module={id_info},import_symbols,import_file_position} : mods ] all_decls modules cs=:{cs_symbol_table}
# (entry, cs_symbol_table) = readPtr id_info cs_symbol_table
# (decls_of_imported_module, modules, cs) = collect_declarations_of_module id_info entry [] modules { cs & cs_symbol_table = cs_symbol_table}
(imported_decls, modules, cs) = possibly_filter_decls
import_symbols decls_of_imported_module (filename, line_nr) modules cs
(imported_decls, modules, cs) = possiblyFilterExplImportedDecls
import_symbols decls_of_imported_module import_file_position modules cs
= collect_imported_symbols mods (imported_decls++all_decls) modules cs
collect_imported_symbols [] all_decls modules cs
= (all_decls, modules, cs)
......@@ -1774,11 +1765,11 @@ NewEntry symbol_table symb_ptr def_kind def_index level previous :==
// -> (![(!Declaration, !LineNr)], !*{# DclModule}, !*CheckState)
addImportsToSymbolTable :: ![ParsedImport] ![ExplicitImport] !*{# DclModule} !*CheckState
-> (![ExplicitImport], !*{# DclModule}, !*CheckState)
addImportsToSymbolTable [{import_module={id_info},import_symbols, import_file_position=LinePos filename line_nr} : mods ] explicit_akku modules cs=:{cs_symbol_table}
addImportsToSymbolTable [{import_module={id_info},import_symbols, import_file_position} : mods ] explicit_akku modules cs=:{cs_symbol_table}
# ({ste_index}, cs_symbol_table) = readPtr id_info cs_symbol_table
# ({dcl_declared=decls_of_imported_module}, modules) = modules![ste_index]
(imported_decls, modules, cs)
= possibly_filter_decls import_symbols [(ste_index, decls_of_imported_module)] (filename,line_nr) modules { cs & cs_symbol_table = cs_symbol_table }
= possiblyFilterExplImportedDecls import_symbols [(ste_index, decls_of_imported_module)] import_file_position modules { cs & cs_symbol_table = cs_symbol_table }
| isEmpty imported_decls
= addImportsToSymbolTable mods explicit_akku modules cs
# (_,{dcls_import,dcls_local,dcls_local_for_import,dcls_explicit}) = hd imported_decls
......
......@@ -75,7 +75,7 @@ cConversionTableSize :== 8
, dcls_explicit ::!{!ExplicitImport}
}
:: ExplicitImport = ExplicitImport !Declaration !LineNr;
:: ExplicitImport = ExplicitImport !Declaration !Position
:: IclModule =
{ icl_name :: !Ident
......@@ -167,3 +167,5 @@ removeLocalsFromSymbolTable :: !Level ![Ident] !LocalDefs !u:{# FunDef} !*(Heap
-> (!u:{# FunDef}, !.Heap SymbolTableEntry)
newFreeVariable :: !FreeVar ![FreeVar] ->(!Bool, ![FreeVar])
local_declaration_for_import :: !u:Declaration .Index -> v:Declaration, [u <= v]
......@@ -18,11 +18,9 @@ cGlobalScope :== 1
cIsNotADclModule :== False
cIsADclModule :== True
// MW..
cNeedStdArray :== 1
cNeedStdEnum :== 2
cNeedStdDynamics:== 4
// ..MW
:: Heaps =
{ hp_var_heap ::!.VarHeap
......@@ -56,7 +54,7 @@ where
toInt (STE_Field _) = cSelectorDefs
toInt STE_Class = cClassDefs
toInt STE_Member = cMemberDefs
toInt STE_Instance = cInstanceDefs
toInt (STE_Instance _) = cInstanceDefs
toInt STE_DclFunction = cFunctionDefs
toInt (STE_FunctionOrMacro _) = cMacroDefs
toInt _ = NoIndex
......@@ -84,7 +82,7 @@ where
, dcls_explicit ::!{!ExplicitImport}
}
:: ExplicitImport = ExplicitImport !Declaration !LineNr;
:: ExplicitImport = ExplicitImport !Declaration !Position
:: IclModule =
{ icl_name :: !Ident
......@@ -252,12 +250,12 @@ retrieveAndRemoveImportsFromSymbolTable [] all_decls symbol_table
retrieveAndRemoveImportsOfModuleFromSymbolTable2 :: !{!.Declaration} !{!.Declaration} ![.Declaration] !*(Heap SymbolTableEntry) -> ([Declaration],.Heap SymbolTableEntry);
retrieveAndRemoveImportsOfModuleFromSymbolTable2 imports locals_for_import all_decls symbol_table
# (all_decls, symbol_table) = retrieve_declared_symbols_in_array 0 imports all_decls symbol_table
= retrieve_declared_symbols_in_array 0 locals_for_import all_decls symbol_table
# (all_decls, symbol_table) = retrieve_declared_symbols_in_array ((size imports)-1) imports all_decls symbol_table
= retrieve_declared_symbols_in_array ((size locals_for_import)-1) locals_for_import all_decls symbol_table
retrieveAndRemoveImportsOfModuleFromSymbolTable :: !{!.Declaration} ![.Declaration] ![.Declaration] !*(Heap SymbolTableEntry) -> ([Declaration],.Heap SymbolTableEntry);
retrieveAndRemoveImportsOfModuleFromSymbolTable imports locals all_decls symbol_table
# (all_decls, symbol_table) = retrieve_declared_symbols_in_array 0 imports all_decls symbol_table
# (all_decls, symbol_table) = retrieve_declared_symbols_in_array ((size imports)-1) imports all_decls symbol_table
= retrieve_declared_symbols locals all_decls symbol_table
where
retrieve_declared_symbols :: ![Declaration] ![Declaration] !*SymbolTable -> (![Declaration], !*SymbolTable)
......@@ -292,13 +290,13 @@ where
retrieve_declared_symbols_in_array :: !Int !{!Declaration} ![Declaration] !*SymbolTable -> (![Declaration], !*SymbolTable)
retrieve_declared_symbols_in_array symbol_index symbols decls symbol_table
| symbol_index<size symbols
| symbol_index>=0
#! (declaration,symbols) = symbols![symbol_index]
# {dcl_ident=ident=:{id_info},dcl_kind}=declaration
#! entry = sreadPtr id_info symbol_table
# {ste_kind,ste_def_level} = entry
| ste_kind == STE_Empty || ste_def_level > cModuleScope
= retrieve_declared_symbols_in_array (symbol_index+1) symbols decls symbol_table
= retrieve_declared_symbols_in_array (symbol_index-1) symbols decls symbol_table
# symbol_table = symbol_table <:= (id_info, entry.ste_previous)
= case ste_kind of
STE_Field selector_id
......@@ -307,29 +305,29 @@ retrieve_declared_symbols_in_array symbol_index symbols decls symbol_table
_ -> False
#! (declaration,symbols) = symbols![symbol_index]
#! dcl_index = symbols.[symbol_index].dcl_index
-> retrieve_declared_symbols_in_array (symbol_index+1) symbols [declaration : decls ] (removeFieldFromSelectorDefinition selector_id NoIndex dcl_index symbol_table)
-> retrieve_declared_symbols_in_array (symbol_index-1) symbols [declaration : decls ] (removeFieldFromSelectorDefinition selector_id NoIndex dcl_index symbol_table)
#! (declaration,symbols) = symbols![symbol_index]
#! dcl_index = declaration.dcl_index
#! declaration = { declaration & dcl_kind = ste_kind }
-> retrieve_declared_symbols_in_array (symbol_index+1) symbols [declaration : decls ] (removeFieldFromSelectorDefinition selector_id NoIndex dcl_index symbol_table)
-> retrieve_declared_symbols_in_array (symbol_index-1) symbols [declaration : decls ] (removeFieldFromSelectorDefinition selector_id NoIndex dcl_index symbol_table)
STE_Imported (STE_Field selector_id) def_mod
| case dcl_kind of
STE_Imported (STE_Field f) d -> d==def_mod && f==selector_id
_ -> False
#! (declaration,symbols) = symbols![symbol_index]
#! dcl_index = symbols.[symbol_index].dcl_index
-> retrieve_declared_symbols_in_array (symbol_index+1) symbols [declaration : decls ] (removeFieldFromSelectorDefinition selector_id def_mod dcl_index symbol_table)
-> retrieve_declared_symbols_in_array (symbol_index-1) symbols [declaration : decls ] (removeFieldFromSelectorDefinition selector_id def_mod dcl_index symbol_table)
#! (declaration,symbols) = symbols![symbol_index]
#! dcl_index = declaration.dcl_index
#! declaration = { declaration & dcl_kind = ste_kind }
-> retrieve_declared_symbols_in_array (symbol_index+1) symbols [declaration : decls ] (removeFieldFromSelectorDefinition selector_id def_mod dcl_index symbol_table)
-> retrieve_declared_symbols_in_array (symbol_index-1) symbols [declaration : decls ] (removeFieldFromSelectorDefinition selector_id def_mod dcl_index symbol_table)
_
| same_STE_Kind ste_kind dcl_kind
#! (declaration,symbols) = symbols![symbol_index]
-> retrieve_declared_symbols_in_array (symbol_index+1) symbols [declaration : decls ] symbol_table
-> retrieve_declared_symbols_in_array (symbol_index-1) symbols [declaration : decls ] symbol_table
#! (declaration,symbols) = symbols![symbol_index]
#! declaration = { declaration & dcl_kind = ste_kind }
-> retrieve_declared_symbols_in_array (symbol_index+1) symbols [declaration : decls ] symbol_table
-> retrieve_declared_symbols_in_array (symbol_index-1) symbols [declaration : decls ] symbol_table
= (decls, symbol_table)
same_STE_Kind (STE_Imported s1 i1) (STE_Imported s2 i2) = i1==i2 && same_STE_Kind s1 s2
......@@ -338,7 +336,7 @@ same_STE_Kind (STE_FunctionOrMacro []) (STE_FunctionOrMacro []) = True
same_STE_Kind STE_Type STE_Type = True
same_STE_Kind STE_Constructor STE_Constructor = True
same_STE_Kind (STE_Field f1) (STE_Field f2) = f1==f2
same_STE_Kind STE_Instance STE_Instance = True
same_STE_Kind (STE_Instance _) (STE_Instance _) = True
same_STE_Kind STE_Member STE_Member = True
same_STE_Kind STE_Class STE_Class = True
same_STE_Kind _ _ = False
......@@ -631,6 +629,14 @@ newFreeVariable new_var []
= (True, [new_var])
local_declaration_for_import :: !u:Declaration .Index -> v:Declaration, [u <= v]
local_declaration_for_import decl=:{dcl_kind=STE_FunctionOrMacro _} module_n
= decl
local_declaration_for_import decl=:{dcl_kind=STE_Imported _ _} module_n
= abort "local_declaration_for_import"
local_declaration_for_import decl=:{dcl_kind} module_n
= {decl & dcl_kind = STE_Imported dcl_kind module_n}
class toIdent a :: !a -> Ident
......@@ -728,7 +734,7 @@ where
STE_Member
= file <<< "STE_Member"
(<<<) file
STE_Instance
(STE_Instance _)
= file <<< "STE_Instance"
(<<<) file
(STE_Variable _)
......
......@@ -2,25 +2,9 @@ definition module explicitimports
import syntax, checksupport
temporary_import_solution_XXX yes no :== yes
// to switch between importing modes.
// iff this is yes, then explicit imports happen in the old Clean 1.3 fashion.
// This feature will be removed, when all programs are ported to Clean 2.0. The last Constructors of AtomType
// and StructureType should then be removed also
possiblyFilterExplImportedDecls :: ![ImportDeclaration] u:[w:(.Index,y:Declarations)] Position u0:{#DclModule} !*CheckState
-> (!v:[x:(Index,z:Declarations)],!u0:{#DclModule},!.CheckState), [y <= z, w <= x, u <= v]
//:: FunctionConsequence
possibly_filter_decls :: .[ImportDeclaration] u:[w:(.Index,y:Declarations)] (.FileName,.LineNr) *{#.DclModule} *CheckState -> (v:[x:(Index,z:Declarations)],.{#DclModule},.CheckState), [y <= z, w <= x, u <= v];
//possibly_filter_decls :: ![ImportDeclaration] ![(Index,Declarations)] !(!FileName,!LineNr) !*{#DclModule} !*CheckState -> (![(Index,Declarations)],!.{#DclModule},!.CheckState)
//check_completeness_of_module :: .Index !Int [(.Declaration,.Int)] .String *(*{!.FunctionConsequence},*{#.DclModule},*{#FunDef},*ExpressionHeap,*CheckState) -> (.{!FunctionConsequence},.{#DclModule},.{#FunDef},.ExpressionHeap,.CheckState);
/*
check_completeness_of_module :: .Index !Int [ExplicitImport] .String *(*{!.FunctionConsequence},*{#.DclModule},*{#FunDef},*ExpressionHeap,*CheckState) -> (.{!FunctionConsequence},.{#DclModule},.{#FunDef},.ExpressionHeap,.CheckState);
check_completeness_of_all_dcl_modules :: !Int !*{#DclModule} !*{#FunDef} !*ExpressionHeap !*CheckState
-> (!Int, !(!*{!FunctionConsequence}, !*{#DclModule}, !*{#FunDef}, !*ExpressionHeap, !*CheckState))
create_empty_consequences_array :: !Int -> *{!FunctionConsequence}
*/
//checkExplicitImportCompleteness :: !String ![(!Declaration,!Int)] !*{#DclModule} !*{#FunDef} !*ExpressionHeap !*CheckState -> (!.{#DclModule},!.{#FunDef},!.ExpressionHeap,!.CheckState)
checkExplicitImportCompleteness :: !String !Int ![ExplicitImport] !*{#DclModule} !*{#FunDef} !*ExpressionHeap !*CheckState -> (!.{#DclModule},!.{#FunDef},!.ExpressionHeap,!.CheckState)
checkExplicitImportCompleteness :: !Int ![ExplicitImport] !*{#DclModule} !*{#FunDef} !*ExpressionHeap !*CheckState
-> (!.{#DclModule},!.{#FunDef},!.ExpressionHeap,!.CheckState)
This diff is collapsed.
......@@ -856,6 +856,24 @@ instance want ImportDeclaration
where
want pState
# (token, pState) = nextToken GeneralContext pState
// MW5..
= (switch_import_syntax want_1_3_import_declaration want_2_0_import_declaration) token pState
want_1_3_import_declaration token pState
= case token of
IdentToken name
# (fun_id, pState) = stringToIdent name IC_Expression pState
(type_id, pState) = stringToIdent name IC_Type pState
(class_id, pState) = stringToIdent name IC_Class pState
-> (ID_OldSyntax [fun_id, type_id, class_id], pState)
token
# (fun_id, pState) = stringToIdent "dummy" IC_Expression pState
-> ( ID_Function { ii_ident = fun_id, ii_extended = False }
, parseError "from import" (Yes token) "imported item" pState
)
want_2_0_import_declaration token pState
// ..MW5
= case token of
DoubleColonToken
# (name, pState) = wantUpperCaseName "import type" pState
......
......@@ -6,6 +6,11 @@ import scanner, general, typeproperties, Heap
PA_BUG on off :== on
switch_import_syntax one_point_three two_point_zero :== one_point_three
/* when finally removing this switch also remove the argument of STE_Instance and ID_OldSyntax */
SwitchFusion fuse dont_fuse :== dont_fuse
:: Ident =
{ id_name :: !String
, id_info :: !SymbolPtr
......@@ -37,7 +42,7 @@ instance toString Ident
| STE_Field !Ident
| STE_Class
| STE_Member
| STE_Instance
| STE_Instance !Ident // argument: the class (used in explicitimports (1.3 syntax only))
| STE_Variable !VarInfoPtr
| STE_TypeVariable !TypeVarInfoPtr
| STE_TypeAttribute !AttrVarInfoPtr
......@@ -55,6 +60,15 @@ instance toString Ident
| STE_DictCons !ConsDef
| STE_DictField !SelectorDef
| STE_Called ![Index] /* used during macro expansion to indicate that this function is called */
| STE_ExplImp !Bool !(Optional ImportDeclaration) !STE_Kind !Bool /* auxiliary used in module explicitimports. */
/* 1st arg: initialized with False and set to True when the searched symbol has been found to indicate.
2nd arg: Yes: the ImportDeclaration with which it was intended to import the symbol.
No: for symbols within a bracket (fields, constructors, members)
3rd arg: for error messages: the expected namespace of the intended imported symbol
4th arg: at first the idents for _all_ fields, constructors & members are added to the symbol table. In
case of a selective import like "... import :: R {f1}" this bit is used to remove all
fields different from "f1" from the symbol table again.
*/
:: Global object =
{ glob_object :: !object
......@@ -277,6 +291,7 @@ instance toString (Import from_symbol), AttributeVar, TypeAttribute, Annotation
| ID_Type !ImportedIdent !(Optional [ImportedIdent])
| ID_Record !ImportedIdent !(Optional [ImportedIdent])
| ID_Instance !ImportedIdent !Ident !(![Type],![TypeContext])
| ID_OldSyntax ![Ident]
cIsImportedLibrary :== True
cIsImportedObject :== False
......
......@@ -5,6 +5,8 @@ import StdEnv, compare_constructor // ,RWSDebug
import scanner, general, Heap, typeproperties, utilities
PA_BUG on off :== on
switch_import_syntax one_point_three two_point_zero :== one_point_three
SwitchFusion fuse dont_fuse :== dont_fuse
:: Ident =
{ id_name :: !String
......@@ -41,7 +43,7 @@ where toString {import_module} = toString import_module
| STE_Field !Ident
| STE_Class
| STE_Member
| STE_Instance
| STE_Instance !Ident // the class (for explicit imports (1.3 syntax only))
| STE_Variable !VarInfoPtr
| STE_TypeVariable !TypeVarInfoPtr
| STE_TypeAttribute !AttrVarInfoPtr
......@@ -57,6 +59,7 @@ where toString {import_module} = toString import_module
| STE_DictCons !ConsDef
| STE_DictField !SelectorDef
| STE_Called ![Index] /* used during macro expansion to indicate that this function is called */
| STE_ExplImp !Bool !(Optional ImportDeclaration) !STE_Kind !Bool /* auxiliary used in module explicitimports. */
:: Global object =
{ glob_object :: !object
......@@ -267,6 +270,7 @@ cNameLocationDependent :== True
| ID_Type !ImportedIdent !(Optional [ImportedIdent])
| ID_Record !ImportedIdent !(Optional [ImportedIdent])
| ID_Instance !ImportedIdent !Ident !(![Type],![TypeContext])
| ID_OldSyntax ![Ident]
cIsImportedLibrary :== True
cIsImportedObject :== False
......
......@@ -1986,7 +1986,7 @@ where
collect_imported_instances imports common_defs dummy error class_instances type_var_heap td_infos
= foldSt (collect_imported_instance common_defs) imports (dummy, error, class_instances, type_var_heap, td_infos)
collect_imported_instance common_defs {dcl_ident, dcl_kind = STE_Imported STE_Instance mod_index, dcl_index } state
collect_imported_instance common_defs {dcl_ident, dcl_kind = STE_Imported (STE_Instance _) mod_index, dcl_index } state
= update_instances_of_class common_defs mod_index dcl_index state
collect_imported_instance common_defs _ state
= state
......
......@@ -4,9 +4,6 @@ import checksupport, StdCompare
from unitype import Coercions, CoercionTree, AttributePartition, CT_Empty
// MW: this switch is used to en(dis)able the fusion algorithm
SwitchFusion fuse dont_fuse :== dont_fuse
errorHeading :: !String !*ErrorAdmin -> *ErrorAdmin
// MW4 was:class (<::) infixl a :: !*File (!Format, !a) -> *File
......
......@@ -3,9 +3,6 @@ implementation module typesupport
import StdEnv, StdCompare
import syntax, parse, check, unitype, utilities, checktypes, RWSDebug
// MW: this switch is used to en(dis)able the fusion algorithm
SwitchFusion fuse dont_fuse :== dont_fuse
:: Store :== Int
:: AttrCoercion =
......
......@@ -120,6 +120,32 @@ iterateSt op st :== iterate_st op st
= iterate_st op st
= st
mapFilterYesSt f l st
:== map_filter_yes_st l st
where
map_filter_yes_st [] st
= ([], st)
map_filter_yes_st [h:t] st
#! (opt_f_h , st) = f h st
(t2, st) = map_filter_yes_st t st
f_h_t2 = optCons opt_f_h t2
st = st
= (f_h_t2, st)
iMapFilterYesSt f fr to st
:== i_map_filter_yes_st fr to st
where
i_map_filter_yes_st fr to st
| fr >= to
= ([], st)
#! (opt_f_fr, st) = f fr st
(t, st) = i_map_filter_yes_st (inc fr) to st
f_fr_t2 = optCons opt_f_fr t
st = st
= (f_fr_t2, st)
optCons :: !(Optional .a) !u:[.a] -> v:[.a] ,[u <= v]
revAppend :: ![a] ![a] -> [a] // Reverse the list using the second argument as accumulator.
revMap :: !(.a -> .b) ![.a] !u:[.b] -> u:[.b]
......
......@@ -205,6 +205,38 @@ iterateSt op st :== iterate_st op st
= iterate_st op st
= st
mapFilterYesSt f l st
:== map_filter_yes_st l st
where
map_filter_yes_st [] st
= ([], st)
map_filter_yes_st [h:t] st
#! (opt_f_h , st) = f h st
(t2, st) = map_filter_yes_st t st
f_h_t2 = optCons opt_f_h t2
st = st
= (f_h_t2, st)
iMapFilterYesSt f fr to st
:== i_map_filter_yes_st fr to st
where
i_map_filter_yes_st fr to st
| fr >= to
= ([], st)
#! (opt_f_fr, st) = f fr st
(t, st) = i_map_filter_yes_st (inc fr) to st
f_fr_t2 = optCons opt_f_fr t
st = st
= (f_fr_t2, st)
optCons :: !(Optional .a) !u:[.a] -> v:[.a] ,[u <= v]
optCons No l
= l
optCons (Yes x) l
= [x:l]
eqMerge :: ![a] ![a] -> [a] | Eq a
eqMerge [a : x] y
| isMember a y
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment