diff options
author | jofret | 2012-07-25 09:26:16 +0000 |
---|---|---|
committer | jofret | 2012-07-25 09:26:16 +0000 |
commit | 96ebf66e990156763a31155f878633bf998c89c5 (patch) | |
tree | 5441b22e9ecc1c6efb3cf84070d1bcf0d883efc0 | |
parent | a1209093b5d0d0eb77d3be9a7013670aac0e35b9 (diff) | |
download | scilab2c-96ebf66e990156763a31155f878633bf998c89c5.tar.gz scilab2c-96ebf66e990156763a31155f878633bf998c89c5.tar.bz2 scilab2c-96ebf66e990156763a31155f878633bf998c89c5.zip |
Adapt Scilab2C to new save behaviour
-rw-r--r-- | scilab2c/macros/ASTManagement/AST2Ccode.sci | 48 | ||||
-rw-r--r-- | scilab2c/macros/ASTManagement/AST_GetASTFile.sci | 2 | ||||
-rw-r--r-- | scilab2c/macros/CCodeGeneration/GenCFunDatFiles.sci | 2 | ||||
-rw-r--r-- | scilab2c/macros/FunctionList/FL_UpdateToBeConv.sci | 14 | ||||
-rw-r--r-- | scilab2c/macros/SymbolTable/ST_Save.sci | 6 | ||||
-rw-r--r-- | scilab2c/macros/ToolInitialization/INIT_LoadLibraries.sci | 10 | ||||
-rw-r--r-- | scilab2c/macros/ToolInitialization/INIT_SCI2C.sci | 10 | ||||
-rw-r--r-- | scilab2c/macros/ToolInitialization/ManageNextConversion.sci | 8 | ||||
-rw-r--r-- | scilab2c/macros/ToolInitialization/UpdateSCI2CInfo.sci | 404 |
9 files changed, 252 insertions, 252 deletions
diff --git a/scilab2c/macros/ASTManagement/AST2Ccode.sci b/scilab2c/macros/ASTManagement/AST2Ccode.sci index 4600f3c3..7c95572e 100644 --- a/scilab2c/macros/ASTManagement/AST2Ccode.sci +++ b/scilab2c/macros/ASTManagement/AST2Ccode.sci @@ -2,7 +2,7 @@ function AST2Ccode(FileInfoDatFile) // function AST2Ccode(FileInfoDatFile) // ----------------------------------------------------------------- // Read the AST and call the corresponding handlers. -// +// // Input data: // //NUT: add description here // @@ -46,7 +46,7 @@ ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; // --------------------------------- // --- Parameter Initialization. --- // --------------------------------- -global SCI2CSTACK +global SCI2CSTACK SCI2CSTACK = ['EMPTYSTACK']; global StackPosition; @@ -92,7 +92,7 @@ AST_PushASTStack('Dummy'); AST_PushASTStack('Dummy'); AST_PushASTStack('Dummy'); AST_PushASTStack('Dummy'); -//NUT: Se ne tolgo qualcuno ottengo errori +//NUT: Se ne tolgo qualcuno ottengo errori // ---------------------------- // --- End Parse AST header. --- // ---------------------------- @@ -104,7 +104,7 @@ AST_PushASTStack('Dummy'); SharedInfo.WorkAreaUsedBytes = OrigWorkAreaUsedBytes; SharedInfo.UsedTempScalarVars = OrigUsedTempScalarVars; //NUT: put here a manageeol so that you can have all the save and load you want. - SharedInfo.ASTReader.UsedTempVars = 0; + SharedInfo.ASTReader.UsedTempVars = 0; // ---------------------------------- // --- Main loop to read the AST. --- @@ -121,34 +121,34 @@ while ~meof(fidAST) if STACKDEDUG == 1 disp('Read AST Line: '+treeline); end - + // Analyze line. select treeline - + // ------------------ // --- Functions. --- // ------------------ //NUT: qui puoi anche aggiunger piu' case per specificare meglio la struttura della funcall //NUT: i case aggiunti ovviamente faranno solo il push della treeline. - case 'EndOperation' then + case 'EndOperation' then [FileInfo,SharedInfo] = AST_HandleEndGenFun(FileInfo,SharedInfo,'Operation'); case 'EndFuncall' then [FileInfo,SharedInfo] = AST_HandleEndGenFun(FileInfo,SharedInfo,'Funcall'); - + // -------------- // --- Equal. --- // -------------- - case 'EndEqual' then + case 'EndEqual' then //NUT: prima di lanciare l'analisi della equal puoi mettere degli argomenti dummy //NUT: per fare in modo di coprire le ins, anche se ci puo' essere qualche rischio quando //NUT: ho miste ins e variabili, per esempio [c(1,1), a] = twooutfun(); //NUT: in questo caso solo una delle due equal va scartata. [FileInfo,SharedInfo] = AST_HandleEndGenFun(FileInfo,SharedInfo,'Equal'); SharedInfo = INIT_SharedInfoEqual(SharedInfo); - case 'Equal' then - SharedInfo.Equal.Enabled = 1; // 1 means enabled -> we are inside an equal AST block. + case 'Equal' then + SharedInfo.Equal.Enabled = 1; // 1 means enabled -> we are inside an equal AST block. AST_PushASTStack(treeline); - case 'Lhs :' then + case 'Lhs :' then SharedInfo.Equal.Lhs = 1; // 1 means that we are inside the Lhs block of the Equal [EqualInArgName,EqualInArgScope,EqualNInArg] = AST_ReadEqualRhsNames(FileInfo,SharedInfo); SharedInfo.Equal.NInArg = EqualNInArg; @@ -184,34 +184,34 @@ while ~meof(fidAST) AST_HandleEOL(FileInfo,SharedInfo); //NUT: si potrebbe differenziare comment da EOL case '<EOL>' then AST_HandleEOL(FileInfo,SharedInfo); - + // ----------------- // --- Epilogue. --- // ----------------- case 'EndProgram' SharedInfo = AST_HandleEndProgram(FileInfo,SharedInfo); - //NUT: per essere precisi si puo' pensare di mettere un check + //NUT: per essere precisi si puo' pensare di mettere un check //NUT: alla fine dell'albero per accertarsi che c'e' end program li' dove ce lo aspettiamo - + // ------------ // --- For. --- // ------------ - case 'For' then + case 'For' then SharedInfo.For.Level = SharedInfo.For.Level + 1; FileInfo = AST_HandleFor(FileInfo,SharedInfo); case 'ForExpression:' - AST_PushASTStack(treeline); + AST_PushASTStack(treeline); SharedInfo.ForExpr.OnExec = SharedInfo.ForExpr.OnExec + 1; case 'ForStatements:' [FileInfo,SharedInfo] = AST_HandleForStatem(FileInfo,SharedInfo); - case 'EndFor' then + case 'EndFor' then SharedInfo = AST_HandleEndFor(FileInfo,SharedInfo); - SharedInfo.For.Level = SharedInfo.For.Level - 1; + SharedInfo.For.Level = SharedInfo.For.Level - 1; // -------------- // --- While. --- // -------------- - case 'While' then + case 'While' then AST_PushASTStack(treeline); SharedInfo.While.Level = SharedInfo.While.Level + 1; case 'WhileExpression:' @@ -219,14 +219,14 @@ while ~meof(fidAST) [FileInfo,SharedInfo] = AST_HandleWhileExpr(FileInfo,SharedInfo); case 'WhileStatements:' [FileInfo,SharedInfo] = AST_HandleWhileStatem(FileInfo,SharedInfo); - case 'EndWhile' then + case 'EndWhile' then SharedInfo = AST_HandleEndWhile(FileInfo,SharedInfo); SharedInfo.While.Level = SharedInfo.While.Level - 1; - + // ---------------- // --- Default. --- // ---------------- - else + else AST_PushASTStack(treeline); end end @@ -239,7 +239,7 @@ mclose(fidAST); // --- Save section. --- // --------------------- // --- Save Shared Info Structure. --- -save(SharedInfoDatFile,SharedInfo); +save(SharedInfoDatFile, "SharedInfo"); // ------------------------- // --- End save section. --- // ------------------------- diff --git a/scilab2c/macros/ASTManagement/AST_GetASTFile.sci b/scilab2c/macros/ASTManagement/AST_GetASTFile.sci index 6fb0f76e..16fbbbac 100644 --- a/scilab2c/macros/ASTManagement/AST_GetASTFile.sci +++ b/scilab2c/macros/ASTManagement/AST_GetASTFile.sci @@ -50,7 +50,7 @@ SciFile2ASTFile(FileInfo.Funct(funnumber).SCIFileName,... // --- Save section. --- // --------------------- // --- Save File Info Structure. --- -// save(FileInfoDatFile,FileInfo); +// save(FileInfoDatFile, "FileInfo"); // ------------------------- // --- End save section. --- // ------------------------- diff --git a/scilab2c/macros/CCodeGeneration/GenCFunDatFiles.sci b/scilab2c/macros/CCodeGeneration/GenCFunDatFiles.sci index 62c8f4bc..9af858c7 100644 --- a/scilab2c/macros/CCodeGeneration/GenCFunDatFiles.sci +++ b/scilab2c/macros/CCodeGeneration/GenCFunDatFiles.sci @@ -67,7 +67,7 @@ FunInfo.OutArg = OutArg; FunInfo.NOutArg = NOutArg; FunInfo.PosFirstOutScalar = PosFirstOutScalar; FunInfo.LibTypeInfo = LibTypeInfo; -save(fullfile(FunInfoDatDir,CFunName+'.dat'),FunInfo); +save(fullfile(FunInfoDatDir,CFunName+'.dat'), "FunInfo"); clear FunInfo endfunction diff --git a/scilab2c/macros/FunctionList/FL_UpdateToBeConv.sci b/scilab2c/macros/FunctionList/FL_UpdateToBeConv.sci index 456467da..1ee2e15d 100644 --- a/scilab2c/macros/FunctionList/FL_UpdateToBeConv.sci +++ b/scilab2c/macros/FunctionList/FL_UpdateToBeConv.sci @@ -30,8 +30,8 @@ nxtscifunnumber = SharedInfo.NextSCIFunNumber; ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName;
SCI2CAvailableCDat = FileInfo.FunctionList.SCI2CAvailableCDat;
USER2CAvailableCDat = FileInfo.FunctionList.USER2CAvailableCDat;
-ConvertedDat = FileInfo.FunctionList.ConvertedDat;
-ToBeConvertedDat = FileInfo.FunctionList.ToBeConvertedDat;
+ConvertedDat = FileInfo.FunctionList.ConvertedDat;
+ToBeConvertedDat = FileInfo.FunctionList.ToBeConvertedDat;
FunInfoDatDir = FileInfo.FunctionList.FunInfoDatDir;
// #RNU_RES_B
@@ -47,7 +47,7 @@ PrintStringInfo(' C Function Name: '+CFunName,ReportFileName,'file','y'); // --------------------------------------------------
// --- Manage anticipated exit from the function. ---
// --------------------------------------------------
-//NUT: questo codice e' identico quasi a quello della CFunCall, si pu0 pensare di
+//NUT: questo codice e' identico quasi a quello della CFunCall, si pu0 pensare di
//NUT: di fare un'unica funzione.
// #RNU_RES_E
@@ -97,14 +97,14 @@ if (flagexist == %F) // --- Add C function to the "ToBeConverted" function list. ---
// #RNU_RES_E
load(ToBeConvertedDat,'ToBeConverted');
-
+
NToConvP1 = size(ToBeConverted,1)+1;
ToBeConverted(NToConvP1).SCIFunctionName = ASTFunName;
ToBeConverted(NToConvP1).CFunctionName = CFunName;
-
- save(ToBeConvertedDat,ToBeConverted);
+
+ save(ToBeConvertedDat, "ToBeConverted");
SharedInfo.NFilesToTranslate = SharedInfo.NFilesToTranslate + 1;
-
+
// #RNU_RES_B
// --- Generate C Function dat file. ---
PrintStringInfo(' Add C Function ""'+CFunName+'"" to: '+ToBeConvertedDat,ReportFileName,'file','y');
diff --git a/scilab2c/macros/SymbolTable/ST_Save.sci b/scilab2c/macros/SymbolTable/ST_Save.sci index f2109591..44e6e868 100644 --- a/scilab2c/macros/SymbolTable/ST_Save.sci +++ b/scilab2c/macros/SymbolTable/ST_Save.sci @@ -30,13 +30,13 @@ end // Identifies the Table name and save it into the .dat file.
if (mtlb_strcmp(tmpnams,'GlobalVars'))
GlobalVars = SCI2CSymbolTable;
- save(SymbolTableFileName,GlobalVars);
+ save(SymbolTableFileName, "GlobalVars");
elseif (mtlb_strcmp(tmpnams,'LocalVars'))
LocalVars = SCI2CSymbolTable;
- save(SymbolTableFileName,LocalVars);
+ save(SymbolTableFileName, "LocalVars");
elseif (mtlb_strcmp(tmpnams,'TempVars'))
TempVars = SCI2CSymbolTable;
- save(SymbolTableFileName,TempVars);
+ save(SymbolTableFileName, "TempVars");
else
SCI2Cerror('Unknow table: ""'+tmpnams+'"".');
end
diff --git a/scilab2c/macros/ToolInitialization/INIT_LoadLibraries.sci b/scilab2c/macros/ToolInitialization/INIT_LoadLibraries.sci index 35ff18af..1ef9ee00 100644 --- a/scilab2c/macros/ToolInitialization/INIT_LoadLibraries.sci +++ b/scilab2c/macros/ToolInitialization/INIT_LoadLibraries.sci @@ -42,7 +42,7 @@ PrintStepInfo('Load SCI2C and USER2C Libraries.',FileInfo.GeneralReport,'both'); // ----------------------------------
SCI2CAvailableC = [];
USER2CAvailableC = [];
-Converted = [];
+Converted = [];
ToBeConverted(1).SCIFunctionName = SharedInfo.NextSCIFunName;
ToBeConverted(1).CFunctionName = SharedInfo.NextCFunName;
@@ -55,10 +55,10 @@ ToBeConverted(1).CFunctionName = SharedInfo.NextCFunName; // --- Save .dat files. ---
Available = SCI2CAvailableC;
-save(FileInfo.FunctionList.SCI2CAvailableCDat,Available);
+save(FileInfo.FunctionList.SCI2CAvailableCDat, "Available");
Available = USER2CAvailableC;
-save(FileInfo.FunctionList.USER2CAvailableCDat,Available);
-save(FileInfo.FunctionList.ConvertedDat,Converted);
-save(FileInfo.FunctionList.ToBeConvertedDat,ToBeConverted);
+save(FileInfo.FunctionList.USER2CAvailableCDat, "Available");
+save(FileInfo.FunctionList.ConvertedDat, "Converted");
+save(FileInfo.FunctionList.ToBeConvertedDat, "ToBeConverted");
endfunction
diff --git a/scilab2c/macros/ToolInitialization/INIT_SCI2C.sci b/scilab2c/macros/ToolInitialization/INIT_SCI2C.sci index 00f25d88..8b3e5b2f 100644 --- a/scilab2c/macros/ToolInitialization/INIT_SCI2C.sci +++ b/scilab2c/macros/ToolInitialization/INIT_SCI2C.sci @@ -91,7 +91,7 @@ PrintStepInfo('SCI2C hArtes/POLIBA Tool!!!',FileInfo.GeneralReport,'file'); // --- Initialize GlobalVars. ---
// ------------------------------
GlobalVars = [];
-save(FileInfo.GlobalVarFileName,GlobalVars);
+save(FileInfo.GlobalVarFileName, "GlobalVars");
// ----------------------------------
// --- Initialize Main .dat file. ---
@@ -119,7 +119,7 @@ FunInfo.OutArg(1).Size(2) = ''; FunInfo.OutArg(1).Dimension = '';
FunInfo.PosFirstOutScalar = 0;
FunInfo.LibTypeInfo = 'USER2C';
-save(fullfile(FileInfo.FunctionList.FunInfoDatDir,FunInfo.CFunctionName+'.dat'),FunInfo);
+save(fullfile(FileInfo.FunctionList.FunInfoDatDir,FunInfo.CFunctionName+'.dat'), "FunInfo");
clear FunInfo
// -------------------------------------
@@ -130,14 +130,14 @@ clear ASTStack ASTStack.SCI2CSTACK = 'EMPTYSTACK';
ASTStack.StackPosition = 1;
ASTStack.STACKDEDUG = 0;
-save(FileInfo.ASTStackDataFile,ASTStack);
+save(FileInfo.ASTStackDataFile, "ASTStack");
clear ASTStack
// ---------------------------------------------
// --- Generate new versions of SCI2C files. ---
// ---------------------------------------------
-save(FileInfo.FileInfoDatFile,FileInfo);
-save(FileInfo.SharedInfoDatFile,SharedInfo);
+save(FileInfo.FileInfoDatFile, "FileInfo");
+save(FileInfo.SharedInfoDatFile, "SharedInfo");
FileInfoDatFile = FileInfo.FileInfoDatFile;
SharedInfoDatFile = FileInfo.SharedInfoDatFile;
diff --git a/scilab2c/macros/ToolInitialization/ManageNextConversion.sci b/scilab2c/macros/ToolInitialization/ManageNextConversion.sci index 68604213..04ec9dbc 100644 --- a/scilab2c/macros/ToolInitialization/ManageNextConversion.sci +++ b/scilab2c/macros/ToolInitialization/ManageNextConversion.sci @@ -54,8 +54,8 @@ if (SharedInfo.NFilesToTranslate >= 1) ToBeConverted(1) = [];
FlagContinueTranslation = 1;
SharedInfo.NextSCIFunName = ToBeConverted(1).SCIFunctionName;
- SharedInfo.NextCFunName = ToBeConverted(1).CFunctionName;
- SharedInfo.NextSCIFunNumber = SharedInfo.NextSCIFunNumber + 1;
+ SharedInfo.NextCFunName = ToBeConverted(1).CFunctionName;
+ SharedInfo.NextSCIFunNumber = SharedInfo.NextSCIFunNumber + 1;
[FlagFound,SharedInfo.NextSCIFileName] = ...
SCI2CFindFile(FileInfo.UserSciFilesPaths,SharedInfo.NextSCIFunName+'.sci');
if (FlagFound == 0)
@@ -71,11 +71,11 @@ end // --- Save section. ---
// ---------------------
// --- Save Shared Info Structure. ---
-save(FileInfo.SharedInfoDatFile,SharedInfo);
+save(FileInfo.SharedInfoDatFile, "SharedInfo");
clear SharedInfo
// --- Save ToBeConverted .dat file. ---
-save(FileInfo.FunctionList.ToBeConvertedDat,ToBeConverted);
+save(FileInfo.FunctionList.ToBeConvertedDat, "ToBeConverted");
clear ToBeConverted
clear FileInfo
diff --git a/scilab2c/macros/ToolInitialization/UpdateSCI2CInfo.sci b/scilab2c/macros/ToolInitialization/UpdateSCI2CInfo.sci index 32085475..445507bb 100644 --- a/scilab2c/macros/ToolInitialization/UpdateSCI2CInfo.sci +++ b/scilab2c/macros/ToolInitialization/UpdateSCI2CInfo.sci @@ -1,203 +1,203 @@ -function UpdateSCI2CInfo(FileInfoDatFile)
-// function UpdateSCI2CInfo(FileInfoDatFile)
-// -----------------------------------------------------------------
-// #RNU_RES_B
-// Updates the FileInfo struct according to the new scilab function
-// to be converted in C.
-//
-// Input data:
-// FileInfoDatFile: name of the .dat file containing the FileInfo structure.
-//
-// Output data:
-// ---
-//
-// #RNU_RES_E
-// Status:
-// 13-Apr-2007 -- Raffaele Nutricato: Author.
-//
-// Copyright 2007 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
-
-// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),1,1);
-
-// ---------------------------------
-// --- Load File Info Structure. ---
-// ---------------------------------
-clear FileInfo
-load(FileInfoDatFile,'FileInfo');
-
-// -----------------------------------
-// --- Load Shared Info Structure. ---
-// -----------------------------------
-clear SharedInfo
-load(FileInfo.SharedInfoDatFile,'SharedInfo');
-
-// ---------------------------------------------------
-// --- Extraction of the function name and number. ---
-// ---------------------------------------------------
-funname = SharedInfo.NextSCIFunName;
-funnumber = SharedInfo.NextSCIFunNumber;
-// #RNU_RES_B
-//NUT: sicuro che mi serve questa struttura? SharedInfo.NextSCIFunNumber cioe' il numero della funzione a che serve?
-// #RNU_RES_E
-PrintStepInfo('Start translation of function ""'+funname+'""',...
- FileInfo.GeneralReport,'both');
-
-// -----------------------------------
-// --- Update File Info structure. ---
-// -----------------------------------
-FileInfo.Funct(funnumber).Name = funname;
-FileInfo.Funct(funnumber).SCIFileName = SharedInfo.NextSCIFileName;
-FileInfo.Funct(funnumber).ASTFileName = fullfile(FileInfo.WorkingDir,funname,funname+'.ast');
-FileInfo.Funct(funnumber).CPass1FileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'_pass1.c');
-FileInfo.Funct(funnumber).PfxP1ForProlFileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'_pass1ProlFor');
-FileInfo.Funct(funnumber).PfxP1ForEpilFileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'_pass1EpilFor');
-FileInfo.Funct(funnumber).PfxP1WhileProlFileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'_pass1ProlWhile');
-FileInfo.Funct(funnumber).PfxP1WhileEpilFileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'_pass1EpilWhile');
-FileInfo.Funct(funnumber).CPass1FreeFileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'_pass1free.c');
-FileInfo.Funct(funnumber).CPass2FileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'_pass2.c');
-FileInfo.Funct(funnumber).Pass1HeaderFileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'.h');
-FileInfo.Funct(funnumber).FinalCFileName = fullfile(FileInfo.OutCCCodeDir,SharedInfo.NextCFunName+'.c');
-FileInfo.Funct(funnumber).FinalHeaderFileName = fullfile(FileInfo.OutCCCodeDir,SharedInfo.NextCFunName+'.h');
-FileInfo.Funct(funnumber).CInitVarsFileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'_initvars.c');
-FileInfo.Funct(funnumber).CDeclarationFileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'_declarations.c');
-FileInfo.Funct(funnumber).CGblDeclarFileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'_globaldeclarations.c');
-FileInfo.Funct(funnumber).ReportFileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'.rpt');
-FileInfo.Funct(funnumber).LocalVarFileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'_LOCVAR.dat');
-FileInfo.Funct(funnumber).TempVarFileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'_TMPVAR.dat');
-FileInfo.Funct(funnumber).SCICopyFileName = fullfile(FileInfo.WorkingDir,funname,funname+'_copy.sci');
-
-
-// -------------------------------------
-// --- Update Shared Info structure. ---
-// -------------------------------------
-SharedInfo.NIndent = 0; // Indentation Level. Useful to produce indentated C code.
-SharedInfo.SkipNextEqual = 0; // 1 = the next equal in the AST will not produce C code.
-SharedInfo.SkipNextPrec = 0; // 1 = the next precision specifier in the AST will not produce C code.
-SharedInfo.SkipNextFun = 0; // 1 = the next function in the AST will not produce C code.
-SharedInfo.ASTReader.fidAST = -1;
-SharedInfo.CountNestedIf = 0;
-SharedInfo.CountForTempVars = 0;
-SharedInfo.For.Level = 0;
-SharedInfo.ForExpr.OnExec = 0;
-SharedInfo.ForExpr.IntCntArg = [];
-SharedInfo.ForExpr.MtxValCntArg = [];
-SharedInfo.ForExpr.SclValCntArg = [];
-SharedInfo.ForExpr.OpColonInfoIn1 = '';
-SharedInfo.ForExpr.OpColonInfoIn2 = '';
-SharedInfo.ForExpr.OpColonInfoIn3 = '';
-SharedInfo.ForExpr.AssignmentFun = 0;
-
-SharedInfo.WhileExpr.OnExec = 0;
-SharedInfo.WhileExpr.CondVar = '';
-SharedInfo.WhileExpr.DimCondVar = -1;
-SharedInfo.While.Level = 0;
-//NUT: anche questa sarebbe da inizializzare con una bella funzione.
-
-
-SharedInfo.CFunId.OpColon = 3;
-SharedInfo.CFunId.EqScalar = 4;
-SharedInfo.CFunId.EqMatrix = 5;
-SharedInfo.CFunId.GenFunMtx = 6; // (scalar functions are fall in the scalar equal category.)
-
-SharedInfo = INIT_SharedInfoEqual(SharedInfo);
-
-// Contains the list of the C calls calls made in the current .sci file.
-SharedInfo.CFunctsAlreadyCalled = '_____________'; // Initialization with a dummy name
-
-// ---------------------------------------
-// --- Update Converted Function List. ---
-// ---------------------------------------
-Converted = FL_UpdateConverted(SharedInfo.NFilesToTranslate,FileInfo.FunctionList.ConvertedDat);
-
-// --------------------------------------
-// --- Create the function directory. ---
-// --------------------------------------
-rmdir(fullfile(FileInfo.WorkingDir,funname),'s');
-mkdir(FileInfo.WorkingDir,funname);
-
-// -----------------------------------------
-// --- Initialize Other FileInfo fields. ---
-// -----------------------------------------
-PrintStringInfo(' ',FileInfo.Funct(funnumber).SCICopyFileName,'file','y'); // Cannot use copyfile when the directory is empty!.
-SCI2Ccopyfile(FileInfo.Funct(funnumber).SCIFileName,FileInfo.Funct(funnumber).SCICopyFileName,'overwrite');
-
-FileInfo.Funct(funnumber).SCICopyFileFid = SCI2COpenFileRead(FileInfo.Funct(funnumber).SCICopyFileName);
-// Perform a dummy reading up to the function.
-//NUT: mettimi in una funzione.
-scicopyfid = FileInfo.Funct(funnumber).SCICopyFileFid;
-CPass1FileName = FileInfo.Funct(funnumber).CPass1FileName;
-IndentLevel = SharedInfo.NIndent;
-FoundFunctionKey = 0;
-PrintStringInfo(C_IndentBlanks(IndentLevel)+'/*',CPass1FileName,'file','y');
-PrintStringInfo(C_IndentBlanks(IndentLevel)+' SCI2C: ------------------------------------------------------------------',CPass1FileName,'file','y');
-while (~meof(scicopyfid) & (FoundFunctionKey==0))
- // Read a line from the scilab file
- sciline = mgetl(scicopyfid,1);
- noblkssciline = stripblanks(sciline);
- if (SCI2Cstrncmps1size('function',noblkssciline))
- FoundFunctionKey = 1;
- end
- PrintStringInfo(C_IndentBlanks(IndentLevel)+' SCI2C: '+sciline,CPass1FileName,'file','y');
-end
-PrintStringInfo(C_IndentBlanks(IndentLevel)+' SCI2C: ------------------------------------------------------------------',CPass1FileName,'file','y');
-PrintStringInfo(C_IndentBlanks(IndentLevel)+'*/',CPass1FileName,'file','y');
-
-// -------------------------
-// --- Initialize Files. ---
-// -------------------------
-PrintStringInfo(' ',FileInfo.Funct(funnumber).CDeclarationFileName,'file','y');
-PrintStringInfo(' ',FileInfo.Funct(funnumber).CGblDeclarFileName,'file','y');
-PrintStringInfo(' ',FileInfo.Funct(funnumber).CInitVarsFileName,'file','y');
-CPass1FreeFileName = FileInfo.Funct(funnumber).CPass1FreeFileName;
-PrintStringInfo(' ',CPass1FreeFileName,'file','y');
-PrintStringInfo(C_IndentBlanks(1)+'/*',CPass1FreeFileName,'file','y');
-PrintStringInfo(C_IndentBlanks(1)+'** --------------------- ',CPass1FreeFileName,'file','y');
-PrintStringInfo(C_IndentBlanks(1)+'** --- Free Section. --- ',CPass1FreeFileName,'file','y');
-PrintStringInfo(C_IndentBlanks(1)+'** --------------------- ',CPass1FreeFileName,'file','y');
-PrintStringInfo(C_IndentBlanks(1)+'*/',CPass1FreeFileName,'file','y');
-
-// -----------------------------------
-// --- Initialize Local/Temp Vars. ---
-// -----------------------------------
-LocalVars = [];
-TempVars = [];
-
-// ------------------------------------
-// --- Determine Default Precision. ---
-// ------------------------------------
-// For the current release only the following approaches are available:
-// 'NO_RESIZE'
-// 'REALLOC_ALL_RESIZE_ALL'
-SharedInfo.DefaultPrecision = ...
- FA_GetDefaultPrecision(FileInfo.Funct(funnumber).SCICopyFileName,FileInfo.Funct(funnumber).ReportFileName);
-
-// ----------------------------------
-// --- Determine Resize Approach. ---
-// ----------------------------------
-SharedInfo.ResizeApproach = FA_GetResizeApproach(FileInfo.Funct(funnumber).SCICopyFileName,FileInfo.Funct(funnumber).ReportFileName);
-
-// ---------------------
-// --- Save section. ---
-// ---------------------
-// --- Save File Info Structure. ---
-save(FileInfoDatFile,FileInfo);
-
-// --- Save File Info Structure. ---
-save(FileInfo.SharedInfoDatFile,SharedInfo);
-
-// --- Save Local/Temp Vars. ---
-save(FileInfo.Funct(funnumber).LocalVarFileName,LocalVars);
-save(FileInfo.Funct(funnumber).TempVarFileName,TempVars);
-
-// --- Save Converted .dat file. ---
-save(FileInfo.FunctionList.ConvertedDat,Converted);
-// -------------------------
-// --- End save section. ---
-// -------------------------
-
+function UpdateSCI2CInfo(FileInfoDatFile) +// function UpdateSCI2CInfo(FileInfoDatFile) +// ----------------------------------------------------------------- +// #RNU_RES_B +// Updates the FileInfo struct according to the new scilab function +// to be converted in C. +// +// Input data: +// FileInfoDatFile: name of the .dat file containing the FileInfo structure. +// +// Output data: +// --- +// +// #RNU_RES_E +// Status: +// 13-Apr-2007 -- Raffaele Nutricato: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),1,1); + +// --------------------------------- +// --- Load File Info Structure. --- +// --------------------------------- +clear FileInfo +load(FileInfoDatFile,'FileInfo'); + +// ----------------------------------- +// --- Load Shared Info Structure. --- +// ----------------------------------- +clear SharedInfo +load(FileInfo.SharedInfoDatFile,'SharedInfo'); + +// --------------------------------------------------- +// --- Extraction of the function name and number. --- +// --------------------------------------------------- +funname = SharedInfo.NextSCIFunName; +funnumber = SharedInfo.NextSCIFunNumber; +// #RNU_RES_B +//NUT: sicuro che mi serve questa struttura? SharedInfo.NextSCIFunNumber cioe' il numero della funzione a che serve? +// #RNU_RES_E +PrintStepInfo('Start translation of function ""'+funname+'""',... + FileInfo.GeneralReport,'both'); + +// ----------------------------------- +// --- Update File Info structure. --- +// ----------------------------------- +FileInfo.Funct(funnumber).Name = funname; +FileInfo.Funct(funnumber).SCIFileName = SharedInfo.NextSCIFileName; +FileInfo.Funct(funnumber).ASTFileName = fullfile(FileInfo.WorkingDir,funname,funname+'.ast'); +FileInfo.Funct(funnumber).CPass1FileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'_pass1.c'); +FileInfo.Funct(funnumber).PfxP1ForProlFileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'_pass1ProlFor'); +FileInfo.Funct(funnumber).PfxP1ForEpilFileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'_pass1EpilFor'); +FileInfo.Funct(funnumber).PfxP1WhileProlFileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'_pass1ProlWhile'); +FileInfo.Funct(funnumber).PfxP1WhileEpilFileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'_pass1EpilWhile'); +FileInfo.Funct(funnumber).CPass1FreeFileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'_pass1free.c'); +FileInfo.Funct(funnumber).CPass2FileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'_pass2.c'); +FileInfo.Funct(funnumber).Pass1HeaderFileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'.h'); +FileInfo.Funct(funnumber).FinalCFileName = fullfile(FileInfo.OutCCCodeDir,SharedInfo.NextCFunName+'.c'); +FileInfo.Funct(funnumber).FinalHeaderFileName = fullfile(FileInfo.OutCCCodeDir,SharedInfo.NextCFunName+'.h'); +FileInfo.Funct(funnumber).CInitVarsFileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'_initvars.c'); +FileInfo.Funct(funnumber).CDeclarationFileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'_declarations.c'); +FileInfo.Funct(funnumber).CGblDeclarFileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'_globaldeclarations.c'); +FileInfo.Funct(funnumber).ReportFileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'.rpt'); +FileInfo.Funct(funnumber).LocalVarFileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'_LOCVAR.dat'); +FileInfo.Funct(funnumber).TempVarFileName = fullfile(FileInfo.WorkingDir,funname,SharedInfo.NextCFunName+'_TMPVAR.dat'); +FileInfo.Funct(funnumber).SCICopyFileName = fullfile(FileInfo.WorkingDir,funname,funname+'_copy.sci'); + + +// ------------------------------------- +// --- Update Shared Info structure. --- +// ------------------------------------- +SharedInfo.NIndent = 0; // Indentation Level. Useful to produce indentated C code. +SharedInfo.SkipNextEqual = 0; // 1 = the next equal in the AST will not produce C code. +SharedInfo.SkipNextPrec = 0; // 1 = the next precision specifier in the AST will not produce C code. +SharedInfo.SkipNextFun = 0; // 1 = the next function in the AST will not produce C code. +SharedInfo.ASTReader.fidAST = -1; +SharedInfo.CountNestedIf = 0; +SharedInfo.CountForTempVars = 0; +SharedInfo.For.Level = 0; +SharedInfo.ForExpr.OnExec = 0; +SharedInfo.ForExpr.IntCntArg = []; +SharedInfo.ForExpr.MtxValCntArg = []; +SharedInfo.ForExpr.SclValCntArg = []; +SharedInfo.ForExpr.OpColonInfoIn1 = ''; +SharedInfo.ForExpr.OpColonInfoIn2 = ''; +SharedInfo.ForExpr.OpColonInfoIn3 = ''; +SharedInfo.ForExpr.AssignmentFun = 0; + +SharedInfo.WhileExpr.OnExec = 0; +SharedInfo.WhileExpr.CondVar = ''; +SharedInfo.WhileExpr.DimCondVar = -1; +SharedInfo.While.Level = 0; +//NUT: anche questa sarebbe da inizializzare con una bella funzione. + + +SharedInfo.CFunId.OpColon = 3; +SharedInfo.CFunId.EqScalar = 4; +SharedInfo.CFunId.EqMatrix = 5; +SharedInfo.CFunId.GenFunMtx = 6; // (scalar functions are fall in the scalar equal category.) + +SharedInfo = INIT_SharedInfoEqual(SharedInfo); + +// Contains the list of the C calls calls made in the current .sci file. +SharedInfo.CFunctsAlreadyCalled = '_____________'; // Initialization with a dummy name + +// --------------------------------------- +// --- Update Converted Function List. --- +// --------------------------------------- +Converted = FL_UpdateConverted(SharedInfo.NFilesToTranslate,FileInfo.FunctionList.ConvertedDat); + +// -------------------------------------- +// --- Create the function directory. --- +// -------------------------------------- +rmdir(fullfile(FileInfo.WorkingDir,funname),'s'); +mkdir(FileInfo.WorkingDir,funname); + +// ----------------------------------------- +// --- Initialize Other FileInfo fields. --- +// ----------------------------------------- +PrintStringInfo(' ',FileInfo.Funct(funnumber).SCICopyFileName,'file','y'); // Cannot use copyfile when the directory is empty!. +SCI2Ccopyfile(FileInfo.Funct(funnumber).SCIFileName,FileInfo.Funct(funnumber).SCICopyFileName,'overwrite'); + +FileInfo.Funct(funnumber).SCICopyFileFid = SCI2COpenFileRead(FileInfo.Funct(funnumber).SCICopyFileName); +// Perform a dummy reading up to the function. +//NUT: mettimi in una funzione. +scicopyfid = FileInfo.Funct(funnumber).SCICopyFileFid; +CPass1FileName = FileInfo.Funct(funnumber).CPass1FileName; +IndentLevel = SharedInfo.NIndent; +FoundFunctionKey = 0; +PrintStringInfo(C_IndentBlanks(IndentLevel)+'/*',CPass1FileName,'file','y'); +PrintStringInfo(C_IndentBlanks(IndentLevel)+' SCI2C: ------------------------------------------------------------------',CPass1FileName,'file','y'); +while (~meof(scicopyfid) & (FoundFunctionKey==0)) + // Read a line from the scilab file + sciline = mgetl(scicopyfid,1); + noblkssciline = stripblanks(sciline); + if (SCI2Cstrncmps1size('function',noblkssciline)) + FoundFunctionKey = 1; + end + PrintStringInfo(C_IndentBlanks(IndentLevel)+' SCI2C: '+sciline,CPass1FileName,'file','y'); +end +PrintStringInfo(C_IndentBlanks(IndentLevel)+' SCI2C: ------------------------------------------------------------------',CPass1FileName,'file','y'); +PrintStringInfo(C_IndentBlanks(IndentLevel)+'*/',CPass1FileName,'file','y'); + +// ------------------------- +// --- Initialize Files. --- +// ------------------------- +PrintStringInfo(' ',FileInfo.Funct(funnumber).CDeclarationFileName,'file','y'); +PrintStringInfo(' ',FileInfo.Funct(funnumber).CGblDeclarFileName,'file','y'); +PrintStringInfo(' ',FileInfo.Funct(funnumber).CInitVarsFileName,'file','y'); +CPass1FreeFileName = FileInfo.Funct(funnumber).CPass1FreeFileName; +PrintStringInfo(' ',CPass1FreeFileName,'file','y'); +PrintStringInfo(C_IndentBlanks(1)+'/*',CPass1FreeFileName,'file','y'); +PrintStringInfo(C_IndentBlanks(1)+'** --------------------- ',CPass1FreeFileName,'file','y'); +PrintStringInfo(C_IndentBlanks(1)+'** --- Free Section. --- ',CPass1FreeFileName,'file','y'); +PrintStringInfo(C_IndentBlanks(1)+'** --------------------- ',CPass1FreeFileName,'file','y'); +PrintStringInfo(C_IndentBlanks(1)+'*/',CPass1FreeFileName,'file','y'); + +// ----------------------------------- +// --- Initialize Local/Temp Vars. --- +// ----------------------------------- +LocalVars = []; +TempVars = []; + +// ------------------------------------ +// --- Determine Default Precision. --- +// ------------------------------------ +// For the current release only the following approaches are available: +// 'NO_RESIZE' +// 'REALLOC_ALL_RESIZE_ALL' +SharedInfo.DefaultPrecision = ... + FA_GetDefaultPrecision(FileInfo.Funct(funnumber).SCICopyFileName,FileInfo.Funct(funnumber).ReportFileName); + +// ---------------------------------- +// --- Determine Resize Approach. --- +// ---------------------------------- +SharedInfo.ResizeApproach = FA_GetResizeApproach(FileInfo.Funct(funnumber).SCICopyFileName,FileInfo.Funct(funnumber).ReportFileName); + +// --------------------- +// --- Save section. --- +// --------------------- +// --- Save File Info Structure. --- +save(FileInfoDatFile, "FileInfo"); + +// --- Save File Info Structure. --- +save(FileInfo.SharedInfoDatFile, "SharedInfo"); + +// --- Save Local/Temp Vars. --- +save(FileInfo.Funct(funnumber).LocalVarFileName, "LocalVars"); +save(FileInfo.Funct(funnumber).TempVarFileName, "TempVars"); + +// --- Save Converted .dat file. --- +save(FileInfo.FunctionList.ConvertedDat, "Converted"); +// ------------------------- +// --- End save section. --- +// ------------------------- + endfunction |