From 7c8426700440f1cd506266c4e0c9be46fbf4e133 Mon Sep 17 00:00:00 2001 From: "johnvg@science.ru.nl" Date: Wed, 10 Jul 2019 13:06:12 +0200 Subject: [PATCH] pass full name of abc file to backend, remove file searching code from windows backend --- backendC/CleanCompilerSources/checker.h | 1 - backendC/CleanCompilerSources/instructions.c | 4 +- backendC/CleanCompilerSources/system.h | 9 +- backendC/CleanCompilerSources/windows_io.c | 255 +------------------ main/compile.icl | 31 ++- 5 files changed, 25 insertions(+), 275 deletions(-) diff --git a/backendC/CleanCompilerSources/checker.h b/backendC/CleanCompilerSources/checker.h index f93e208e..778f3bed 100644 --- a/backendC/CleanCompilerSources/checker.h +++ b/backendC/CleanCompilerSources/checker.h @@ -12,7 +12,6 @@ extern SymbDef scc_dependency_list; SymbDef MakeNewSymbolDefinition (char *module, char *name, int arity, SDefKind kind); char *ConvertSymbolToString (Symbol symb); -void ReadInlineCode (void); void InitChecker (void); void GenDependencyList (void); NodeDefs NewNodeDef (NodeId nid, Node node); diff --git a/backendC/CleanCompilerSources/instructions.c b/backendC/CleanCompilerSources/instructions.c index 0913d2de..52c82c31 100644 --- a/backendC/CleanCompilerSources/instructions.c +++ b/backendC/CleanCompilerSources/instructions.c @@ -103,7 +103,7 @@ char *ABCFileName; Bool OpenABCFile (char *fname) { - OutFile = FOpen (fname, abcFile, "w"); + OutFile = FOpen (fname, "w"); if (OutFile!=NULL){ #if defined (POWER) @@ -131,7 +131,7 @@ void CloseABCFile (char *fname) StaticMessage (True, "", "Write error (disk full?)"); } if (CompilerError) - FDelete (fname, abcFile); + FDelete (fname); OpenedFile = (File) NIL; } } diff --git a/backendC/CleanCompilerSources/system.h b/backendC/CleanCompilerSources/system.h index bccc7d36..afc023ec 100644 --- a/backendC/CleanCompilerSources/system.h +++ b/backendC/CleanCompilerSources/system.h @@ -44,9 +44,8 @@ extern char *PATHLIST; -extern char *GetFileExtension (FileKind kind); -extern File FOpen (char *wname, FileKind kind, char *mode); -extern int FDelete (char *fname, FileKind kind); +extern File FOpen (char *fname, char *mode); +extern int FDelete (char *fname); extern int FClose (File f); extern int FPutS (char *s, File f); @@ -56,10 +55,6 @@ extern int FPrintF (File f, char *fmt,...); extern int FPrintF (); /* (File w, char *fmt,...) */ #endif -#ifndef __ppc__ -extern char *FGetS (char *s, int n, File f); -#endif - #ifdef _VARARGS_ extern void DoError (char *fmt,...); extern void DoFatalError (char *fmt,...); diff --git a/backendC/CleanCompilerSources/windows_io.c b/backendC/CleanCompilerSources/windows_io.c index 1d661e5e..edf915c2 100644 --- a/backendC/CleanCompilerSources/windows_io.c +++ b/backendC/CleanCompilerSources/windows_io.c @@ -20,261 +20,19 @@ # include #endif -char *GetFileExtension (FileKind kind) +File FOpen (char *fname,char *mode) { - switch (kind){ - case abcFile: - return ".abc"; - case obj00File: - case obj20File: - case obj81File: - return ".obj"; - case iclFile: - return ".icl"; - case dclFile: - return ".dcl"; - case hsFile: - return ".hs"; - case assFile: - return ".a"; - case sunAssFile: - return ".s"; - case applFile: - case otherFile: - default: - return ""; - } -} - -char clean_lib_directory[129] = "."; - -static int file_exists (char *file_name) -{ - HANDLE h; - WIN32_FIND_DATA find_data; - - h=FindFirstFile (file_name,&find_data); - - if (h!=INVALID_HANDLE_VALUE){ - FindClose (h); - return True; - } else - return False; -} - -static int use_clean_system_files_folder=1; - -extern char *path_parameter; - -static void append_file_name_and_ext (char *path_p,char *fname_p,char *ext,int in_clean_system_files_folder) -{ - int i; - char c; - - if (in_clean_system_files_folder){ - int last_dot_i; - - last_dot_i = -1; - - i=0; - while (c=fname_p[i], c!='\0'){ - if (c=='.') - last_dot_i=i; - ++i; - } - - if (last_dot_i>=0){ - i=0; - while (i (!Bool, !String, !*File, !*Files) +abc_file_name_in_clean_system_files_folder mod_dir mod_name error files + // mod_dir ends with DirectorySeparator + # (csf_directory_path,file_name) = make_clean_system_files_dir_and_file_name (mod_dir +++ mod_name) + # file_path = csf_directory_path +++ {DirectorySeparator} +++ file_name +++ ".abc" + # (ok, files) = ensureCleanSystemFilesExists csf_directory_path files + | not ok + # error = fwrites ("can't create folder \"" +++ csf_directory_path +++"\"\n") error + = (False, file_path, error, files) + = (True, file_path, error, files) + :: CoclOptions = { moduleName:: {#Char} , pathName ::{#Char} @@ -325,14 +336,16 @@ compileModule options backendArgs cache=:{dcl_modules,functions_and_macros,prede hp_type_heaps=heaps.hp_type_heaps type_var_heap=hp_type_heaps.th_vars attrHeap=hp_type_heaps.th_attrs - # (success,functions_and_macros,var_heap,type_var_heap,attrHeap,error,out) + # (success,functions_and_macros,var_heap,type_var_heap,attrHeap,error,out,files) = case optionalSyntaxTree of Yes syntaxTree # functions_and_macros = syntaxTree.fe_icl.icl_functions + # (Yes path) = mbModPath + # (csf_dir_exists,abc_file_path,error,files) = abc_file_name_in_clean_system_files_folder path options.moduleName error files # (success, var_heap, type_var_heap, attrHeap, error, out) - = backEndInterface outputPath (map appendRedirection backendArgs) options.listTypes options.outPath predef_symbols syntaxTree main_dcl_module_n + = backEndInterface abc_file_path (map appendRedirection backendArgs) options.listTypes options.outPath predef_symbols syntaxTree main_dcl_module_n var_heap type_var_heap attrHeap error out - -> (success,functions_and_macros,var_heap,type_var_heap,attrHeap,error,out) + -> (success,functions_and_macros,var_heap,type_var_heap,attrHeap,error,out,files) with appendRedirection arg = case arg of @@ -343,17 +356,7 @@ compileModule options backendArgs cache=:{dcl_modules,functions_and_macros,prede arg -> arg No - -> (False,{},var_heap,type_var_heap,attrHeap,error,out) - with -/* - outputPath - = if (options.outputPathName == "") - (directoryName options.pathName +++ "Clean System Files" +++ {DirectorySeparator} +++ baseName options.pathName) - options.outputPathName -*/ - outputPath - // = /* directoryName options.pathName +++ "Clean System Files" +++ {DirectorySeparator} +++ */ baseName options.pathName - = baseName options.pathName + -> (False,{},var_heap,type_var_heap,attrHeap,error,out,files) # heaps = {heaps & hp_var_heap=var_heap, hp_type_heaps = {th_vars=type_var_heap, th_attrs=attrHeap}} # (closed, files) = fclose out files | not closed -- GitLab