diff --git a/backendC/CleanCompilerSources/backend.c b/backendC/CleanCompilerSources/backend.c index b0ee1856cd62c466242e8eb62862dbbcfc32c126..8a4bc497a5a5c34b5a79ffa183107b0ffb18bf55 100644 --- a/backendC/CleanCompilerSources/backend.c +++ b/backendC/CleanCompilerSources/backend.c @@ -118,7 +118,6 @@ STRUCT (be_state, BEState) BEIclS be_icl; unsigned int be_nModules; - SymbolP be_function_symbols; SymbolP be_dontCareSymbol; SymbolP be_dictionarySelectFunSymbol; SymbolP be_dictionaryUpdateFunSymbol; @@ -176,32 +175,15 @@ PredefinedSymbol (SymbKind symbolKind, int arity) } /* PredefinedSymbol */ static SymbolP -AllocateSymbols (int nFunctions, int nTypesConstructorsAndFields, SymbolP *function_symbols_h) -{ - int nSymbols; - - nSymbols = nFunctions+nTypesConstructorsAndFields; - if (nSymbols!=0){ +AllocateSymbols (int n_symbols) +{ + if (n_symbols!=0){ SymbolP symbols; int i; - symbols = (SymbolP) ConvertAlloc (nSymbols * sizeof (SymbolS)); - i = 0; - - if (nFunctions>0){ - for (; i < nFunctions; ++i){ - symbols [i].symb_kind = erroneous_symb; - symbols [i].symb_next = &symbols [i+1]; - } - - symbols [nFunctions-1].symb_next = *function_symbols_h; - *function_symbols_h = symbols; - } - - for (; i < nSymbols; i++){ + symbols = (SymbolP) ConvertAlloc (n_symbols * sizeof (SymbolS)); + for (i = 0; i < n_symbols; i++) symbols [i].symb_kind = erroneous_symb; - symbols [i].symb_next = NULL; - } return symbols; } else @@ -277,13 +259,12 @@ NewGuardNode (NodeP ifNode, NodeP node, NodeDefP nodeDefs, StrictNodeIdP stricts } /* NewGuardNode */ static void -DeclareModule (int moduleIndex, char *name, Bool isSystemModule, int nFunctions, - int nTypes, int nConstructors, int nFields) +DeclareModule (int moduleIndex, char *name, Bool isSystemModule, int nFunctions,int nTypes, int nConstructors, int nFields) { + SymbolP symbols; BEModuleP module; - SymbolP symbols; - symbols = AllocateSymbols (nFunctions, nTypes + nConstructors + nFields, &gBEState.be_function_symbols); + symbols = AllocateSymbols (nFunctions + nTypes + nConstructors + nFields); Assert ((unsigned int) moduleIndex < gBEState.be_nModules); module = &gBEState.be_modules [moduleIndex]; @@ -359,11 +340,11 @@ BEDeclareIclModule (CleanString name, CleanString modificationTime, int nFunctio icl->beicl_depsP = &scc_dependency_list; { - struct module_type_symbols *dcl_type_symbols_a; + struct module_function_and_type_symbols *dcl_type_symbols_a; int n_dcl_type_symbols; struct def_list *def_mod; - dcl_type_symbols_a = (struct module_type_symbols*) ConvertAlloc (gBEState.be_nModules * sizeof (struct module_type_symbols)); + dcl_type_symbols_a = (struct module_function_and_type_symbols*) ConvertAlloc (gBEState.be_nModules * sizeof (struct module_function_and_type_symbols)); n_dcl_type_symbols=0; for (def_mod=OpenDefinitionModules; def_mod!=NULL; def_mod=def_mod->mod_next){ @@ -371,23 +352,28 @@ BEDeclareIclModule (CleanString name, CleanString modificationTime, int nFunctio module_n = def_mod->mod_body->dm_module_n; if (module_n!=main_dcl_module_n){ - dcl_type_symbols_a[n_dcl_type_symbols].mts_n_types = gBEState.be_modules [module_n].bem_nTypes; - dcl_type_symbols_a[n_dcl_type_symbols].mts_type_symbol_a = gBEState.be_modules [module_n].bem_types; + dcl_type_symbols_a[n_dcl_type_symbols].mfts_n_types = gBEState.be_modules[module_n].bem_nTypes; + dcl_type_symbols_a[n_dcl_type_symbols].mfts_type_symbol_a = gBEState.be_modules[module_n].bem_types; + dcl_type_symbols_a[n_dcl_type_symbols].mfts_n_functions = gBEState.be_modules[module_n].bem_nFunctions; + dcl_type_symbols_a[n_dcl_type_symbols].mfts_function_symbol_a = gBEState.be_modules[module_n].bem_functions; ++n_dcl_type_symbols; } } - dcl_type_symbols_a[n_dcl_type_symbols].mts_n_types = gBEState.be_modules [kPredefinedModuleIndex].bem_nTypes; - dcl_type_symbols_a[n_dcl_type_symbols].mts_type_symbol_a = gBEState.be_modules [kPredefinedModuleIndex].bem_types; + dcl_type_symbols_a[n_dcl_type_symbols].mfts_n_types = gBEState.be_modules[kPredefinedModuleIndex].bem_nTypes; + dcl_type_symbols_a[n_dcl_type_symbols].mfts_type_symbol_a = gBEState.be_modules[kPredefinedModuleIndex].bem_types; + dcl_type_symbols_a[n_dcl_type_symbols].mfts_n_functions = gBEState.be_modules[kPredefinedModuleIndex].bem_nFunctions; + dcl_type_symbols_a[n_dcl_type_symbols].mfts_function_symbol_a = gBEState.be_modules[kPredefinedModuleIndex].bem_functions; ++n_dcl_type_symbols; Assert (n_dcl_type_symbols<=gBEState.be_nModules); - icl->beicl_module->im_dcl_type_symbols_a = dcl_type_symbols_a; - icl->beicl_module->im_size_dcl_type_symbols_a = n_dcl_type_symbols; + icl->beicl_module->im_dcl_mfts_a = dcl_type_symbols_a; + icl->beicl_module->im_size_dcl_mfts_a = n_dcl_type_symbols; } nFunctions += ArraySize (gLocallyGeneratedFunctions); + DeclareModule (main_dcl_module_n, cName, False, nFunctions, nTypes, nConstructors, nFields); iclModule = icl->beicl_module; @@ -396,9 +382,10 @@ BEDeclareIclModule (CleanString name, CleanString modificationTime, int nFunctio iclModule->im_def_module = im_def_module; iclModule->im_rules = NULL; iclModule->im_start = NULL; - iclModule->im_type_symbols.mts_n_types = nTypes; - iclModule->im_type_symbols.mts_type_symbol_a = gBEState.be_modules [main_dcl_module_n].bem_types; - iclModule->im_function_symbols = gBEState.be_function_symbols; + iclModule->im_mfts_a.mfts_n_types = nTypes; + iclModule->im_mfts_a.mfts_type_symbol_a = gBEState.be_modules [main_dcl_module_n].bem_types; + iclModule->im_mfts_a.mfts_n_functions = nFunctions; + iclModule->im_mfts_a.mfts_function_symbol_a = gBEState.be_modules[main_dcl_module_n].bem_functions; # if IMPORT_OBJ_AND_LIB iclModule->im_imported_objs = NULL; iclModule->im_imported_libs = NULL; @@ -429,20 +416,12 @@ BEDeclareDclModule (int moduleIndex, CleanString name, CleanString modificationT char *cName; SymbolP moduleNameSymbol; DefMod dclModule; - SymbolP saved_function_symbols,previous_all_symbols; cName = ConvertCleanString (name); moduleNameSymbol = ConvertAllocType (SymbolS); moduleNameSymbol->symb_ident = Identifier (cName); - if (moduleIndex == main_dcl_module_n){ - saved_function_symbols = gBEState.be_function_symbols; - gBEState.be_function_symbols = NULL; - } - - previous_all_symbols = gBEState.be_function_symbols; - DeclareModule (moduleIndex, cName, isSystemModule, nFunctions, nTypes, nConstructors, nFields); dclModule = ConvertAllocType (DefRepr); @@ -450,16 +429,11 @@ BEDeclareDclModule (int moduleIndex, CleanString name, CleanString modificationT dclModule->dm_module_n = moduleIndex; dclModule->dm_modification_time = ConvertCleanString (modificationTime); dclModule->dm_system_module = isSystemModule; - dclModule->dm_function_symbols = gBEState.be_function_symbols; - dclModule->dm_symbols_end = previous_all_symbols; + dclModule->dm_function_symbol_a = gBEState.be_modules[moduleIndex].bem_functions; + dclModule->dm_n_function_symbols = gBEState.be_modules[moduleIndex].bem_nFunctions; dclModule->dm_system_module_table_kind = FirstSystemModuleTable + moduleIndex; AddOpenDefinitionModule (moduleNameSymbol, dclModule); - - if (moduleIndex == main_dcl_module_n){ - gBEState.be_function_symbols = saved_function_symbols; - im_def_module=dclModule; - } } /* BEDeclareDclModule */ void @@ -564,10 +538,11 @@ BESymbolP BESpecialArrayFunctionSymbol (BEArrayFunKind arrayFunKind, int functionIndex, int moduleIndex) { BEModuleP module; - SymbolP functionSymbol,previousFunctionSymbol; + SymbolP functionSymbol; SymbDefP originalsdef; TypeAlt *typeAlt; TypeNode elementType, arrayType; + SymbDef previousFunctionSymbDef; Assert ((unsigned int) moduleIndex < gBEState.be_nModules); module = &gBEState.be_modules [moduleIndex]; @@ -599,21 +574,18 @@ BESpecialArrayFunctionSymbol (BEArrayFunKind arrayFunKind, int functionIndex, in return (functionSymbol); } - previousFunctionSymbol = functionSymbol; - functionSymbol = functionSymbol->symb_next; - - if (functionSymbol != NULL && functionSymbol->symb_kind == definition){ + previousFunctionSymbDef = originalsdef; + if (previousFunctionSymbDef->sdef_mark & SDEF_HAS_SPECIAL_ARRAY_FUNCTION){ + functionSymbol = previousFunctionSymbDef->sdef_special_array_function_symbol; if (functionSymbol->symb_def->sdef_arfun == (ArrayFunKind) arrayFunKind) return functionSymbol; if (arrayFunKind == BE_UnqArraySelectLastFun && functionSymbol->symb_def->sdef_arfun == BE_UnqArraySelectFun){ - previousFunctionSymbol = functionSymbol; - functionSymbol = functionSymbol->symb_next; - - if (functionSymbol != NULL && functionSymbol->symb_kind == definition && - functionSymbol->symb_def->sdef_arfun == (ArrayFunKind) arrayFunKind) - { - return functionSymbol; + previousFunctionSymbDef = functionSymbol->symb_def; + if (previousFunctionSymbDef->sdef_mark & SDEF_HAS_SPECIAL_ARRAY_FUNCTION){ + functionSymbol = previousFunctionSymbDef->sdef_special_array_function_symbol; + if (functionSymbol->symb_def->sdef_arfun == (ArrayFunKind) arrayFunKind) + return functionSymbol; } } } @@ -720,9 +692,14 @@ BESpecialArrayFunctionSymbol (BEArrayFunKind arrayFunKind, int functionIndex, in newFunctionSymbol->symb_kind = definition; newFunctionSymbol->symb_def = newsdef; - functionSymbol = previousFunctionSymbol->symb_next; - previousFunctionSymbol->symb_next = newFunctionSymbol; - newFunctionSymbol->symb_next = functionSymbol; + if ((previousFunctionSymbDef->sdef_mark & SDEF_HAS_SPECIAL_ARRAY_FUNCTION)==0){ + previousFunctionSymbDef->sdef_special_array_function_symbol = newFunctionSymbol; + previousFunctionSymbDef->sdef_mark |= SDEF_HAS_SPECIAL_ARRAY_FUNCTION; + } else { + newsdef->sdef_special_array_function_symbol = previousFunctionSymbDef->sdef_special_array_function_symbol; + newsdef->sdef_mark |= SDEF_HAS_SPECIAL_ARRAY_FUNCTION; + previousFunctionSymbDef->sdef_special_array_function_symbol = newFunctionSymbol; + } AddUserDefinedArrayFunction (newFunctionSymbol); @@ -3281,14 +3258,12 @@ static void init_unboxed_list_symbols (void) symbol_p->symb_head_strictness=4; symbol_p->symb_tail_strictness=0; symbol_p->symb_state_p=&BasicSymbolStates[i]; - symbol_p->symb_next=NULL; - + symbol_p=&unboxed_list_symbols[i][1]; symbol_p->symb_kind=cons_symb; symbol_p->symb_head_strictness=4; symbol_p->symb_tail_strictness=1; symbol_p->symb_state_p=&BasicSymbolStates[i]; - symbol_p->symb_next=NULL; } array_state_p=ConvertAllocType (StateS); @@ -3398,7 +3373,6 @@ BEInit (int argc) gBEState.be_argi = 0; gBEState.be_modules = NULL; - gBEState.be_function_symbols = NULL; gBEState.be_dontCareSymbol = NULL; gBEState.be_dictionarySelectFunSymbol = NULL; gBEState.be_dictionaryUpdateFunSymbol = NULL; diff --git a/backendC/CleanCompilerSources/checker_2.c b/backendC/CleanCompilerSources/checker_2.c index cc896adb0588255466776c44c28beea5fcd33ffc..c4835fa80f95d9a94a9c43da35ca857aaa2b8c8e 100644 --- a/backendC/CleanCompilerSources/checker_2.c +++ b/backendC/CleanCompilerSources/checker_2.c @@ -51,20 +51,21 @@ void ReadInlineCode (void) def_mod=d_mod->mod_body; if (def_mod->dm_system_module){ - Symbol symbol,symbols_end; + int i,n_function_symbols; + Symbol function_symbol_a; - symbols_end=def_mod->dm_symbols_end; - - for (symbol=def_mod->dm_function_symbols; symbol!=NULL && symbol!=symbols_end; symbol=symbol->symb_next) - if (symbol->symb_kind==definition){ + n_function_symbols=def_mod->dm_n_function_symbols; + function_symbol_a=def_mod->dm_function_symbol_a; + for (i=0; isymb_def; + sdef=function_symbol_a[i].symb_def; if (sdef->sdef_kind==SYSRULE && sdef->sdef_mark & SDEF_USED_STRICTLY_MASK) break; } - - if (symbol!=NULL && symbol!=symbols_end && d_mod->mod_name->symb_ident->ident_name!=CurrentModule) + + if (imod_name->symb_ident->ident_name!=CurrentModule) /* Get the inline instructions of all the rules that are defined in this module */ ScanInlineFile (d_mod->mod_name->symb_ident->ident_name,def_mod->dm_system_module_table_kind); } diff --git a/backendC/CleanCompilerSources/codegen.c b/backendC/CleanCompilerSources/codegen.c index 9d77a875657ce152e36e08e2231f696394a4810b..9bdddb75468aee7b000b2a395b48cee8170f017f 100644 --- a/backendC/CleanCompilerSources/codegen.c +++ b/backendC/CleanCompilerSources/codegen.c @@ -951,7 +951,7 @@ static void CodeRule (ImpRuleP rule) break; } } - + GenRtn (1,0,OnAState); } @@ -1130,29 +1130,29 @@ void CodeGeneration (ImpMod imod, char *fname) { if (! CompilerError){ int DoStrictnessAnalysis_and_init_ok; + ImpRuleP new_rules; CurrentPhase = NULL; #if 0 PrintRules (imod->im_rules); #endif - DetermineSharedAndAnnotatedNodes (imod->im_rules,&imod->im_function_symbols); - ExitOnInterrupt(); + + new_rules=DetermineSharedAndAnnotatedNodes (imod->im_rules); #if 0 PrintRules (imod->im_rules,rules_file); #endif - GenerateStatesForRecords (imod->im_type_symbols,imod->im_size_dcl_type_symbols_a,imod->im_dcl_type_symbols_a); + GenerateStatesForRecords (imod->im_mfts_a,imod->im_size_dcl_mfts_a,imod->im_dcl_mfts_a); DoStrictnessAnalysis_and_init_ok = DoStrictnessAnalysis && init_strictness_analysis (imod); if (DoStrictnessAnalysis_and_init_ok){ do_strictness_analysis(); - ExitOnInterrupt(); } - ExamineTypesAndLhsOfSymbols (imod->im_function_symbols,imod->im_type_symbols,imod->im_size_dcl_type_symbols_a,imod->im_dcl_type_symbols_a); + ExamineTypesAndLhsOfSymbols (imod->im_mfts_a,imod->im_size_dcl_mfts_a,imod->im_dcl_mfts_a,new_rules); #ifdef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS { @@ -1168,11 +1168,8 @@ void CodeGeneration (ImpMod imod, char *fname) generate_states (imod->im_rules,True); if (DoStrictnessAnalysis_and_init_ok){ - ExitOnInterrupt(); - finish_strictness_analysis(); } - ExitOnInterrupt(); #if 0 PrintRules (imod->im_rules); @@ -1181,7 +1178,6 @@ void CodeGeneration (ImpMod imod, char *fname) optimise_strict_tuple_result_functions=0; OptimiseRules (imod->im_rules,imod->im_start); - ExitOnInterrupt(); #if 0 PrintRules (imod->im_rules,rules_file); #endif @@ -1228,21 +1224,19 @@ void CodeGeneration (ImpMod imod, char *fname) #endif GenSystemImports(); FileComment(); - ExitOnInterrupt(); - ReadInlineCode (); + ReadInlineCode(); CreateStackFrames(); - ImportSymbols (imod->im_function_symbols,imod->im_size_dcl_type_symbols_a,imod->im_dcl_type_symbols_a); + ImportSymbols (imod->im_size_dcl_mfts_a,imod->im_dcl_mfts_a); - GenerateCodeForConstructorsAndRecords (imod->im_type_symbols); + GenerateCodeForConstructorsAndRecords (imod->im_mfts_a); GenerateForeignExports (imod->im_foreign_exports); if (imod->im_start) GenStart (imod->im_start); - ExitOnInterrupt (); #if SHARE_UPDATE_CODE create_result_state_database (imod->im_rules); @@ -1275,8 +1269,6 @@ void CodeGeneration (ImpMod imod, char *fname) } update_function_p=&first_update_function; } - - ExitOnInterrupt (); } GenerateCodeForLazyTupleSelectorEntries (LazyTupleSelectors); @@ -1285,7 +1277,7 @@ void CodeGeneration (ImpMod imod, char *fname) GenerateCodeForLazyUnboxedRecordListFunctions(); #endif - import_not_yet_imported_record_r_labels (imod->im_size_dcl_type_symbols_a,imod->im_dcl_type_symbols_a); + import_not_yet_imported_record_r_labels (imod->im_size_dcl_mfts_a,imod->im_dcl_mfts_a); import_not_yet_imported_system_labels(); WriteLastNewlineToABCFile(); diff --git a/backendC/CleanCompilerSources/codegen1.c b/backendC/CleanCompilerSources/codegen1.c index 7a90f6fb6b46fdb3cbe1cb9efcc0ed627c2ed7f4..ba442d3d0cc2da54b6210b2ab65ced1ebc5bcc43 100644 --- a/backendC/CleanCompilerSources/codegen1.c +++ b/backendC/CleanCompilerSources/codegen1.c @@ -1603,7 +1603,7 @@ void GenerateCodeForLazyArrayFunctionEntries (void) } } -void GenerateCodeForConstructorsAndRecords (struct module_type_symbols mts) +void GenerateCodeForConstructorsAndRecords (struct module_function_and_type_symbols mfts) { int n_types,i; SymbolP type_symbol_a; @@ -1611,8 +1611,8 @@ void GenerateCodeForConstructorsAndRecords (struct module_type_symbols mts) PolyList unboxed_record_cons_element; #endif - n_types = mts.mts_n_types; - type_symbol_a = mts.mts_type_symbol_a; + n_types = mfts.mfts_n_types; + type_symbol_a = mfts.mfts_type_symbol_a; for (i=0; i #include - -#ifdef THINK_C -# include -#else -# include -#endif +#include #include #include typedef FILE *File; -#ifdef THINK_C - /* special for MacIntosh command line support */ - extern void InitIO (void); - extern void GetPreferences (char *fname); -#else - void GetInitialPathList (void); - void FreePathList (void); -#endif +void GetInitialPathList (void); +void FreePathList (void); #define StdOut stdout #if defined (__MWERKS__) || defined (__MRC__) @@ -62,9 +43,3 @@ typedef FILE *File; #define FGetS(s,n,f) fgets(s,n,f) #define FPutC(c,f) fputc(c,f) -extern int open_dcl_file_for_block_reading (char *fname,File *file_p); -extern int read_next_block_from_dcl_file (char *buffer); - -#if WRITE_DCL_MODIFICATION_TIME -extern int open_dcl_file_for_block_reading_with_file_time (char *file_name,File *file_p,FileTime *file_time_p); -#endif \ No newline at end of file diff --git a/backendC/CleanCompilerSources/mac_io.c b/backendC/CleanCompilerSources/mac_io.c index 09ad4f0b2415eb9044ccbb9dbd3d3e1ae0e682d3..633e2460f72e18c531dc2f077e8e69d1c1c54ec3 100644 --- a/backendC/CleanCompilerSources/mac_io.c +++ b/backendC/CleanCompilerSources/mac_io.c @@ -902,12 +902,6 @@ void CmdError (char *errormsg,...) va_end (args); } -extern long GetMainModuleVolume (void); -long GetMainModuleVolume (void) -{ - return 0; -} - void Free (void *p) { #if USE_SYSTEM_ALLOC diff --git a/backendC/CleanCompilerSources/sa.c b/backendC/CleanCompilerSources/sa.c index 1ef38fe55635003a557698c90e8bffe3f3d45457..93f96e76bbdf6d65720c64c2b9fc9528586532e4 100644 --- a/backendC/CleanCompilerSources/sa.c +++ b/backendC/CleanCompilerSources/sa.c @@ -2185,21 +2185,8 @@ static void InitNode (Node node) static void InitAlternative (RuleAltS *alt) { -#ifndef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS - NodeDefs nds; -#endif - InitNode (alt->alt_lhs_root); -#ifndef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS - for_l (nds,alt->alt_lhs_defs,def_next){ - if (nds->def_id) - nds->def_id->nid_exp_ = NULL; - - InitNode (nds->def_node); - } -#endif - if (alt->alt_kind==Contractum){ InitNode (alt->alt_rhs_root); InitNodeDefs (alt->alt_rhs_defs); @@ -2412,7 +2399,7 @@ static Exp ConvertNode (Node node, NodeId nid) return e; } else { e->e_fun = sdef->sdef_sa_fun; - + if (arity==sdef->sdef_arity) e->e_kind = Value; else { @@ -2520,7 +2507,7 @@ static Exp ConvertNode (Node node, NodeId nid) e->e_fun = selectsym [field_nr]; e->e_args = NewExpArgs (1); - + e->e_args[0] = ConvertNode (arg->arg_node, Null); break; } @@ -2856,11 +2843,7 @@ static void ConvertAlternatives (Alts *funalts,RuleAlts rulealts) InitAlternative (rulealts); -#ifndef TRANSFORM_PATTERNS_BEFORE_STRICTNESS_ANALYSIS - fun_alt_p->fun_lhs = ConvertNodeDefs (rulealts->alt_lhs_root,rulealts->alt_lhs_defs,NULL); -#else fun_alt_p->fun_lhs = ConvertNodeDefs (rulealts->alt_lhs_root,NULL,NULL); -#endif has_fail = False; @@ -3676,7 +3659,7 @@ static void convert_type (SymbDef sdef) } static void ConvertSyntaxTree - (struct module_type_symbols mts,int size_dcl_type_symbols_a,struct module_type_symbols dcl_type_symbols_a[]) + (struct module_function_and_type_symbols mfts,int size_dcl_type_symbols_a,struct module_function_and_type_symbols dcl_type_symbols_a[]) { SymbolP type_symbol_a; Bool annot_warning; @@ -3688,15 +3671,15 @@ static void ConvertSyntaxTree init_predefined_symbols(); /* initialise the function table with constructors */ - n_types = mts.mts_n_types; - type_symbol_a = mts.mts_type_symbol_a; + n_types = mfts.mfts_n_types; + type_symbol_a = mfts.mfts_type_symbol_a; for (i=0; iim_type_symbols,imod->im_size_dcl_type_symbols_a,imod->im_dcl_type_symbols_a); + ConvertSyntaxTree (imod->im_mfts_a,imod->im_size_dcl_mfts_a,imod->im_dcl_mfts_a); /* other values are converted after syntaxconversion (because of cons symbol) */ InitValues (); diff --git a/backendC/CleanCompilerSources/statesgen.c b/backendC/CleanCompilerSources/statesgen.c index a243ddd68587184e87f4cceccb27dedb6d72cd7a..dde770ed4d442551266c6b1f2fc7d533f1f55a1f 100644 --- a/backendC/CleanCompilerSources/statesgen.c +++ b/backendC/CleanCompilerSources/statesgen.c @@ -569,13 +569,13 @@ static void ChangeElementStateForStrictAbsTypeFields (SymbDef icl_sdef,SymbDef d SymbDefP special_types[2]; #endif -void GenerateStatesForRecords (struct module_type_symbols mts,int size_dcl_type_symbols_a,struct module_type_symbols dcl_type_symbols_a[]) +void GenerateStatesForRecords (struct module_function_and_type_symbols mfts,int size_dcl_mfts_a,struct module_function_and_type_symbols dcl_mfts_a[]) { int n_types,i,dcl_type_symbols_n; SymbolP type_symbol_a; - n_types = mts.mts_n_types; - type_symbol_a = mts.mts_type_symbol_a; + n_types = mfts.mfts_n_types; + type_symbol_a = mfts.mfts_type_symbol_a; for (i=0; isymb_kind==definition) - ExamineTypesAndLhsOfSymbolDefinition (symbs->symb_def); + n_functions = mfts.mfts_n_functions; + function_symbol_a = mfts.mfts_function_symbol_a; + for (i=0; irule_root->node_symbol->symb_def); + new_imp_rules=new_imp_rules->rule_next; + } + + for (dcl_mfts_i=0; dcl_mfts_ipl_elem)->symb_def; + ExamineTypesAndLhsOfSymbolDefinition (fun_def); + } - n_types = mts.mts_n_types; - type_symbol_a = mts.mts_type_symbol_a; + n_types = mfts.mfts_n_types; + type_symbol_a = mfts.mfts_type_symbol_a; for (i=0; ipl_elem)->symb_def; - if (fun_def ->sdef_mark & (SDEF_USED_LAZILY_MASK | SDEF_USED_CURRIED_MASK)) fun_def -> sdef_module = CurrentModule; } - for_l (symbol,function_symbols,symb_next){ + for (dcl_mfts_i=0; dcl_mfts_isymb_kind!=definition) - continue; + n_functions = dcl_mfts_a[dcl_mfts_i].mfts_n_functions; + function_symbol_a = dcl_mfts_a[dcl_mfts_i].mfts_function_symbol_a; + for (i=0; isymb_def; - if (sdef->sdef_module!=CurrentModule){ - if (sdef->sdef_isused - && sdef->sdef_mark & (SDEF_USED_STRICTLY_MASK | SDEF_USED_LAZILY_MASK | SDEF_USED_CURRIED_MASK) - ){ - if (sdef->sdef_module!=current_imported_module){ - current_imported_module=sdef->sdef_module; - GenImpMod (current_imported_module); + sdef=function_symbol_a[i].symb_def; + if (sdef->sdef_module!=CurrentModule){ + if (sdef->sdef_isused + && sdef->sdef_mark & (SDEF_USED_STRICTLY_MASK | SDEF_USED_LAZILY_MASK | SDEF_USED_CURRIED_MASK) + ){ + if (sdef->sdef_module!=current_imported_module){ + current_imported_module=sdef->sdef_module; + GenImpMod (current_imported_module); + } + GenImport (sdef); } - GenImport (sdef); } } } - for (dcl_type_symbols_n=0; dcl_type_symbols_nrule_next; - - while (*im_symbols_h) - im_symbols_h=&(*im_symbols_h)->symb_next; - + + new_rules_h=rule_h; + while (new_rules_with_more_arguments!=NULL){ SymbolP new_symbol_p; @@ -4511,14 +4545,13 @@ void DetermineSharedAndAnnotatedNodes (ImpRules rules,SymbolP *im_symbols_h) rule_h=&new_rule_p->rule_next; new_symbol_p=new_rule_p->rule_root->node_symbol; - *im_symbols_h=new_symbol_p; - im_symbols_h=&new_symbol_p->symb_next; } *rule_h=NULL; - *im_symbols_h=NULL; } #endif + + return new_rules_h==NULL ? NULL : *new_rules_h; } void InitStatesGen (void) diff --git a/backendC/CleanCompilerSources/statesgen.h b/backendC/CleanCompilerSources/statesgen.h index 455374db26250df184dcc533c0ec4fa5809e8bde..112b4002918729e23ceab014dcf6331e507d20bb 100644 --- a/backendC/CleanCompilerSources/statesgen.h +++ b/backendC/CleanCompilerSources/statesgen.h @@ -11,14 +11,15 @@ extern int FieldArgumentNodeStatesAreStricter (ArgS *offered_args,ArgS *field_ar extern void ConvertAnnotationToState (Annotation annot, States state); extern void SetUnaryState (States state, StateKind kind, ObjectKind object); extern Bool HasExternalAnnot (Node node); -extern void GenerateStatesForRecords (struct module_type_symbols mts,int size_dcl_type_symbols_a,struct module_type_symbols dcl_type_symbols_a[]); +extern void GenerateStatesForRecords (struct module_function_and_type_symbols mts,int size_dcl_mfts_a,struct module_function_and_type_symbols dcl_mfts_a[]); extern void InitStatesGen (void); extern void GenerateStates (ImpRules rules); -extern void DetermineSharedAndAnnotatedNodes (ImpRules rules,SymbolP *im_symbols_h); +extern ImpRuleP DetermineSharedAndAnnotatedNodes (ImpRules rules); extern void DetermineStateOfArrayElem (Symbol elemtype, States state); -extern void ExamineTypesAndLhsOfSymbols (SymbolP function_symbols,struct module_type_symbols mts,int size_dcl_type_symbols_a,struct module_type_symbols dcl_type_symbols_a[]); -extern void ImportSymbols (SymbolP function_symbols,int size_dcl_type_symbols_a,struct module_type_symbols dcl_type_symbols_a[]); -extern void import_not_yet_imported_record_r_labels (int size_dcl_type_symbols_a,struct module_type_symbols dcl_type_symbols_a[]); +extern void ExamineTypesAndLhsOfSymbols + (struct module_function_and_type_symbols mfts,int size_dcl_mfts_a,struct module_function_and_type_symbols dcl_mfts_a[],ImpRuleP new_imp_rules); +extern void ImportSymbols (int size_dcl_mfts_a,struct module_function_and_type_symbols dcl_mfts_a[]); +extern void import_not_yet_imported_record_r_labels (int size_dcl_mfts_a,struct module_function_and_type_symbols dcl_mfts_a[]); extern void DetermineStatesOfRootNodeAndDefs (Node root_node,NodeDefs *rootdef,StateS demstate,int local_scope); extern unsigned next_def_number; diff --git a/backendC/CleanCompilerSources/syntaxtr.t b/backendC/CleanCompilerSources/syntaxtr.t index 70331792bb2178b77d77fad2f78fb960cf2b0074..a05c3e85a3c9e51fc5fb7ee80d363147e1d8ed3b 100644 --- a/backendC/CleanCompilerSources/syntaxtr.t +++ b/backendC/CleanCompilerSources/syntaxtr.t @@ -133,7 +133,6 @@ struct unboxed_cons { STRUCT (symbol,Symbol) { SymbValue symb_val; - Symbol symb_next; unsigned symb_kind:8; /* SymbKind */ unsigned symb_head_strictness:4; /* 0=lazy,1=overloaded,2=strict,3=unboxed overloaded,4=unboxed*/ unsigned symb_tail_strictness:2; /* 0=lazy,1=strict */ @@ -593,8 +592,9 @@ STRUCT (symbol_def,SymbDef){ struct symbol_def * sdef_next_scc; union { - struct symbol_def * sdef_u2_next_version; /* for IMPRULES */ - struct type_alt * sdef_u2_member_type_of_field; /* for FIELDSELECTOR if SDEF_FIELD_HAS_MEMBER_TYPE */ + struct symbol_def * sdef_u2_next_version; /* for IMPRULES */ + struct type_alt * sdef_u2_member_type_of_field; /* for FIELDSELECTOR if SDEF_FIELD_HAS_MEMBER_TYPE */ + struct symbol * sdef_u2_special_array_function_symbol; /* if SDEF_HAS_SPECIAL_ARRAY_FUNCTION */ } sdef_u2; int sdef_mark; @@ -631,12 +631,14 @@ STRUCT (symbol_def,SymbDef){ #define SDEF_FIELD_HAS_MEMBER_TYPE 1024 #define SDEF_INSTANCE_RULE_WITH_FIELD_P 16384 #define SDEF_RULE_INSTANCE_RULE_P 32768 +#define SDEF_HAS_SPECIAL_ARRAY_FUNCTION 512 /* some macros to reuse bit fields */ #define sdef_group_number sdef_ancestor #define sdef_next_version sdef_u2.sdef_u2_next_version +#define sdef_special_array_function_symbol sdef_u2.sdef_u2_special_array_function_symbol #define sdef_member_type_of_field sdef_u2.sdef_u2_member_type_of_field #define sdef_constructor sdef_typeinfo.typeinfo_constructor @@ -664,17 +666,18 @@ struct foreign_export_list { typedef char *ModuleFileTime; -struct module_type_symbols { - int mts_n_types; - SymbolP mts_type_symbol_a; +struct module_function_and_type_symbols { + int mfts_n_functions; + SymbolP mfts_function_symbol_a; + int mfts_n_types; + SymbolP mfts_type_symbol_a; }; typedef struct { char * im_name; - SymbolP im_function_symbols; - struct module_type_symbols im_type_symbols; - int im_size_dcl_type_symbols_a; - struct module_type_symbols *im_dcl_type_symbols_a; + struct module_function_and_type_symbols im_mfts_a; + int im_size_dcl_mfts_a; + struct module_function_and_type_symbols *im_dcl_mfts_a; ImpRules im_rules; struct symbol_def * im_start; DefMod im_def_module; @@ -689,8 +692,8 @@ typedef struct { struct def_repr { char * dm_name; int dm_module_n; - SymbolP dm_function_symbols; - Symbol dm_symbols_end; + int dm_n_function_symbols; + SymbolP dm_function_symbol_a; TableKind dm_system_module_table_kind; Bool dm_system_module; ModuleFileTime dm_modification_time;