Commit 2e8e2db1 authored by John van Groningen's avatar John van Groningen
Browse files

pass dcl cache using DclCache type

parent 5b686507
definition module compile definition module compile
from StdFile import Files from StdFile import Files
import checksupport
compile :: [{#Char}] *Files -> (!Bool, !*Files) compile :: ![{#Char}] !*DclCache !*Files -> (!Bool,!*DclCache,!*Files)
:: DclCache = {
dcl_modules::!{#DclModule},
functions_and_macros::!{#FunDef},
predef_symbols::!.PredefinedSymbols,
hash_table::!.HashTable,
heaps::!.Heaps
};
empty_cache :: *DclCache
...@@ -4,49 +4,47 @@ import StdEnv ...@@ -4,49 +4,47 @@ import StdEnv
import frontend import frontend
import backendinterface import backendinterface
import CoclSystemDependent import CoclSystemDependent
import RWSDebug //import RWSDebug
:: CoclOptions = :: CoclOptions =
{ {
moduleName moduleName:: {#Char}
:: {#Char} , pathName ::{#Char}
, pathName :: , errorPath:: {#Char}
{#Char} , errorMode:: Int
, errorPath , outPath:: {#Char}
:: {#Char} , outMode:: Int
, errorMode , searchPaths:: SearchPaths
:: Int
, outPath
:: {#Char}
, outMode
:: Int
, searchPaths
:: SearchPaths
} }
InitialCoclOptions = InitialCoclOptions =
{ moduleName { moduleName= ""
= "" , pathName= ""
, pathName , errorPath= "errors"
= "" , errorMode= FWriteText
, errorPath , outPath= "out"
= "errors" , outMode= FWriteText
, errorMode , searchPaths= {sp_locations = [], sp_paths = []}
= FWriteText
, outPath
= "out"
, outMode
= FWriteText
, searchPaths
= {sp_locations = [], sp_paths = []}
} }
compile :: [{#Char}] *Files -> (!Bool, !*Files) :: DclCache = {
compile args files dcl_modules::!{#DclModule},
# (args_without_modules,modules,cocl_options) = parseCommandLine args InitialCoclOptions functions_and_macros::!{#FunDef},
# heaps = { hp_var_heap = newHeap, hp_expression_heap = newHeap, hp_type_heaps = { th_vars = newHeap, th_attrs = newHeap }} predef_symbols::!.PredefinedSymbols,
hash_table::!.HashTable,
heaps::!.Heaps
};
empty_cache :: *DclCache
empty_cache
# heaps = {hp_var_heap = newHeap, hp_expression_heap = newHeap, hp_type_heaps = {th_vars = newHeap, th_attrs = newHeap}}
# (predef_symbols, hash_table) = buildPredefinedSymbols newHashTable # (predef_symbols, hash_table) = buildPredefinedSymbols newHashTable
= compile_modules modules 0 cocl_options args_without_modules {} {} predef_symbols hash_table heaps files; = {dcl_modules={},functions_and_macros={},predef_symbols=predef_symbols,hash_table=hash_table,heaps=heaps}
compile :: ![{#Char}] !*DclCache !*Files -> (!Bool,!*DclCache,!*Files)
compile args cache files
# (args_without_modules,modules,cocl_options) = parseCommandLine args InitialCoclOptions
= compile_modules modules 0 cocl_options args_without_modules cache files;
parseCommandLine :: [{#Char}] CoclOptions -> ([{#Char}],[{#Char}],CoclOptions) parseCommandLine :: [{#Char}] CoclOptions -> ([{#Char}],[{#Char}],CoclOptions)
parseCommandLine [] options parseCommandLine [] options
...@@ -134,7 +132,7 @@ directoryName :: {#Char} -> {#Char} ...@@ -134,7 +132,7 @@ directoryName :: {#Char} -> {#Char}
directoryName path directoryName path
= foldr (\p ps -> p +++ {DirectorySeparator} +++ ps) "" (init (splitBy DirectorySeparator path)) = foldr (\p ps -> p +++ {DirectorySeparator} +++ ps) "" (init (splitBy DirectorySeparator path))
compile_modules [module_:modules] n_compiles cocl_options args_without_modules dcl_modules functions_and_macros predef_symbols hash_table heaps files compile_modules [module_:modules] n_compiles cocl_options args_without_modules cache files
# cocl_options = prependModulePath {cocl_options & pathName=stripExtension ".icl" (stripQuotes module_)} # cocl_options = prependModulePath {cocl_options & pathName=stripExtension ".icl" (stripQuotes module_)}
with with
// RWS +++ hack, both module name and file path should be passed to frontEndInterface // RWS +++ hack, both module name and file path should be passed to frontEndInterface
...@@ -144,39 +142,22 @@ compile_modules [module_:modules] n_compiles cocl_options args_without_modules d ...@@ -144,39 +142,22 @@ compile_modules [module_:modules] n_compiles cocl_options args_without_modules d
// RWS, voor Maarten +++ , searchPaths = {searchPaths & sp_paths = [directoryName pathName : searchPaths.sp_paths]} // RWS, voor Maarten +++ , searchPaths = {searchPaths & sp_paths = [directoryName pathName : searchPaths.sp_paths]}
// , searchPaths = [directoryName pathName : searchPaths] // , searchPaths = [directoryName pathName : searchPaths]
} }
# (ok,dcl_modules,functions_and_macros,n_functions_and_macros_in_dcl_modules,predef_symbols,hash_table,heaps,files) # (ok,cache,files)
= compileModule cocl_options (args_without_modules++[module_]) dcl_modules functions_and_macros predef_symbols hash_table heaps files; = compileModule cocl_options (args_without_modules++[module_]) cache files;
| ok | ok
// # hash_table=remove_module_idents_from_symbol_table 0 dcl_modules hash_table;
/* # hash_table=remove_module_ident_from_symbol_table dcl_modules.[0] hash_table;
with
remove_module_idents_from_symbol_table module_n dcl_modules hash_table
| module_n==size dcl_modules
= hash_table;
# hash_table = remove_module_ident_from_symbol_table dcl_modules.[module_n] hash_table
= remove_module_idents_from_symbol_table (module_n+1) dcl_modules hash_table
remove_module_ident_from_symbol_table dcl_module hash_table
# module_symbol_pointer = dcl_module.dcl_name.id_info;
# symbol_heap=hash_table.hte_symbol_heap;
# (hte_entry,symbol_heap) = readPtr module_symbol_pointer symbol_heap
# symbol_heap=writePtr module_symbol_pointer {hte_entry & ste_kind=STE_Empty} symbol_heap
= {hash_table & hte_symbol_heap=symbol_heap}
# dcl_modules = {dcl_modules.[module_n] \\ module_n <-[1..size dcl_modules-1]}
*/
/* /*
# heaps = { hp_var_heap = newHeap, hp_expression_heap = newHeap, hp_type_heaps = { th_vars = newHeap, th_attrs = newHeap }} # heaps = { hp_var_heap = newHeap, hp_expression_heap = newHeap, hp_type_heaps = { th_vars = newHeap, th_attrs = newHeap }}
# (predef_symbols, hash_table) = buildPredefinedSymbols newHashTable # (predef_symbols, hash_table) = buildPredefinedSymbols newHashTable
= compile_modules modules 0 cocl_options args_without_modules {} {} predef_symbols hash_table heaps files; = compile_modules modules 0 cocl_options args_without_modules {} {} predef_symbols hash_table heaps files;
*/ */
= compile_modules modules (n_compiles+1) cocl_options args_without_modules dcl_modules functions_and_macros predef_symbols hash_table heaps files; = compile_modules modules (n_compiles+1) cocl_options args_without_modules cache files;
= (ok,files); = (ok,cache,files);
compile_modules [] n_compiles cocl_options args_without_modules dcl_modules functions_and_macros predef_symbols hash_table heaps files compile_modules [] n_compiles cocl_options args_without_modules cache files
= (True,files); = (True,cache,files);
compileModule :: CoclOptions [{#Char}] {#DclModule} {#FunDef} *PredefinedSymbols !*HashTable *Heaps *Files -> (!Bool,!{#DclModule},!{#FunDef},!Int,!*PredefinedSymbols,!*HashTable,!*Heaps, !*Files) compileModule :: CoclOptions [{#Char}] *DclCache *Files -> (!Bool,!*DclCache,!*Files)
compileModule options commandLineArgs dcl_modules functions_and_macros predef_symbols hash_table heaps files compileModule options commandLineArgs {dcl_modules,functions_and_macros,predef_symbols,hash_table,heaps} files
# (opened, error, files) # (opened, error, files)
= fopen options.errorPath options.errorMode files = fopen options.errorPath options.errorMode files
| not opened | not opened
...@@ -189,7 +170,7 @@ compileModule options commandLineArgs dcl_modules functions_and_macros predef_sy ...@@ -189,7 +170,7 @@ compileModule options commandLineArgs dcl_modules functions_and_macros predef_sy
= stdio files = stdio files
// (moduleIdent, hash_table) = putIdentInHashTable options.moduleName IC_Module hash_table // (moduleIdent, hash_table) = putIdentInHashTable options.moduleName IC_Module hash_table
# ({boxed_ident=moduleIdent}, hash_table) = putIdentInHashTable options.moduleName IC_Module hash_table # ({boxed_ident=moduleIdent}, hash_table) = putIdentInHashTable options.moduleName IC_Module hash_table
# list_inferred_types = if (isMember "-lt" commandLineArgs) (Yes (not (isMember "-lattr" commandLineArgs))) No # list_inferred_types = if (isMember "-lt" commandLineArgs) (Yes (not (isMember "-lattr" commandLineArgs))) No
# (optionalSyntaxTree,cached_functions_and_macros,n_functions_and_macros_in_dcl_modules,main_dcl_module_n,predef_symbols, hash_table, files, error, io, out,heaps) # (optionalSyntaxTree,cached_functions_and_macros,n_functions_and_macros_in_dcl_modules,main_dcl_module_n,predef_symbols, hash_table, files, error, io, out,heaps)
= frontEndInterface FrontEndPhaseAll moduleIdent options.searchPaths dcl_modules functions_and_macros list_inferred_types predef_symbols hash_table files error io out heaps = frontEndInterface FrontEndPhaseAll moduleIdent options.searchPaths dcl_modules functions_and_macros list_inferred_types predef_symbols hash_table files error io out heaps
# unique_copy_of_predef_symbols={predef_symbol\\predef_symbol<-:predef_symbols} # unique_copy_of_predef_symbols={predef_symbol\\predef_symbol<-:predef_symbols}
...@@ -203,23 +184,24 @@ compileModule options commandLineArgs dcl_modules functions_and_macros predef_sy ...@@ -203,23 +184,24 @@ compileModule options commandLineArgs dcl_modules functions_and_macros predef_sy
= abort ("couldn't close out file \"" +++ options.outPath +++ "\"\n") = abort ("couldn't close out file \"" +++ options.outPath +++ "\"\n")
# var_heap=heaps.hp_var_heap # var_heap=heaps.hp_var_heap
# (success,dcl_modules,functions_and_macros,n_functions_and_macros_in_dcl_modules,var_heap,error, files) # (success,dcl_modules,functions_and_macros,n_functions_and_macros_in_dcl_modules,var_heap,error, files)
= case optionalSyntaxTree of = case optionalSyntaxTree of
Yes syntaxTree Yes syntaxTree
# dcl_modules=syntaxTree.fe_dcls # dcl_modules=syntaxTree.fe_dcls
# functions_and_macros = syntaxTree.fe_icl.icl_functions # functions_and_macros = syntaxTree.fe_icl.icl_functions
# (success,var_heap,error, files) = backEndInterface outputPath (map appendRedirection commandLineArgs) predef_symbols syntaxTree main_dcl_module_n var_heap error files # (success,var_heap,error, files)
-> (success,dcl_modules,functions_and_macros,n_functions_and_macros_in_dcl_modules,var_heap,error, files) = backEndInterface outputPath (map appendRedirection commandLineArgs) predef_symbols syntaxTree main_dcl_module_n var_heap error files
with -> (success,dcl_modules,functions_and_macros,n_functions_and_macros_in_dcl_modules,var_heap,error, files)
appendRedirection arg with
= case arg of appendRedirection arg
"-RE" = case arg of
-> "-RAE" "-RE"
"-RO" -> "-RAE"
-> "-RAO" "-RO"
arg -> "-RAO"
-> arg arg
No -> arg
-> (False,{},{},0,var_heap,error, files) No
-> (False,{},{},0,var_heap,error, files)
with with
outputPath outputPath
// = /* directoryName options.pathName +++ "Clean System Files" +++ {DirectorySeparator} +++ */ baseName options.pathName // = /* directoryName options.pathName +++ "Clean System Files" +++ {DirectorySeparator} +++ */ baseName options.pathName
...@@ -231,5 +213,7 @@ compileModule options commandLineArgs dcl_modules functions_and_macros predef_sy ...@@ -231,5 +213,7 @@ compileModule options commandLineArgs dcl_modules functions_and_macros predef_sy
= abort ("couldn't close error file \"" +++ options.errorPath +++ "\"\n") = abort ("couldn't close error file \"" +++ options.errorPath +++ "\"\n")
| success | success
# dcl_modules={{dcl_module \\ dcl_module<-:dcl_modules} & [main_dcl_module_n].dcl_conversions=No} # dcl_modules={{dcl_module \\ dcl_module<-:dcl_modules} & [main_dcl_module_n].dcl_conversions=No}
= (success,dcl_modules,cached_functions_and_macros,n_functions_and_macros_in_dcl_modules,unique_copy_of_predef_symbols,hash_table,heaps,files) # cache={dcl_modules=dcl_modules,functions_and_macros=cached_functions_and_macros,predef_symbols=unique_copy_of_predef_symbols,hash_table=hash_table,heaps=heaps}
= (success,dcl_modules,cached_functions_and_macros,n_functions_and_macros_in_dcl_modules,unique_copy_of_predef_symbols,hash_table,heaps,files) = (success,cache,files)
# cache={dcl_modules=dcl_modules,functions_and_macros=cached_functions_and_macros,predef_symbols=unique_copy_of_predef_symbols,hash_table=hash_table,heaps=heaps}
= (success,cache,files)
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