From 79f469725862e0bc1ee1be9b7e2d6cdb12911e76 Mon Sep 17 00:00:00 2001 From: nutricato Date: Thu, 4 Jun 2009 04:51:29 +0000 Subject: --- macros/ASTManagement/%for_string.sci | 15 ++++ macros/ASTManagement/AST_HandleEOL.sci | 20 ++--- macros/ASTManagement/AST_HandleEndGenFun.sci | 3 +- macros/ASTManagement/AST_ParseEqualStruct.sci | 16 ++-- macros/ASTManagement/AST_ParseFuncallStruct.sci | 10 +-- macros/ASTManagement/for_string.sci | 15 ---- macros/CCodeGeneration/C_FinalizeCode.sci | 1 + macros/CCodeGeneration/C_ForExpression.sci | 15 +++- macros/CCodeGeneration/C_GenerateMakefile.sci | 88 +++++++++++----------- macros/CCodeGeneration/C_InitHeader.sci | 3 + macros/GeneralFunctions/PrintStepInfo.sci | 32 ++++---- macros/GeneralFunctions/PrintStringInfo.sci | 36 +++++---- macros/GeneralFunctions/filenamefprintf.sci | 15 ++-- macros/SymbolTable/ST_InsOutArg.sci | 20 ++--- macros/ToolInitialization/INIT_RemoveDirs.sci | 12 ++- macros/ToolInitialization/INIT_SCI2C.sci | 2 +- macros/runscicode.sci | 2 + macros/scilab2c.sci | 2 +- .../test999_WorkingDir/scilabcode/LinComb.sci | 16 ---- .../test999_WorkingDir/scilabcode/mainfunction.sci | 44 ++++++----- 20 files changed, 198 insertions(+), 169 deletions(-) create mode 100644 macros/ASTManagement/%for_string.sci delete mode 100644 macros/ASTManagement/for_string.sci delete mode 100644 src/Scilab2C/SCI2CTests/test999_WorkingDir/scilabcode/LinComb.sci diff --git a/macros/ASTManagement/%for_string.sci b/macros/ASTManagement/%for_string.sci new file mode 100644 index 00000000..0ed9ca28 --- /dev/null +++ b/macros/ASTManagement/%for_string.sci @@ -0,0 +1,15 @@ +function txt=%for_string(F) +//overloading function for "for" type tlist string function +//this is a node of the AST +//fields: +// expression : "expression" type tlist (the loop expression) +// statements : list of "equal" type tlist and list('EOL') (the +// for instructions list) +//NUT: raf cambiato ForExpression e ForStatements + txt=['For' + ' ForExpression:' + ' '+string(F.expression) + ' ForStatements:' + ' '+objectlist2string(F.statements) + 'EndFor'] +endfunction \ No newline at end of file diff --git a/macros/ASTManagement/AST_HandleEOL.sci b/macros/ASTManagement/AST_HandleEOL.sci index 286bab7b..c258ff94 100644 --- a/macros/ASTManagement/AST_HandleEOL.sci +++ b/macros/ASTManagement/AST_HandleEOL.sci @@ -41,22 +41,22 @@ IndentLevel = SharedInfo.NIndent; PrintStepInfo('Handling EOL',ReportFileName,'file'); sciline = mgetl(SciFileFid,1); - + // #RNU_RES_B -PrintStringInfo(' ',ReportFileName,'file','y'); -PrintStringInfo('##################'+'################'+'##################'+'##################'+'##################',ReportFileName,'file','y'); -PrintStringInfo('##################'+'################'+'##################'+'##################'+'##################',ReportFileName,'file','y'); -PrintStringInfo('### Scilab code: '+sciline+' ###',ReportFileName,'file','y'); -PrintStringInfo('##################'+'################'+'##################'+'##################'+'##################',ReportFileName,'file','y'); -PrintStringInfo('##################'+'################'+'##################'+'##################'+'##################',ReportFileName,'file','y'); +PrintStringInfo(' ',ReportFileName,'file','y','n'); +PrintStringInfo('##################'+'################'+'##################'+'##################'+'##################',ReportFileName,'file','y','n'); +PrintStringInfo('##################'+'################'+'##################'+'##################'+'##################',ReportFileName,'file','y','n'); +PrintStringInfo('### Scilab code: '+sciline+' ###',ReportFileName,'file','y','n'); +PrintStringInfo('##################'+'################'+'##################'+'##################'+'##################',ReportFileName,'file','y','n'); +PrintStringInfo('##################'+'################'+'##################'+'##################'+'##################',ReportFileName,'file','y','n'); // #RNU_RES_E PrintStringInfo(' ',CPass1FileName,'file','y'); modeprintstringinfo = 'stdout'; if (SharedInfo.CopySciCodeIntoCCode == 1) modeprintstringinfo = 'both'; end -PrintStringInfo(C_IndentBlanks(IndentLevel)+'/*SCI2C: #############'+'############'+'##############'+'###############'+'############',CPass1FileName,modeprintstringinfo,'y'); -PrintStringInfo(C_IndentBlanks(IndentLevel)+' SCI2C: '+sciline,CPass1FileName,modeprintstringinfo,'y'); -PrintStringInfo(C_IndentBlanks(IndentLevel)+' SCI2C: #############'+'############'+'##############'+'###############'+'############*/',CPass1FileName,modeprintstringinfo,'y'); +PrintStringInfo(C_IndentBlanks(IndentLevel)+'/*SCI2C: #############'+'############'+'##############'+'###############'+'############',CPass1FileName,modeprintstringinfo,'y','n'); +PrintStringInfo(C_IndentBlanks(IndentLevel)+' SCI2C: '+sciline,CPass1FileName,modeprintstringinfo,'y','n'); +PrintStringInfo(C_IndentBlanks(IndentLevel)+' SCI2C: #############'+'############'+'##############'+'###############'+'############*/',CPass1FileName,modeprintstringinfo,'y','n'); endfunction diff --git a/macros/ASTManagement/AST_HandleEndGenFun.sci b/macros/ASTManagement/AST_HandleEndGenFun.sci index 2bc31969..3db11733 100644 --- a/macros/ASTManagement/AST_HandleEndGenFun.sci +++ b/macros/ASTManagement/AST_HandleEndGenFun.sci @@ -419,7 +419,8 @@ load(FunInfoDatFileName,'FunInfo'); //#RNU_RES_B // --- Generate include. --- //#RNU_RES_E -if ((Flag_FunAlreadyCalled == 0) & (FunInfo.LibTypeInfo == 'USER2C')) +if ((Flag_FunAlreadyCalled == 0) & (FunInfo.LibTypeInfo == 'USER2C') & (SharedInfo.NextCFunName ~= CFunName)) + // (SharedInfo.NextCFunName ~= CFunName) I don't want an include in the same file. Ex. in main.h I don't want include "main.h" // #RNU_RES_B PrintStringInfo('Adding include',ReportFileName,'file','y'); PrintStringInfo('#include ""'+CFunName+'.h""',... diff --git a/macros/ASTManagement/AST_ParseEqualStruct.sci b/macros/ASTManagement/AST_ParseEqualStruct.sci index 1c86b765..3d917682 100644 --- a/macros/ASTManagement/AST_ParseEqualStruct.sci +++ b/macros/ASTManagement/AST_ParseEqualStruct.sci @@ -44,8 +44,8 @@ global StackPosition; global STACKDEDUG //#RNU_RES_B -PrintStringInfo(' ',ReportFileName,'file','y'); -PrintStringInfo('***Reading AST***',ReportFileName,'file','y'); +PrintStringInfo(' ',ReportFileName,'file','y','n'); +PrintStringInfo('***Reading AST***',ReportFileName,'file','y','n'); //#RNU_RES_E // ------------------------------- @@ -122,8 +122,8 @@ end // --- Print Some Info. --- // ------------------------ //#RNU_RES_B -PrintStringInfo('Function Name: '+FunctionName,ReportFileName,'file','y'); -PrintStringInfo('N Intput Arguments: '+string(NInArg),ReportFileName,'file','y'); +PrintStringInfo('Function Name: '+FunctionName,ReportFileName,'file','y','n'); +PrintStringInfo('N Intput Arguments: '+string(NInArg),ReportFileName,'file','y','n'); //#RNU_RES_E if (SharedInfo.Equal.Nins > 0) //#RNU_RES_B @@ -147,17 +147,17 @@ else for counterinputargs = 1:NInArg //#RNU_RES_B PrintStringInfo('Input Argument Number '+string(counterinputargs)+': '+InArg(counterinputargs).Name,... - ReportFileName,'file','y'); + ReportFileName,'file','y','n'); PrintStringInfo(' Scope: '+InArg(counterinputargs).Scope,... - ReportFileName,'file','y'); + ReportFileName,'file','y','n'); //#RNU_RES_E end for counteroutputargs = 1:NOutArg //#RNU_RES_B PrintStringInfo('Output Argument Number '+string(counteroutputargs)+': '+OutArg(counteroutputargs).Name,... - ReportFileName,'file','y'); + ReportFileName,'file','y','n'); PrintStringInfo(' Scope: '+OutArg(counterinputargs).Scope,... - ReportFileName,'file','y'); + ReportFileName,'file','y','n'); //#RNU_RES_E end if (NInArg ~= NOutArg) diff --git a/macros/ASTManagement/AST_ParseFuncallStruct.sci b/macros/ASTManagement/AST_ParseFuncallStruct.sci index 54496597..5840c05e 100644 --- a/macros/ASTManagement/AST_ParseFuncallStruct.sci +++ b/macros/ASTManagement/AST_ParseFuncallStruct.sci @@ -100,16 +100,16 @@ for counterinputargs = 1:NInArg end //#RNU_RES_B -PrintStringInfo('Function Name: '+FunctionName,ReportFileName,'file','y'); -PrintStringInfo('N Intput Arguments: '+string(NInArg),ReportFileName,'file','y'); -PrintStringInfo('N Output Arguments: '+string(NOutArg),ReportFileName,'file','y'); +PrintStringInfo('Function Name: '+FunctionName,ReportFileName,'file','y','n'); +PrintStringInfo('N Intput Arguments: '+string(NInArg),ReportFileName,'file','y','n'); +PrintStringInfo('N Output Arguments: '+string(NOutArg),ReportFileName,'file','y','n'); //#RNU_RES_E for counterinputargs = 1:NInArg //#RNU_RES_B PrintStringInfo('Input Argument Number '+string(counterinputargs)+': '+InArg(counterinputargs).Name,... - ReportFileName,'file','y'); + ReportFileName,'file','y','n'); PrintStringInfo(' Scope: '+InArg(counterinputargs).Scope,... - ReportFileName,'file','y'); + ReportFileName,'file','y','n'); //#RNU_RES_E end diff --git a/macros/ASTManagement/for_string.sci b/macros/ASTManagement/for_string.sci deleted file mode 100644 index 0ed9ca28..00000000 --- a/macros/ASTManagement/for_string.sci +++ /dev/null @@ -1,15 +0,0 @@ -function txt=%for_string(F) -//overloading function for "for" type tlist string function -//this is a node of the AST -//fields: -// expression : "expression" type tlist (the loop expression) -// statements : list of "equal" type tlist and list('EOL') (the -// for instructions list) -//NUT: raf cambiato ForExpression e ForStatements - txt=['For' - ' ForExpression:' - ' '+string(F.expression) - ' ForStatements:' - ' '+objectlist2string(F.statements) - 'EndFor'] -endfunction \ No newline at end of file diff --git a/macros/CCodeGeneration/C_FinalizeCode.sci b/macros/CCodeGeneration/C_FinalizeCode.sci index 2c6b600c..5c26dd85 100644 --- a/macros/CCodeGeneration/C_FinalizeCode.sci +++ b/macros/CCodeGeneration/C_FinalizeCode.sci @@ -50,6 +50,7 @@ PrintStringInfo('** ---------------------------- ',Pass1HeaderFileName,'file','y PrintStringInfo('** --- End USER2C Includes. --- ',Pass1HeaderFileName,'file','y'); PrintStringInfo('** ---------------------------- ',Pass1HeaderFileName,'file','y'); PrintStringInfo('*/',Pass1HeaderFileName,'file','y'); +PrintStringInfo('#endif',Pass1HeaderFileName,'file','y'); // ------------------------------------- // --- End Finalize the header file. --- // ------------------------------------- diff --git a/macros/CCodeGeneration/C_ForExpression.sci b/macros/CCodeGeneration/C_ForExpression.sci index 7afc5526..a5ed1346 100644 --- a/macros/CCodeGeneration/C_ForExpression.sci +++ b/macros/CCodeGeneration/C_ForExpression.sci @@ -35,7 +35,7 @@ CPass1ForEpilFileName = FileInfo.Funct(nxtscifunnumber).CPass1ForEpilFileName(Sh // #RNU_RES_B PrintStringInfo(' ',ReportFileName,'file','y'); -PrintStringInfo('***Generating C code***',ReportFileName,'file','y'); +PrintStringInfo('***Generating C code***',ReportFileName,'file','y','n'); // #RNU_RES_E CCall =''; // --------------------------- @@ -97,11 +97,20 @@ elseif (SharedInfo.ForExpr.AssignmentFun == SharedInfo.CFunId.OpColon) // #RNU_RES_B // Prologue // #RNU_RES_E - PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+C_Strings(cntstr),CPass1FileName,'file','y'); + PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+C_Strings(cntstr),CPass1FileName,'file','y','n'); // #RNU_RES_B // Epilogue // #RNU_RES_E - PrintStringInfo(C_Strings(cntstr),CPass1ForEpilFileName ,'file','y'); + disp('C_Strings(cntstr)') + disp(C_Strings(cntstr)) + disp('CPass1ForEpilFileName') + disp(CPass1ForEpilFileName) + if (length(C_Strings(cntstr)) == 0) + C_Strings(cntstr) = ''; // If I don't do that I get a PrintStringInfo error related to mputstr. + // Function not defined for given argument type(s), + // check arguments or define function %0_mputstr for overloading. + end + PrintStringInfo(string(C_Strings(cntstr)),CPass1ForEpilFileName ,'file','y','n'); end // #RNU_RES_B // ---------------------------------------- diff --git a/macros/CCodeGeneration/C_GenerateMakefile.sci b/macros/CCodeGeneration/C_GenerateMakefile.sci index 6f4f8e75..424ccb81 100644 --- a/macros/CCodeGeneration/C_GenerateMakefile.sci +++ b/macros/CCodeGeneration/C_GenerateMakefile.sci @@ -48,66 +48,66 @@ makesci2cdir = FileInfo.CStyleOutCCCodeDir; // makesci2cdir = FileInfo.CStyleOutCCCodeDir; -PrintStringInfo('CSRCDIR = '+makecsrcdir,FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('HSRCDIR = '+makehsrcdir,FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('ISRCDIR = '+makeisrcdir,FileInfo.MakefileFilename,'file','y'); -//PrintStringInfo('SCI2CDIR = '+makesci2cdir,FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('SCI2CDIR = .',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('CSRCDIR = '+makecsrcdir,FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('HSRCDIR = '+makehsrcdir,FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('ISRCDIR = '+makeisrcdir,FileInfo.MakefileFilename,'file','y','y'); +//PrintStringInfo('SCI2CDIR = '+makesci2cdir,FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('SCI2CDIR = .',FileInfo.MakefileFilename,'file','y','y'); // Compiler definition -PrintStringInfo('CC = gcc',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('CFLAGS = -Wall -pedantic -O3 -I $(HSRCDIR) -I $(ISRCDIR) -lm',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('CC = gcc',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('CFLAGS = -Wall -pedantic -O3 -I $(HSRCDIR) -I $(ISRCDIR) -lm',FileInfo.MakefileFilename,'file','y','y'); // Binary definition -PrintStringInfo('EXEFILENAME = mytest.exe',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('EXEFILE = $(SCI2CDIR)/$(EXEFILENAME)', FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('EXEFILENAME = mytest.exe',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('EXEFILE = $(SCI2CDIR)/$(EXEFILENAME)', FileInfo.MakefileFilename,'file','y','y'); // Sources -PrintStringInfo('SRC = \\', FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('SRC = \\', FileInfo.MakefileFilename,'file','y','y'); allSources = getAllSources(); nbSources = size(allSources); for i = 1:(nbSources(1) - 1) [tmppath,tmpfile,tmpext] = fileparts(allSources(i)); - PrintStringInfo(' $(CSRCDIR)/'+tmpfile+tmpext+' \\', FileInfo.MakefileFilename,'file','y'); + PrintStringInfo(' $(CSRCDIR)/'+tmpfile+tmpext+' \\', FileInfo.MakefileFilename,'file','y','y'); end [tmppath,tmpfile,tmpext] = fileparts(allSources(nbSources(1))); -PrintStringInfo(' $(CSRCDIR)/'+tmpfile+tmpext, FileInfo.MakefileFilename,'file','y'); +PrintStringInfo(' $(CSRCDIR)/'+tmpfile+tmpext, FileInfo.MakefileFilename,'file','y','y'); // Objects -PrintStringInfo('OBJ = $(SRC:.c=.o)', FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('OBJ = $(SRC:.c=.o)', FileInfo.MakefileFilename,'file','y','y'); // Rules -PrintStringInfo('# ---------------',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('# --- TARGETS ---',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('# ---------------',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('compileexecute: $(OBJ)',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('\t@echo ""============================""',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('\t@echo ""Generation of the executable""',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('\t@echo ""============================""',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('\t$(CC) $(CFLAGS) $(OBJ) *.c -llapack -lblas -o $(EXEFILE)',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('\t@echo ""==============""',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('\t@echo ""Executing code""',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('\t@echo ""==============""',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('\t$(EXEFILE)',FileInfo.MakefileFilename,'file','y'); - -PrintStringInfo('clean:',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('\t@echo ""=============================""',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('\t@echo ""Removing only exe + obj files""',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('\t@echo ""=============================""',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('\trm -rf $(EXEFILE)',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('\trm -rf $(OBJ)',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y'); - -PrintStringInfo('distclean: clean',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('\t@echo ""==========================""',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('\t@echo ""Removing only the exe file""',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('\t@echo ""==========================""',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('\trm -rf $(EXEFILE)',FileInfo.MakefileFilename,'file','y'); -PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('# ---------------',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('# --- TARGETS ---',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('# ---------------',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('compileexecute: $(OBJ)',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""============================""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""Generation of the executable""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""============================""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t$(CC) $(CFLAGS) $(OBJ) *.c -llapack -lblas -o $(EXEFILE)',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""==============""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""Executing code""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""==============""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t$(EXEFILE)',FileInfo.MakefileFilename,'file','y','y'); + +PrintStringInfo('clean:',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""=============================""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""Removing only exe + obj files""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""=============================""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\trm -rf $(EXEFILE)',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\trm -rf $(OBJ)',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y','y'); + +PrintStringInfo('distclean: clean',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""==========================""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""Removing only the exe file""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""==========================""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\trm -rf $(EXEFILE)',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y','y'); // ------------------------------- diff --git a/macros/CCodeGeneration/C_InitHeader.sci b/macros/CCodeGeneration/C_InitHeader.sci index 8d088939..7d794127 100644 --- a/macros/CCodeGeneration/C_InitHeader.sci +++ b/macros/CCodeGeneration/C_InitHeader.sci @@ -30,6 +30,9 @@ SCI2CNInArgCheck(argn(2),3,3); C_SCI2CHeader(HeaderFileName); +[tmppath,tmpfname,tmpextension]=fileparts(HeaderFileName); +PrintStringInfo('#ifndef '+tmpfname+'_h',HeaderFileName,'file','y'); +PrintStringInfo('#define '+tmpfname+'_h',HeaderFileName,'file','y'); PrintStringInfo('/*',HeaderFileName,'file','y'); PrintStringInfo('** ----------------------- ',HeaderFileName,'file','y'); PrintStringInfo('** --- SCI2C Includes. --- ',HeaderFileName,'file','y'); diff --git a/macros/GeneralFunctions/PrintStepInfo.sci b/macros/GeneralFunctions/PrintStepInfo.sci index f4a17926..2550e327 100644 --- a/macros/GeneralFunctions/PrintStepInfo.sci +++ b/macros/GeneralFunctions/PrintStepInfo.sci @@ -1,5 +1,5 @@ -function PrintStepInfo(inputstring,filename,outputtype) -// function PrintStepInfo(inputstring,filename,outputtype) +function PrintStepInfo(inputstring,filename,outputtype,formattedstring) +// function PrintStepInfo(inputstring,filename,outputtype,formattedstring) // ----------------------------------------------------------------- // #RNU_RES_B // Prints a string by using a predefined format into a file or on @@ -13,6 +13,8 @@ function PrintStepInfo(inputstring,filename,outputtype) // 'stdout' -> prints only on the stdout. // 'both' -> prints on both file and stdoud. // Default is 'stdout'. +// formattedstring: if 'n' (default) it means that str is considered as a simple string (mputstr). +// if 'y' then str is considered formatted according to mfprint syntax // Output data: // // #RNU_RES_E @@ -27,13 +29,15 @@ function PrintStepInfo(inputstring,filename,outputtype) // ------------------------------ // --- Check input arguments. --- // ------------------------------ -SCI2CNInArgCheck(argn(2),1,3); +SCI2CNInArgCheck(argn(2),1,4); - -if argn(2) < 3 - bothout = 'n'; - if argn(2) < 2 - filename = ''; +if argn(2) < 4 + formattedstring = 'n'; + if argn(2) < 3 + bothout = 'n'; + if argn(2) < 2 + filename = ''; + end end end if (length(filename) == 0) @@ -57,11 +61,11 @@ if ((outputtype=='both') | (outputtype=='stdout')) end if ((outputtype=='both') | (outputtype=='file')) - filenamefprintf(filename,'y',' '); - filenamefprintf(filename,'y',' '); - filenamefprintf(filename,'y',blankstring+' '+starstring); - filenamefprintf(filename,'y',blankstring+'==> '+inputstring); - filenamefprintf(filename,'y',blankstring+' '+starstring); - filenamefprintf(filename,'y',' '); + filenamefprintf(filename,'y',' ',formattedstring); + filenamefprintf(filename,'y',' ',formattedstring); + filenamefprintf(filename,'y',blankstring+' '+starstring,formattedstring); + filenamefprintf(filename,'y',blankstring+'==> '+inputstring,formattedstring); + filenamefprintf(filename,'y',blankstring+' '+starstring,formattedstring); + filenamefprintf(filename,'y',' ',formattedstring); end endfunction diff --git a/macros/GeneralFunctions/PrintStringInfo.sci b/macros/GeneralFunctions/PrintStringInfo.sci index 6fd4ec20..a554d122 100644 --- a/macros/GeneralFunctions/PrintStringInfo.sci +++ b/macros/GeneralFunctions/PrintStringInfo.sci @@ -1,5 +1,5 @@ -function PrintStringInfo(str, filename, outputtype, ennewline) -// function PrintStringInfo(str,filename,outputtype,ennewline) +function PrintStringInfo(str, filename, outputtype, ennewline,formattedstring) +// function PrintStringInfo(str,filename,outputtype,ennewline,formattedstring) // ----------------------------------------------------------------- // #RNU_RES_B // Prints a string into a file or on the stdout or on both. @@ -14,6 +14,8 @@ function PrintStringInfo(str, filename, outputtype, ennewline) // Default is 'stdout'. // ennewline: optional (default = 'y'); If y adds a newline character // at the end of the input string. +// formattedstring: if 'n' (default) it means that str is considered as a simple string (mputstr). +// if 'y' then str is considered formatted according to mfprint syntax // // Output data: // --- @@ -31,8 +33,10 @@ function PrintStringInfo(str, filename, outputtype, ennewline) // ------------------------------ // --- Check input arguments. --- // ------------------------------ -SCI2CNInArgCheck(argn(2),0,4); +SCI2CNInArgCheck(argn(2),0,5); +if argn(2) < 5 + formattedstring = 'n'; if argn(2) < 4 ennewline = 'y'; if argn(2) < 3 @@ -45,21 +49,21 @@ SCI2CNInArgCheck(argn(2),0,4); end end end +end +if (length(filename) == 0) then + outputtype = 'stdout'; // Prints only on the stdout. +end - if (length(filename) == 0) then - outputtype = 'stdout'; // Prints only on the stdout. - end - - if (outputtype=='both') | (outputtype=='stdout') - disp(str) - end +if (outputtype=='both') | (outputtype=='stdout') + disp(str) +end - if (outputtype=='both') | (outputtype=='file') - if (ennewline=='y') - filenamefprintf(filename,'y',str); - else - filenamefprintf(filename,'n',str); - end +if (outputtype=='both') | (outputtype=='file') + if (ennewline=='y') + filenamefprintf(filename,'y',str,formattedstring); + else + filenamefprintf(filename,'n',str,formattedstring); end +end endfunction diff --git a/macros/GeneralFunctions/filenamefprintf.sci b/macros/GeneralFunctions/filenamefprintf.sci index 34875e99..0b64bd88 100644 --- a/macros/GeneralFunctions/filenamefprintf.sci +++ b/macros/GeneralFunctions/filenamefprintf.sci @@ -1,5 +1,5 @@ -function filenamefprintf(filename,ennewline,str) -// function filenamefprintf(filename,ennewline,str) +function filenamefprintf(filename,ennewline,str,formattedstring) +// function filenamefprintf(filename,ennewline,str,formattedstring) // -------------------------------------------------------------------------------- // Uses the printf to print the string specified by varargin. filenamefprintf // uses the filename instead of the fid parameter used by fprintf. @@ -10,6 +10,8 @@ function filenamefprintf(filename,ennewline,str) // Input data: // filename: string that specifies the name of the file. // varargin are the input arguments for the printf. +// formattedstring: if 'n' (default) it means that str is considered as a simple string (mputstr). +// if 'y' then str is considered formatted according to mfprint syntax // // Output data: // --- @@ -25,7 +27,7 @@ function filenamefprintf(filename,ennewline,str) // ------------------------------ // --- Check input arguments. --- // ------------------------------ -SCI2CNInArgCheck(argn(2),3,3); +SCI2CNInArgCheck(argn(2),4,4); // [FidReportFile, mess] = mopen(deblank(filename),'at+'); @@ -33,10 +35,13 @@ SCI2CNInArgCheck(argn(2),3,3); if (FidReportFile == -1) then SCI2Cerror(mess); end - if ennewline=='y' then - mfprintf(FidReportFile, str+'\n'); + if formattedstring == 'n' + mputstr(str,FidReportFile); else mfprintf(FidReportFile, str); + end + if ennewline=='y' then + mfprintf(FidReportFile,'\n'); end mclose(FidReportFile); diff --git a/macros/SymbolTable/ST_InsOutArg.sci b/macros/SymbolTable/ST_InsOutArg.sci index f0df5388..c6051772 100644 --- a/macros/SymbolTable/ST_InsOutArg.sci +++ b/macros/SymbolTable/ST_InsOutArg.sci @@ -42,7 +42,7 @@ CPass1FreeFileName = FileInfo.Funct(nxtscifunnumber).CPass1FreeFileName; // #RNU_RES_B PrintStringInfo(' ',ReportFileName,'file','y'); -PrintStringInfo('***Putting output arguments in the symbol table***',ReportFileName,'file','y'); +PrintStringInfo('***Putting output arguments in the symbol table***',ReportFileName,'file','y','n'); // #RNU_RES_E // --------------------------- // --- End Initialization. --- @@ -51,15 +51,15 @@ PrintStringInfo('***Putting output arguments in the symbol table***',ReportFileN for counteroutput = 1:NOutArg // #RNU_RES_B - PrintStringInfo(' Symbol ""'+OutArg(counteroutput).Name+'""',ReportFileName,'file','y'); - PrintStringInfo(' Type: '+OutArg(counteroutput).Type,ReportFileName,'file','y'); - PrintStringInfo(' Size(1): '+string(OutArg(counteroutput).Size(1)),ReportFileName,'file','y'); - PrintStringInfo(' Size(2): '+string(OutArg(counteroutput).Size(2)),ReportFileName,'file','y'); - PrintStringInfo(' Value: '+string(OutArg(counteroutput).Value),ReportFileName,'file','y'); - PrintStringInfo(' FindLike: '+string(OutArg(counteroutput).FindLike),ReportFileName,'file','y'); - PrintStringInfo(' Dimension: '+string(OutArg(counteroutput).Dimension),ReportFileName,'file','y'); - PrintStringInfo(' Scope: '+string(OutArg(counteroutput).Scope),ReportFileName,'file','y'); - PrintStringInfo(' ',ReportFileName,'file','y'); + PrintStringInfo(' Symbol ""'+OutArg(counteroutput).Name+'""',ReportFileName,'file','y','n'); + PrintStringInfo(' Type: '+OutArg(counteroutput).Type,ReportFileName,'file','y','n'); + PrintStringInfo(' Size(1): '+string(OutArg(counteroutput).Size(1)),ReportFileName,'file','y','n'); + PrintStringInfo(' Size(2): '+string(OutArg(counteroutput).Size(2)),ReportFileName,'file','y','n'); + PrintStringInfo(' Value: '+string(OutArg(counteroutput).Value),ReportFileName,'file','y','n'); + PrintStringInfo(' FindLike: '+string(OutArg(counteroutput).FindLike),ReportFileName,'file','y','n'); + PrintStringInfo(' Dimension: '+string(OutArg(counteroutput).Dimension),ReportFileName,'file','y','n'); + PrintStringInfo(' Scope: '+string(OutArg(counteroutput).Scope),ReportFileName,'file','y','n'); + PrintStringInfo(' ',ReportFileName,'file','y','n'); // #RNU_RES_E if mtlb_strcmp(OutArg(counteroutput).Scope,'Temp') diff --git a/macros/ToolInitialization/INIT_RemoveDirs.sci b/macros/ToolInitialization/INIT_RemoveDirs.sci index 0fa288bd..536b909e 100644 --- a/macros/ToolInitialization/INIT_RemoveDirs.sci +++ b/macros/ToolInitialization/INIT_RemoveDirs.sci @@ -35,9 +35,15 @@ if (SharedInfoRunMode == 'GenLibraryStructure' | SharedInfoRunMode == 'All') // Remove software<->user interaction. // yesno=input('Are you sure [y/n]?','string'); yesno = 'y'; - if (yesno=='y') - rmdir(FileInfo.WorkingDir,'s'); - rmdir(FileInfo.OutCCCodeDir,'s'); + + if (yesno=='y') + rmdir(FileInfo.WorkingDir,'s'); // delete WorkingDir if it exists due to previous translations... + mdelete(FileInfo.OutCCCodeDir+'/*.h'); // delete .h files generated in previous translations (if any). + mdelete(FileInfo.OutCCCodeDir+'/*.c'); // delete .h files generated in previous translations (if any). + mdelete(FileInfo.OutCCCodeDir+'/Makefile'); // delete .h files generated in previous translations (if any). + // Note I don't delete includes, interfaces and and src directories to avoid recompiling them every time + // a new translation is launched. I only delete source files generated by user. + else SCI2Cerror('Cannot continue, because you don''t want to delete: '+FileInfo.WorkingDir); SCI2Cerror('Cannot continue, because you don''t want to delete: '+FileInfo.OutCCCodeDir); diff --git a/macros/ToolInitialization/INIT_SCI2C.sci b/macros/ToolInitialization/INIT_SCI2C.sci index 0ffe5b58..00f25d88 100644 --- a/macros/ToolInitialization/INIT_SCI2C.sci +++ b/macros/ToolInitialization/INIT_SCI2C.sci @@ -79,7 +79,7 @@ PrintStepInfo('SCI2C hArtes/POLIBA Tool!!!',FileInfo.GeneralReport,'stdout'); // ---------------------------------------------------- // --- Remove previous versions of SCI2C files/dir. --- // ---------------------------------------------------- -//-- INIT_RemoveDirs(FileInfo,SharedInfo.RunMode); +INIT_RemoveDirs(FileInfo,SharedInfo.RunMode); // --------------------------- // --- Create Directories. --- diff --git a/macros/runscicode.sci b/macros/runscicode.sci index d6bdc37d..c2574f91 100644 --- a/macros/runscicode.sci +++ b/macros/runscicode.sci @@ -62,4 +62,6 @@ execstr(tmpfile); disp('------------------------------------------'); disp('--- End Execution of your SCILAB code. ---'); disp('------------------------------------------'); + + endfunction \ No newline at end of file diff --git a/macros/scilab2c.sci b/macros/scilab2c.sci index 41a5ac8e..10ae9539 100644 --- a/macros/scilab2c.sci +++ b/macros/scilab2c.sci @@ -12,7 +12,7 @@ function scilab2c(varargin) [lhs, rhs] = argn(); - + select rhs // // scilab2c() diff --git a/src/Scilab2C/SCI2CTests/test999_WorkingDir/scilabcode/LinComb.sci b/src/Scilab2C/SCI2CTests/test999_WorkingDir/scilabcode/LinComb.sci deleted file mode 100644 index 9f74b454..00000000 --- a/src/Scilab2C/SCI2CTests/test999_WorkingDir/scilabcode/LinComb.sci +++ /dev/null @@ -1,16 +0,0 @@ -//SCI2C: NIN= 6 -//SCI2C: NOUT= 1 -//SCI2C: OUT(1).TP= IN(1).TP -//SCI2C: OUT(1).SZ(1)= IN(2).SZ(1) -//SCI2C: OUT(1).SZ(2)= IN(2).SZ(2) - -//SCI2C: DEFAULT_PRECISION= DOUBLE - -function z = LinComb(a,x,b,y,t1,t2) - -t1 = a*x; -t2 = b*y; -z = t1+t2; -// z = a*x+b*y; - -endfunction diff --git a/src/Scilab2C/SCI2CTests/test999_WorkingDir/scilabcode/mainfunction.sci b/src/Scilab2C/SCI2CTests/test999_WorkingDir/scilabcode/mainfunction.sci index 0fafb592..e39f7648 100644 --- a/src/Scilab2C/SCI2CTests/test999_WorkingDir/scilabcode/mainfunction.sci +++ b/src/Scilab2C/SCI2CTests/test999_WorkingDir/scilabcode/mainfunction.sci @@ -1,20 +1,30 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction() - -//test OpColon - - -2+%i:2-%i - -1+%i:6+%i*5 - -2+%i*3:1-%i*4:2+%i*2 - -2+%i:1+%i:5+%i - -1+%i:2+%i:1+%i - -1+%i:3+%i:10+%i - +function mainfunction() + +// ------------------------------ +// --- Simple Scalar Addition --- +// ------------------------------ +a = 1; +b = 2; +c = 0; +c = a + b; +disp(c); + +// ------------------------------ +// --- Trigonometric Identity --- +// ------------------------------ +x = (1:3)' * (4:9); +y = (sin(x).^2) + (cos(x).^2); +disp(x); +disp(y-ones(3,6)); + +// ------------------------------- +// --- Computation of Distance --- +// ------------------------------- +// generate a vector w +w = cos(sin(cos(x*3)*2).* x+ones(3,6).*cos(x-sin(y*2))); +distxw = sqrt(x.^2 + w.^2); +disp(distxw); endfunction + \ No newline at end of file -- cgit