diff options
170 files changed, 8374 insertions, 4231 deletions
diff --git a/src/Scilab2C/Scilab2C/ASTManagement/%program_p.sci b/src/Scilab2C/Scilab2C/ASTManagement/%program_p.sci index 7ed7832a..931f1f17 100644 --- a/src/Scilab2C/Scilab2C/ASTManagement/%program_p.sci +++ b/src/Scilab2C/Scilab2C/ASTManagement/%program_p.sci @@ -148,9 +148,9 @@ function txt=%variable_string(v) else if (v.name == 'ans') anscounter = anscounter + 1; - txt=['Var: '+v.name+string(anscounter)]; + txt=['Variable: '+v.name+string(anscounter)]; else - txt=['Var: '+v.name]; + txt=['Variable: '+v.name]; end end endfunction diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST2Ccode.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST2Ccode.sci index 0bcd2556..4600f3c3 100644 --- a/src/Scilab2C/Scilab2C/ASTManagement/AST2Ccode.sci +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST2Ccode.sci @@ -1,6 +1,13 @@ function AST2Ccode(FileInfoDatFile) // function AST2Ccode(FileInfoDatFile) // ----------------------------------------------------------------- +// Read the AST and call the corresponding handlers. +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 11-May-2007 -- Raffaele Nutricato: Author. @@ -74,6 +81,9 @@ PrintStepInfo('Generate C code in '+FileInfo.Funct(nxtscifunnumber).FinalCFileNa // ------------------------ ASTHeader = AST_ReadASTHeader(fidAST,ReportFileName); SharedInfo = AST_HandleHeader(ASTHeader,FileInfo,SharedInfo); +//NUT: le metto per ora perche' quando provo a cercare lo specifier di precisione al termine +//NUT: del programma non ho piu' nulla da poppare se lo specifier e' assente. Al limite posso mettere la program e i nomi +//NUT: al posto di dummy. AST_PushASTStack('Dummy'); AST_PushASTStack('Dummy'); AST_PushASTStack('Dummy'); @@ -82,18 +92,25 @@ AST_PushASTStack('Dummy'); AST_PushASTStack('Dummy'); AST_PushASTStack('Dummy'); AST_PushASTStack('Dummy'); +//NUT: Se ne tolgo qualcuno ottengo errori // ---------------------------- // --- End Parse AST header. --- // ---------------------------- + //NUT: better to have a function. + // --- Reset TempVars Structure. --- TempVars = []; + // Reset info related to temp variables used in the C code. 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; // ---------------------------------- // --- Main loop to read the AST. --- // ---------------------------------- +//NUT: file ottenuto con m2sci se hai tempo prova a vedere se ci sono inesattezze. +//NUT: inoltre per maggiore eleganza si puo' pensare di introdurre piu' funzioni while ~meof(fidAST) // Read a line from the AST @@ -111,6 +128,8 @@ while ~meof(fidAST) // ------------------ // --- 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 [FileInfo,SharedInfo] = AST_HandleEndGenFun(FileInfo,SharedInfo,'Operation'); case 'EndFuncall' then @@ -120,6 +139,10 @@ while ~meof(fidAST) // --- Equal. --- // -------------- 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 @@ -140,7 +163,6 @@ while ~meof(fidAST) // ---------------- //NUT: da verificare la gestione dello stack case 'If Statements' then - error('IF NOT SUPPORTED YET'); [FileInfo,SharedInfo] = AST_HandleIfElse(FileInfo,SharedInfo,'if'); case 'Else If Expression' then AST_PushASTStack(treeline); @@ -168,12 +190,13 @@ while ~meof(fidAST) // ----------------- case 'EndProgram' SharedInfo = AST_HandleEndProgram(FileInfo,SharedInfo); + //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 - error('FOR NOT SUPPORTED YET'); SharedInfo.For.Level = SharedInfo.For.Level + 1; FileInfo = AST_HandleFor(FileInfo,SharedInfo); case 'ForExpression:' @@ -189,7 +212,6 @@ while ~meof(fidAST) // --- While. --- // -------------- case 'While' then - error('WHILE NOT SUPPORTED YET'); AST_PushASTStack(treeline); SharedInfo.While.Level = SharedInfo.While.Level + 1; case 'WhileExpression:' diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_CheckCommonInOutArgs.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_CheckCommonInOutArgs.sci index f4593253..952514cc 100644 --- a/src/Scilab2C/Scilab2C/ASTManagement/AST_CheckCommonInOutArgs.sci +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_CheckCommonInOutArgs.sci @@ -1,6 +1,20 @@ function AST_CheckCommonInOutArgs(InArg,NInArg,OutArg,NOutArg,ReportFileName) // function AST_CheckCommonInOutArgs(InArg,NInArg,OutArg,NOutArg,ReportFileName) // ----------------------------------------------------------------- +// #RNU_RES_B +// Compares input and output arguments names and issues and error +// when at least one output argument is equal to the one of the +// input arguments. The error is issued only when the common argument +// is not a scalar value. This is a safe approach that prevents error +// when the same matrix is used as both input and output argument of +// a function. +// #RNU_RES_E +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 08-Jan-2008 -- Raffaele Nutricato: Author. @@ -17,6 +31,10 @@ SCI2CNInArgCheck(argn(2),5,5); ncommonstrings = 0; commonstrings = ''; +//RNU non mi ricordo per quale motivo avevo commentato il seguente codice +//RNU e decommentato l'altro a seguire. Sembra che avessi deciso che anche +//RNU le variabili scalari non potessero essere usate nella stessa expr +//RNU contemporaneamente come input e come output for cnt1 = 1:NInArg for cnt2 = 1:NOutArg if ((InArg(cnt1).Name == OutArg(cnt2).Name) & ... @@ -27,6 +45,14 @@ for cnt1 = 1:NInArg end end +// for cnt1 = 1:NInArg +// for cnt2 = 1:NOutArg +// if ((InArg(cnt1).Name == OutArg(cnt2).Name)) +// ncommonstrings = ncommonstrings + 1; +// commonstrings(ncommonstrings) = InArg(cnt1).Name; +// end +// end +// end if (ncommonstrings > 0) PrintStringInfo(' ',ReportFileName,'both','y'); diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_CheckLastFunc.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_CheckLastFunc.sci index 35e0d239..0fff6b22 100644 --- a/src/Scilab2C/Scilab2C/ASTManagement/AST_CheckLastFunc.sci +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_CheckLastFunc.sci @@ -1,6 +1,13 @@ function [LhsArgNames,LhsArgScope,NLhsArg] = AST_CheckLastFunc(fidAST,SearchLevel) // function [LhsArgNames,LhsArgScope,NLhsArg] = AST_CheckLastFunc(fidAST,SearchLevel) // ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 11-Apr-2007 -- Raffaele Nutricato: Author. @@ -27,6 +34,9 @@ FlagLastFunc = 0; // --- End Initialization. --- // --------------------------- +//NUT: non capisco come mai tu non faccia il flipud degli argometi letti. +//NUT: Level 1 e' quando abbiamo una equal float fun +//NUT: level 0 quando abbiamo equal fun tline = mgetl(fidAST,1); AST_CheckLineLength(tline); LhsField = stripblanks(tline); @@ -48,6 +58,8 @@ if ((SearchLevel == 0) & (LhsField == 'Lhs :')) SCI2Cerror('Found EndProgram before EndEqual'); end if (LhsField == 'Operation') + // if (LhsField == 'Operator: ins') + // It means that we have to store the results of the function in temp vars. LhsField = 'EndEqual'; // Force the exit from the while. NLhsArg = 0; LhsArgNames = ''; diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_CheckLineLength.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_CheckLineLength.sci index 2936a306..882133a9 100644 --- a/src/Scilab2C/Scilab2C/ASTManagement/AST_CheckLineLength.sci +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_CheckLineLength.sci @@ -1,6 +1,14 @@ function AST_CheckLineLength(instring) // function AST_CheckLineLength(instring) // ----------------------------------------------------------------- +// "Fixes" the AST generator bug. When a line of code is greater +// than 80 chars the generated AST is wrong. +// +// Input data: +// instring: string read from the AST. +// +// Output data: +// --- // // Status: // 15-May-2008 -- Raffaele Nutricato: Author. diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_CheckPrecSpecifier.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_CheckPrecSpecifier.sci index 83e881b4..e8ffbf1f 100644 --- a/src/Scilab2C/Scilab2C/ASTManagement/AST_CheckPrecSpecifier.sci +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_CheckPrecSpecifier.sci @@ -1,6 +1,20 @@ function AnnotationFnc = AST_CheckPrecSpecifier(FunctionName,FileInfo,SharedInfo); // function AnnotationFnc = AST_CheckPrecSpecifier(FunctionName,FileInfo,SharedInfo); // ----------------------------------------------------------------- +// #RNU_RES_B +// Searches for one of the following data annotation functions: +// Funcall : int +// Funcall : float +// Funcall : double +// Note: remember to execute this function before pushing the output +// argument names into the stack. +// #RNU_RES_E +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 13-Apr-2007 -- Raffaele Nutricato: Author. @@ -21,8 +35,10 @@ nxtscifunname = SharedInfo.NextSCIFunName; nxtscifunnumber = SharedInfo.NextSCIFunNumber; ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; PrintStringInfo(' ',ReportFileName,'file','y'); - +// #RNU_RES_B +PrintStringInfo(' Checking presence of precision specifier',ReportFileName,'file','y'); //NUT: da sistemare senza le global +// #RNU_RES_E global SCI2CSTACK global StackPosition; global STACKDEDUG @@ -43,11 +59,24 @@ if (mtlb_strcmp(stripblanks(Pop1),'Rhs :')) AnnotationFnc = FunctionName; end end + // --- Repush strings into the AST stack. --- AST_PushASTStack(Pop3); end + // --- Repush strings into the AST stack. --- AST_PushASTStack(Pop2); end +// --- Repush strings into the AST stack. --- AST_PushASTStack(Pop1); +if mtlb_strcmp(AnnotationFnc,'default') + // #RNU_RES_B + PrintStringInfo('Function is not annotated',ReportFileName,'file','y'); + PrintStringInfo('The ""'+SharedInfo.DefaultPrecision+'"" default precision will be used.',ReportFileName,'file','y'); + // #RNU_RES_E +else + // #RNU_RES_B + PrintStringInfo('Function is annotated with ""'+AnnotationFnc+'"" specifier',ReportFileName,'file','y'); + // #RNU_RES_E +end endfunction diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_DisplayStack.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_DisplayStack.sci index b4e89a21..8543e2e0 100644 --- a/src/Scilab2C/Scilab2C/ASTManagement/AST_DisplayStack.sci +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_DisplayStack.sci @@ -1,6 +1,15 @@ function AST_DisplayStack() // function AST_DisplayStack() // ----------------------------------------------------------------- +// Displays the AST stack content. The AST stack is used to read the +// AST. +// +// Input data: +// --- +// +// Output data: +// //NUT: add description here +// // Status: // 11-Apr-2007 -- Raffaele Nutricato: Author. // diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_ExtractNameAndScope.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_ExtractNameAndScope.sci index c2564714..7e71f75a 100644 --- a/src/Scilab2C/Scilab2C/ASTManagement/AST_ExtractNameAndScope.sci +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_ExtractNameAndScope.sci @@ -1,5 +1,13 @@ function [ArgName,ArgScope] = AST_ExtractNameAndScope(ASTField) // ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// // Status: // 27-Dec-2007 -- Raffaele Nutricato: Author. // @@ -28,7 +36,7 @@ tagname(cnttag) = 'String:'; taglength(cnttag) = length(tagname(cnttag)); cnttag = cnttag + 1; -tagname(cnttag) = 'Var:'; +tagname(cnttag) = 'Variable:'; taglength(cnttag) = length(tagname(cnttag)); cnttag = cnttag + 1; @@ -49,7 +57,14 @@ taglength(cnttag) = length(tagname(cnttag)); fieldlength = length(ASTField); +//NUT: il seguente codice e' poco elegante. if (SCI2Cstrncmps1size(tagname(1),ASTField)) + // Here we can have: + // Number_x: it means default precision. + // Number_s: it means float real type. + // Number_d: it means double real type. + // Number_c: it means float complex type. + // Number_z: it means double complex type. ArgName = stripblanks(part(ASTField,taglength(1)+3:fieldlength)); ArgScope = stripblanks(part(ASTField,1:taglength(1)+1)); elseif (SCI2Cstrncmps1size(tagname(2),ASTField)) @@ -58,7 +73,7 @@ elseif (SCI2Cstrncmps1size(tagname(2),ASTField)) ArgScope = 'String'; elseif (SCI2Cstrncmps1size(tagname(3),ASTField)) ArgName = stripblanks(part(ASTField,taglength(3)+1:fieldlength)); - ArgScope = 'Var'; + ArgScope = 'Variable'; elseif (SCI2Cstrncmps1size(tagname(4),ASTField)) ArgName = stripblanks(part(ASTField,taglength(4)+1:fieldlength)); ArgScope = 'Global'; diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_GetASTFile.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_GetASTFile.sci index 91e5dd0b..025aca74 100644 --- a/src/Scilab2C/Scilab2C/ASTManagement/AST_GetASTFile.sci +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_GetASTFile.sci @@ -1,6 +1,15 @@ function AST_GetASTFile(FileInfoDatFile) // function AST_GetASTFile(FileInfoDatFile) // ----------------------------------------------------------------- +// Generates the AST file starting from the .sci file specified +// in SharedInfo.NextSCIFileName. +// +// Input data: +// FileInfoDatFile: name of the .dat file containing the FileInfo structure. +// +// Output data: +// --- +// // Status: // 11-Apr-2007 -- Raffaele Nutricato: Author. // @@ -34,6 +43,7 @@ funnumber = SharedInfo.NextSCIFunNumber; PrintStepInfo('Generate the AST in '+FileInfo.Funct(funnumber).ASTFileName,... FileInfo.GeneralReport,'both'); +// --- Generation of the AST file. --- SciFile2ASTFile(FileInfo.Funct(funnumber).SCIFileName,... FileInfo.Funct(funnumber).ASTFileName); diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_GetFuncallPrm.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_GetFuncallPrm.sci index e97f0bfa..aa5ab62c 100644 --- a/src/Scilab2C/Scilab2C/ASTManagement/AST_GetFuncallPrm.sci +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_GetFuncallPrm.sci @@ -3,6 +3,13 @@ function [FunctionName,InArg,NInArg,OutArg,NOutArg] = ... // function [FunctionName,InArg,NInArg,NOutArg] = ... // AST_GetFuncallPrm(FileInfo,SharedInfo,ASTFunType) // ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 11-Apr-2007 -- Raffaele Nutricato: Author. @@ -22,12 +29,18 @@ SCI2CNInArgCheck(argn(2),3,3); nxtscifunname = SharedInfo.NextSCIFunName; nxtscifunnumber = SharedInfo.NextSCIFunNumber; ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; +//#RNU_RES_B +PrintStringInfo('***Retrieving '+ASTFunType+' Parameters from AST***',ReportFileName,'file','y'); +//#RNU_RES_E OutArg = []; NOutArg = 0; // --------------------------- // --- End Initialization. --- // --------------------------- +// ------------------------------------------------------ +// --- Get Parameters from the AST Funcall structure. --- +// ------------------------------------------------------ if (ASTFunType=='Funcall') [FunctionName,InArg,NInArg,NOutArg] = AST_ParseFuncallStruct(FileInfo,SharedInfo); elseif (ASTFunType=='Operation') diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_GetPrecAndLhsArg.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_GetPrecAndLhsArg.sci index 10b3cc4e..feb8a6ec 100644 --- a/src/Scilab2C/Scilab2C/ASTManagement/AST_GetPrecAndLhsArg.sci +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_GetPrecAndLhsArg.sci @@ -1,6 +1,13 @@ function [LhsArg,NLhsArg,PrecisionSpecifier,SharedInfo] = AST_GetPrecAndLhsArg(OutArg,NOutArg,FunctionName,FunTypeAnnot,FunSizeAnnot,ASTFunType,FileInfo,SharedInfo); // function [LhsArg,NLhsArg,PrecisionSpecifier,SharedInfo] = AST_GetPrecAndLhsArg(OutArg,NOutArg,FunctionName,FunTypeAnnot,FunSizeAnnot,ASTFunType,FileInfo,SharedInfo); // ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 11-Apr-2007 -- Raffaele Nutricato: Author. @@ -20,13 +27,18 @@ SCI2CNInArgCheck(argn(2),8,8); nxtscifunname = SharedInfo.NextSCIFunName; nxtscifunnumber = SharedInfo.NextSCIFunNumber; ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; +// #RNU_RES_B +PrintStringInfo('***Search for Equal Lhs and precision specifier to be applied to the current function.***',ReportFileName,'file','y'); +// #RNU_RES_E // --------------------------- // --- End Initialization. --- // --------------------------- +// #RNU_RES_B // --------------------------------------- // --- Search for Precision Specifier. --- // --------------------------------------- +// #RNU_RES_E if (NOutArg == 1 & FunTypeAnnot == 'FA_TP_USER') PrecisionSpecifier = AST_CheckPrecSpecifier(FunctionName,FileInfo,SharedInfo); if (PrecisionSpecifier == 'default') @@ -40,7 +52,16 @@ else SearchLevel = 0; end +// #RNU_RES_B +// ------------------------------------------------------------- +// --- Check Last Function Condition and update LhsArg info. --- +// ------------------------------------------------------------- +// #RNU_RES_E if (ASTFunType~='Equal') + // #RNU_RES_B + PrintStringInfo(' ',ReportFileName,'file','y'); + PrintStringInfo(' Checking presence of Equal after the current function...',ReportFileName,'file','y'); + // #RNU_RES_E [LhsArgNames,LhsArgScope,NLhsArg] = AST_CheckLastFunc(SharedInfo.ASTReader.fidAST,SearchLevel); else LhsArgNames = ''; @@ -48,18 +69,31 @@ else NLhsArg = 0; end +// --- Generate the LhsArg structure. --- LhsArg = []; for cntarg = 1:NLhsArg LhsArg(cntarg).Name = LhsArgNames(cntarg); LhsArg(cntarg).Scope = LhsArgScope(cntarg); end +// #RNU_RES_B +// ------------------------- +// --- Check on NLhsArg. --- +// ------------------------- +// #RNU_RES_E if (NLhsArg > 0) + // #RNU_RES_B + PrintStringInfo('...Found Equal.',ReportFileName,'file','y'); + PrintStringInfo('OutArg Names will be replaced with Lhs Names of the Equal.',ReportFileName,'file','y'); + // #RNU_RES_E SharedInfo.SkipNextEqual = 1; // 1 = the next equal in the AST will not produce C code. if (NLhsArg ~= NOutArg) SCI2CerrorFile('NLhsArg='+string(NLhsArg)+' must be equal to NOutArg='+string(NOutArg)+'.',ReportFileName); end else + // #RNU_RES_B + PrintStringInfo('...Equal not found.',ReportFileName,'file','y'); + // #RNU_RES_E end endfunction diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleEOL.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleEOL.sci index 00872e22..286bab7b 100644 --- a/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleEOL.sci +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleEOL.sci @@ -1,6 +1,13 @@ function AST_HandleEOL(FileInfo,SharedInfo) // function AST_HandleEOL(FileInfo,SharedInfo) // ----------------------------------------------------------------- +// Handles the EOL tag of the AST. +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 11-Apr-2007 -- Raffaele Nutricato: Author. @@ -15,10 +22,12 @@ function AST_HandleEOL(FileInfo,SharedInfo) SCI2CNInArgCheck(argn(2),2,2); +//#RNU_RES_B //NUT: questa parte e' molto interessante perche' ti puo' aiutare per fare confronti //NUT: incrociati tra le annotazioni della funzione e gli argomenti in uscita. //NUT: in particolare una volta messi nella tabella dei simboli anche gli argomenti //NUT: di uscita puoi benissimo verificare che li stai utilizzando bene nel corpo della funzione stessa. +//#RNU_RES_E // ----------------------- // --- Initialization. --- @@ -33,6 +42,14 @@ 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'); +// #RNU_RES_E PrintStringInfo(' ',CPass1FileName,'file','y'); modeprintstringinfo = 'stdout'; if (SharedInfo.CopySciCodeIntoCCode == 1) diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleEndFor.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleEndFor.sci new file mode 100644 index 00000000..dc6c4126 --- /dev/null +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleEndFor.sci @@ -0,0 +1,78 @@ +function SharedInfo = AST_HandleEndFor(FileInfo,SharedInfo) +// function SharedInfo = AST_HandleEndFor(FileInfo,SharedInfo) +// ----------------------------------------------------------------- +// #RNU_RES_B +// Handles the EndFor tag of the AST. +// 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) +// txt=['For' +// ' ForExpression:' +// ' '+string(F.expression) +// ' ForStatements:' +// ' '+objectlist2string(F.statements) +// 'EndFor'] +// +// #RNU_RES_E +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 15-Nov-2007 -- Raffaele Nutricato: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),2,2); + +// ----------------------- +// --- Initialization. --- +// ----------------------- +nxtscifunname = SharedInfo.NextSCIFunName; +nxtscifunnumber = SharedInfo.NextSCIFunNumber; + +ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; +CPass1FileName = FileInfo.Funct(nxtscifunnumber).CPass1FileName; +CPass1ForProlFileName = FileInfo.Funct(nxtscifunnumber).CPass1ForProlFileName(SharedInfo.For.Level); +CPass1ForEpilFileName = FileInfo.Funct(nxtscifunnumber).CPass1ForEpilFileName(SharedInfo.For.Level); + +PrintStringInfo(' ',ReportFileName,'file','y'); +PrintStringInfo('***Handling EndFor***',ReportFileName,'file','y'); +CCall =''; +// --------------------------- +// --- End Initialization. --- +// --------------------------- + +// ---------------------------- +// --- Generate the C code. --- +// ---------------------------- +// --- Copy Epilogue into C code (Pass1) file. --- +[CLinesArray,N_Lines] = File2StringArray(CPass1ForEpilFileName); +CLinesArray = stripblanks(CLinesArray); + +for tmpcnt = 1:N_Lines-1 + PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+CLinesArray(tmpcnt),CPass1FileName,'file','y'); +end +PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent-1)+CLinesArray(N_Lines),CPass1FileName,'file','y'); + +// -------------------------- +// --- Update SharedInfo. --- +// -------------------------- +SharedInfo.NIndent = SharedInfo.NIndent - 1; + +// ------------------------------- +// --- Delete temporary files. --- +// ------------------------------- +SCI2Cmdelete(FileInfo.Funct(nxtscifunnumber).CPass1ForEpilFileName(SharedInfo.For.Level)); + +endfunction diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleEndGenFun.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleEndGenFun.sci index d57089a6..2bc31969 100644 --- a/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleEndGenFun.sci +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleEndGenFun.sci @@ -1,6 +1,29 @@ function [FileInfo,SharedInfo] = AST_HandleEndGenFun(FileInfo,SharedInfo,ASTFunType) // function [FileInfo,SharedInfo] = AST_HandleEndGenFun(FileInfo,SharedInfo,ASTFunType) // ----------------------------------------------------------------- +// #RNU_RES_B +// Handles the EndFuncall, EndOperation and EndEqual tags of the AST. +// ASTFunType can be 'Funcall', 'Operation', 'Equal' +// Structure of Funcall: +// overloading function for "funcall" type tlist string function +// this is a node of the AST +// fields: +// rhs : a list +// name : string, the name of the function +// lhsnb: number, the number of function lhs +// txt=['Funcall : '+F.name +// ' #lhs : '+string(F.lhsnb) +// ' Rhs : ' +// ' '+objectlist2string(F.rhs) +// 'EndFuncall' +// ] +// #RNU_RES_E +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 11-Apr-2007 -- Raffaele Nutricato: Author. @@ -22,10 +45,12 @@ nxtscifunnumber = SharedInfo.NextSCIFunNumber; ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; Pass1HeaderFileName = FileInfo.Funct(nxtscifunnumber).Pass1HeaderFileName; FunInfoDatDir = FileInfo.FunctionList.FunInfoDatDir; +CGblDeclarFileName = FileInfo.Funct(nxtscifunnumber).CGblDeclarFileName; Flag_FunAlreadyCalled = 0; +// #RNU_RES_B PrintStepInfo('Handling Funcall/Operation/Equal',FileInfo.Funct(nxtscifunnumber).ReportFileName,'file'); - +// #RNU_RES_E //NUT: da sistemare senza le global global SCI2CSTACK global StackPosition; @@ -34,21 +59,25 @@ global STACKDEDUG // --- End Initialization. --- // --------------------------- +// #RNU_RES_B // --------------------------------------------- // --- Retrieve FunCall Parameters from AST. --- // --------------------------------------------- //NUT: verifica se ASTFunType e' veramente importante +// #RNU_RES_E [ASTFunName,InArg,NInArg,OutArg,NOutArg] = AST_GetFuncallPrm(FileInfo,SharedInfo,ASTFunType); if (ASTFunName == 'OpIns') SharedInfo.SkipNextEqual = 1; SharedInfo.Equal.Nins = SharedInfo.Equal.Nins + 1; //NUT: Force ins to have 0 args. Double check it. NOutArg = 0; + // #RNU_RES_B //NUT: io aumenterei qui gli argomenti in ingresso della ins cosi qui vengono fatte tutte le modifiche del //NUT: caso e la C_FunCall non se ne deve preoccupare, vedi se lo stesso vale per le altre funzioni //NUT: speciali presenti nell C_FunCall. - + // 1 more input argument containing the values to be inserted in the matrix. + // #RNU_RES_E NInArg = NInArg + 1; InArg(NInArg).Name = SharedInfo.Equal.InArg(SharedInfo.Equal.Nins).Name; InArg(NInArg).Scope = SharedInfo.Equal.InArg(SharedInfo.Equal.Nins).Scope; @@ -75,9 +104,11 @@ elseif (ASTFunName == 'global') end end +// #RNU_RES_B // -------------------------------------- // --- Read the function annotations. --- // -------------------------------------- +// #RNU_RES_E if (ASTFunName == 'OpEqual') FunTypeAnnot = ''; FunSizeAnnot = ''; @@ -85,16 +116,20 @@ else [FunTypeAnnot,FunSizeAnnot] = FA_GetFunAnn(NInArg,NOutArg,ASTFunName,FileInfo,SharedInfo); end +// #RNU_RES_B // ------------------------------------------------------------------------------------------- // --- Search for Equal Lhs and precision specifier to be applied to the current function. --- // ------------------------------------------------------------------------------------------- +// #RNU_RES_E [LhsArg,NLhsArg,FunPrecSpecifier,SharedInfo] = AST_GetPrecAndLhsArg(OutArg,NOutArg,ASTFunName,FunTypeAnnot,FunSizeAnnot,ASTFunType,FileInfo,SharedInfo); //NUT: questa funzione contiene troppi parametri e mi sembra disordinata. +// #RNU_RES_B // -------------------------------- // --- Input Arguments Section. --- // -------------------------------- // --- Get Input Arguments info from their numerical value or from the symbol table. --- +// #RNU_RES_E if (ASTFunName == 'global') [TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension,TBScope] = ... ST_GetSymbolInfo(InArg(1).Name,FileInfo,SharedInfo); @@ -105,10 +140,15 @@ if (ASTFunName == 'global') InArg(1).FindLike = TBFindLike; InArg(1).Dimension = TBDimension; InArg(1).Scope = TBScope; + IndentLevelGlobal = 0; //NUT: forced always to 1 + FlagExt = 1; + C_GenDeclarations(InArg(1),CGblDeclarFileName,IndentLevelGlobal,ReportFileName,FlagExt,SharedInfo.ResizeApproach); else + // #RNU_RES_B // That means it is the first time we encounter // this global variable and in C this means that // we don't have to do nothing. + // #RNU_RES_E // SharedInfo.SkipNextFun = SharedInfo.SkipNextFun + 1; SharedInfo.SkipNextFun = 1; @@ -120,6 +160,19 @@ if (ASTFunName == 'global') InArg(1).Dimension = %nan; InArg(1).Scope = 'Global'; + // #RNU_RES_B + PrintStringInfo('***Putting global variable in the symbol table***',ReportFileName,'file','y'); + PrintStringInfo(' Symbol ""'+InArg(1).Name+'""',ReportFileName,'file','y'); + + PrintStringInfo(' Type: '+InArg(1).Type,ReportFileName,'file','y'); + PrintStringInfo(' Size(1): '+string(InArg(1).Size(1)),ReportFileName,'file','y'); + PrintStringInfo(' Size(2): '+string(InArg(1).Size(2)),ReportFileName,'file','y'); + PrintStringInfo(' Value: '+string(InArg(1).Value),ReportFileName,'file','y'); + PrintStringInfo(' FindLike: '+string(InArg(1).FindLike),ReportFileName,'file','y'); + PrintStringInfo(' Dimension: '+string(InArg(1).Dimension),ReportFileName,'file','y'); + PrintStringInfo(' Scope: '+string(InArg(1).Scope),ReportFileName,'file','y'); + PrintStringInfo(' ',ReportFileName,'file','y'); + // #RNU_RES_E ST_Set(InArg(1).Name,... InArg(1).Type,... @@ -133,10 +186,41 @@ else [InArg,SharedInfo] = ST_GetInArgInfo(InArg,NInArg,FileInfo,SharedInfo); end +// #RNU_RES_B +// ------------------------------------------------------------------- +// --- Change info of Input Argument according to resize approach. --- +// ------------------------------------------------------------------- +//RNU toglimi nella versione da dare ad hartes. +//RNU per ora gestisco solo la resize all con tutte realloc. +//RNU global variables are still coded with fixed size. +// #RNU_RES_E +if (SharedInfo.ResizeApproach=='REALLOC_ALL_RESIZE_ALL') + for cntin = 1:NInArg + if ((InArg(cntin).Dimension > 0)) + // if ((InArg(cntin).Dimension > 0) & (InArg(cntin).Scope ~= 'Global')) + InArg(cntin).Size(1) = '__'+InArg(cntin).Name+'Size[0]'; + InArg(cntin).Size(2) = '__'+InArg(cntin).Name+'Size[1]'; + end + //#RNUREM_MERNU vedi se la seguente fa casino l'ho aggiunta in modo che agia=ones(1,3) sia generata come realloc ma non ho verificato. + tmpscope = InArg(cntin).Scope; + lengthNumber = length('Number_'); + if (part(tmpscope,1:lengthNumber) == 'Number_') + //#RNUREM_ME RNU il problema e' che ones(3,1) allora l'output e' 3,1 e come faccio a trasformare 3 e 1 in simboli in modo tale che realloco anziche' allocare + InArg(cntin).Value = %nan; //RNU non va bene dove per esempio hai problemi di 1:3:4 se al posto dei numeri metti nan ti impalli + //#RNUREM_ME Credo che dove c'e' uan allocazione secca ones(3,1) non vada lasciata cosi' ma tutto vada ricondotto a realloc + //#RNUREM_ME quindi devo vedere nella dichiarazione delle variabili come forzare la dichiarazione dei null pointer. + //#RNUREM_ME successivamente devo vedere come fare a riscrivere la size dell'output. + else + end + end +end + +// #RNU_RES_B // --------------------------------- // --- Output Arguments Section. --- // --------------------------------- // --- Update Out arg structure with info stored in the function annotations. --- +// #RNU_RES_E if (ASTFunName == 'OpEqual') for cntin = 1:NInArg OutArg(cntin).Type = InArg(cntin).Type; @@ -148,9 +232,11 @@ if (ASTFunName == 'OpEqual') //NUT: per ora lo scope viene settato da AST_ParseEqualStruct end elseif ((ASTFunName == 'OpMinus') & (NInArg == 1) & (InArg(1).Dimension == 0)&(InArg(1).Scope == 'Number')) + // #RNU_RES_B // --- Manage OpMinus when applied to scalars. --- // -1 is not translated as tmp = OpMinus(1), but // it is considered as a single entity "-1" + // #RNU_RES_E SharedInfo.SkipNextFun = 1; //RN: SISTEMAMI OutArg(1).Type = InArg(1).Type; OutArg(1).Size = InArg(1).Size; @@ -159,9 +245,11 @@ elseif ((ASTFunName == 'OpMinus') & (NInArg == 1) & (InArg(1).Dimension == 0)&(I OutArg(1).FindLike = InArg(1).FindLike; OutArg(1).Scope = 'Number_'+InArg(1).Type; elseif ((ASTFunName == 'float') & (NInArg == 1) & (InArg(1).Dimension == 0) & (InArg(1).Scope == 'Number')) + // #RNU_RES_B // --- Manage OpMinus when applied to scalars. --- // -1 is not translated as tmp = OpMinus(1), but // it is considered as a single entity "-1" + // #RNU_RES_E SharedInfo.SkipNextFun = 1; //RN: SISTEMAMI OutArg(1).Type = InArg(1).Type; OutArg(1).Size = InArg(1).Size; @@ -170,9 +258,11 @@ elseif ((ASTFunName == 'float') & (NInArg == 1) & (InArg(1).Dimension == 0) & (I OutArg(1).FindLike = InArg(1).FindLike; OutArg(1).Scope = 'Number_s'; elseif ((ASTFunName == 'double') & (NInArg == 1) & (InArg(1).Dimension == 0) & (InArg(1).Scope == 'Number')) + // #RNU_RES_B // --- Manage OpMinus when applied to scalars. --- // -1 is not translated as tmp = OpMinus(1), but // it is considered as a single entity "-1" + // #RNU_RES_E SharedInfo.SkipNextFun = 1; //RN: SISTEMAMI SharedInfo.SkipNextFun = 1; //RN: SISTEMAMI @@ -186,8 +276,10 @@ else OutArg = FA_GetOutArgInfo(InArg,NInArg,OutArg,NOutArg,SharedInfo,FunPrecSpecifier,FunTypeAnnot,FunSizeAnnot,ReportFileName); end +// #RNU_RES_B // --- Generate the names for the output arguments. --- // Update of OutArg.Name and OutArg.Scope fields. +// #RNU_RES_E if ((ASTFunName == 'OpMinus') & (NInArg == 1) & (InArg(1).Dimension == 0) & (InArg(1).Scope == 'Number')) OutArg(1).Name = string(OutArg(1).Value); elseif ((ASTFunName == 'float') & (NInArg == 1) & (InArg(1).Dimension == 0) & (InArg(1).Scope == 'Number')) @@ -198,19 +290,26 @@ else [OutArg,SharedInfo] = GenOutArgNames(ASTFunName,InArg,NInArg,OutArg,NOutArg,LhsArg,NLhsArg,FileInfo,SharedInfo); end +// #RNU_RES_B // --- Push in the AST stack the Output arguments. --- +// #RNU_RES_E if (ASTFunName == 'OpEqual') // Do nothing else for counteroutargs = 1:NOutArg tmppushstack = OutArg(counteroutargs).Scope+': '+OutArg(counteroutargs).Name; + // #RNU_RES_B + PrintStringInfo(' Pushing in the AST stack: ""'+tmppushstack+'"".',ReportFileName,'file','y'); + // #RNU_RES_E AST_PushASTStack(tmppushstack); end end +// #RNU_RES_B //NUT: verificare se si puo' accorpare qualcosa qui sotto //RN: non capisco come mai analizzo lo scope dopo che faccio il push nello stack dove lo utilizzo!!! // --- Scope analysis of the output arguments. --- +// #RNU_RES_E if (ASTFunName == 'OpMinus' & NInArg == 1 & (InArg(1).Dimension == 0) & (InArg(1).Scope == 'Number')) // Scope already set above. elseif (ASTFunName == 'float' & NInArg == 1 & (InArg(1).Dimension == 0) & (InArg(1).Scope == 'Number')) @@ -221,47 +320,58 @@ else OutArg = ST_AnalyzeScope(OutArg,NOutArg,FileInfo,SharedInfo); end -// --- Check if the current function is handling for counter variables. --- +//#RNUREM_ME --- Check if the current function is handling for counter variables. --- [OutArg,SharedInfo] = ST_InsForCntVars(InArg,NInArg,OutArg,NOutArg,ASTFunName,FileInfo,SharedInfo); -// --- Store the while condition variable (if any). --- +//#RNUREM_ME --- Store the while condition variable (if any). --- SharedInfo = GetWhileCondVariable(OutArg,NOutArg,ASTFunName,FileInfo,SharedInfo); -// --- Update Symbol Table with output arguments. --- +//#RNUREM_ME --- Update Symbol Table with output arguments. --- if ((ASTFunName == 'OpMinus') & (NInArg == 1) & (InArg(1).Dimension == 0) & (InArg(1).Scope == 'Number')) - // A number is not inserted in the symbol table. + //#RNUREM_ME A number is not inserted in the symbol table. elseif ((ASTFunName == 'float') & (NInArg == 1) & (InArg(1).Dimension == 0) & (InArg(1).Scope == 'Number')) - // A number is not inserted in the symbol table. + //#RNUREM_ME A number is not inserted in the symbol table. elseif ((ASTFunName == 'double') & (NInArg == 1) & (InArg(1).Dimension == 0) & (InArg(1).Scope == 'Number')) - // A number is not inserted in the symbol table. + //#RNUREM_ME A number is not inserted in the symbol table. else ST_InsOutArg(OutArg,NOutArg,FileInfo,SharedInfo,'all'); end -//NUT: per risparmiare tempo di esecuzione puoi mettere delle if sulle funzioni che devono -//NUT: essere skippate. +//#RNUREM_ME NUT: per risparmiare tempo di esecuzione puoi mettere delle if sulle funzioni che devono +//#RNUREM_ME NUT: essere skippate. +//#RNU_RES_B // -------------------------------------------- // --- Generate the C name of the function. --- // -------------------------------------------- -CFunName = C_GenerateFunName(ASTFunName,InArg,NInArg,OutArg,NOutArg); +//#RNU_RES_E +CFunName = C_GenerateFunName(ASTFunName,InArg,NInArg,OutArg,NOutArg); +//#RNU_RES_B +PrintStringInfo(' C Function Name: '+CFunName,ReportFileName,'file','y'); // ------------------------------------------------------------------------- // --- Determine which library the function belongs to: USER2C or SCI2C. --- // ------------------------------------------------------------------------- +//#RNU_RES_E if SCI2Cfileexist(FileInfo.SCI2CLibCAnnFun,ASTFunName+'.ann') LibTypeInfo = 'SCI2C'; else LibTypeInfo = 'USER2C'; end -// --------------------------------------------------------------------------- -// --- Check existence of the FunInfo.dat file -> function already called. --- -// --------------------------------------------------------------------------- -FunInfoDatFileName = fullfile(FunInfoDatDir,CFunName+'.dat'); -if SCI2Cfileexist(FunInfoDatDir,CFunName+'.dat') +//#RNU_RES_B +// ------------------------------------------------------------------------------------ +// --- Check whether the function has been already called in the current .sci file. --- +// ------------------------------------------------------------------------------------ +//#RNU_RES_E +if (sum(SharedInfo.CFunctsAlreadyCalled == CFunName) == 1) Flag_FunAlreadyCalled = 1; +else + + //#RNUREM_ME Add the C function name to the list of C functions called in the current .sci file. + SharedInfo.CFunctsAlreadyCalled(size(SharedInfo.CFunctsAlreadyCalled,1)+1) = CFunName; end +//#RNU_RES_B // ---------------------------------- // --- Generate FunInfo dat file. --- // ---------------------------------- @@ -269,8 +379,10 @@ end //NUT: essere tutto uguale //NUT: magari posso fare una funzione che inserisce solo i campi diversi e fa un check su quelli che //NUT: dovrebbero essere identici. +//#RNU_RES_E GenCFunDatFiles(ASTFunName,FunPrecSpecifier,FunTypeAnnot,FunSizeAnnot,InArg,NInArg,OutArg,NOutArg,CFunName,LibTypeInfo,FunInfoDatDir); +//#RNU_RES_B // ----------------------------------- // --- Update SCI2C Function List. --- // ----------------------------------- @@ -279,11 +391,14 @@ GenCFunDatFiles(ASTFunName,FunPrecSpecifier,FunTypeAnnot,FunSizeAnnot,InArg,NInA // the translation of the current .sci file. //NUT: il problema della d0d0OpEqual dovrebbe essere legato al fatto che cerco di fare la opequal legata alla ins... //NUT: devo evitare di scriveral dentro la lsista delle funzioni da tradurre. +//#RNU_RES_E SharedInfo = FL_UpdateToBeConv(ASTFunName,CFunName,FunPrecSpecifier,FunTypeAnnot,FunSizeAnnot,InArg,NInArg,OutArg,NOutArg,FileInfo,SharedInfo); +//#RNU_RES_B // ----------------------------------------------- // --- Check on common input/output arguments. --- // ----------------------------------------------- +//#RNU_RES_E if (((ASTFunName=='OpEqual') & (SharedInfo.SkipNextEqual == 1)) | ... SharedInfo.SkipNextFun > 0 | ... ((sum(mtlb_strcmp(ASTFunName,SharedInfo.Annotations.DataPrec)) > 0) & (SharedInfo.SkipNextPrec == 1))) @@ -292,24 +407,36 @@ else AST_CheckCommonInOutArgs(InArg,NInArg,OutArg,NOutArg,ReportFileName); end +//#RNU_RES_B // ----------------------------- // --- C Generation Section. --- // ----------------------------- // --- Load FunInfo structure. --- +//#RNU_RES_E +FunInfoDatFileName = fullfile(FunInfoDatDir,CFunName+'.dat'); load(FunInfoDatFileName,'FunInfo'); +//#RNU_RES_B // --- Generate include. --- +//#RNU_RES_E if ((Flag_FunAlreadyCalled == 0) & (FunInfo.LibTypeInfo == 'USER2C')) + // #RNU_RES_B + PrintStringInfo('Adding include',ReportFileName,'file','y'); PrintStringInfo('#include ""'+CFunName+'.h""',... ReportFileName,'file','y'); + // #RNU_RES_E PrintStringInfo('#include ""'+CFunName+'.h""',... Pass1HeaderFileName,'file','y'); end +//#RNU_RES_B // --- Generate the C code for the current function. --- +//#RNU_RES_E FlagCall = 1; SharedInfo = C_Funcall(FunInfo,FileInfo,SharedInfo,FlagCall); +//#RNU_RES_B //NUT: anziche farla fare alla cfuncall l'aggiornamento delle skip metti qui una funzione dedicata a cio' //NUT: e' piu' ordinato. +//#RNU_RES_E endfunction diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleEndProgram.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleEndProgram.sci index 4d50317b..2d6d77a9 100644 --- a/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleEndProgram.sci +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleEndProgram.sci @@ -1,6 +1,14 @@ function SharedInfo = AST_HandleEndProgram(FileInfo,SharedInfo) // function SharedInfo = AST_HandleEndProgram(FileInfo,SharedInfo) // ----------------------------------------------------------------- +// Handles the EndProgram tag of the AST. +// +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 12-Jun-2007 -- Raffaele Nutricato: Author. @@ -37,15 +45,18 @@ if (1==2) end end + PrintStringInfo(' '+CCall,ReportFileName,'file','y'); PrintStringInfo(C_IndentBlanks(IndentLevel)+CCall,CPass1FileName,'file','y'); end SharedInfo.NIndent = SharedInfo.NIndent - 1; IndentLevel = SharedInfo.NIndent; +PrintStringInfo(' }',ReportFileName,'file','y'); PrintStringInfo(C_IndentBlanks(IndentLevel)+'}',CPass1FileName,'file','y'); // --- Close the copy of the scilab file. --- +PrintStringInfo(' Closing: '+FileInfo.Funct(nxtscifunnumber).SCICopyFileName,ReportFileName,'file','y'); mclose(FileInfo.Funct(nxtscifunnumber).SCICopyFileFid); endfunction diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleEndWhile.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleEndWhile.sci index 952497cb..94649b10 100644 --- a/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleEndWhile.sci +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleEndWhile.sci @@ -1,6 +1,22 @@ function SharedInfo = AST_HandleEndWhile(FileInfo,SharedInfo) // function SharedInfo = AST_HandleEndWhile(FileInfo,SharedInfo) // ----------------------------------------------------------------- +//#RNU_RES_B +// Handles the EndWhile tag of the AST. +// +// txt=['While' +// ' WhileExpression:' +// ' '+string(W.expression) +// ' WhileStatements:' +// ' '+objectlist2string(W.statements) +// 'EndWhile'] +//#RNU_RES_E +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 15-Nov-2007 -- Raffaele Nutricato: Author. @@ -24,15 +40,19 @@ ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; CPass1FileName = FileInfo.Funct(nxtscifunnumber).CPass1FileName; CPass1WhileEpilFileName = FileInfo.Funct(nxtscifunnumber).CPass1WhileEpilFileName(SharedInfo.While.Level); +PrintStringInfo(' ',ReportFileName,'file','y'); +PrintStringInfo('***Handling EndWhile***',ReportFileName,'file','y'); CCall =''; // --------------------------- // --- End Initialization. --- // --------------------------- +//#RNU_RES_B // ---------------------------- // --- Generate the C code. --- // ---------------------------- // --- Copy Epilogue into C code (Pass1) file. --- +//#RNU_RES_E [CLinesArray,N_Lines] = File2StringArray(CPass1WhileEpilFileName); CLinesArray = stripblanks(CLinesArray); @@ -41,9 +61,11 @@ for tmpcnt = 1:N_Lines-1 end PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent-1)+CLinesArray(N_Lines),CPass1FileName,'file','y'); +//#RNU_RES_B // -------------------------- // --- Update SharedInfo. --- // -------------------------- +//#RNU_RES_E SharedInfo.NIndent = SharedInfo.NIndent - 1; // ------------------------------- diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleFor.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleFor.sci new file mode 100644 index 00000000..e96edd4c --- /dev/null +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleFor.sci @@ -0,0 +1,84 @@ +function FileInfo = AST_HandleFor(FileInfo,SharedInfo) +// function FileInfo = AST_HandleFor(FileInfo,SharedInfo) +// ----------------------------------------------------------------- +//#RNU_RES_B +// Handles the For tag of the AST. +// +// 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) +// txt=['For' +// ' Expression:' +// ' '+string(F.expression) +// ' Statements:' +// ' '+objectlist2string(F.statements) +// 'EndFor'] +// +//#RNU_RES_E +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 10-Nov-2007 -- Raffaele Nutricato: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),2,2); + +// ----------------------- +// --- Initialization. --- +// ----------------------- +nxtscifunname = SharedInfo.NextSCIFunName; +nxtscifunnumber = SharedInfo.NextSCIFunNumber; +ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; +PfxP1ForProlFileName = FileInfo.Funct(nxtscifunnumber).PfxP1ForProlFileName; +PfxP1ForEpilFileName = FileInfo.Funct(nxtscifunnumber).PfxP1ForEpilFileName; +PrintStepInfo('Handling For',FileInfo.Funct(nxtscifunnumber).ReportFileName,'file'); +// --------------------------- +// --- End Initialization. --- +// --------------------------- + +//#RNU_RES_B +// --- Signal the entrance in a for expression. --- +//#RNU_RES_E +SharedInfo.ForExpr.OnExec = SharedInfo.ForExpr.OnExec + 1; + +//#RNU_RES_B +// --- Generate the file names for the prologue and epilogue files. --- +//#RNU_RES_E +FileInfo.Funct(nxtscifunnumber).CPass1ForProlFileName(SharedInfo.For.Level) = ... + PfxP1ForProlFileName+string(SharedInfo.For.Level)+'.c'; +FileInfo.Funct(nxtscifunnumber).CPass1ForEpilFileName(SharedInfo.For.Level) = ... + PfxP1ForEpilFileName+string(SharedInfo.For.Level)+'.c'; + +//#RNU_RES_B +// --------------------------------------------------------- +// --- Create a copy of the For Prologue/Epilogue Files. --- +// --------------------------------------------------------- +//#RNU_RES_E +PrintStringInfo(' ',FileInfo.Funct(nxtscifunnumber).CPass1ForProlFileName(SharedInfo.For.Level),'file'); +PrintStringInfo(' ',FileInfo.Funct(nxtscifunnumber).CPass1ForEpilFileName(SharedInfo.For.Level),'file'); + +//#RNU_RES_B +// ------------------------------------------------------ +// --- Replace the CPass1V1 file with a temp ForFile. --- +// ------------------------------------------------------ +// From now up to Expression: all the C code will be written in a for temporary file. +//#RNU_RES_E +tmpfilename = FileInfo.Funct(nxtscifunnumber).CPass1FileName; +FileInfo.Funct(nxtscifunnumber).CPass1FileName = FileInfo.Funct(nxtscifunnumber).CPass1ForProlFileName(SharedInfo.For.Level); +FileInfo.Funct(nxtscifunnumber).CPass1ForProlFileName(SharedInfo.For.Level) = tmpfilename; +PrintStringInfo('Redirecting C code to: '+FileInfo.Funct(nxtscifunnumber).CPass1FileName,FileInfo.Funct(nxtscifunnumber).ReportFileName,'file'); + +endfunction diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleForStatem.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleForStatem.sci new file mode 100644 index 00000000..f47538a6 --- /dev/null +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleForStatem.sci @@ -0,0 +1,87 @@ +function [FileInfo,SharedInfo] = AST_HandleForStatem(FileInfo,SharedInfo) +// ----------------------------------------------------------------- +//#RNU_RES_B +// Handles the ForStatements tag of the AST. +// 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) +// txt=['For' +// ' ForExpression:' +// ' '+string(F.expression) +// ' ForStatements:' +// ' '+objectlist2string(F.statements) +// 'EndFor'] +// +//#RNU_RES_E +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 15-Nov-2007 -- Raffaele Nutricato: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(2,2,2); + +// ----------------------- +// --- Initialization. --- +// ----------------------- +nxtscifunname = SharedInfo.NextSCIFunName; +nxtscifunnumber = SharedInfo.NextSCIFunNumber; +ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; +PrintStepInfo('Handling ForStatements',FileInfo.Funct(nxtscifunnumber).ReportFileName,'file'); +// --------------------------- +// --- End Initialization. --- +// --------------------------- + +//#RNU_RES_B +// --------------------------------------------- +// --- Resume the correct name for CPass1V1. --- +// --------------------------------------------- +//#RNU_RES_E +tmpfilename = FileInfo.Funct(nxtscifunnumber).CPass1FileName; +FileInfo.Funct(nxtscifunnumber).CPass1FileName = FileInfo.Funct(nxtscifunnumber).CPass1ForProlFileName(SharedInfo.For.Level); +FileInfo.Funct(nxtscifunnumber).CPass1ForProlFileName(SharedInfo.For.Level) = tmpfilename; +PrintStringInfo(' Redirecting C code to: '+FileInfo.Funct(nxtscifunnumber).CPass1FileName,FileInfo.Funct(nxtscifunnumber).ReportFileName,'file'); + +//#RNU_RES_B +// ------------------------ +// --- Generate C code. --- +// ------------------------ +//#RNU_RES_E +SharedInfo = C_ForExpression(FileInfo,SharedInfo); + +//#RNU_RES_B +// -------------------------- +// --- Update SharedInfo. --- +// -------------------------- +// Signal the exit from a for expression. +//#RNU_RES_E +SharedInfo.ForExpr.OnExec = SharedInfo.ForExpr.OnExec - 1; +SharedInfo.ForExpr.IntCntArg = []; +SharedInfo.ForExpr.MtxValCntArg = []; +SharedInfo.ForExpr.SclValCntArg = []; +SharedInfo.ForExpr.OpColonInfoIn1 = ''; +SharedInfo.ForExpr.OpColonInfoIn2 = ''; +SharedInfo.ForExpr.OpColonInfoIn3 = ''; + + +SharedInfo.ForExpr.AssignmentFun = 0; + +// ------------------------------- +// --- Delete temporary files. --- +// ------------------------------- +SCI2Cmdelete(FileInfo.Funct(nxtscifunnumber).CPass1ForProlFileName(SharedInfo.For.Level)); + +endfunction diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleHeader.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleHeader.sci index fdb6396a..7439b784 100644 --- a/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleHeader.sci +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleHeader.sci @@ -1,6 +1,13 @@ function SharedInfo = AST_HandleHeader(ASTHeader,FileInfo,SharedInfo) // function SharedInfo = AST_HandleHeader(ASTHeader,FileInfo,SharedInfo) // ----------------------------------------------------------------- +// Handles the Header of the AST. +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 11-Apr-2007 -- Raffaele Nutricato: Author. @@ -36,11 +43,13 @@ end TmpInNames = tokens(ASTHeader.Inputs,' '); TmpOutNames = tokens(ASTHeader.Outputs,' '); -// Remove Var: Number: or String: specifier. +//#RNU_RES_B +// Remove Variable: Number: or String: specifier. +//#RNU_RES_E NInArg = 0; for tmpcnt = 1:size(TmpInNames,1) TmpSingleName = TmpInNames(tmpcnt); - if ((TmpSingleName == 'Var:') | ... + if ((TmpSingleName == 'Variable:') | ... (TmpSingleName == 'String:') | ... (TmpSingleName == 'Number:')) // Skip the specifier. @@ -50,11 +59,13 @@ for tmpcnt = 1:size(TmpInNames,1) end end -// Remove Var: Number: or String: specifier. +//#RNU_RES_B +// Remove Variable: Number: or String: specifier. +//#RNU_RES_E NOutArg = 0; for tmpcnt = 1:size(TmpOutNames,1) TmpSingleName = TmpOutNames(tmpcnt); - if ((TmpSingleName == 'Var:') | ... + if ((TmpSingleName == 'Variable:') | ... (TmpSingleName == 'String:') | ... (TmpSingleName == 'Number_x:') | ... (TmpSingleName == 'Number_s:') | ... @@ -75,26 +86,33 @@ else end if ((OutNames(1)=='<empty>') | (FunctionName == 'ins')) + //#RNU_RES_B //NUT: Force ins to have 0 args. Double check it. + //#RNU_RES_E + NOutArg = 0; else NOutArg = size(OutNames,1); end +//#RNU_RES_B // ------------------------------------- // --- Load the C function dat file. --- // ------------------------------------- //NUT: This load is useful expecially for the second approach. In this case we are not using //NUT: the size info. +//#RNU_RES_E load(fullfile(FileInfo.FunctionList.FunInfoDatDir,SharedInfo.NextCFunName+'.dat'),'FunInfo'); SharedInfo.CurrentFunInfo = FunInfo; clear FunInfo +//#RNU_RES_B // ----------------------------------------------------------------------------- // --- Check coherence between In/Out names and In/Out Arg structure loaded. --- // ----------------------------------------------------------------------------- +//#RNU_RES_E if (length(SharedInfo.CurrentFunInfo.InArg(1).Name) > 0) NInArgDat = size(SharedInfo.CurrentFunInfo.InArg,1); else @@ -109,7 +127,9 @@ if (NInArgDat == NInArg) SharedInfo.CurrentFunInfo.InArg(tmpcnt).Size(2) = '1'; SharedInfo.CurrentFunInfo.InArg(tmpcnt).Value = %nan; else + //#RNU_RES_B //NUT: using approach 1: Setting for input and output arguments symbolic sizes. + //#RNU_RES_E SharedInfo.CurrentFunInfo.InArg(tmpcnt).Size(1) = '__'+SharedInfo.CurrentFunInfo.InArg(tmpcnt).Name+'Size[0]'; SharedInfo.CurrentFunInfo.InArg(tmpcnt).Size(2) = '__'+SharedInfo.CurrentFunInfo.InArg(tmpcnt).Name+'Size[1]'; SharedInfo.CurrentFunInfo.InArg(tmpcnt).Value = %nan; @@ -125,9 +145,15 @@ if (SharedInfo.CurrentFunInfo.NOutArg == NOutArg) SharedInfo.CurrentFunInfo.OutArg(tmpcnt).Name = OutNames(tmpcnt); end else - // + //#RNU_RES_B + PrintStringInfo('N. of output arguments found in the AST: '+string(NOutArg),ReportFileName,'both','y'); + PrintStringInfo('N. of output arguments found in the call (FunInfo structure): '+string(SharedInfo.CurrentFunInfo.NOutArg),ReportFileName,'both','y'); + //#RNU_RES_E + SCI2CerrorFile('Number of output arguments specified in AST is different from the number specified in .dat file.',ReportFileName); end +//#RNU_RES_B //NUT: using approach 1: Setting for input and output arguments symbolic sizes. +//#RNU_RES_E SharedInfo.CurrentFunInfo.OutArg = ... FA_GetOutArgInfo(SharedInfo.CurrentFunInfo.InArg,NInArg,... SharedInfo.CurrentFunInfo.OutArg,NOutArg,... @@ -135,14 +161,23 @@ SharedInfo.CurrentFunInfo.OutArg = ... SharedInfo.CurrentFunInfo.FunPrecSpecifier,... SharedInfo.CurrentFunInfo.FunTypeAnnot,SharedInfo.CurrentFunInfo.FunSizeAnnot,ReportFileName); +//#RNU_RES_B // ------------------------------------------------------------------------- // --- Stores InArg structure into the temporary variables symbol table. --- // ------------------------------------------------------------------------- +//#RNU_RES_E SymbTableFileName = FileInfo.Funct(nxtscifunnumber).LocalVarFileName; - +// #RNU_RES_B +PrintStringInfo(' ',ReportFileName,'file','y'); +PrintStringInfo('***Putting Input and Output arguments in the local symbol table***',ReportFileName,'file','y'); +// #RNU_RES_E for tmpcnt = 1:NInArg - + //#RNU_RES_B + PrintStringInfo(' Symbol ""'+SharedInfo.CurrentFunInfo.InArg(tmpcnt).Name+'""',ReportFileName,'file','y'); + PrintStringInfo(' Setting symbol ""'+SharedInfo.CurrentFunInfo.InArg(tmpcnt).Name+'"" in '+SymbTableFileName+'.',ReportFileName,'file','y'); + //#RNU_RES_E + ST_Set(SharedInfo.CurrentFunInfo.InArg(tmpcnt).Name,... SharedInfo.CurrentFunInfo.InArg(tmpcnt).Type,... SharedInfo.CurrentFunInfo.InArg(tmpcnt).Size,... @@ -150,6 +185,15 @@ for tmpcnt = 1:NInArg SharedInfo.CurrentFunInfo.InArg(tmpcnt).FindLike,... SharedInfo.CurrentFunInfo.InArg(tmpcnt).Dimension,... SymbTableFileName); + //#RNU_RES_B + PrintStringInfo(' Type: '+SharedInfo.CurrentFunInfo.InArg(tmpcnt).Type,ReportFileName,'file','y'); + PrintStringInfo(' Size(1): '+string(SharedInfo.CurrentFunInfo.InArg(tmpcnt).Size(1)),ReportFileName,'file','y'); + PrintStringInfo(' Size(2): '+string(SharedInfo.CurrentFunInfo.InArg(tmpcnt).Size(2)),ReportFileName,'file','y'); + PrintStringInfo(' Value: '+string(SharedInfo.CurrentFunInfo.InArg(tmpcnt).Value),ReportFileName,'file','y'); + PrintStringInfo(' FindLike: '+string(SharedInfo.CurrentFunInfo.InArg(tmpcnt).FindLike),ReportFileName,'file','y'); + PrintStringInfo(' Dimension: '+string(SharedInfo.CurrentFunInfo.InArg(tmpcnt).Dimension),ReportFileName,'file','y'); + PrintStringInfo(' ',ReportFileName,'file','y'); + //#RNU_RES_E end // -------------------------------------------------------------------------- @@ -157,7 +201,12 @@ end // -------------------------------------------------------------------------- //NUT: verifica se puoi usare l'outarg2symboltable qui. for tmpcnt = 1:NOutArg + //#RNU_RES_B + PrintStringInfo(' Symbol ""'+SharedInfo.CurrentFunInfo.OutArg(tmpcnt).Name+'""',ReportFileName,'file','y'); + PrintStringInfo(' Setting symbol ""'+SharedInfo.CurrentFunInfo.OutArg(tmpcnt).Name+'"" in '+SymbTableFileName+'.',ReportFileName,'file','y'); + //#RNU_RES_E + ST_Set(SharedInfo.CurrentFunInfo.OutArg(tmpcnt).Name,... SharedInfo.CurrentFunInfo.OutArg(tmpcnt).Type,... SharedInfo.CurrentFunInfo.OutArg(tmpcnt).Size,... @@ -165,16 +214,30 @@ for tmpcnt = 1:NOutArg SharedInfo.CurrentFunInfo.OutArg(tmpcnt).FindLike,... SharedInfo.CurrentFunInfo.OutArg(tmpcnt).Dimension,... SymbTableFileName); + //#RNU_RES_B + PrintStringInfo(' Type: '+SharedInfo.CurrentFunInfo.OutArg(tmpcnt).Type,ReportFileName,'file','y'); + PrintStringInfo(' Size(1): '+string(SharedInfo.CurrentFunInfo.OutArg(tmpcnt).Size(1)),ReportFileName,'file','y'); + PrintStringInfo(' Size(2): '+string(SharedInfo.CurrentFunInfo.OutArg(tmpcnt).Size(2)),ReportFileName,'file','y'); + PrintStringInfo(' Value: '+string(SharedInfo.CurrentFunInfo.OutArg(tmpcnt).Value),ReportFileName,'file','y'); + PrintStringInfo(' FindLike: '+string(SharedInfo.CurrentFunInfo.OutArg(tmpcnt).FindLike),ReportFileName,'file','y'); + PrintStringInfo(' Dimension: '+string(SharedInfo.CurrentFunInfo.OutArg(tmpcnt).Dimension),ReportFileName,'file','y'); + PrintStringInfo(' ',ReportFileName,'file','y'); + //#RNU_RES_E + end +//#RNU_RES_B // ----------------------------------------------- // --- Check on common input/output arguments. --- // ----------------------------------------------- +//#RNU_RES_E AST_CheckCommonInOutArgs(SharedInfo.CurrentFunInfo.InArg,NInArg,SharedInfo.CurrentFunInfo.OutArg,NOutArg,ReportFileName); +//#RNU_RES_B // ------------------------ // --- Generate C code. --- // ------------------------ +//#RNU_RES_E FlagCall = 0; SharedInfo = C_Funcall(SharedInfo.CurrentFunInfo,FileInfo,SharedInfo,FlagCall); SharedInfo.NIndent = SharedInfo.NIndent+1; // Increase indentation level. diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleIfElse.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleIfElse.sci new file mode 100644 index 00000000..5373adf6 --- /dev/null +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleIfElse.sci @@ -0,0 +1,92 @@ +function [FileInfo,SharedInfo] = AST_HandleIfElse(FileInfo,SharedInfo,ASTIfExpType) +// function [FileInfo,SharedInfo] = AST_HandleIfElse(FileInfo,SharedInfo,ASTIfExpType) +// ----------------------------------------------------------------- +//#RNU_RES_B +// Handles the Else If tag of the AST. +// +// overloading function for "ifthenel" type tlist string function +// this is a node of the AST +// fields: +// expression : "expression" type tlist (the if expression) +// then : list of "equal" type tlist and list('EOL') (the +// then instructions list) +// elseifs : a list of tlists +// else : list of "equal" type tlist and list('EOL') (the +// else instructions list) +// txt=['If ' +// ' Expression:' +// ' '+string(I.expression) +// ' If Statements' +// ' '+objectlist2string(I.then)] +// for e=I.elseifs +// txt=[txt; +// ' Else If Expression' +// ' '+string(e.expression) +// ' Else If Statements' +// ' '+objectlist2string(e.then)] +// end +// txt=[txt; +// ' Else Statements' +// ' '+objectlist2string(I.else) +// 'EndIf'] +// +// Input data: +// ASTIfExpType: it specifies if we are handling a if condition (ASTIfExpType='if') +// or an elseif condition (ASTIfExpType='elseif') or else statement (ASTIfExpType='else') +//#RNU_RES_E +// //NUT: add description here +// +// +// Output data: +// //NUT: add description here +// +// +// Status: +// 11-Apr-2007 -- Raffaele Nutricato: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),3,3); + +// ----------------------- +// --- Initialization. --- +// ----------------------- +nxtscifunname = SharedInfo.NextSCIFunName; +nxtscifunnumber = SharedInfo.NextSCIFunNumber; +ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; +PrintStepInfo('Handling If Statements',FileInfo.Funct(nxtscifunnumber).ReportFileName,'file'); + +global SCI2CSTACK +global StackPosition; +global STACKDEDUG +// --------------------------- +// --- End Initialization. --- +// --------------------------- + +//#RNU_RES_B +// --------------------------------------------------- +// --- Retrieve If Expression Parameters from AST. --- +// --------------------------------------------------- +//#RNU_RES_E +if (ASTIfExpType~='else') + [IfCondArg,NIfCondArg] = AST_ParseIfExprStruct(FileInfo,SharedInfo,ASTIfExpType); +else + // "else" type doesn't contain any condition to test. + IfCondArg = ''; + NIfCondArg = 0; +end + +//#RNU_RES_B +// ----------------------------- +// --- C Generation Section. --- +// ----------------------------- +// --- Generate the C code for if/elseif Expression. --- +//#RNU_RES_E +SharedInfo = C_IfExpression(IfCondArg,NIfCondArg,ASTIfExpType,FileInfo,SharedInfo); + +endfunction diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleWhileExpr.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleWhileExpr.sci new file mode 100644 index 00000000..ffcf2f45 --- /dev/null +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleWhileExpr.sci @@ -0,0 +1,80 @@ +function [FileInfo,SharedInfo] = AST_HandleWhileExpr(FileInfo,SharedInfo) +// function [FileInfo,SharedInfo] = AST_HandleWhileExpr(FileInfo,SharedInfo) +// ----------------------------------------------------------------- +//#RNU_RES_B +// Handles the WhileExpression tag of the AST. +// +// txt=['While' +// ' WhileExpression:' +// ' '+string(W.expression) +// ' WhileStatements:' +// ' '+objectlist2string(W.statements) +// 'EndWhile'] +// +//#RNU_RES_E +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 29-Dec-2007 -- Raffaele Nutricato: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),2,2); + +// ----------------------- +// --- Initialization. --- +// ----------------------- +nxtscifunname = SharedInfo.NextSCIFunName; +nxtscifunnumber = SharedInfo.NextSCIFunNumber; +ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; +PfxP1WhileProlFileName = FileInfo.Funct(nxtscifunnumber).PfxP1WhileProlFileName; +PfxP1WhileEpilFileName = FileInfo.Funct(nxtscifunnumber).PfxP1WhileEpilFileName; +PrintStepInfo('Handling While',FileInfo.Funct(nxtscifunnumber).ReportFileName,'file'); +// --------------------------- +// --- End Initialization. --- +// --------------------------- + +//#RNU_RES_B +// --- Signal the entrance in a while expression. --- +//#RNU_RES_E +SharedInfo.WhileExpr.OnExec = SharedInfo.WhileExpr.OnExec + 1; + +//#RNU_RES_B +// --- Generate the file names for the prologue and epilogue files. --- +//#RNU_RES_E +FileInfo.Funct(nxtscifunnumber).CPass1WhileProlFileName(SharedInfo.While.Level) = ... + PfxP1WhileProlFileName+string(SharedInfo.While.Level)+'.c'; +FileInfo.Funct(nxtscifunnumber).CPass1WhileEpilFileName(SharedInfo.While.Level) = ... + PfxP1WhileEpilFileName+string(SharedInfo.While.Level)+'.c'; + +//#RNU_RES_B +// ----------------------------------------------------------- +// --- Create a copy of the While Prologue/Epilogue Files. --- +// ----------------------------------------------------------- +//#RNU_RES_E +PrintStringInfo(' ',FileInfo.Funct(nxtscifunnumber).CPass1WhileProlFileName(SharedInfo.While.Level),'file'); +PrintStringInfo(' ',FileInfo.Funct(nxtscifunnumber).CPass1WhileEpilFileName(SharedInfo.While.Level),'file'); + +//#RNU_RES_B +// -------------------------------------------------------- +// --- Replace the CPass1V1 file with a temp WhileFile. --- +// -------------------------------------------------------- +// From now up to Expression: all the C code will be written in a while temporary file. +//#RNU_RES_E +tmpfilename = FileInfo.Funct(nxtscifunnumber).CPass1FileName; +FileInfo.Funct(nxtscifunnumber).CPass1FileName = FileInfo.Funct(nxtscifunnumber).CPass1WhileProlFileName(SharedInfo.While.Level); +FileInfo.Funct(nxtscifunnumber).CPass1WhileProlFileName(SharedInfo.While.Level) = tmpfilename; +//#RNU_RES_B +PrintStringInfo('Redirecting C code to: '+FileInfo.Funct(nxtscifunnumber).CPass1FileName,FileInfo.Funct(nxtscifunnumber).ReportFileName,'file'); +//#RNU_RES_E + +endfunction diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleWhileStatem.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleWhileStatem.sci new file mode 100644 index 00000000..5c823ab3 --- /dev/null +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_HandleWhileStatem.sci @@ -0,0 +1,119 @@ +function [FileInfo,SharedInfo] = AST_HandleWhileStatem(FileInfo,SharedInfo) +// ----------------------------------------------------------------- +//#RNU_RES_B +// Handles the WhileStatements tag of the AST. +// +// txt=['While' +// ' WhileExpression:' +// ' '+string(W.expression) +// ' WhileStatements:' +// ' '+objectlist2string(W.statements) +// 'EndWhile'] +// +//#RNU_RES_E +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 20-Jan-2008 -- Edoardo Nutricato: Author. +// 20-Jan-2008 -- Rubby Nutricato: Minor Changes. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +//#RNU_RES_B + +//NUT: accertati che l'epilogo e il prologo del while siano effettivamente differenti o se +//NUT: si puo' avere un solo file utilizzato sia per il prologo che per l'epilogo. + +//NUT: da sistemare senza le global +//#RNU_RES_E +global SCI2CSTACK +global StackPosition; +global STACKDEDUG + + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),2,2); + +// ----------------------- +// --- Initialization. --- +// ----------------------- +nxtscifunname = SharedInfo.NextSCIFunName; +nxtscifunnumber = SharedInfo.NextSCIFunNumber; +ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; +CPass1WhileProlFileName = FileInfo.Funct(nxtscifunnumber).CPass1WhileProlFileName(SharedInfo.While.Level); +PrintStepInfo('Handling WhileStatements',FileInfo.Funct(nxtscifunnumber).ReportFileName,'file'); +// --------------------------- +// --- End Initialization. --- +// --------------------------- + +//#RNU_RES_B +// ----------------------------------------------- +// --- Resume the correct name while CPass1V1. --- +// ----------------------------------------------- +//#RNU_RES_E +tmpfilename = FileInfo.Funct(nxtscifunnumber).CPass1FileName; +FileInfo.Funct(nxtscifunnumber).CPass1FileName = FileInfo.Funct(nxtscifunnumber).CPass1WhileProlFileName(SharedInfo.While.Level); +FileInfo.Funct(nxtscifunnumber).CPass1WhileProlFileName(SharedInfo.While.Level) = tmpfilename; +CPass1WhileProlFileName = FileInfo.Funct(nxtscifunnumber).CPass1WhileProlFileName(SharedInfo.While.Level); +PrintStringInfo(' Redirecting C code to: '+FileInfo.Funct(nxtscifunnumber).CPass1FileName,FileInfo.Funct(nxtscifunnumber).ReportFileName,'file'); + +//#RNU_RES_B +// ------------------------ +// --- Generate C code. --- +// ------------------------ +//#RNU_RES_E +if(SharedInfo.WhileExpr.CondVar == '') + //#RNU_RES_B + // It means that we are handling something like while(a) or while(1) + // The while condition variable is generated by the HandleEndGenFun. + //#RNU_RES_E + + // --- Pop the name of the condition variable or number. --- + Pop1 = AST_PopASTStack(); + + [ArgName,ArgScope] = AST_ExtractNameAndScope(Pop1); + if (length(ArgName) == 0) + PrintStringInfo(' ',ReportFileName,'both','y'); + PrintStringInfo('SCI2CERROR: Expected while(variable) or while(number).','','stdout','y'); + PrintStringInfo('SCI2CERROR: Expected a variable or number in the AST while expression.','','stdout','y'); + PrintStringInfo('SCI2CERROR: Report this error to raffaele.nutricato@tiscali.it.','','stdout','y'); + PrintStringInfo(' ',ReportFileName,'both','y'); + SCI2Cerror(' '); + SCI2Cerror('Expected a conditional variable in the while expression'); + end + + SharedInfo.WhileExpr.CondVar = ArgName; + //#RNU_RES_B + // --- Repush strings into the AST stack. --- + //#RNU_RES_E + + AST_PushASTStack(Pop1); + +elseif (SharedInfo.WhileExpr.DimCondVar > 0) + SCI2CerrorFile('Cannot manage while with matrix conditions',ReportFileName); +end +SharedInfo = C_WhileExpression(FileInfo,SharedInfo); + +// -------------------------- +// --- Update SharedInfo. --- +// -------------------------- +// Signal the exit from a while expression. +SharedInfo.WhileExpr.OnExec = SharedInfo.WhileExpr.OnExec - 1; +SharedInfo.WhileExpr.CondVar = ''; +SharedInfo.WhileExpr.DimCondVar = -1; +SharedInfo.WhileExpr.AssignmentFun = 0; //NUT: siamo sicuri che serva? + +// ------------------------------- +// --- Delete temporary files. --- +// ------------------------------- +SCI2Cmdelete(CPass1WhileProlFileName); + +endfunction diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_ParseEqualStruct.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_ParseEqualStruct.sci index 50158a1a..1c86b765 100644 --- a/src/Scilab2C/Scilab2C/ASTManagement/AST_ParseEqualStruct.sci +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_ParseEqualStruct.sci @@ -1,6 +1,25 @@ function [FunctionName,InArg,NInArg,OutArg,NOutArg] = AST_ParseEqualStruct(FileInfo,SharedInfo) // function [FunctionName,InArg,NInArg,OutArg,NOutArg] = AST_ParseEqualStruct(FileInfo,SharedInfo) // ----------------------------------------------------------------- +//#RNU_RES_B +// Parses the Equal structure of the AST. +// Structure of Equal: +// txt=['Equal' +// ' Expression: ' +// ' '+string(e.expression) +// ' Lhs : ' +// ' '+objectlist2string(e.lhs) +// 'EndEqual' +// ] +//#RNU_RES_E +// +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// // Status: // 11-Apr-2007 -- Raffaele Nutricato: Author. // @@ -24,6 +43,10 @@ global SCI2CSTACK global StackPosition; global STACKDEDUG +//#RNU_RES_B +PrintStringInfo(' ',ReportFileName,'file','y'); +PrintStringInfo('***Reading AST***',ReportFileName,'file','y'); +//#RNU_RES_E // ------------------------------- // --- Read Output parameters. --- @@ -62,27 +85,33 @@ end InputArgumentNames = SCI2Cflipud(InputArgumentNames); InputArgumentScope = SCI2Cflipud(InputArgumentScope); +//#RNU_RES_B // ------------------------------ // --- Extract function name. --- // ------------------------------ +//#RNU_RES_E FunctionName = AST_PopASTStack(); if (FunctionName ~= 'Equal') then SCI2Cerror('Problems with Equal, Expected Equal tag.'); end FunctionName = 'OpEqual'; +//#RNU_RES_B // ------------------------------------- // --- Generate the InArg structure. --- // ------------------------------------- +//#RNU_RES_E InArg = []; for counterinputargs = 1:NInArg InArg(counterinputargs).Name=InputArgumentNames(counterinputargs); InArg(counterinputargs).Scope=InputArgumentScope(counterinputargs); end +//#RNU_RES_B // ------------------------------------- // --- Generate the InArg structure. --- // ------------------------------------- +//#RNU_RES_E OutArg = []; for counteroutputargs = 1:NOutArg OutArg(counteroutputargs).Name=OutputArgumentNames(counteroutputargs); @@ -92,11 +121,45 @@ end // ------------------------ // --- Print Some Info. --- // ------------------------ +//#RNU_RES_B +PrintStringInfo('Function Name: '+FunctionName,ReportFileName,'file','y'); +PrintStringInfo('N Intput Arguments: '+string(NInArg),ReportFileName,'file','y'); +//#RNU_RES_E if (SharedInfo.Equal.Nins > 0) + //#RNU_RES_B + PrintStringInfo('N ins functions: '+string(SharedInfo.Equal.Nins),ReportFileName,'file','y'); + //#RNU_RES_E + for counterinputargs = 1:NInArg + //#RNU_RES_B + PrintStringInfo('Input Argument Number '+string(counterinputargs)+': '+InArg(counterinputargs).Name,... + ReportFileName,'file','y'); + PrintStringInfo(' Scope: '+InArg(counterinputargs).Scope,... + ReportFileName,'file','y'); + //#RNU_RES_E + end if (NInArg ~= SharedInfo.Equal.Nins) SCI2CerrorFile('Number of input arguments must be equal to number of ins functions.',ReportFileName); end else + //#RNU_RES_B + PrintStringInfo('N Output Arguments: '+string(NOutArg),ReportFileName,'file','y'); + //#RNU_RES_E + for counterinputargs = 1:NInArg + //#RNU_RES_B + PrintStringInfo('Input Argument Number '+string(counterinputargs)+': '+InArg(counterinputargs).Name,... + ReportFileName,'file','y'); + PrintStringInfo(' Scope: '+InArg(counterinputargs).Scope,... + ReportFileName,'file','y'); + //#RNU_RES_E + end + for counteroutputargs = 1:NOutArg + //#RNU_RES_B + PrintStringInfo('Output Argument Number '+string(counteroutputargs)+': '+OutArg(counteroutputargs).Name,... + ReportFileName,'file','y'); + PrintStringInfo(' Scope: '+OutArg(counterinputargs).Scope,... + ReportFileName,'file','y'); + //#RNU_RES_E + end if (NInArg ~= NOutArg) SCI2CerrorFile('Number of input arguments must be equal to number of output arguments.',ReportFileName); end diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_ParseFuncallStruct.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_ParseFuncallStruct.sci index 97a2bb3f..54496597 100644 --- a/src/Scilab2C/Scilab2C/ASTManagement/AST_ParseFuncallStruct.sci +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_ParseFuncallStruct.sci @@ -1,6 +1,30 @@ function [FunctionName,InArg,NInArg,NOutArg] = AST_ParseFuncallStruct(FileInfo,SharedInfo) // function [FunctionName,InArg,NInArg,NOutArg] = AST_ParseFuncallStruct(FileInfo,SharedInfo) // ----------------------------------------------------------------- +//#RNU_RES_B +// Extracts Input Arguments, Output Arguments and Function Name +// from the AST. +// +// Structure of Funcall: +// overloading function for "funcall" type tlist string function +// this is a node of the AST +// fields: +// rhs : a list +// name : string, the name of the function +// lhsnb: number, the number of function lhs +// txt=['Funcall : '+F.name +// ' #lhs : '+string(F.lhsnb) +// ' Rhs : ' +// ' '+objectlist2string(F.rhs) +// 'EndFuncall' +// ] +// +//#RNU_RES_E +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 11-Apr-2007 -- Raffaele Nutricato: Author. @@ -20,7 +44,9 @@ SCI2CNInArgCheck(argn(2),2,2); nxtscifunname = SharedInfo.NextSCIFunName; nxtscifunnumber = SharedInfo.NextSCIFunNumber; ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; - +// #RNU_RES_B +PrintStringInfo(' Parsing Funcall structure',ReportFileName,'file','y'); +// #RNU_RES_E global SCI2CSTACK global StackPosition; global STACKDEDUG @@ -73,5 +99,18 @@ for counterinputargs = 1:NInArg InArg(counterinputargs).Scope=InputArgumentScope(counterinputargs); 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'); +//#RNU_RES_E +for counterinputargs = 1:NInArg + //#RNU_RES_B + PrintStringInfo('Input Argument Number '+string(counterinputargs)+': '+InArg(counterinputargs).Name,... + ReportFileName,'file','y'); + PrintStringInfo(' Scope: '+InArg(counterinputargs).Scope,... + ReportFileName,'file','y'); + //#RNU_RES_E +end endfunction diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_ParseIfExprStruct.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_ParseIfExprStruct.sci index f80b07e5..12ad077a 100644 --- a/src/Scilab2C/Scilab2C/ASTManagement/AST_ParseIfExprStruct.sci +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_ParseIfExprStruct.sci @@ -1,6 +1,34 @@ function [IfCondArg,NIfCondArg] = AST_ParseIfExprStruct(FileInfo,SharedInfo,ASTIfExpType) // function [IfCondArg,NIfCondArg] = AST_ParseIfExprStruct(FileInfo,SharedInfo,ASTIfExpType) // ----------------------------------------------------------------- +//#RNU_RES_B +// Parses the IfExpression structure of the AST. +// +// txt=['If ' +// ' Expression:' +// ' '+string(I.expression) +// ' If Statements' +// ' '+objectlist2string(I.then)] +// for e=I.elseifs +// txt=[txt; +// ' Else If Expression' +// ' '+string(e.expression) +// ' Else If Statements' +// ' '+objectlist2string(e.then)] +// end +// txt=[txt; +// ' Else Statements' +// ' '+objectlist2string(I.else) +// 'EndIf'] +// +//#RNU_RES_E +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// // Status: // 11-Apr-2007 -- Raffaele Nutricato: Author. // @@ -19,6 +47,9 @@ SCI2CNInArgCheck(argn(2),3,3); nxtscifunname = SharedInfo.NextSCIFunName; nxtscifunnumber = SharedInfo.NextSCIFunNumber; ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; +//#RNU_RES_B +PrintStringInfo('***Retrieving '+ASTIfExpType+' expression parameters from AST***',ReportFileName,'file','y'); +//#RNU_RES_E IfCondArg = []; NIfCondArg = 0; @@ -37,6 +68,7 @@ IfExprField = AST_PopASTStack(); if (ASTIfExpType=='if') if (IfExprField=='Expression:') flagendpop = 1; + // Pop Again the If tag from the AST. IfExprField = AST_PopASTStack(); end elseif (ASTIfExpType=='elseif') @@ -52,6 +84,7 @@ while (flagendpop == 0) if (ASTIfExpType=='if') if (IfExprField=='Expression:') flagendpop = 1; + // Pop Again the If tag from the AST. IfExprField = AST_PopASTStack(); else NIfCondArg = NIfCondArg + 1; @@ -70,5 +103,17 @@ while (flagendpop == 0) IfExprField = AST_PopASTStack(); end +//#RNU_RES_B +// ------------------------------------------- +// --- Print some info in the report file. --- +// ------------------------------------------- +PrintStringInfo('N '+ASTIfExpType+' Condition Arguments: '+string(NIfCondArg),ReportFileName,'file','y'); +//#RNU_RES_E +for counterifcondargs = 1:NIfCondArg + //#RNU_RES_B + PrintStringInfo(ASTIfExpType+' Condition Argument Number '+string(counterifcondargs)+': '+IfCondArg(counterifcondargs),... + ReportFileName,'file','y'); + //#RNU_RES_E +end endfunction diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_ParseOperStruct.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_ParseOperStruct.sci index 4061d07c..179c5578 100644 --- a/src/Scilab2C/Scilab2C/ASTManagement/AST_ParseOperStruct.sci +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_ParseOperStruct.sci @@ -1,6 +1,28 @@ function [FunctionName,InArg,NInArg,NOutArg] = AST_ParseOperStruct(FileInfo,SharedInfo) // function [FunctionName,InArg,NInArg,NOutArg] = AST_ParseOperStruct(FileInfo,SharedInfo) // ----------------------------------------------------------------- +//#RNU_RES_B +// Parses the Operation structure of the AST. +// +// Structure of Operation: +//overloading function for "operation" type tlist string function +//this is a node of the AST +//fields: +// operands: a list +// operator: a string +// txt=['Operation' +// ' Operands:' +// ' '+objectlist2string(O.operands) +// ' Operator: '+O.operator +// 'EndOperation' +// ] +// +//#RNU_RES_E +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 11-Apr-2007 -- Raffaele Nutricato: Author. @@ -9,21 +31,40 @@ function [FunctionName,InArg,NInArg,NOutArg] = AST_ParseOperStruct(FileInfo,Shar // Contact: raffaele.nutricato@tiscali.it // ----------------------------------------------------------------- +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ SCI2CNInArgCheck(argn(2),2,2); +// ----------------------- +// --- Initialization. --- +// ----------------------- nxtscifunname = SharedInfo.NextSCIFunName; nxtscifunnumber = SharedInfo.NextSCIFunNumber; ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; +PrintStringInfo(' ',ReportFileName,'file','y'); +PrintStringInfo('***Reading AST***',ReportFileName,'file','y'); global SCI2CSTACK global StackPosition; global STACKDEDUG +// --------------------------- +// --- End Initialization. --- +// --------------------------- + +// ------------------------------ +// --- Extract function name. --- +// ------------------------------ buffstring = AST_PopASTStack(); LabelFunctName = 'Operator: '; FunctionName = stripblanks(part(buffstring,length(LabelFunctName)+1:length(buffstring))); +// Generate the proper function name. FunctionName = Operator2FunName(FunctionName); +// ------------------------------ +// --- Read input parameters. --- +// ------------------------------ RhsField = AST_PopASTStack(); NInArg = 0; while (RhsField ~= 'Operands:') @@ -36,6 +77,7 @@ while (RhsField ~= 'Operands:') end if (stripblanks(InputArgumentNames(NInArg)) == '<empty>') + //NUT: forse non serve per l'operation NInArg = 0; InputArgumentNames = []; InputArgumentScope = []; @@ -43,22 +85,43 @@ end InputArgumentNames = SCI2Cflipud(InputArgumentNames); InputArgumentScope = SCI2Cflipud(InputArgumentScope); +//#RNU_RES_B +// Remove tag "Operation" from the stack. +//#RNU_RES_E OperationField = AST_PopASTStack(); if (OperationField ~= 'Operation') then SCI2Cerror('Problems with Operation, Expected Operation tag.'); end +// -------------------------------------------- +// --- Extract number of output parameters. --- +// -------------------------------------------- if (FunctionName == 'ins') NOutArg = 0; // It is always 1. Double check it! else NOutArg = 1; // It is always 1. Double check it! end - +// ------------------------------------- +// --- Generate the InArg structure. --- +// ------------------------------------- InArg = []; for counterinputargs = 1:NInArg InArg(counterinputargs).Name=InputArgumentNames(counterinputargs); InArg(counterinputargs).Scope=InputArgumentScope(counterinputargs); end +//#RNU_RES_B +PrintStringInfo('Operation Name: '+FunctionName,ReportFileName,'file','y'); +PrintStringInfo('N Intput Arguments: '+string(NInArg),ReportFileName,'file','y'); +PrintStringInfo('N Output Arguments: '+string(NOutArg),ReportFileName,'file','y'); +//#RNU_RES_E +for counterinputargs = 1:NInArg + //#RNU_RES_B + PrintStringInfo('Input Argument Number '+string(counterinputargs)+': '+InArg(counterinputargs).Name,... + ReportFileName,'file','y'); + PrintStringInfo(' Scope: '+InArg(counterinputargs).Scope,... + ReportFileName,'file','y'); + //#RNU_RES_E +end endfunction diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_PopSCI2CStack.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_PopSCI2CStack.sci index d32cb400..bff1d9fa 100644 --- a/src/Scilab2C/Scilab2C/ASTManagement/AST_PopSCI2CStack.sci +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_PopSCI2CStack.sci @@ -1,6 +1,14 @@ function stackelement = AST_PopASTStack() // function stackelement = AST_PopASTStack() // ----------------------------------------------------------------- +// Pop the AST stack. +// +// Input data: +// --- +// +// Output data: +// //NUT: add description here +// // Status: // 11-Aug-2007 -- Raffaele Nutricato: Author. // @@ -8,6 +16,9 @@ function stackelement = AST_PopASTStack() // Contact: raffaele.nutricato@tiscali.it // ----------------------------------------------------------------- +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ SCI2CNInArgCheck(argn(2),0,0); global SCI2CSTACK; diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_PushSCI2CStack.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_PushSCI2CStack.sci index 130f300f..34cd883b 100644 --- a/src/Scilab2C/Scilab2C/ASTManagement/AST_PushSCI2CStack.sci +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_PushSCI2CStack.sci @@ -1,6 +1,13 @@ function AST_PushASTStack(stackelement) // function AST_PushASTStack(stackelement) // ----------------------------------------------------------------- +// Push the AST stack. +// +// Input data: +// --- +// +// Output data: +// //NUT: add description here // // Status: // 11-Aug-2007 -- Raffaele Nutricato: Author. @@ -9,6 +16,9 @@ function AST_PushASTStack(stackelement) // Contact: raffaele.nutricato@tiscali.it // ----------------------------------------------------------------- +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ SCI2CNInArgCheck(argn(2),1,1); diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_ReadASTHeader.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_ReadASTHeader.sci index cf92d881..3df6cd28 100644 --- a/src/Scilab2C/Scilab2C/ASTManagement/AST_ReadASTHeader.sci +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_ReadASTHeader.sci @@ -1,6 +1,20 @@ function ASTHeader = AST_ReadASTHeader(fidAST,ReportFileName) // function ASTHeader = AST_ReadASTHeader(fidAST,ReportFileName) // ----------------------------------------------------------------- +// Reads the AST header +// txt=['Program' +// 'Name : '+p.name +// 'Outputs: '+strcat(objectlist2string(p.outputs),' ') +// 'Inputs : '+strcat(objectlist2string(p.inputs),' ') +// 'Statements ' +// +// Input data: +// //NUT: add description here +// +// +// Output data: +// //NUT: add description here +// // // Status: // 11-Apr-2007 -- Raffaele Nutricato: Author. @@ -23,7 +37,7 @@ treeline = stripblanks(tline); if STACKDEDUG == 1 disp('Read AST Line: '+treeline); end -if (SCI2Cstrncmps1size('Program',treeline) == 0) +if (SCI2Cstrncmps1size('Program',treeline) == %F) SCI2CerrorFile('Expected ""Program"" label in the AST',ReportFileName); end @@ -33,7 +47,7 @@ treeline = stripblanks(tline); if STACKDEDUG == 1 disp('Read AST Line: '+treeline); end -if (SCI2Cstrncmps1size('Name : ',treeline) == 0) +if (SCI2Cstrncmps1size('Name : ',treeline) == %F) SCI2CerrorFile('Expected ""Name : "" label in the AST',ReportFileName); else ASTHeader.Name = stripblanks(part(treeline,length('Name : ')+1:length(treeline))); @@ -45,7 +59,7 @@ treeline = stripblanks(tline); if STACKDEDUG == 1 disp('Read AST Line: '+treeline); end -if (SCI2Cstrncmps1size('Outputs: ',treeline) == 0) +if (SCI2Cstrncmps1size('Outputs: ',treeline) == %F) SCI2CerrorFile('Expected ""Outputs: "" label in the AST',ReportFileName); else ASTHeader.Outputs = stripblanks(part(treeline,length('Outputs: ')+1:length(treeline))); @@ -57,7 +71,7 @@ treeline = stripblanks(tline); if STACKDEDUG == 1 disp('Read AST Line: '+treeline); end -if (SCI2Cstrncmps1size('Inputs : ',treeline) == 0) +if (SCI2Cstrncmps1size('Inputs : ',treeline) == %F) SCI2CerrorFile('Expected ""Inputs : "" label in the AST',ReportFileName); else ASTHeader.Inputs = stripblanks(part(treeline,length('Inputs : ')+1:length(treeline))); @@ -69,7 +83,7 @@ treeline = stripblanks(tline); if STACKDEDUG == 1 disp('Read AST Line: '+treeline); end -if (SCI2Cstrncmps1size('Statements ',treeline) == 0) +if (SCI2Cstrncmps1size('Statements ',treeline) == %F) SCI2CerrorFile('Expected ""Statements "" label in the AST',ReportFileName); end diff --git a/src/Scilab2C/Scilab2C/ASTManagement/AST_ReadEqualRhsNames.sci b/src/Scilab2C/Scilab2C/ASTManagement/AST_ReadEqualRhsNames.sci index f4424de5..96ec3ebe 100644 --- a/src/Scilab2C/Scilab2C/ASTManagement/AST_ReadEqualRhsNames.sci +++ b/src/Scilab2C/Scilab2C/ASTManagement/AST_ReadEqualRhsNames.sci @@ -1,6 +1,14 @@ function [RhsNames,RhsScope,NRhs] = AST_ReadEqualRhsNames(FileInfo,SharedInfo) // function [RhsNames,RhsScope,NRhs] = AST_ReadEqualRhsNames(FileInfo,SharedInfo) // ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// // Status: // 11-Apr-2007 -- Raffaele Nutricato: Author. // @@ -24,6 +32,10 @@ global SCI2CSTACK global StackPosition; global STACKDEDUG +//#RNU_RES_B +PrintStringInfo(' ',ReportFileName,'file','y'); +PrintStringInfo('***Reading Equal Rhs Names***',ReportFileName,'file','y'); +//#RNU_RES_E // ------------------------------- // --- Read Output parameters. --- @@ -41,6 +53,7 @@ end RhsNames = SCI2Cflipud(RhsNames); RhsScope = SCI2Cflipud(RhsScope); +// --- Repush everything into the stack. --- for cntpush = cntpop:-1:1 AST_PushASTStack(RhsField(cntpush)); end diff --git a/src/Scilab2C/Scilab2C/ASTManagement/GenOutArgNames.sci b/src/Scilab2C/Scilab2C/ASTManagement/GenOutArgNames.sci index 1107f321..d31d4ca5 100644 --- a/src/Scilab2C/Scilab2C/ASTManagement/GenOutArgNames.sci +++ b/src/Scilab2C/Scilab2C/ASTManagement/GenOutArgNames.sci @@ -1,6 +1,18 @@ function [OutArg,SharedInfo] = GenOutArgNames(FunctionName,InArg,NInArg,OldOutArg,NOutArg,LhsArg,NLhsArg,FileInfo,SharedInfo) // function [OutArg,SharedInfo] = GenOutArgNames(FunctionName,OutArg,NOutArg,LhsArg,NLhsArg,FileInfo,SharedInfo) // ----------------------------------------------------------------- +//#RNU_RES_B +// Generate the names for the temporary variables that store the +// output arguments. +//#RNU_RES_E +// +// Input data: +// //NUT: add description here +// +// Output data: +// OutArg: is the Output arguments structure containing the field +// name that specifies the output argument names. +// //NUT: add description here // // Status: // 11-Apr-2007 -- Raffaele Nutricato: Author. @@ -9,14 +21,33 @@ function [OutArg,SharedInfo] = GenOutArgNames(FunctionName,InArg,NInArg,OldOutAr // Contact: raffaele.nutricato@tiscali.it // ----------------------------------------------------------------- +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ SCI2CNInArgCheck(argn(2),9,9); +// ----------------------- +// --- Initialization. --- +// ----------------------- nxtscifunname = SharedInfo.NextSCIFunName; nxtscifunnumber = SharedInfo.NextSCIFunNumber; ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; +// #RNU_RES_B +PrintStringInfo(' Generating Out Arg names.',ReportFileName,'file','y'); +// #RNU_RES_E OutArg = OldOutArg; +//#RNU_RES_B +// --------------------------------------------------------------------------------------- +// --- Generate the names for the temporary variables that store the output arguments. --- +// --------------------------------------------------------------------------------------- +// At this step only the name of the output arguments can be generated. --- +//#RNU_RES_E if (NLhsArg > 0) + //#RNU_RES_B + // Use the equal Lhs names. + PrintStringInfo('Using Equal Lhs names.',ReportFileName,'file','y'); + //#RNU_RES_E if (NLhsArg ~= NOutArg) SCI2CerrorFile('NLhsArg='+string(NLhsArg)+' must be equal to NOutArg='+string(NOutArg)+'.',ReportFileName); end @@ -25,12 +56,21 @@ if (NLhsArg > 0) OutArg(counteroutputargs).Scope=LhsArg(counteroutputargs).Scope; end else + //#RNU_RES_B + // Generate temporary variables. + PrintStringInfo('Generating temporary variables.',ReportFileName,'file','y'); + //#RNU_RES_E if ((sum(mtlb_strcmp(FunctionName,SharedInfo.Annotations.DataPrec)) > 0) & ... (SharedInfo.SkipNextPrec == 1)) + //#RNU_RES_B + PrintStringInfo(' Skipping code generating because already generated in the previous function.',ReportFileName,'file','y'); + //#RNU_RES_E for counteroutputargs = 1:NOutArg OutArg(counteroutputargs).Name = InArg(counteroutputargs).Name; end elseif (mtlb_strcmp(FunctionName,'OpEqual')) + // do nothing. + //NUT: verifica questa parte di codice. e' sicuro che se ho equal gli oldoutarg contengono gia' il nome? else for counteroutputargs = 1:NOutArg if ((SharedInfo.ASTReader.EnableTempVarsReuse == 1) & ... diff --git a/src/Scilab2C/Scilab2C/ASTManagement/Operator2FunName.sci b/src/Scilab2C/Scilab2C/ASTManagement/Operator2FunName.sci index 89cea7fb..de6aebf7 100644 --- a/src/Scilab2C/Scilab2C/ASTManagement/Operator2FunName.sci +++ b/src/Scilab2C/Scilab2C/ASTManagement/Operator2FunName.sci @@ -1,101 +1,118 @@ function FunName = Operator2FunName(OperatorName); -// ----------------------------------------------------------------- -// -// Status: -// 29-May-2007 -- Nutricato Raffaele: Changed code into a function. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- +// -----------------------------------------------------------------
+// Returns the function name corresponding to the input operator.
+// From intmacr2tree.c we have:
+// char *operators[]={"+","-","*",".*","*.",".*.","/","./","/.","./.",
+// "\\",".\\","\\.",".\\.","^","==","<",">","<=",">=","~=",
+// ":","rc","ins","ext","'","cc","|","&","~",".^",".'","cceol"};
+// I also added "<>".
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 29-May-2007 -- Nutricato Raffaele: Changed code into a function.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+//NUT: non e' inserito il "\" verifica come mai.
+//NUT: il ".\" l'ho inserito io
- -SCI2CNInArgCheck(argn(2),1,1); - -FuncPrefix = 'Op'; -FuncSuffix = ''; - -if (OperatorName == '+') - FunName = FuncPrefix+'Plus'+FuncSuffix; -elseif (OperatorName == '-') - FunName = FuncPrefix+'Minus'+FuncSuffix; -elseif (OperatorName == '*') - FunName = FuncPrefix+'Star'+FuncSuffix; -elseif (OperatorName == '.*') - FunName = FuncPrefix+'DotStar'+FuncSuffix; -elseif (OperatorName == '*.') - PrintStringInfo('SCI2CERROR: Operator ""'+OperatorName+'"" not supported.','','stout','y'); - SCI2Cerror(' '); -elseif (OperatorName == '.*.') - PrintStringInfo('SCI2CERROR: Operator ""'+OperatorName+'"" not supported.','','stout','y'); - SCI2Cerror(' '); -elseif (OperatorName == '/') - FunName = FuncPrefix+'Slash'+FuncSuffix; -elseif (OperatorName == './') - FunName = FuncPrefix+'DotSlash'+FuncSuffix; -elseif (OperatorName == '/.') - PrintStringInfo('SCI2CERROR: Operator ""'+OperatorName+'"" not supported.','','stout','y'); - SCI2Cerror(' '); -elseif (OperatorName == './.') - PrintStringInfo('SCI2CERROR: Operator ""'+OperatorName+'"" not supported.','','stout','y'); - SCI2Cerror(' '); -elseif (OperatorName == '.\') - FunName = FuncPrefix+'DotBackSlash'+FuncSuffix; -elseif (OperatorName == '\\') - PrintStringInfo('SCI2CERROR: Operator ""'+OperatorName+'"" not supported.','','stout','y'); - SCI2Cerror(' '); -elseif (OperatorName == '.\\') - PrintStringInfo('SCI2CERROR: Operator ""'+OperatorName+'"" not supported.','','stout','y'); - SCI2Cerror(' '); -elseif (OperatorName == '\\.') - PrintStringInfo('SCI2CERROR: Operator ""'+OperatorName+'"" not supported.','','stout','y'); - SCI2Cerror(' '); -elseif (OperatorName == '.\\.') - PrintStringInfo('SCI2CERROR: Operator ""'+OperatorName+'"" not supported.','','stout','y'); - SCI2Cerror(' '); -elseif (OperatorName == '^') - FunName = FuncPrefix+'Hat'+FuncSuffix; -elseif (OperatorName == '.^') - FunName = FuncPrefix+'DotHat'+FuncSuffix; -elseif (OperatorName == '''') - FunName = FuncPrefix+'Apex'+FuncSuffix; -elseif (OperatorName == '.''') - FunName = FuncPrefix+'DotApex'+FuncSuffix; -elseif (OperatorName == '==') - FunName = FuncPrefix+'LogEq'+FuncSuffix; -elseif (OperatorName == '<') - FunName = FuncPrefix+'LogLt'+FuncSuffix; -elseif (OperatorName == '>') - FunName = FuncPrefix+'LogGt'+FuncSuffix; -elseif (OperatorName == '<=') - FunName = FuncPrefix+'LogLe'+FuncSuffix; -elseif (OperatorName == '>=') - FunName = FuncPrefix+'LogGe'+FuncSuffix; -elseif (OperatorName == '~=') - FunName = FuncPrefix+'LogNe'+FuncSuffix; -elseif (OperatorName == '<>') - FunName = FuncPrefix+'LogNe'+FuncSuffix; -elseif (OperatorName == '|') - FunName = FuncPrefix+'LogOr'+FuncSuffix; -elseif (OperatorName == '&') - FunName = FuncPrefix+'LogAnd'+FuncSuffix; -elseif (OperatorName == '~') - FunName = FuncPrefix+'LogNot'+FuncSuffix; -elseif (OperatorName == ':') - FunName = FuncPrefix+'Colon'+FuncSuffix; -elseif (OperatorName == 'rc') - FunName = 'OpRc'; -elseif (OperatorName == 'cc') - FunName = 'OpCc'; -elseif (OperatorName == 'ins') - FunName = 'OpIns'; -elseif (OperatorName == 'ext') - FunName = 'OpExt'; -elseif (OperatorName == 'cceol') - PrintStringInfo('SCI2CERROR: Operator ""'+OperatorName+'"" not supported.','','stout','y'); - SCI2Cerror(' '); -else - PrintStringInfo('SCI2CERROR: Unknown Operator ""'+OperatorName+'.','','stout','y'); - SCI2Cerror(' '); -end - -endfunction +// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+FuncPrefix = 'Op';
+FuncSuffix = '';
+
+if (OperatorName == '+')
+ FunName = FuncPrefix+'Plus'+FuncSuffix;
+elseif (OperatorName == '-')
+ FunName = FuncPrefix+'Minus'+FuncSuffix;
+elseif (OperatorName == '*')
+ FunName = FuncPrefix+'Star'+FuncSuffix;
+elseif (OperatorName == '.*')
+ FunName = FuncPrefix+'DotStar'+FuncSuffix;
+elseif (OperatorName == '*.')
+ PrintStringInfo('SCI2CERROR: Operator ""'+OperatorName+'"" not supported.','','stout','y');
+ SCI2Cerror(' ');
+elseif (OperatorName == '.*.')
+ PrintStringInfo('SCI2CERROR: Operator ""'+OperatorName+'"" not supported.','','stout','y');
+ SCI2Cerror(' ');
+elseif (OperatorName == '/')
+ FunName = FuncPrefix+'Slash'+FuncSuffix;
+elseif (OperatorName == './')
+ FunName = FuncPrefix+'DotSlash'+FuncSuffix;
+elseif (OperatorName == '/.')
+ PrintStringInfo('SCI2CERROR: Operator ""'+OperatorName+'"" not supported.','','stout','y');
+ SCI2Cerror(' ');
+elseif (OperatorName == './.')
+ PrintStringInfo('SCI2CERROR: Operator ""'+OperatorName+'"" not supported.','','stout','y');
+ SCI2Cerror(' ');
+elseif (OperatorName == '.\')
+ FunName = FuncPrefix+'DotBackSlash'+FuncSuffix;
+elseif (OperatorName == '\\')
+ PrintStringInfo('SCI2CERROR: Operator ""'+OperatorName+'"" not supported.','','stout','y');
+ SCI2Cerror(' ');
+elseif (OperatorName == '.\\')
+ PrintStringInfo('SCI2CERROR: Operator ""'+OperatorName+'"" not supported.','','stout','y');
+ SCI2Cerror(' ');
+elseif (OperatorName == '\\.')
+ PrintStringInfo('SCI2CERROR: Operator ""'+OperatorName+'"" not supported.','','stout','y');
+ SCI2Cerror(' ');
+elseif (OperatorName == '.\\.')
+ PrintStringInfo('SCI2CERROR: Operator ""'+OperatorName+'"" not supported.','','stout','y');
+ SCI2Cerror(' ');
+elseif (OperatorName == '^')
+ FunName = FuncPrefix+'Hat'+FuncSuffix;
+elseif (OperatorName == '.^')
+ FunName = FuncPrefix+'DotHat'+FuncSuffix;
+elseif (OperatorName == '''')
+ FunName = FuncPrefix+'Apex'+FuncSuffix;
+elseif (OperatorName == '.''')
+ FunName = FuncPrefix+'DotApex'+FuncSuffix;
+elseif (OperatorName == '==')
+ FunName = FuncPrefix+'LogEq'+FuncSuffix;
+elseif (OperatorName == '<')
+ FunName = FuncPrefix+'LogLt'+FuncSuffix;
+elseif (OperatorName == '>')
+ FunName = FuncPrefix+'LogGt'+FuncSuffix;
+elseif (OperatorName == '<=')
+ FunName = FuncPrefix+'LogLe'+FuncSuffix;
+elseif (OperatorName == '>=')
+ FunName = FuncPrefix+'LogGe'+FuncSuffix;
+elseif (OperatorName == '~=')
+ FunName = FuncPrefix+'LogNe'+FuncSuffix;
+elseif (OperatorName == '<>')
+ FunName = FuncPrefix+'LogNe'+FuncSuffix;
+elseif (OperatorName == '|')
+ FunName = FuncPrefix+'LogOr'+FuncSuffix;
+elseif (OperatorName == '&')
+ FunName = FuncPrefix+'LogAnd'+FuncSuffix;
+elseif (OperatorName == '~')
+ FunName = FuncPrefix+'LogNot'+FuncSuffix;
+elseif (OperatorName == ':')
+ FunName = FuncPrefix+'Colon'+FuncSuffix;
+elseif (OperatorName == 'rc')
+ FunName = 'OpRc';
+elseif (OperatorName == 'cc')
+ FunName = 'OpCc';
+elseif (OperatorName == 'ins')
+ FunName = 'OpIns';
+elseif (OperatorName == 'ext')
+ FunName = 'OpExt';
+elseif (OperatorName == 'cceol')
+ PrintStringInfo('SCI2CERROR: Operator ""'+OperatorName+'"" not supported.','','stout','y');
+ SCI2Cerror(' ');
+else
+ PrintStringInfo('SCI2CERROR: Unknown Operator ""'+OperatorName+'.','','stout','y');
+ SCI2Cerror(' ');
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/ASTManagement/SciFile2ASTFile.sci b/src/Scilab2C/Scilab2C/ASTManagement/SciFile2ASTFile.sci index ed377eb8..943b8e58 100644 --- a/src/Scilab2C/Scilab2C/ASTManagement/SciFile2ASTFile.sci +++ b/src/Scilab2C/Scilab2C/ASTManagement/SciFile2ASTFile.sci @@ -1,6 +1,16 @@ function SciFile2ASTFile(SciFile,ASTFile); // function SciFile2ASTFile(SciFile,ASTFile); // ----------------------------------------------------------------- +// This function makes use of the macr2tree function to generate +// the ASTFile containing the AST (Abstract Syntactic Tree) of the +// input Scilab function (SciFile). +// +// Input data: +// SciFile: full path of the input function. +// ASTFile: full path of the file that will store the AST. +// +// Output data: +// --- // // Status: // 12-Apr-2007 -- Raffaele Nutricato: Author. diff --git a/src/Scilab2C/Scilab2C/CCodeGeneration/C_FinalizeCode.sci b/src/Scilab2C/Scilab2C/CCodeGeneration/C_FinalizeCode.sci index 222ce911..2c6b600c 100644 --- a/src/Scilab2C/Scilab2C/CCodeGeneration/C_FinalizeCode.sci +++ b/src/Scilab2C/Scilab2C/CCodeGeneration/C_FinalizeCode.sci @@ -1,6 +1,13 @@ function C_FinalizeCode(FileInfo,SharedInfo) // function C_FinalizeCode(FileInfo,SharedInfo) // ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 27-Oct-2007 -- Raffaele Nutricato: Author. @@ -14,23 +21,46 @@ function C_FinalizeCode(FileInfo,SharedInfo) // ------------------------------ SCI2CNInArgCheck(argn(2),2,2); +// ----------------------- +// --- Initialization. --- +// ----------------------- +// --- Load File Info Structure. --- load(FileInfoDatFile,'FileInfo'); +// --- Load Shared Info Structure. --- load(FileInfo.SharedInfoDatFile,'SharedInfo'); CPass2FileName = FileInfo.Funct(SharedInfo.NextSCIFunNumber).CPass2FileName; FinalCFileName = FileInfo.Funct(SharedInfo.NextSCIFunNumber).FinalCFileName; Pass1HeaderFileName = FileInfo.Funct(SharedInfo.NextSCIFunNumber).Pass1HeaderFileName; FinalHeaderFileName = FileInfo.Funct(SharedInfo.NextSCIFunNumber).FinalHeaderFileName; +// #RNU_RES_B +PrintStringInfo('Generating the final C code in:'+FinalCFileName,... + FileInfo.Funct(SharedInfo.NextSCIFunNumber).ReportFileName,'file','y'); +// #RNU_RES_E +// --------------------------- +// --- End Initialization. --- +// --------------------------- +// --------------------------------- +// --- Finalize the header file. --- +// --------------------------------- PrintStringInfo('/*',Pass1HeaderFileName,'file','y'); PrintStringInfo('** ---------------------------- ',Pass1HeaderFileName,'file','y'); PrintStringInfo('** --- End USER2C Includes. --- ',Pass1HeaderFileName,'file','y'); PrintStringInfo('** ---------------------------- ',Pass1HeaderFileName,'file','y'); PrintStringInfo('*/',Pass1HeaderFileName,'file','y'); +// ------------------------------------- +// --- End Finalize the header file. --- +// ------------------------------------- [tmphdrpath,tmphdrname,tmphdrext] = fileparts(Pass1HeaderFileName); +// #RNU_RES_B +// -------------------------------------------------- +// --- Copy the C code into the C code directory. --- +// -------------------------------------------------- +// #RNU_RES_E C_SCI2CHeader(FinalCFileName); PrintStringInfo('/*',FinalCFileName,'file','y'); PrintStringInfo('** ----------------- ',FinalCFileName,'file','y'); diff --git a/src/Scilab2C/Scilab2C/CCodeGeneration/C_ForExpression.sci b/src/Scilab2C/Scilab2C/CCodeGeneration/C_ForExpression.sci index a290a24e..7afc5526 100644 --- a/src/Scilab2C/Scilab2C/CCodeGeneration/C_ForExpression.sci +++ b/src/Scilab2C/Scilab2C/CCodeGeneration/C_ForExpression.sci @@ -1,6 +1,13 @@ function SharedInfo = C_ForExpression(FileInfo,SharedInfo) // function SharedInfo = C_ForExpression(FileInfo,SharedInfo) // ----------------------------------------------------------------- +// Get function for a generic SCI2C table. +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 15-Nov-2007 -- Raffaele Nutricato: Author. @@ -14,6 +21,9 @@ function SharedInfo = C_ForExpression(FileInfo,SharedInfo) // ------------------------------ SCI2CNInArgCheck(argn(2),2,2); +// ----------------------- +// --- Initialization. --- +// ----------------------- nxtscifunname = SharedInfo.NextSCIFunName; nxtscifunnumber = SharedInfo.NextSCIFunNumber; @@ -23,65 +33,179 @@ CPass1ForProlFileName = FileInfo.Funct(nxtscifunnumber).CPass1ForProlFileName(Sh CDeclarationFileName = FileInfo.Funct(nxtscifunnumber).CDeclarationFileName; CPass1ForEpilFileName = FileInfo.Funct(nxtscifunnumber).CPass1ForEpilFileName(SharedInfo.For.Level); +// #RNU_RES_B +PrintStringInfo(' ',ReportFileName,'file','y'); +PrintStringInfo('***Generating C code***',ReportFileName,'file','y'); +// #RNU_RES_E CCall =''; +// --------------------------- +// --- End Initialization. --- +// --------------------------- +// ---------------------------- +// --- Generate the C call. --- +// ---------------------------- + +// ------------------------- +// --- Manage all cases. --- +// ------------------------- if (SharedInfo.ForExpr.AssignmentFun == SharedInfo.CFunId.EqScalar) + // #RNU_RES_B + // --------------- + // --- Case 1. --- + // --------------- + PrintStringInfo(' Handling For Expression with scalar equal.',ReportFileName,'file','y'); + + // for a = 10 or for a = sin(tan(b)) where b is scalar: + // In this case non for loops are needed.--> Do nothing! + // ------------------------------------------------------------------------------------- + // --- Generate Prologue and Epilogue -> Copy the first N-1 lines of the for.c code. --- + // ------------------------------------------------------------------------------------- + // #RNU_RES_E [C_Strings,NumCStrings] = File2StringArray(FileInfo.Funct(nxtscifunnumber).CPass1ForProlFileName(SharedInfo.For.Level)); C_Strings = stripblanks(C_Strings); for cntstr = 1:NumCStrings + // #RNU_RES_B + // Prologue + // #RNU_RES_E PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+C_Strings(cntstr),CPass1FileName,'file','y'); end + // #RNU_RES_B + // Epilogue + // #RNU_RES_E PrintStringInfo(' ',CPass1ForEpilFileName ,'file','y'); elseif (SharedInfo.ForExpr.AssignmentFun == SharedInfo.CFunId.OpColon) + // #RNU_RES_B + // --------------- + // --- Case 2. --- + // --------------- + // for a = 1:10 + PrintStringInfo(' Handling For Expression with OpColon.',ReportFileName,'file','y'); + // #RNU_RES_E + + // #RNU_RES_B + // ------------------------------------------------------------------------------------- + // --- Generate Prologue and Epilogue -> Copy the first N-1 lines of the for.c code. --- + // ------------------------------------------------------------------------------------- + // #RNU_RES_E [C_Strings,NumCStrings] = File2StringArray(FileInfo.Funct(nxtscifunnumber).CPass1ForProlFileName(SharedInfo.For.Level)); C_Strings = stripblanks(C_Strings); for cntstr = 1:NumCStrings + // #RNU_RES_B + // Prologue + // #RNU_RES_E PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+C_Strings(cntstr),CPass1FileName,'file','y'); + // #RNU_RES_B + // Epilogue + // #RNU_RES_E PrintStringInfo(C_Strings(cntstr),CPass1ForEpilFileName ,'file','y'); end + // #RNU_RES_B + // ---------------------------------------- + // --- Insert "}" in the epilogue file. --- + // ---------------------------------------- + // #RNU_RES_E PrintStringInfo('}',CPass1ForEpilFileName ,'file','y'); + // #RNU_RES_B + // ------------------------------ + // --- Insert for expression. --- + // ------------------------------ + // #RNU_RES_E CCall = 'for('+SharedInfo.ForExpr.SclValCntArg.Name+' = '+SharedInfo.ForExpr.OpColonInfoIn1+'; '... +SharedInfo.ForExpr.SclValCntArg.Name+' <= '+SharedInfo.ForExpr.OpColonInfoIn3+'; '... +SharedInfo.ForExpr.SclValCntArg.Name+' += '+SharedInfo.ForExpr.OpColonInfoIn2+')'; PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+CCall,CPass1FileName,'file','y'); + // #RNU_RES_B + // ------------------- + // --- Insert "{". --- + // ------------------- + // #RNU_RES_E CCall = '{'; PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+CCall,CPass1FileName,'file','y'); + // --------------------------------- + // --- Update Indentation Level. --- + // --------------------------------- SharedInfo.NIndent = SharedInfo.NIndent + 1; elseif (SharedInfo.ForExpr.AssignmentFun == SharedInfo.CFunId.EqMatrix | ... SharedInfo.ForExpr.AssignmentFun == SharedInfo.CFunId.GenFunMtx) + // #RNU_RES_B + // --------------- + // --- Case 3. --- + // --------------- + PrintStringInfo(' Handling For Expression with Matrix Equal/Function.',ReportFileName,'file','y'); + + // for cnt = TMP where TMP is a matrix + // for cnt = fun(TMP) where TMP is a matrix + // Conversion is performed as shown in the following example: + // init code for temp vars --> copy all for.c code (up to last-1 line) into C pass1 code. + // intSCI2C __forcnt1; --> declaration file. + // replace in the last C line CntArg.Name with '__TmpVal'+CntArg.Name + // for (__forcnt1 = 0; __forcnt1 < CntArg.Size(1)*CntArg.Size(2); __forcnt1++) + // { + // CntArg.Name = '__TmpVal'+CntArg.Name[__forcnt1]; + // init code for temp vars + // } - + // ------------------------------------------------------------------------------------- + // --- Generate Prologue and Epilogue -> Copy the first N-1 lines of the for.c code. --- + // ------------------------------------------------------------------------------------- + // #RNU_RES_E [C_Strings,NumCStrings] = File2StringArray(FileInfo.Funct(nxtscifunnumber).CPass1ForProlFileName(SharedInfo.For.Level)); C_Strings = stripblanks(C_Strings); for cntstr = 1:NumCStrings + // Prologue PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+C_Strings(cntstr),CPass1FileName,'file','y'); + // Epilogue PrintStringInfo(C_Strings(cntstr),CPass1ForEpilFileName ,'file','y'); end + // #RNU_RES_B + // ---------------------------------------- + // --- Insert "}" in the epilogue file. --- + // ---------------------------------------- + // #RNU_RES_E PrintStringInfo('}',CPass1ForEpilFileName ,'file','y'); + // ------------------------------ + // --- Insert for expression. --- + // ------------------------------ CCall = 'for('+SharedInfo.ForExpr.IntCntArg.Name+' = 0'+'; '+... SharedInfo.ForExpr.IntCntArg.Name+' < '+SharedInfo.ForExpr.MtxValCntArg.Size(1)+'*'+SharedInfo.ForExpr.MtxValCntArg.Size(2)+'; '+... SharedInfo.ForExpr.IntCntArg.Name+'++)'; PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+CCall,CPass1FileName,'file','y'); + // ------------------- + // --- Insert "{". --- + // ------------------- CCall = '{'; PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+CCall,CPass1FileName,'file','y'); + // --------------------------------- + // --- Update Indentation Level. --- + // --------------------------------- SharedInfo.NIndent = SharedInfo.NIndent + 1; + // #RNU_RES_B + // ---------------------------------------------------- + // --- Add code to read the element of CntArg.Name. --- + // ---------------------------------------------------- + // #RNU_RES_E CCall = SharedInfo.ForExpr.SclValCntArg.Name+' = '+SharedInfo.ForExpr.MtxValCntArg.Name+'['+SharedInfo.ForExpr.IntCntArg.Name+'];'; PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+CCall,CPass1FileName,'file','y'); else + // --------------- + // --- Case 5. --- + // --------------- + SCI2Cerror('Could not manage the for expression.'); end diff --git a/src/Scilab2C/Scilab2C/CCodeGeneration/C_GenDeclarations.sci b/src/Scilab2C/Scilab2C/CCodeGeneration/C_GenDeclarations.sci index 5caa8d7c..d63fcf41 100644 --- a/src/Scilab2C/Scilab2C/CCodeGeneration/C_GenDeclarations.sci +++ b/src/Scilab2C/Scilab2C/CCodeGeneration/C_GenDeclarations.sci @@ -1,90 +1,132 @@ -function Cdeclaration = C_GenDeclarations(ArgStruct,CDeclarationFileName,IndentLevel,ReportFileName,FlagExt)
-// function Cdeclaration = C_GenDeclarations(ArgStruct,CDeclarationFileName,IndentLevel,ReportFileName,FlagExt)
-// -----------------------------------------------------------------
-// Status:
-// 27-Oct-2007 -- Raffaele Nutricato: Author.
-// 10-Jun-2008 -- Raffaele Nutricato: adapted to work with realloc function.
-//
-// Copyright 2007 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
-
-// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),5,5);
-
-
-PrintStringInfo(' ',ReportFileName,'file','y');
-PrintStringInfo('***Generating C declaration***',ReportFileName,'file','y');
-
-Cdeclaration = '';
-NDeclarations = 0;
-if (ArgStruct.Dimension > 0)
- if (FlagExt == 1)
- Cdeclaration(1) = 'extern ';
- Cdeclaration(2) = 'extern ';
- else
- Cdeclaration(1) = '';
- Cdeclaration(2) = '';
- end
- if (ArgStruct.Type=='g')
- if (isnan(ArgStruct.Value))
- Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+...
- ' * '+ArgStruct.Name+';';
- else
- Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+...
- ' '+ArgStruct.Name+'['+ArgStruct.Size(1)+']['+ArgStruct.Size(2)+'] = {'+ArgStruct.Value+'};';
- end
- Cdeclaration(2) = Cdeclaration(2)+C_Type('i')+' __'+ArgStruct.Name+'Size[2] = {'+ArgStruct.Size(1)+','+ArgStruct.Size(2)+'};';
- NDeclarations = 2;
- elseif ((ArgStruct.FindLike == -1) | (SCI2Cisnum(ArgStruct.Size(1))==%F) | (SCI2Cisnum(ArgStruct.Size(2))==%F))
- // Generate only the pointer that will be used by the malloc function.
- Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+'* '+...
- ArgStruct.Name+' = NULL;';
- // Declare the Size array
- Cdeclaration(2) = Cdeclaration(2)+C_Type('i')+' __'+ArgStruct.Name+'Size[2];';
- NDeclarations = 2;
- else
- // Declare the array with its size.
- Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+...
- ' '+ArgStruct.Name+'['+ArgStruct.Size(1)+'*'+ArgStruct.Size(2)+'];';
- Cdeclaration(2) = Cdeclaration(2)+C_Type('i')+' __'+ArgStruct.Name+'Size[2] = {'+ArgStruct.Size(1)+','+ArgStruct.Size(2)+'};';
- NDeclarations = 2;
- end
-else
- if (FlagExt == 1)
- Cdeclaration(1) = 'extern ';
- else
- Cdeclaration(1) = '';
- end
- Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+' '+ArgStruct.Name;
- if (~isnan(ArgStruct.Value) & (FlagExt == 0))
- if isreal(ArgStruct.Value)
- Cdeclaration(1) = Cdeclaration(1)+' = '+SCI2Cstring(ArgStruct.Value);
- else
- if (ArgStruct.Type == 'z')
- Cdeclaration(1) = Cdeclaration(1)+' = DoubleComplex('+SCI2Cstring(real(ArgStruct.Value))+','+SCI2Cstring(imag(ArgStruct.Value))+')';
- else
- Cdeclaration(1) = Cdeclaration(1)+' = FloatComplex('+SCI2Cstring(real(ArgStruct.Value))+','+SCI2Cstring(imag(ArgStruct.Value))+')';
- end
- end
- end
- Cdeclaration(1) = Cdeclaration(1)+';';
- NDeclarations = 1;
-end
-
-
-// --------------------------------------------
-// --- Write C declaration into the C file. ---
-// --------------------------------------------
-for cntdecl = 1:NDeclarations
- PrintStringInfo(' '+Cdeclaration(cntdecl),ReportFileName,'file','y');
-end
-PrintStringInfo(' Writing C declaration in: '+CDeclarationFileName,ReportFileName,'file','y');
-for cntdecl = 1:NDeclarations
- PrintStringInfo(C_IndentBlanks(IndentLevel)+Cdeclaration(cntdecl),CDeclarationFileName,'file','y');
-end
-PrintStringInfo(' ',CDeclarationFileName,'file','y');
-
-endfunction
+function Cdeclaration = C_GenDeclarations(ArgStruct,CDeclarationFileName,IndentLevel,ReportFileName,FlagExt,ResizeApproach) +// function Cdeclaration = C_GenDeclarations(ArgStruct,CDeclarationFileName,IndentLevel,ReportFileName,FlagExt,ResizeApproach) +// ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 27-Oct-2007 -- Raffaele Nutricato: Author. +// 10-Jun-2008 -- Raffaele Nutricato: adapted to work with realloc function. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),6,6); + +// #RNU_RES_B +//NUT: ilnome di questa funzione va cambiato perche' le dichiarazioni le fanno anche i for e i while. + +PrintStringInfo(' ',ReportFileName,'file','y'); +PrintStringInfo('***Generating C declaration***',ReportFileName,'file','y'); +// #RNU_RES_E + +Cdeclaration = ''; +NDeclarations = 0; +if (ArgStruct.Dimension > 0) + if (FlagExt == 1) + Cdeclaration(1) = 'extern '; + Cdeclaration(2) = 'extern '; + else + Cdeclaration(1) = ''; + Cdeclaration(2) = ''; + end + // #RNU_RES_B + //NUT: vedi Mem_Alloc_Out per maggiori info sulla rimozione della temp nella if + // if ((ArgStruct.Scope=='Temp') | (ArgStruct.FindLike == -1) | (SCI2Cisnum(ArgStruct.Size(1))==%F) | (SCI2Cisnum(ArgStruct.Size(2))==%F)) + // #RNU_RES_E + if (ArgStruct.Type=='g') + if (isnan(ArgStruct.Value)) + Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+... + ' * '+ArgStruct.Name+';'; + else + if (FlagExt == 1) + Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+... + ' '+ArgStruct.Name+'['+ArgStruct.Size(1)+'*'+ArgStruct.Size(2)+'];'; + else + Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+... + ' '+ArgStruct.Name+'['+ArgStruct.Size(1)+'*'+ArgStruct.Size(2)+'] = {'+ArgStruct.Value+'};'; + end + end + Cdeclaration(2) = Cdeclaration(2)+C_Type('i')+' __'+ArgStruct.Name+'Size[2] = {'+ArgStruct.Size(1)+','+ArgStruct.Size(2)+'};'; + NDeclarations = 2; + elseif ((ArgStruct.FindLike == -1) | ... + (SCI2Cisnum(ArgStruct.Size(1))==%F) | (SCI2Cisnum(ArgStruct.Size(2))==%F) | ... + (ResizeApproach=='REALLOC_ALL_RESIZE_ALL' & ArgStruct.Type~='g')) + // #RNU_RES_B + //RNU sulle stringhe non ho ancora deciso se applicare la realloc. + // Generate only the pointer that will be used by the malloc function. + // #RNU_RES_E + if (FlagExt == 1) + Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+'* '+... + ArgStruct.Name+';'; + else + Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+'* '+... + ArgStruct.Name+' = NULL;'; + end + // Declare the Size array + Cdeclaration(2) = Cdeclaration(2)+C_Type('i')+' __'+ArgStruct.Name+'Size[2];'; + NDeclarations = 2; + else + // Declare the array with its size. + Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+... + ' '+ArgStruct.Name+'['+ArgStruct.Size(1)+'*'+ArgStruct.Size(2)+'];'; + if (FlagExt == 1) + Cdeclaration(2) = Cdeclaration(2)+C_Type('i')+' __'+ArgStruct.Name+'Size[2];'; + else + Cdeclaration(2) = Cdeclaration(2)+C_Type('i')+' __'+ArgStruct.Name+'Size[2] = {'+ArgStruct.Size(1)+','+ArgStruct.Size(2)+'};'; + end + NDeclarations = 2; + end +else + if (FlagExt == 1) + Cdeclaration(1) = 'extern '; + else + Cdeclaration(1) = ''; + end + Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+' '+ArgStruct.Name; + if (~isnan(ArgStruct.Value) & (FlagExt == 0)) + if isreal(ArgStruct.Value) + Cdeclaration(1) = Cdeclaration(1)+' = '+SCI2Cstring(ArgStruct.Value); + else + if (ArgStruct.Type == 'z') + Cdeclaration(1) = Cdeclaration(1)+' = DoubleComplex('+SCI2Cstring(real(ArgStruct.Value))+','+SCI2Cstring(imag(ArgStruct.Value))+')'; + else + Cdeclaration(1) = Cdeclaration(1)+' = FloatComplex('+SCI2Cstring(real(ArgStruct.Value))+','+SCI2Cstring(imag(ArgStruct.Value))+')'; + end + end + end + Cdeclaration(1) = Cdeclaration(1)+';'; + NDeclarations = 1; +end + + +// -------------------------------------------- +// --- Write C declaration into the C file. --- +// -------------------------------------------- +for cntdecl = 1:NDeclarations + // #RNU_RES_B + PrintStringInfo(' '+Cdeclaration(cntdecl),ReportFileName,'file','y'); + // #RNU_RES_E +end +// #RNU_RES_B +PrintStringInfo(' Writing C declaration in: '+CDeclarationFileName,ReportFileName,'file','y'); +// #RNU_RES_E +for cntdecl = 1:NDeclarations + PrintStringInfo(C_IndentBlanks(IndentLevel)+Cdeclaration(cntdecl),CDeclarationFileName,'file','y'); +end +PrintStringInfo(' ',CDeclarationFileName,'file','y'); + +endfunction +// #RNU_RES_B +//NUT: dove sta il controllo che verifica se dopo aver dichiarato una local A[10] essa viene utilizzata +//NUT: per memorizzare un A = sin(B) dove B[11]?? +// #RNU_RES_E diff --git a/src/Scilab2C/Scilab2C/CCodeGeneration/C_GenerateFunName.sci b/src/Scilab2C/Scilab2C/CCodeGeneration/C_GenerateFunName.sci index 3ab9daed..b5b8c12d 100644 --- a/src/Scilab2C/Scilab2C/CCodeGeneration/C_GenerateFunName.sci +++ b/src/Scilab2C/Scilab2C/CCodeGeneration/C_GenerateFunName.sci @@ -1,6 +1,13 @@ function CFunName = C_GenerateFunName(FunctionName,InArg,NInArg,OutArg,NOutArg) // function CFunName = C_GenerateFunName(FunctionName,InArg,NInArg,OutArg,NOutArg) // ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 26-Oct-2007 -- Raffaele Nutricato: Author. diff --git a/src/Scilab2C/Scilab2C/CCodeGeneration/C_GenerateLaunchScript.sci b/src/Scilab2C/Scilab2C/CCodeGeneration/C_GenerateLaunchScript.sci index cedc0291..027d4c70 100644 --- a/src/Scilab2C/Scilab2C/CCodeGeneration/C_GenerateLaunchScript.sci +++ b/src/Scilab2C/Scilab2C/CCodeGeneration/C_GenerateLaunchScript.sci @@ -1,6 +1,17 @@ function C_GenerateLaunchScript(OutDir,ListSCI2CInputPrmFiles) // function C_GenerateLaunchScript(OutDir,ListSCI2CInputPrmFiles) // ----------------------------------------------------------------- +// #RNU_RES_B +// Generate the script that can be used to compile all the regression +// tests and to run them and finally to write results in the report +// file. +// #RNU_RES_E +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 26-Jan-2008 -- Raffaele Nutricato: Author. diff --git a/src/Scilab2C/Scilab2C/CCodeGeneration/C_GenerateMakefile.sci b/src/Scilab2C/Scilab2C/CCodeGeneration/C_GenerateMakefile.sci index dab2bf86..cb9bfb6d 100644 --- a/src/Scilab2C/Scilab2C/CCodeGeneration/C_GenerateMakefile.sci +++ b/src/Scilab2C/Scilab2C/CCodeGeneration/C_GenerateMakefile.sci @@ -1,6 +1,13 @@ function C_GenerateMakefile(FileInfo,SharedInfo) // function C_GenerateMakefile(FileInfo,SharedInfo) // ----------------------------------------------------------------- +// Generate the makefile. +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 26-Jan-2008 -- Raffaele Nutricato: Author. @@ -31,17 +38,26 @@ PrintStringInfo('# --- USER PARAMETERS ---',FileInfo.MakefileFilename,'file','y' PrintStringInfo('# -----------------------',FileInfo.MakefileFilename,'file','y'); PrintStringInfo('# --- DIRECTORIES AND FILES ---',FileInfo.MakefileFilename,'file','y'); if (SharedInfo.CCompilerPathStyle == 'windows') - makeobjpath = FileInfo.CStyleSCI2CMainDir+'\CFiles\sci2cobj'; - makecsrcdir = FileInfo.CStyleSCI2CMainDir+'\CFiles\sci2ccode'; - makehsrcdir = FileInfo.CStyleSCI2CMainDir+'\CFiles\sci2cincludes'; - makeisrcdir = FileInfo.CStyleSCI2CMainDir+'\CFiles\sci2cinterfaces'; + makeobjpath = '..\..\..\Scilab2C\CFiles\sci2cobj'; + // makeobjpath = FileInfo.CStyleSCI2CMainDir+'\CFiles\sci2cobj'; + makecsrcdir = '..\..\..\Scilab2C\CFiles\sci2ccode'; + // makecsrcdir = FileInfo.CStyleSCI2CMainDir+'\CFiles\sci2ccode'; + makehsrcdir = '..\..\..\Scilab2C\CFiles\sci2cincludes'; + // makehsrcdir = FileInfo.CStyleSCI2CMainDir+'\CFiles\sci2cincludes'; + makeisrcdir = '..\..\..\Scilab2C\CFiles\sci2cinterfaces'; + // makeisrcdir = FileInfo.CStyleSCI2CMainDir+'\CFiles\sci2cinterfaces'; makesci2cdir = FileInfo.CStyleOutCCCodeDir; + // makesci2cdir = FileInfo.CStyleOutCCCodeDir; elseif (SharedInfo.CCompilerPathStyle == 'unix' | ... SharedInfo.CCompilerPathStyle == 'cygwin') - makeobjpath = FileInfo.CStyleSCI2CMainDir+'/CFiles/sci2cobj'; - makecsrcdir = FileInfo.CStyleSCI2CMainDir+'/CFiles/sci2ccode'; - makehsrcdir = FileInfo.CStyleSCI2CMainDir+'/CFiles/sci2cincludes'; - makeisrcdir = FileInfo.CStyleSCI2CMainDir+'/CFiles/sci2cinterfaces'; + makeobjpath = '../../../Scilab2C/CFiles/sci2cobj'; + // makeobjpath = FileInfo.CStyleSCI2CMainDir+'/CFiles/sci2cobj'; + makecsrcdir = '../../../Scilab2C/CFiles/sci2ccode'; + // makecsrcdir = FileInfo.CStyleSCI2CMainDir+'/CFiles/sci2ccode'; + makehsrcdir = '../../../Scilab2C/CFiles/sci2cincludes'; + // makehsrcdir = FileInfo.CStyleSCI2CMainDir+'/CFiles/sci2cincludes'; + makeisrcdir = '../../../Scilab2C/CFiles/sci2cinterfaces'; + // makeisrcdir = FileInfo.CStyleSCI2CMainDir+'/CFiles/sci2cinterfaces'; makesci2cdir = FileInfo.CStyleOutCCCodeDir; else PrintStringInfo(' ',ReportFileName,'stdout','y'); diff --git a/src/Scilab2C/Scilab2C/CCodeGeneration/C_IfElseBlocks.sci b/src/Scilab2C/Scilab2C/CCodeGeneration/C_IfElseBlocks.sci index e9375252..71b45966 100644 --- a/src/Scilab2C/Scilab2C/CCodeGeneration/C_IfElseBlocks.sci +++ b/src/Scilab2C/Scilab2C/CCodeGeneration/C_IfElseBlocks.sci @@ -1,6 +1,13 @@ function SharedInfo = C_IfElseBlocks(FileInfo,SharedInfo,InOutStatements) // function SharedInfo = C_IfElseBlocks(FileInfo,SharedInfo,InOutStatements) // ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 27-Oct-2007 -- Raffaele Nutricato: Author. @@ -25,26 +32,37 @@ CPass1FileName = FileInfo.Funct(nxtscifunnumber).CPass1FileName; IndentLevel = SharedInfo.NIndent; +// #RNU_RES_B +PrintStringInfo(' ',ReportFileName,'file','y'); +PrintStringInfo(' Generate ""{"" or ""}"" code for if/else statement',ReportFileName,'file','y'); +// #RNU_RES_E CCall = ''; // --------------------------- // --- End Initialization. --- // --------------------------- +// #RNU_RES_B // ----------------------------------------------------- // --- Generate the C call/Update indentation level. --- // ----------------------------------------------------- +// #RNU_RES_E if (InOutStatements=='in') CCall = CCall+'{'; + PrintStringInfo(' '+CCall,ReportFileName,'file','y'); PrintStringInfo(C_IndentBlanks(IndentLevel)+CCall,CPass1FileName,'file','y'); IndentLevel = IndentLevel + 1; elseif (InOutStatements=='out') CCall = CCall+'}'; IndentLevel = IndentLevel - 1; + PrintStringInfo(' '+CCall,ReportFileName,'file','y'); PrintStringInfo(C_IndentBlanks(IndentLevel)+CCall,CPass1FileName,'file','y'); else SCI2CerrorFile('Unknown setting for InOutStatements: '+InOutStatements'.',ReportFileName); end +// #RNU_RES_B +PrintStringInfo(' Updating indentation level to:'+string(IndentLevel),ReportFileName,'file','y'); +// #RNU_RES_E SharedInfo.NIndent = IndentLevel; endfunction diff --git a/src/Scilab2C/Scilab2C/CCodeGeneration/C_IfExpression.sci b/src/Scilab2C/Scilab2C/CCodeGeneration/C_IfExpression.sci index 020267fe..772f24ff 100644 --- a/src/Scilab2C/Scilab2C/CCodeGeneration/C_IfExpression.sci +++ b/src/Scilab2C/Scilab2C/CCodeGeneration/C_IfExpression.sci @@ -1,6 +1,13 @@ function SharedInfo = C_IfExpression(IfCondArg,NIfCondArg,ASTIfExpType,FileInfo,SharedInfo) // function SharedInfo = C_IfExpression(IfCondArg,NIfCondArg,ASTIfExpType,FileInfo,SharedInfo) // ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 27-Oct-2007 -- Raffaele Nutricato: Author. @@ -14,17 +21,31 @@ function SharedInfo = C_IfExpression(IfCondArg,NIfCondArg,ASTIfExpType,FileInfo, // ------------------------------ SCI2CNInArgCheck(argn(2),5,5); +// --- Check NIfCondArg value. --- if ((NIfCondArg ~= 1) & (ASTIfExpType~='else')) SCI2CerrorFile('Cannot manage ""if/elseif"" with a number of condition variables not equal to 1.',ReportFileName); end +// ----------------------- +// --- Initialization. --- +// ----------------------- nxtscifunname = SharedInfo.NextSCIFunName; nxtscifunnumber = SharedInfo.NextSCIFunNumber; ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; CPass1FileName = FileInfo.Funct(nxtscifunnumber).CPass1FileName; +// #RNU_RES_B +PrintStringInfo(' ',ReportFileName,'file','y'); +PrintStringInfo('***Generating C code***',ReportFileName,'file','y'); +// #RNU_RES_E +// --------------------------- +// --- End Initialization. --- +// --------------------------- +// -------------------------------------------- +// --- Generate the C name of the function. --- +// -------------------------------------------- if (ASTIfExpType=='if') CFunName = 'if'; elseif (ASTIfExpType=='elseif') @@ -35,7 +56,13 @@ else SCI2CerrorFile('Unknown ASTIfExpType ""'+ASTIfExpType+'"".',ReportFileName); end +// ---------------------------- +// --- Generate the C call. --- +// ---------------------------- if SCI2Cstrncmps1size(ASTIfExpType,'else') + // #RNU_RES_B + // before opening a new C block, closes the previous one. + // #RNU_RES_E SharedInfo = C_IfElseBlocks(FileInfo,SharedInfo,'out'); end @@ -44,11 +71,20 @@ CCall = CCall+CFunName; if (ASTIfExpType~='else') CCall = CCall+'('+IfCondArg(1)+')'; end +PrintStringInfo(' '+CCall,ReportFileName,'file','y'); PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+CCall,CPass1FileName,'file','y'); SharedInfo = C_IfElseBlocks(FileInfo,SharedInfo,'in'); +// #RNU_RES_B +// --------------------------------- +// --- Update counter nested if. --- +// --------------------------------- +// #RNU_RES_E if (ASTIfExpType=='elseif') + // #RNU_RES_B + // every elseif statement a new } is required. + // #RNU_RES_E SharedInfo.CountNestedIf = SharedInfo.CountNestedIf + 1; end diff --git a/src/Scilab2C/Scilab2C/CCodeGeneration/C_IndentBlanks.sci b/src/Scilab2C/Scilab2C/CCodeGeneration/C_IndentBlanks.sci index 33b9896e..9304aefb 100644 --- a/src/Scilab2C/Scilab2C/CCodeGeneration/C_IndentBlanks.sci +++ b/src/Scilab2C/Scilab2C/CCodeGeneration/C_IndentBlanks.sci @@ -1,6 +1,13 @@ function OutBlanksString = C_IndentBlanks(IndentLevel) // function OutBlanksString = C_IndentBlanks(IndentLevel) // ----------------------------------------------------------------- +// Delete function for a generic SCI2C table. +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 26-Oct-2007 -- Raffaele Nutricato: Author. @@ -10,6 +17,9 @@ function OutBlanksString = C_IndentBlanks(IndentLevel) // Contact: raffaele.nutricato@tiscali.it // ----------------------------------------------------------------- +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ SCI2CNInArgCheck(argn(2),1,1); OutBlanksString = ''; diff --git a/src/Scilab2C/Scilab2C/CCodeGeneration/C_InitHeader.sci b/src/Scilab2C/Scilab2C/CCodeGeneration/C_InitHeader.sci index 824db943..8d088939 100644 --- a/src/Scilab2C/Scilab2C/CCodeGeneration/C_InitHeader.sci +++ b/src/Scilab2C/Scilab2C/CCodeGeneration/C_InitHeader.sci @@ -1,6 +1,13 @@ function C_InitHeader(C_Prototype,HeaderFileName,Sci2CLibMainHeaderFName) // function C_InitHeader(C_Prototype,HeaderFileName,Sci2CLibMainHeaderFName) // ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 27-Oct-2007 -- Raffaele Nutricato: Author. @@ -9,8 +16,18 @@ function C_InitHeader(C_Prototype,HeaderFileName,Sci2CLibMainHeaderFName) // Contact: raffaele.nutricato@tiscali.it // ----------------------------------------------------------------- +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ SCI2CNInArgCheck(argn(2),3,3); +// ----------------------- +// --- Initialization. --- +// ----------------------- +// --------------------------- +// --- End Initialization. --- +// --------------------------- + C_SCI2CHeader(HeaderFileName); PrintStringInfo('/*',HeaderFileName,'file','y'); diff --git a/src/Scilab2C/Scilab2C/CCodeGeneration/C_MemAllocOutTempVars.sci b/src/Scilab2C/Scilab2C/CCodeGeneration/C_MemAllocOutTempVars.sci index 6272a22a..5d92d4c8 100644 --- a/src/Scilab2C/Scilab2C/CCodeGeneration/C_MemAllocOutTempVars.sci +++ b/src/Scilab2C/Scilab2C/CCodeGeneration/C_MemAllocOutTempVars.sci @@ -1,42 +1,64 @@ -function C_MemAllocOutTempVars(OutArg,NOutArg,CPass1FileName,CPass1FreeFileName,IndentLevel,ReportFileName)
-// function C_MemAllocOutTempVars(OutArg,NOutArg,CPass1FileName,CPass1FreeFileName,IndentLevel,ReportFileName)
-// -----------------------------------------------------------------
-//
-// Status:
-// 27-Oct-2007 -- Raffaele Nutricato: Author.
-// 10-Jun-2008 -- Raffaele Nutricato: replaced malloc with realloc.
-//
-// Copyright 2007 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
-
-// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),6,6);
-
-PrintStringInfo(' ',ReportFileName,'file','y');
-PrintStringInfo('***Allocating memory for temp variables***',ReportFileName,'file','y');
-
-// --- Allocate memory and size array for output arguments. ---
-for counterout = 1:NOutArg
- if (OutArg(counterout).Dimension > 0)
- if ((OutArg(counterout).FindLike == -1) | (SCI2Cisnum(OutArg(counterout).Size(1))==%F) | (SCI2Cisnum(OutArg(counterout).Size(2))==%F))
- OutArgName = OutArg(counterout).Name;
- tmpcode = '__'+OutArgName+'Size[0]='+OutArg(counterout).Size(1)+';';
- PrintStringInfo(C_IndentBlanks(IndentLevel)+tmpcode,CPass1FileName,'file','y');
- PrintStringInfo(' '+tmpcode,ReportFileName,'file','y');
- tmpcode = '__'+OutArgName+'Size[1]='+OutArg(counterout).Size(2)+';';
- PrintStringInfo(C_IndentBlanks(IndentLevel)+tmpcode,CPass1FileName,'file','y');
- PrintStringInfo(' '+tmpcode,ReportFileName,'file','y');
- //a->val = (double *) malloc(nnz * sizeof(double));
- // numbers = (int*) realloc (numbers, count * sizeof(int));
- tmpcode = OutArgName+' = ('+C_Type(OutArg(counterout).Type)+'*) realloc('+OutArgName+',('+OutArg(counterout).Size(1)+')*('+OutArg(counterout).Size(2)+')*sizeof('+C_Type(OutArg(counterout).Type)+'));';
- PrintStringInfo(C_IndentBlanks(IndentLevel)+tmpcode,CPass1FileName,'file','y');
- PrintStringInfo(' '+tmpcode,ReportFileName,'file','y');
- PrintStringInfo(C_IndentBlanks(1)+'free('+OutArgName+');',CPass1FreeFileName,'file','y');
- end
- end
-end
-
-endfunction
+function C_MemAllocOutTempVars(OutArg,NOutArg,CPass1FileName,CPass1FreeFileName,IndentLevel,ReportFileName,ResizeApproach) +// function C_MemAllocOutTempVars(OutArg,NOutArg,CPass1FileName,CPass1FreeFileName,IndentLevel,ReportFileName,ResizeApproach) +// ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 27-Oct-2007 -- Raffaele Nutricato: Author. +// 10-Jun-2008 -- Raffaele Nutricato: replaced malloc with realloc. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),7,7); + +// #RNU_RES_B +PrintStringInfo(' ',ReportFileName,'file','y'); +PrintStringInfo('***Allocating memory for temp variables***',ReportFileName,'file','y'); +// #RNU_RES_E + +// #RNU_RES_B +// --- Allocate memory and size array for output arguments. --- +// #RNU_RES_E +for counterout = 1:NOutArg + if (OutArg(counterout).Dimension > 0) + // #RNU_RES_B + // if ((OutArg(counterout).Scope == 'Temp') | (OutArg(counterout).FindLike == -1) | ... + // (SCI2Cisnum(OutArg(counterout).Size(1))==%F) | (SCI2Cisnum(OutArg(counterout).Size(2))==%F)) + //NUT: qui forse ci vuole un check per verificare se per caso la variabile e' globale e non se ne conosce la size numerica. + //NUT infatti. Per ora se la size numerica assumo che la variabile globale e' da reallocare. Secondo me occorre aggiungere + //NUT un campo negli argomenti che specifichi la presenza di realloc da fare. + //NUT: ho tolto il check sulle temp perche' se una temp ha size numerica non voglio fare malloc. + //RNU sulle stringhe ancora non applico realloc + // #RNU_RES_E + if ((OutArg(counterout).FindLike == -1) | ... + (SCI2Cisnum(OutArg(counterout).Size(1))==%F) | (SCI2Cisnum(OutArg(counterout).Size(2))==%F)| ... + (ResizeApproach=='REALLOC_ALL_RESIZE_ALL' & OutArg(counterout).Type ~= 'g')) + OutArgName = OutArg(counterout).Name; + tmpcode = '__'+OutArgName+'Size[0]='+OutArg(counterout).Size(1)+';'; + PrintStringInfo(C_IndentBlanks(IndentLevel)+tmpcode,CPass1FileName,'file','y'); + PrintStringInfo(' '+tmpcode,ReportFileName,'file','y'); + tmpcode = '__'+OutArgName+'Size[1]='+OutArg(counterout).Size(2)+';'; + PrintStringInfo(C_IndentBlanks(IndentLevel)+tmpcode,CPass1FileName,'file','y'); + PrintStringInfo(' '+tmpcode,ReportFileName,'file','y'); + //a->val = (double *) malloc(nnz * sizeof(double)); + // numbers = (int*) realloc (numbers, count * sizeof(int)); + tmpcode = OutArgName+' = ('+C_Type(OutArg(counterout).Type)+'*) realloc('+OutArgName+',('+OutArg(counterout).Size(1)+')*('+OutArg(counterout).Size(2)+')*sizeof('+C_Type(OutArg(counterout).Type)+'));'; + PrintStringInfo(C_IndentBlanks(IndentLevel)+tmpcode,CPass1FileName,'file','y'); + PrintStringInfo(' '+tmpcode,ReportFileName,'file','y'); + PrintStringInfo(C_IndentBlanks(1)+'free('+OutArgName+');',CPass1FreeFileName,'file','y'); + end + end +end + +endfunction diff --git a/src/Scilab2C/Scilab2C/CCodeGeneration/C_SCI2CHeader.sci b/src/Scilab2C/Scilab2C/CCodeGeneration/C_SCI2CHeader.sci index c121f6b7..5e8acd5d 100644 --- a/src/Scilab2C/Scilab2C/CCodeGeneration/C_SCI2CHeader.sci +++ b/src/Scilab2C/Scilab2C/CCodeGeneration/C_SCI2CHeader.sci @@ -1,6 +1,13 @@ function C_SCI2CHeader(FileName) // function C_SCI2CHeader(FileName) // ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 21-Dec-2007 -- Raffaele Nutricato: Author. @@ -9,8 +16,18 @@ function C_SCI2CHeader(FileName) // Contact: raffaele.nutricato@tiscali.it // ----------------------------------------------------------------- +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ SCI2CNInArgCheck(argn(2),1,1); +// ----------------------- +// --- Initialization. --- +// ----------------------- +// --------------------------- +// --- End Initialization. --- +// --------------------------- + PrintStringInfo('/*',FileName,'file','y'); PrintStringInfo('** ************************************************',FileName,'file','y'); diff --git a/src/Scilab2C/Scilab2C/CCodeGeneration/C_Type.sci b/src/Scilab2C/Scilab2C/CCodeGeneration/C_Type.sci index 36b0021a..f49dd9b1 100644 --- a/src/Scilab2C/Scilab2C/CCodeGeneration/C_Type.sci +++ b/src/Scilab2C/Scilab2C/CCodeGeneration/C_Type.sci @@ -1,6 +1,13 @@ function OutC_Type = C_Type(ArgType) // function OutC_Type = C_Type(ArgType) // ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 27-Oct-2007 -- Raffaele Nutricato: Author. @@ -9,6 +16,9 @@ function OutC_Type = C_Type(ArgType) // Contact: raffaele.nutricato@tiscali.it // ----------------------------------------------------------------- +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ SCI2CNInArgCheck(argn(2),1,1); if (ArgType == 's') diff --git a/src/Scilab2C/Scilab2C/CCodeGeneration/C_WhileExpression.sci b/src/Scilab2C/Scilab2C/CCodeGeneration/C_WhileExpression.sci index cfd6b096..24898a1b 100644 --- a/src/Scilab2C/Scilab2C/CCodeGeneration/C_WhileExpression.sci +++ b/src/Scilab2C/Scilab2C/CCodeGeneration/C_WhileExpression.sci @@ -1,6 +1,13 @@ function SharedInfo = C_WhileExpression(FileInfo,SharedInfo) // function SharedInfo = C_WhileExpression(FileInfo,SharedInfo) // ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 15-Nov-2007 -- Raffaele Nutricato: Author. @@ -9,8 +16,14 @@ function SharedInfo = C_WhileExpression(FileInfo,SharedInfo) // Contact: raffaele.nutricato@tiscali.it // ----------------------------------------------------------------- +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ SCI2CNInArgCheck(argn(2),2,2); +// ----------------------- +// --- Initialization. --- +// ----------------------- nxtscifunname = SharedInfo.NextSCIFunName; nxtscifunnumber = SharedInfo.NextSCIFunNumber; @@ -21,23 +34,57 @@ CPass1WhileProlFileName = FileInfo.Funct(nxtscifunnumber).CPass1WhileProlFileNam CPass1WhileEpilFileName = FileInfo.Funct(nxtscifunnumber).CPass1WhileEpilFileName(SharedInfo.While.Level); CDeclarationFileName = FileInfo.Funct(nxtscifunnumber).CDeclarationFileName; +// #RNU_RES_B +PrintStringInfo(' ',ReportFileName,'file','y'); +PrintStringInfo('***Generating C code***',ReportFileName,'file','y'); +// #RNU_RES_E CCall =''; +// --------------------------- +// --- End Initialization. --- +// --------------------------- + +// ---------------------------- +// --- Generate the C call. --- +// ---------------------------- +// ------------------------- +// --- Manage all cases. --- +// ------------------------- +PrintStringInfo(' Handling While Expression with OpColon.',ReportFileName,'file','y'); //NUT: sistema il commento. + +// #RNU_RES_B +// ------------------------------------------------------------------------------------- +// --- Generate Prologue and Epilogue -> Copy the first N-1 lines of the for.c code. --- +// ------------------------------------------------------------------------------------- +// #RNU_RES_E [C_Strings,NumCStrings] = File2StringArray(CPass1WhileProlFileName); C_Strings = stripblanks(C_Strings); for cntstr = 1:NumCStrings + // Prologue PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+C_Strings(cntstr),CPass1FileName,'file','y'); + // Epilogue PrintStringInfo(C_Strings(cntstr),CPass1WhileEpilFileName ,'file','y'); end - +// ---------------------------------------- +// --- Insert "}" in the epilogue file. --- +// ---------------------------------------- PrintStringInfo('}',CPass1WhileEpilFileName ,'file','y'); +// ------------------------------ +// --- Insert for expression. --- +// ------------------------------ CCall = 'while('+SharedInfo.WhileExpr.CondVar+')'; PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+CCall,CPass1FileName,'file','y'); +// ------------------- +// --- Insert "{". --- +// ------------------- CCall = '{'; PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+CCall,CPass1FileName,'file','y'); +// --------------------------------- +// --- Update Indentation Level. --- +// --------------------------------- SharedInfo.NIndent = SharedInfo.NIndent + 1; endfunction diff --git a/src/Scilab2C/Scilab2C/CCodeGeneration/GenCFunDatFiles.sci b/src/Scilab2C/Scilab2C/CCodeGeneration/GenCFunDatFiles.sci index 0f304ba3..62c8f4bc 100644 --- a/src/Scilab2C/Scilab2C/CCodeGeneration/GenCFunDatFiles.sci +++ b/src/Scilab2C/Scilab2C/CCodeGeneration/GenCFunDatFiles.sci @@ -1,6 +1,13 @@ function GenCFunDatFiles(FunctionName,FunPrecSpecifier,FunTypeAnnot,FunSizeAnnot,InArg,NInArg,OutArg,NOutArg,CFunName,LibTypeInfo,FunInfoDatDir) // function GenCFunDatFiles(FunctionName,FunPrecSpecifier,FunTypeAnnot,FunSizeAnnot,InArg,NInArg,OutArg,NOutArg,CFunName,LibTypeInfo,FunInfoDatDir) // ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 30-Oct-2007 -- Raffaele Nutricato: Author. @@ -10,9 +17,30 @@ function GenCFunDatFiles(FunctionName,FunPrecSpecifier,FunTypeAnnot,FunSizeAnnot // Contact: raffaele.nutricato@tiscali.it // ----------------------------------------------------------------- +// #RNU_RES_B +//NUT Nella fun info posso mettere le size simboliche per out arg e non quelle numeriche +//NUT che non usero' mai, anche perche' se un giorno decidero' di cambiare approccio e usero' funzioni +//NUT differenti per size differenti allora dovro' cambiare anche il loro nome per distinguerle +//NUT e di conseguenza avro' funinfo differenti. +// #RNU_RES_E +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ SCI2CNInArgCheck(argn(2),11,11); +// ----------------------- +// --- Initialization. --- +// ----------------------- +// --------------------------- +// --- End Initialization. --- +// --------------------------- + +// #RNU_RES_B +// ---------------------------------------------------------- +// --- Find Position of the first output scalar argument. --- +// ---------------------------------------------------------- +// #RNU_RES_E PosFirstOutScalar = 0; FoundOutScalar = 0; for counterout = 1:NOutArg @@ -24,6 +52,9 @@ for counterout = 1:NOutArg end end +// ------------------------------------ +// --- Update C function dat files. --- +// ------------------------------------ clear FunInfo FunInfo.SCIFunctionName = FunctionName; FunInfo.CFunctionName = CFunName; diff --git a/src/Scilab2C/Scilab2C/CCodeGeneration/GetClsFileName.sci b/src/Scilab2C/Scilab2C/CCodeGeneration/GetClsFileName.sci index 1f8195d0..ec9ce5b9 100644 --- a/src/Scilab2C/Scilab2C/CCodeGeneration/GetClsFileName.sci +++ b/src/Scilab2C/Scilab2C/CCodeGeneration/GetClsFileName.sci @@ -1,6 +1,13 @@ function SCI2CClassFileName = GetClsFileName(FunName,FileInfo,SharedInfo) // function SCI2CClassFileName = GetClsFileName(FunName,FileInfo,SharedInfo) // ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 11-Jul-2007 -- Nutricato Raffaele: Author. @@ -9,13 +16,21 @@ function SCI2CClassFileName = GetClsFileName(FunName,FileInfo,SharedInfo) // Contact: raffaele.nutricato@tiscali.it // ----------------------------------------------------------------- +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ SCI2CNInArgCheck(argn(2),3,3); +// //NUT: verifica che il nome sia accettabile e che non +// //NUT: occorra spezzettarla in piu funzioni. + +// --- Extraction of the function name and number. --- nxtscifunname = SharedInfo.NextSCIFunName; nxtscifunnumber = SharedInfo.NextSCIFunNumber; ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; +// --- Initialization. --- tmpannfilename = FunName+'.ann'; tmpscifilename = FunName+'.sci'; AnnFileName = ''; @@ -23,22 +38,37 @@ ClsFileName = '' SCI2CClassSpecifier = SharedInfo.Annotations.FUNCLASS; FlagFoundAnnFile = 0; +// #RNU_RES_B +//NUT: qui e' presente la lista delle priorita' di accesso alle annotazioni. +// #RNU_RES_E if SCI2Cfileexist(FileInfo.USER2CLibCAnnFun,tmpannfilename) + // #RNU_RES_B + // It is a C function of the USER2C library. + // #RNU_RES_E FlagFoundAnnFile = 1; AnnFileName = fullfile(FileInfo.USER2CLibCAnnFun,tmpannfilename); SCI2CClassName = FL_GetFunctionClass(AnnFileName,SCI2CClassSpecifier,ReportFileName); SCI2CClassFileName = fullfile(FileInfo.USER2CLibCAnnCls,SCI2CClassName+'.acls'); elseif SCI2Cfileexist(FileInfo.USER2CLibSCIAnnFun,tmpannfilename) + // #RNU_RES_B + // It is a scilab function of the USER2C library. + // #RNU_RES_E FlagFoundAnnFile = 1; AnnFileName = fullfile(FileInfo.USER2CLibSCIAnnFun,tmpannfilename); SCI2CClassName = FL_GetFunctionClass(AnnFileName,SCI2CClassSpecifier,ReportFileName); SCI2CClassFileName = fullfile(FileInfo.USER2CLibSCIAnnCls,SCI2CClassName+'.acls'); elseif (SCI2Cfileexist(FileInfo.SCI2CLibCAnnFun,tmpannfilename)) + // #RNU_RES_B + // It is a C function of the SCI2C library. + // #RNU_RES_E FlagFoundAnnFile = 1; AnnFileName = fullfile(FileInfo.SCI2CLibCAnnFun,tmpannfilename); SCI2CClassName = FL_GetFunctionClass(AnnFileName,SCI2CClassSpecifier,ReportFileName); SCI2CClassFileName = fullfile(FileInfo.SCI2CLibCAnnCls,SCI2CClassName+'.acls'); elseif (SCI2Cfileexist(FileInfo.SCI2CLibSCIAnnFun,tmpannfilename)) + // #RNU_RES_B + // It is a scilab function of the SCI2C library. + // #RNU_RES_E FlagFoundAnnFile = 1; AnnFileName = fullfile(FileInfo.SCI2CLibSCIAnnFun,tmpannfilename); SCI2CClassName = FL_GetFunctionClass(AnnFileName,SCI2CClassSpecifier,ReportFileName); @@ -48,10 +78,12 @@ end if (FlagFoundAnnFile == 0) [FlagFoundAnnFile,fullpathscifilename] = SCI2CFindFile(FileInfo.UserSciFilesPaths,FunName+'.sci'); if (FlagFoundAnnFile == 0) + // #RNU_RES_B PrintStringInfo(' ',ReportFileName,'both','y'); PrintStringInfo('SCI2CERROR: Missing function annotation. Could not find',ReportFileName,'both','y'); PrintStringInfo('SCI2CERROR: an associated .sci or .ann file for function: '+FunName,ReportFileName,'both','y'); PrintStringInfo(' ',ReportFileName,'both','y'); + // #RNU_RES_E SCI2Cerror(' '); end AnnFileName = fullfile(FileInfo.USER2CLibSCIAnnFun,tmpannfilename); diff --git a/src/Scilab2C/Scilab2C/CCodeGeneration/GetSymbolDimension.sci b/src/Scilab2C/Scilab2C/CCodeGeneration/GetSymbolDimension.sci index c47fdedb..6f4010ac 100644 --- a/src/Scilab2C/Scilab2C/CCodeGeneration/GetSymbolDimension.sci +++ b/src/Scilab2C/Scilab2C/CCodeGeneration/GetSymbolDimension.sci @@ -1,6 +1,19 @@ function symboldimension = GetSymbolDimension(Field_Size) // function symboldimension = GetSymbolDimension(Field_Size) // ----------------------------------------------------------------- +// #RNU_RES_B +// Get the dimesion (0D,1D,2D) of a symbol given its size. +// +// Input data: +// Field_Size: it is the Size field of the InArg or OutArg structures. +// It is a 2-element array. N-dim array are not supported +// in this release. +// +// Output data: +// symboldimension: number specifying the dimension of the symbol. +// 0 = scalar; 1 = column or row; 2 = matrix. +// +// #RNU_RES_E // Status: // 26-Oct-2007 -- Raffaele Nutricato: Author. // 26-Oct-2007 -- Alberto Morea: Test Ok. @@ -9,13 +22,25 @@ function symboldimension = GetSymbolDimension(Field_Size) // Contact: raffaele.nutricato@tiscali.it // ----------------------------------------------------------------- +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ SCI2CNInArgCheck(argn(2),1,1); +// Size is expressed as an array of two strings. Nelem = max(size(Field_Size)); if (Nelem < 2) SCI2Cerror('The size of a symbol cannot be expressed with one or zero numbers.'); end for countersize = 1:Nelem + // #RNU_RES_B + // Field_Type = 1; if Size is Symbol or a number > 1 + // Field_Type = 0; if Size is a number == 1 + // error if Size is 0. + // A symbol is scalar if the sum of the Field_Type elements is zero. + // A symbol is column or row if the sum of the Field_Type elements is one. + // A symbol is a matrix if the sum of the Field_Type elements is > 1. + // #RNU_RES_E if (SCI2Cisnum(Field_Size(countersize))) tmpnum = eval(Field_Size(countersize)); if (tmpnum == 0) @@ -34,6 +59,9 @@ Sum_Field_Type = sum(Field_Type); if (Sum_Field_Type == 0) symboldimension = 0; elseif (Sum_Field_Type == 1) + // #RNU_RES_B + // symboldimension = 1; //NUT for this release there will not be difference between vectors and matrices. + // #RNU_RES_E symboldimension = 2; else symboldimension = 2; diff --git a/src/Scilab2C/Scilab2C/CCodeGeneration/GetWhileCondVariable.sci b/src/Scilab2C/Scilab2C/CCodeGeneration/GetWhileCondVariable.sci index 1a76023a..ba4c7e92 100644 --- a/src/Scilab2C/Scilab2C/CCodeGeneration/GetWhileCondVariable.sci +++ b/src/Scilab2C/Scilab2C/CCodeGeneration/GetWhileCondVariable.sci @@ -1,6 +1,13 @@ function SharedInfo = GetWhileCondVariable(OutArg,NOutArg,FunctionName,FileInfo,SharedInfo) // function SharedInfo = GetWhileCondVariable(OutArg,NOutArg,FunctionName,FileInfo,SharedInfo) // ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 26-Oct-2007 -- Raffaele Nutricato: Author. @@ -10,15 +17,56 @@ function SharedInfo = GetWhileCondVariable(OutArg,NOutArg,FunctionName,FileInfo, // Contact: raffaele.nutricato@tiscali.it // ----------------------------------------------------------------- +//NUT: secondo me questa funzione non serve a nulla + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ SCI2CNInArgCheck(argn(2),5,5); +// ----------------------- +// --- Initialization. --- +// ----------------------- nxtscifunname = SharedInfo.NextSCIFunName; nxtscifunnumber = SharedInfo.NextSCIFunNumber; ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; +// #RNU_RES_B +PrintStringInfo(' ',ReportFileName,'file','y'); +PrintStringInfo('***Checking if the current function is handling while counter variables.***',ReportFileName,'file','y'); +// #RNU_RES_E + +// --------------------------- +// --- End Initialization. --- +// --------------------------- + +// #RNU_RES_B +// ----------------------------------------------- +// --- Initial Check on While counter variables. --- +// ----------------------------------------------- +// #RNU_RES_E if ((SharedInfo.WhileExpr.OnExec > 0) & (NOutArg==1)) + // #RNU_RES_B + //NUT: se sono in una while expression devo memorizzarmi l'ultima variabile di output + //NUT: perche' e' quella che contiene la condizione da testare, + //NUT: allora io me le salvo tutte e l'ultima salvata sara' quella che andra' a finire + //NUT: nella while. + // #RNU_RES_E SharedInfo.WhileExpr.CondVar = OutArg(1).Name; + // #RNU_RES_B + //if (SharedInfo.WhileExpr.AssignmentFun == 0) + //NUT: Test also that SharedInfo.WhileExpr.AssignmentFun because sometimes Equal are dummy! + //NUT: verifica se e' giusta questa mia affermazione. + //RNU il seguente test e' stato spostato nella AST_HandleWhileStatem.c perche' + //RNU: secondo me la matrice finale non e' supportata dalla while, ma while(det(M)>0) + //RNU: puo' essere benissimo supportato. + // if (OutArg.Dimension > 0) + // SCI2CerrorFile('Cannot manage while with matrix conditions',ReportFileName); + // SharedInfo.SkipNextFun = 0; //NUT verifica se serve + // end + // #RNU_RES_E SharedInfo.WhileExpr.DimCondVar = OutArg(1).Dimension; + ///end end endfunction diff --git a/src/Scilab2C/Scilab2C/CCodeGeneration/JoinDeclarAndCcode.sci b/src/Scilab2C/Scilab2C/CCodeGeneration/JoinDeclarAndCcode.sci index a869cdab..ebbf0023 100644 --- a/src/Scilab2C/Scilab2C/CCodeGeneration/JoinDeclarAndCcode.sci +++ b/src/Scilab2C/Scilab2C/CCodeGeneration/JoinDeclarAndCcode.sci @@ -1,6 +1,14 @@ function JoinDeclarAndCcode(FileInfoDatFile) // function JoinDeclarAndCcode(FileInfoDatFile) // ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// // Status: // 07-Nov-2007 -- Raffaele Nutricato: Author. // @@ -8,12 +16,26 @@ function JoinDeclarAndCcode(FileInfoDatFile) // Contact: raffaele.nutricato@tiscali.it // ----------------------------------------------------------------- +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ SCI2CNInArgCheck(argn(2),1,1); +// --------------------- +// --- Load section. --- +// --------------------- +// --- Load File Info Structure. --- load(FileInfoDatFile,'FileInfo'); +// --- Load Shared Info Structure. --- load(FileInfo.SharedInfoDatFile,'SharedInfo'); +// ------------------------- +// --- End load section. --- +// ------------------------- +// ----------------------- +// --- Initialization. --- +// ----------------------- nxtscifunname = SharedInfo.NextSCIFunName; funnumber = SharedInfo.NextSCIFunNumber; @@ -28,16 +50,22 @@ CPass1V1FileFid = SCI2COpenFileRead(CPass1FileName); CDeclarationFileFid = SCI2COpenFileRead(CDeclarationFileName); CGblDeclarFileFid = SCI2COpenFileRead(CGblDeclarFileName); CInitVarsFileFid = SCI2COpenFileRead(CInitVarsFileName); +// --------------------------- +// --- End Initialization. --- +// --------------------------- +PrintStepInfo('Joining declaration and C-call files',ReportFileName,'file'); PrintStringInfo('/*',CPass2FileName,'file','y'); PrintStringInfo('** -------------------------------------',CPass2FileName,'file','y'); PrintStringInfo('** --- Global Variables Declaration. ---',CPass2FileName,'file','y'); PrintStringInfo('** -------------------------------------',CPass2FileName,'file','y'); PrintStringInfo('*/',CPass2FileName,'file','y'); - +// #RNU_RES_B +// --- Copy in V2 the global declaration file. --- +// #RNU_RES_E while (~meof(CGblDeclarFileFid)) - + // Read a line from C Global Declaration file. tmpcline = mgetl(CGblDeclarFileFid,1); if (length(tmpcline) == 0) tmpcline = ' '; @@ -53,8 +81,12 @@ PrintStringInfo('** -----------------------------------------',CPass2FileName,'f PrintStringInfo('*/',CPass2FileName,'file','y'); PrintStringInfo(' ',CPass2FileName,'file','y'); +// #RNU_RES_B +// --- Copy in V2 the first part of V1 up to "{". --- +// #RNU_RES_E FoundCurlyBracket = 0; while ((~meof(CPass1V1FileFid)) & (FoundCurlyBracket == 0)) + // Read a line from C Pass1 file. tmpcline = mgetl(CPass1V1FileFid,1); noblkstmpcline = stripblanks(tmpcline); if (length(noblkstmpcline) > 0) @@ -76,7 +108,9 @@ PrintStringInfo('** -----------------------------',CPass2FileName,'file','y'); PrintStringInfo('** --- Variable Declaration. ---',CPass2FileName,'file','y'); PrintStringInfo('** -----------------------------',CPass2FileName,'file','y'); PrintStringInfo('*/',CPass2FileName,'file','y'); +// --- Copy in V2 the declaration file. --- while (~meof(CDeclarationFileFid)) + // Read a line from C Declaration file. tmpcline = mgetl(CDeclarationFileFid,1); if (length(tmpcline) == 0) tmpcline = ' '; @@ -86,7 +120,11 @@ while (~meof(CDeclarationFileFid)) PrintStringInfo(tmpcline,CPass2FileName,'file','y'); end +// #RNU_RES_B +// --- Copy in V2 the variable initialization file. --- +// #RNU_RES_E while (~meof(CInitVarsFileFid)) + // Read a line from C Declaration file. tmpcline = mgetl(CInitVarsFileFid,1); if (length(tmpcline) == 0) tmpcline = ' '; @@ -107,7 +145,11 @@ PrintStringInfo('** ---------------',CPass2FileName,'file','y'); PrintStringInfo('** --- C code. ---',CPass2FileName,'file','y'); PrintStringInfo('** ---------------',CPass2FileName,'file','y'); PrintStringInfo('*/',CPass2FileName,'file','y'); +// --- Copy the remaining part of V1 in V2. --- while (~meof(CPass1V1FileFid)) + // #RNU_RES_B + // Read a line from C Pass1 file. + // #RNU_RES_E tmpcline = mgetl(CPass1V1FileFid,1); if (length(tmpcline) == 0) tmpcline = ' '; @@ -115,6 +157,9 @@ while (~meof(CPass1V1FileFid)) PrintStringInfo(tmpcline,CPass2FileName,'file','y'); end +// -------------------- +// --- Close Files. --- +// -------------------- mclose(CPass1V1FileFid); mclose(CDeclarationFileFid); mclose(CGblDeclarFileFid); diff --git a/src/Scilab2C/Scilab2C/CCodeGeneration/Sci2AnnotationFile.sci b/src/Scilab2C/Scilab2C/CCodeGeneration/Sci2AnnotationFile.sci index 9fa9aac9..001ed250 100644 --- a/src/Scilab2C/Scilab2C/CCodeGeneration/Sci2AnnotationFile.sci +++ b/src/Scilab2C/Scilab2C/CCodeGeneration/Sci2AnnotationFile.sci @@ -1,6 +1,16 @@ function Sci2AnnotationFile(SciFileName,ClsFileName,AnnFileName,AnnSpecifier,ReportFileName) // function Sci2AnnotationFile(SciFileName,ClsFileName,AnnFileName,AnnSpecifier,ReportFileName) // -------------------------------------------------------------------------------- +// #RNU_RES_B +// This function reads the .sci input file and generates the correspondig .ann +// and .acls files. +// #RNU_RES_E +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here // // Status: // 25-Jun-2007 -- Nutricato Raffaele: Author. @@ -9,12 +19,21 @@ function Sci2AnnotationFile(SciFileName,ClsFileName,AnnFileName,AnnSpecifier,Rep // Contact: raffaele.nutricato@tiscali.it // ----------------------------------------------------------------- +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ SCI2CNInArgCheck(argn(2),5,5); [tmppath,tmpfunname,tmpext] = fileparts(SciFileName); +// --------------------------------------- +// --- Open the .sci file (read only). --- +// --------------------------------------- inscifid = SCI2COpenFileRead(SciFileName); +// ---------------------------------------------- +// --- Loop over the lines of the input file. --- +// ---------------------------------------------- line_position = 0; L_AnnSpecifierP1 = length(AnnSpecifier)+1; while (meof(inscifid) == 0) @@ -29,5 +48,8 @@ while (meof(inscifid) == 0) end end mclose(inscifid); +// -------------------------------------------------- +// --- End loop over the lines of the input file. --- +// -------------------------------------------------- PrintStringInfo('CLASS: '+tmpfunname,AnnFileName,'file','y'); endfunction diff --git a/src/Scilab2C/Scilab2C/ErrorMessages/EM_NanSize.sci b/src/Scilab2C/Scilab2C/ErrorMessages/EM_NanSize.sci index 145c2f79..2595a32b 100644 --- a/src/Scilab2C/Scilab2C/ErrorMessages/EM_NanSize.sci +++ b/src/Scilab2C/Scilab2C/ErrorMessages/EM_NanSize.sci @@ -1,82 +1,82 @@ -function EM_NanSize(ReportFileName) -// function EM_NanSize(ReportFileName) -// ----------------------------------------------------------------- -// -// Input data: -// //NUT: Add description here -// -// Output data: -// //NUT: Add description here -// -// Status: -// 13-Feb-2008 -- Raffaele Nutricato: Author. -// -// Copyright 2008 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -// ------------------------------ -// --- Check input arguments. --- -// ------------------------------ -SCI2CNInArgCheck(argn(2),1,1); - -PrintStringInfo(' ',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: Cannot initialize a local or global variable with a variable value',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: coming from a function or an operation.',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: See code below:',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: a = 10;',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: b = 10;',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: c = a+b;',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: D = zeros(a,b); // Allowed',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: E = zeros(10,b); // Allowed',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: F = zeros(10,5); // Allowed',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: G = zeros(10,c); // Not Allowed because c value is not known at transation time.',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: H = 10:c:9;// Not Allowed because c value is not known at transation time.',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: The same problem arises in for loops.',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: SCI2C forbids use of step values in ""for"" loops which come from ',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: a function or an operation.',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: Always specify its value.',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: Example: ',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: Scilab Code:',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: unkstep = 2*cos(0); // It means that unkstep is not known at translation time.',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: for cnt=10:unkstep:1',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: disp(cnt)',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: end',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: The code above is not allowed. You can change it as shown below:',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: unkstep = 2; // This time the value of unkstep is known at translation time.',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: for cnt=10:unkstep:1',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: disp(cnt)',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: end',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: The reason for this limitation is related to the impossibility to generate optimized C code.',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: when the step is unknown.',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: Look at the following example for more details,',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: Scilab Code:;',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: for cnt=10:unkstep:1',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: disp(cnt)',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: end',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: If unkstep variable value is unkwnown it is not possible to generate',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: optimized C code.',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: Infact, if unkstep is >= 0, the correct C code is:',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: for (cnt=10;cnt<=1;cnt+=unkstep)',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: disp(cnt);',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: If unkstep is < 0 the correct C code is:',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: for (cnt=10; cnt>=1; cnt+=unkstep)',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: disp(cnt);',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: Note how the condition cnt<=1 changes to cnt>=1.',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: In order to take into account of this possibility ',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: SCI2C translator should generate both codes and then ',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: insert them into an if/else block as shown here: ',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: if (unkstep >= 0)',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: {',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: for (cnt=10;cnt<=1;cnt+=unkstep)',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: disp(cnt);',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: }',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: else{',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: {',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: for (cnt=10;cnt<=1;cnt+=unkstep)',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: disp(cnt);',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: }',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: Of course it is not optimized C code.',ReportFileName,'both','y'); -PrintStringInfo(' ',ReportFileName,'both','y'); -SCI2Cerror(' '); -endfunction +function EM_NanSize(ReportFileName)
+// function EM_NanSize(ReportFileName)
+// -----------------------------------------------------------------
+//
+// Input data:
+// //NUT: Add description here
+//
+// Output data:
+// //NUT: Add description here
+//
+// Status:
+// 13-Feb-2008 -- Raffaele Nutricato: Author.
+//
+// Copyright 2008 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+PrintStringInfo(' ',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: Cannot initialize a local or global variable with a variable value',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: coming from a function or an operation.',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: See code below:',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: a = 10;',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: b = 10;',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: c = a+b;',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: D = zeros(a,b); // Allowed',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: E = zeros(10,b); // Allowed',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: F = zeros(10,5); // Allowed',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: G = zeros(10,c); // Not Allowed because c value is not known at transation time.',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: H = 10:c:9;// Not Allowed because c value is not known at transation time.',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: The same problem arises in for loops.',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: SCI2C forbids use of step values in ""for"" loops which come from ',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: a function or an operation.',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: Always specify its value.',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: Example: ',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: Scilab Code:',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: unkstep = 2*cos(0); // It means that unkstep is not known at translation time.',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: for cnt=10:unkstep:1',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: disp(cnt)',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: end',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: The code above is not allowed. You can change it as shown below:',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: unkstep = 2; // This time the value of unkstep is known at translation time.',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: for cnt=10:unkstep:1',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: disp(cnt)',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: end',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: The reason for this limitation is related to the impossibility to generate optimized C code.',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: when the step is unknown.',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: Look at the following example for more details,',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: Scilab Code:;',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: for cnt=10:unkstep:1',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: disp(cnt)',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: end',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: If unkstep variable value is unkwnown it is not possible to generate',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: optimized C code.',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: Infact, if unkstep is >= 0, the correct C code is:',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: for (cnt=10;cnt<=1;cnt+=unkstep)',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: disp(cnt);',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: If unkstep is < 0 the correct C code is:',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: for (cnt=10; cnt>=1; cnt+=unkstep)',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: disp(cnt);',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: Note how the condition cnt<=1 changes to cnt>=1.',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: In order to take into account of this possibility ',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: SCI2C translator should generate both codes and then ',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: insert them into an if/else block as shown here: ',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: if (unkstep >= 0)',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: {',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: for (cnt=10;cnt<=1;cnt+=unkstep)',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: disp(cnt);',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: }',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: else{',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: {',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: for (cnt=10;cnt<=1;cnt+=unkstep)',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: disp(cnt);',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: }',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: Of course it is not optimized C code.',ReportFileName,'both','y');
+PrintStringInfo(' ',ReportFileName,'both','y');
+SCI2Cerror(' ');
+endfunction
diff --git a/src/Scilab2C/Scilab2C/ErrorMessages/EM_UnknownStep.sci b/src/Scilab2C/Scilab2C/ErrorMessages/EM_UnknownStep.sci index dfa3b542..9f8d39e7 100644 --- a/src/Scilab2C/Scilab2C/ErrorMessages/EM_UnknownStep.sci +++ b/src/Scilab2C/Scilab2C/ErrorMessages/EM_UnknownStep.sci @@ -1,70 +1,70 @@ -function EM_UnknownStep(ReportFileName) -// function EM_UnknownStep(ReportFileName) -// ----------------------------------------------------------------- -// -// Input data: -// //NUT: Add description here -// -// Output data: -// //NUT: Add description here -// -// Status: -// 13-Feb-2008 -- Raffaele Nutricato: Author. -// -// Copyright 2008 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -// ------------------------------ -// --- Check input arguments. --- -// ------------------------------ -SCI2CNInArgCheck(argn(2),1,1); - -PrintStringInfo(' ',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: SCI2C forbids use of step values in ""for"" loops which come from ',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: a function or an operation.',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: Always specify its value.',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: Example: ',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: Scilab Code:',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: unkstep = 2*cos(0); // It means that unkstep is not known at translation time.',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: for cnt=10:unkstep:1',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: disp(cnt)',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: end',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: The code above is not allowed. You can change it as shown below:',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: unkstep = 2; // This time the value of unkstep is known at translation time.',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: for cnt=10:unkstep:1',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: disp(cnt)',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: end',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: The reason for this limitation is related to the impossibility to generate optimized C code.',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: when the step is unknown.',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: Look at the following example for more details,',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: Scilab Code:;',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: for cnt=10:unkstep:1',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: disp(cnt)',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: end',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: If unkstep variable value is unkwnown it is not possible to generate',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: optimized C code.',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: Infact, if unkstep is >= 0, the correct C code is:',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: for (cnt=10;cnt<=1;cnt+=unkstep)',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: disp(cnt);',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: If unkstep is < 0 the correct C code is:',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: for (cnt=10; cnt>=1; cnt+=unkstep)',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: disp(cnt);',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: Note how the condition cnt<=1 changes to cnt>=1.',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: In order to take into account of this possibility ',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: SCI2C translator should generate both codes and then ',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: insert them into an if/else block as shown here: ',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: if (unkstep >= 0)',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: {',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: for (cnt=10;cnt<=1;cnt+=unkstep)',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: disp(cnt);',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: }',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: else{',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: {',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: for (cnt=10;cnt<=1;cnt+=unkstep)',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: disp(cnt);',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: }',ReportFileName,'both','y'); -PrintStringInfo('SCI2CERROR: Of course it is not optimized C code.',ReportFileName,'both','y'); -PrintStringInfo(' ',ReportFileName,'both','y'); -SCI2Cerror(' '); -endfunction +function EM_UnknownStep(ReportFileName)
+// function EM_UnknownStep(ReportFileName)
+// -----------------------------------------------------------------
+//
+// Input data:
+// //NUT: Add description here
+//
+// Output data:
+// //NUT: Add description here
+//
+// Status:
+// 13-Feb-2008 -- Raffaele Nutricato: Author.
+//
+// Copyright 2008 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+PrintStringInfo(' ',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: SCI2C forbids use of step values in ""for"" loops which come from ',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: a function or an operation.',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: Always specify its value.',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: Example: ',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: Scilab Code:',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: unkstep = 2*cos(0); // It means that unkstep is not known at translation time.',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: for cnt=10:unkstep:1',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: disp(cnt)',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: end',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: The code above is not allowed. You can change it as shown below:',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: unkstep = 2; // This time the value of unkstep is known at translation time.',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: for cnt=10:unkstep:1',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: disp(cnt)',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: end',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: The reason for this limitation is related to the impossibility to generate optimized C code.',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: when the step is unknown.',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: Look at the following example for more details,',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: Scilab Code:;',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: for cnt=10:unkstep:1',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: disp(cnt)',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: end',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: If unkstep variable value is unkwnown it is not possible to generate',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: optimized C code.',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: Infact, if unkstep is >= 0, the correct C code is:',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: for (cnt=10;cnt<=1;cnt+=unkstep)',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: disp(cnt);',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: If unkstep is < 0 the correct C code is:',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: for (cnt=10; cnt>=1; cnt+=unkstep)',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: disp(cnt);',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: Note how the condition cnt<=1 changes to cnt>=1.',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: In order to take into account of this possibility ',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: SCI2C translator should generate both codes and then ',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: insert them into an if/else block as shown here: ',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: if (unkstep >= 0)',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: {',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: for (cnt=10;cnt<=1;cnt+=unkstep)',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: disp(cnt);',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: }',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: else{',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: {',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: for (cnt=10;cnt<=1;cnt+=unkstep)',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: disp(cnt);',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: }',ReportFileName,'both','y');
+PrintStringInfo('SCI2CERROR: Of course it is not optimized C code.',ReportFileName,'both','y');
+PrintStringInfo(' ',ReportFileName,'both','y');
+SCI2Cerror(' ');
+endfunction
diff --git a/src/Scilab2C/Scilab2C/ErrorMessages/EM_ZeroSize.sci b/src/Scilab2C/Scilab2C/ErrorMessages/EM_ZeroSize.sci index c017bca0..fede8f0d 100644 --- a/src/Scilab2C/Scilab2C/ErrorMessages/EM_ZeroSize.sci +++ b/src/Scilab2C/Scilab2C/ErrorMessages/EM_ZeroSize.sci @@ -1,27 +1,27 @@ -function EM_ZeroSize(ReportFileName) -// function EM_ZeroSize(ReportFileName) -// ----------------------------------------------------------------- -// -// Input data: -// //NUT: Add description here -// -// Output data: -// //NUT: Add description here -// -// Status: -// 13-Feb-2008 -- Raffaele Nutricato: Author. -// -// Copyright 2008 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -// ------------------------------ -// --- Check input arguments. --- -// ------------------------------ -SCI2CNInArgCheck(argn(2),1,1); - -PrintStringInfo('SCI2CERROR: Cannot handle zero-size arrays.',ReportFileName,'both','y'); -PrintStringInfo(' ',ReportFileName,'both','y'); -SCI2Cerror(' '); - -endfunction +function EM_ZeroSize(ReportFileName)
+// function EM_ZeroSize(ReportFileName)
+// -----------------------------------------------------------------
+//
+// Input data:
+// //NUT: Add description here
+//
+// Output data:
+// //NUT: Add description here
+//
+// Status:
+// 13-Feb-2008 -- Raffaele Nutricato: Author.
+//
+// Copyright 2008 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+PrintStringInfo('SCI2CERROR: Cannot handle zero-size arrays.',ReportFileName,'both','y');
+PrintStringInfo(' ',ReportFileName,'both','y');
+SCI2Cerror(' ');
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_ADD.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_ADD.sci index 4eb9700d..1973f8d7 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_ADD.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_ADD.sci @@ -1,29 +1,43 @@ -function opout = FA_ADD(in1,in2) -// function opout = FA_ADD(in1,in2) -// ----------------------------------------------------------------- -// -// Status: -// 26-Oct-2007 -- Raffaele Nutricato: Author. -// 26-Oct-2007 -- Alberto Morea: Test Ok. -// -// Copyright 2007 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),2,2); - - -if (SCI2Cisnum(in1) & SCI2Cisnum(in2)) - in1num = eval(in1); - in2num = eval(in2); - outnum = in1num+in2num; - if isnan(outnum) - opout = '__SCI2CNANSIZE'; - else - opout = string(outnum); - end -else - opout = string(in1+'+'+in2); -end - -endfunction +function opout = FA_ADD(in1,in2)
+// function opout = FA_ADD(in1,in2)
+// -----------------------------------------------------------------
+// Addition function for Function Annotations.
+//
+// Input data:
+// in1: string specifying a number or a symbol.
+// in2: string specifying a number or a symbol.
+//
+// Output data:
+// opout: string containing the computed result.
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+
+// ------------------------
+// --- Generate Output. ---
+// ------------------------
+if (SCI2Cisnum(in1) & SCI2Cisnum(in2))
+ in1num = eval(in1);
+ in2num = eval(in2);
+ outnum = in1num+in2num;
+ if isnan(outnum)
+ opout = '__SCI2CNANSIZE';
+ else
+ opout = string(outnum);
+ end
+else
+ opout = string('('+in1+'+'+in2+')');
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_DIV.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_DIV.sci index 788ac45f..bce6966d 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_DIV.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_DIV.sci @@ -1,27 +1,41 @@ -function opout = FA_DIV(in1,in2) -// function opout = FA_DIV(in1,in2) -// ----------------------------------------------------------------- -// -// Status: -// 26-Oct-2007 -- Raffaele Nutricato: Author. -// 26-Oct-2007 -- Alberto Morea: Test Ok. -// -// Copyright 2008 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),2,2); - -if (SCI2Cisnum(in1) & SCI2Cisnum(in2)) - in1num = eval(in1); - in2num = eval(in2); - outnum = in1num/in2num; - if isnan(outnum) - opout = '__SCI2CNANSIZE'; - else - opout = string(outnum); - end -else - opout = string(in1)+'/'+string(in2); -end -endfunction +function opout = FA_DIV(in1,in2)
+// function opout = FA_DIV(in1,in2)
+// -----------------------------------------------------------------
+// Division function for Function Annotations.
+//
+// Input data:
+// in1: string specifying a number or a symbol.
+// in2: string specifying a number or a symbol.
+//
+// Output data:
+// opout: string containing the computed result.
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+// ------------------------
+// --- Generate Output. ---
+// ------------------------
+if (SCI2Cisnum(in1) & SCI2Cisnum(in2))
+ in1num = eval(in1);
+ in2num = eval(in2);
+ outnum = in1num/in2num;
+ if isnan(outnum)
+ opout = '__SCI2CNANSIZE';
+ else
+ opout = string(outnum);
+ end
+else
+ opout = '('+string(in1)+'/'+string(in2)+')';
+end
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_GetDefaultPrecision.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_GetDefaultPrecision.sci index 5d74effd..3afe2648 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_GetDefaultPrecision.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_GetDefaultPrecision.sci @@ -1,43 +1,86 @@ -function defaultprecision = FA_GetDefaultPrecision(scifilename,ReportFileName) -// function defaultprecision = FA_GetDefaultPrecision(scifilename,ReportFileName) -// ----------------------------------------------------------------- -// -// Status: -// 12-Feb-2008 -- Raffaele Nutricato: Author. -// 12-Feb-2008 -- Alberto Morea: Test Ok. -// -// Copyright 2008 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),2,2); - -defaultprecision = 'd'; -annotationstring = '//SCI2C: DEFAULT_PRECISION=' - -scifid = SCI2COpenFileRead(scifilename); - -foundannotation = 0; -line_position = 0; -while ((meof(scifid) == 0) & (foundannotation == 0)) - check_string = stripblanks(mgetl(scifid,1)); - line_position = line_position + 1; - if (~isempty(check_string)) - - if (SCI2Cstrncmps1size(annotationstring,check_string)) - tmpprecision = stripblanks(part(check_string,length(annotationstring)+1:length(check_string))); - foundannotation = 1; - end - end -end - -if (foundannotation == 0) -else - if (tmpprecision == 'FLOAT') - defaultprecision = 's'; - elseif (tmpprecision == 'DOUBLE') - defaultprecision = 'd'; - end -end - -endfunction +function defaultprecision = FA_GetDefaultPrecision(scifilename,ReportFileName)
+// function defaultprecision = FA_GetDefaultPrecision(scifilename,ReportFileName)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// Extracts the default precision for the file .sci passed in input.
+// The following annotation will be searched in the scilab code:
+// //SCI2C: DEFAULT_PRECISION= FLOAT
+// //SCI2C: DEFAULT_PRECISION= DOUBLE
+// If the annotation is missing the default DOUBLE precision will be
+// implicitly used.
+// #RNU_RES_E
+//
+// Input data:
+// ---
+//
+// Output data:
+// defaultprecision: string which specifies the default precision to be
+// used in the translation of scifilename.
+//
+// Status:
+// 12-Feb-2008 -- Raffaele Nutricato: Author.
+// 12-Feb-2008 -- Alberto Morea: Test Ok.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+// -----------------------
+// --- Initialization. ---
+// -----------------------
+defaultprecision = 'd';
+annotationstring = '//SCI2C: DEFAULT_PRECISION='
+// #RNU_RES_B
+PrintStringInfo('***Get default precision from: '+scifilename,ReportFileName,'file','y');
+// #RNU_RES_E
+// ---------------------------
+// --- End Initialization. ---
+// ---------------------------
+
+// --- Open the .sci file (read only). ---
+scifid = SCI2COpenFileRead(scifilename);
+
+// #RNU_RES_B
+// --- Loop over the lines of the input file. ---
+// Position file pointer to the desired NInArg/NOutArg section,
+// and read the NOutArg annotation.
+// #RNU_RES_E
+foundannotation = 0;
+line_position = 0;
+while ((meof(scifid) == 0) & (foundannotation == 0))
+ check_string = stripblanks(mgetl(scifid,1));
+ line_position = line_position + 1;
+ if (~isempty(check_string))
+
+ if (SCI2Cstrncmps1size(annotationstring,check_string))
+ tmpprecision = stripblanks(part(check_string,length(annotationstring)+1:length(check_string)));
+ // #RNU_RES_B
+ PrintStringInfo(' Line '+string(line_position)+...
+ ' - Found annotation for default precision'+' ""'+check_string+' ""',...
+ ReportFileName,'file','y');
+ // #RNU_RES_E
+ foundannotation = 1;
+ end
+ end
+end
+
+if (foundannotation == 0)
+ // #RNU_RES_B
+ PrintStringInfo('Annotation for default precision not found.',ReportFileName,'file','y');
+ PrintStringInfo('Using the ""DOUBLE"" default precision.',ReportFileName,'file','y');
+ // #RNU_RES_E
+else
+ if (tmpprecision == 'FLOAT')
+ defaultprecision = 's';
+ elseif (tmpprecision == 'DOUBLE')
+ defaultprecision = 'd';
+ end
+end
+
+mclose(scifid);
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_GetFunAnn.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_GetFunAnn.sci index 1954e773..b3d842ab 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_GetFunAnn.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_GetFunAnn.sci @@ -1,129 +1,206 @@ -function [FunTypeAnnot,FunSizeAnnot] = ... - FA_GetFunAnn(NInArg,NOutArg,FunName,FileInfo,SharedInfo) -// function [FunTypeAnnot,FunSizeAnnot] = ... -// FA_GetFunAnn(NInArg,NOutArg,FunName,FileInfo,SharedInfo) -// ----------------------------------------------------------------- -// -// Status: -// 11-Jul-2007 -- Nutricato Raffaele: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),5,5); - -nxtscifunname = SharedInfo.NextSCIFunName; -nxtscifunnumber = SharedInfo.NextSCIFunNumber; -ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; -SCI2CClassFileName = GetClsFileName(FunName,FileInfo,SharedInfo); -FunTypeAnnot = ''; -FunSizeAnnot = ''; -inclsfid = SCI2COpenFileRead(SCI2CClassFileName); - -FoundNIn = 0; -FoundNOut = 0; -line_position = 0; -while ((meof(inclsfid) == 0) & (FoundNIn == 0) & (FoundNOut == 0)) - check_string = stripblanks(mgetl(inclsfid,1)); - line_position = line_position + 1; - if (~isempty(check_string)) - - if (SCI2Cstrncmps1size(SharedInfo.Annotations.FUNNIN,check_string)) - FUNNINAnnot = part(check_string,length(SharedInfo.Annotations.FUNNIN)+1:length(check_string)); - if (eval(FUNNINAnnot) == NInArg) - FoundNIn = 1; - check_string = stripblanks(mgetl(inclsfid,1)); - line_position = line_position + 1; - if (~isempty(check_string)) - - if (SCI2Cstrncmps1size(SharedInfo.Annotations.FUNNOUT,check_string)) - FUNNOUTAnnot = part(check_string,length(SharedInfo.Annotations.FUNNOUT)+1:length(check_string)); - - if (eval(FUNNOUTAnnot) == NOutArg) - FoundNOut = 1; - else - FoundNIn = 0; - end - else - PrintStringInfo(' ',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: Incorrect format for function annotation.',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: Expected '+SharedInfo.Annotations.FUNNIN+' field in the annotations of the function.',ReportFileName,'both','y'); - PrintStringInfo(' ',ReportFileName,'both','y'); - SCI2Cerror(' '); - end - else - PrintStringInfo(' ',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: Incorrect format for function annotation.',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: Expected '+SharedInfo.Annotations.FUNNIN+' field in the annotations of the function.',ReportFileName,'both','y'); - PrintStringInfo(' ',ReportFileName,'both','y'); - SCI2Cerror(' '); - end - end - end - end -end - -if (FoundNOut*FoundNIn == 0) - PrintStringInfo(' ',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: Please check file: '+SCI2CClassFileName,ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: Incorrect function annotation.',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: There are two possibilities:',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: 1. Syntax error in function annotations.',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: 2. Missing the right combination of NIN/NOUT annotations: ""'+SharedInfo.Annotations.FUNNIN+string(NInArg)+','+SharedInfo.Annotations.FUNNOUT+' '+string(NOutArg)+'"".',ReportFileName,'both','y'); - PrintStringInfo(' ',ReportFileName,'both','y'); - SCI2Cerror(' '); -else - for cntout = 1:NOutArg - SCI2C_nout=cntout; // Useful for eval. - - check_string = stripblanks(mgetl(inclsfid,1)); - line_position = line_position + 1; - if (isempty(check_string) == %F) - tmpannstring = eval(SharedInfo.Annotations.FUNTYPE); - if (SCI2Cstrncmps1size(tmpannstring,check_string)) - FunTypeAnnot(cntout) = ... - stripblanks(part(check_string,length(tmpannstring)+1:length(check_string))); - end - else - PrintStringInfo(' ',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: Line '+string(line_position)+' Function type annotation not found in file: '+SCI2CClassFileName,ReportFileName,'both','y'); - PrintStringInfo(' ',ReportFileName,'both','y'); - SCI2Cerror(' '); - end - - SCI2C_nelem = 1; // Useful for eval. - line_position = line_position + 1; - if (isempty(check_string) == %F) - tmpannstring = eval(SharedInfo.Annotations.FUNSIZE); - check_string = stripblanks(mgetl(inclsfid,1)); - if (SCI2Cstrncmps1size(tmpannstring,check_string)) - FunSizeAnnot(cntout,1) = ... - stripblanks(part(check_string,length(tmpannstring)+1:length(check_string))); - end - else - PrintStringInfo(' ',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: Line '+string(line_position)+' Function size annotation not found in file: '+SCI2CClassFileName,ReportFileName,'both','y'); - PrintStringInfo(' ',ReportFileName,'both','y'); - SCI2Cerror(' '); - end - SCI2C_nelem = 2; - line_position = line_position + 1; - if (isempty(check_string) == %F) - tmpannstring = eval(SharedInfo.Annotations.FUNSIZE); - check_string = stripblanks(mgetl(inclsfid,1)); - if (SCI2Cstrncmps1size(tmpannstring,check_string)) - FunSizeAnnot(cntout,2) = ... - stripblanks(part(check_string,length(tmpannstring)+1:length(check_string))); - end - else - PrintStringInfo(' ',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: Line '+string(line_position)+' Function type annotation (//_SCI2C_FUNSIZE:) not found in file: '+SCI2CClassFileName,ReportFileName,'both','y'); - PrintStringInfo(' ',ReportFileName,'both','y'); - SCI2Cerror(' '); - end - end -end -mclose(inclsfid); - -endfunction +function [FunTypeAnnot,FunSizeAnnot] = ...
+ FA_GetFunAnn(NInArg,NOutArg,FunName,FileInfo,SharedInfo)
+// function [FunTypeAnnot,FunSizeAnnot] = ...
+// FA_GetFunAnn(NInArg,NOutArg,FunName,FileInfo,SharedInfo)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// This function extracts the TYPE and SIZE annotations from the
+// input .ann file.
+// No blank lines are allowed between function annotations.
+//
+// #RNU_RES_E
+// Input data:
+// //NUT: Add description here
+//
+// Output data:
+// //NUT: Add description here
+//
+// Status:
+// 11-Jul-2007 -- Nutricato Raffaele: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+//NUT: consider the possibility to split this function into more functions.
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),5,5);
+
+// -----------------------
+// --- Initialization. ---
+// -----------------------
+nxtscifunname = SharedInfo.NextSCIFunName;
+nxtscifunnumber = SharedInfo.NextSCIFunNumber;
+ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName;
+// #RNU_RES_B
+PrintStringInfo(' ',ReportFileName,'file','y');
+PrintStringInfo('***Reading function annotations***',ReportFileName,'file','y');
+// #RNU_RES_E
+SCI2CClassFileName = GetClsFileName(FunName,FileInfo,SharedInfo);
+FunTypeAnnot = '';
+FunSizeAnnot = '';
+// ---------------------------
+// --- End Initialization. ---
+// ---------------------------
+
+
+// ---------------------------------------------
+// --- Read the annotations of the function. ---
+// ---------------------------------------------
+// --- Open the .sci file (read only). ---
+inclsfid = SCI2COpenFileRead(SCI2CClassFileName);
+
+// #RNU_RES_B
+// --- Loop over the lines of the input file. ---
+// Position file pointer to the desired NInArg/NOutArg section,
+// and read the NOutArg annotation.
+// #RNU_RES_E
+FoundNIn = 0;
+FoundNOut = 0;
+line_position = 0;
+while ((meof(inclsfid) == 0) & (FoundNIn == 0) & (FoundNOut == 0))
+ check_string = stripblanks(mgetl(inclsfid,1));
+ line_position = line_position + 1;
+ if (~isempty(check_string))
+
+ // #RNU_RES_B
+ // --- Search for the NIN annotation. ---
+ // #RNU_RES_E
+ if (SCI2Cstrncmps1size(SharedInfo.Annotations.FUNNIN,check_string))
+ FUNNINAnnot = part(check_string,length(SharedInfo.Annotations.FUNNIN)+1:length(check_string));
+ // #RNU_RES_B
+ // --- Check NIN value. ---
+ // #RNU_RES_E
+ if (eval(FUNNINAnnot) == NInArg)
+ // #RNU_RES_B
+ PrintStringInfo(' Line '+string(line_position)+' - Function NInArg Annotation: '+' ""'+check_string+' ""',...
+ ReportFileName,'file','y');
+ // #RNU_RES_E
+ FoundNIn = 1;
+ check_string = stripblanks(mgetl(inclsfid,1));
+ line_position = line_position + 1;
+ if (~isempty(check_string))
+
+ // #RNU_RES_B
+ // --- Search for the NOUT annotation. ---
+ // #RNU_RES_E
+ if (SCI2Cstrncmps1size(SharedInfo.Annotations.FUNNOUT,check_string))
+ FUNNOUTAnnot = part(check_string,length(SharedInfo.Annotations.FUNNOUT)+1:length(check_string));
+
+ // #RNU_RES_B
+ // --- Check NOUT value. ---
+ // #RNU_RES_E
+ if (eval(FUNNOUTAnnot) == NOutArg)
+ // #RNU_RES_B
+ PrintStringInfo(' Line '+string(line_position)+' - Function NOutArg Annotation: '+' ""'+check_string+' ""',...
+ ReportFileName,'file','y');
+ // #RNU_RES_E
+ FoundNOut = 1;
+ else
+ FoundNIn = 0;
+ end
+ else
+ PrintStringInfo(' ',ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: Incorrect format for function annotation.',ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: Expected '+SharedInfo.Annotations.FUNNIN+' field in the annotations of the function.',ReportFileName,'both','y');
+ PrintStringInfo(' ',ReportFileName,'both','y');
+ SCI2Cerror(' ');
+ end
+ else
+ PrintStringInfo(' ',ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: Incorrect format for function annotation.',ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: Expected '+SharedInfo.Annotations.FUNNIN+' field in the annotations of the function.',ReportFileName,'both','y');
+ PrintStringInfo(' ',ReportFileName,'both','y');
+ SCI2Cerror(' ');
+ end
+ end
+ end
+ end
+end
+
+if (FoundNOut*FoundNIn == 0)
+ PrintStringInfo(' ',ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: Please check file: '+SCI2CClassFileName,ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: Incorrect function annotation.',ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: There are two possibilities:',ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: 1. Syntax error in function annotations.',ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: 2. Missing the right combination of NIN/NOUT annotations: ""'+SharedInfo.Annotations.FUNNIN+string(NInArg)+','+SharedInfo.Annotations.FUNNOUT+' '+string(NOutArg)+'"".',ReportFileName,'both','y');
+ PrintStringInfo(' ',ReportFileName,'both','y');
+ SCI2Cerror(' ');
+else
+ for cntout = 1:NOutArg
+ SCI2C_nout=cntout; // Useful for eval.
+
+ // #RNU_RES_B
+ // Read the Fun type annotation.
+ // #RNU_RES_E
+ check_string = stripblanks(mgetl(inclsfid,1));
+ line_position = line_position + 1;
+ if (isempty(check_string) == %F)
+ tmpannstring = eval(SharedInfo.Annotations.FUNTYPE);
+ if (SCI2Cstrncmps1size(tmpannstring,check_string))
+ // #RNU_RES_B
+ PrintStringInfo(' Line '+string(line_position)+' - Function Type Annotation: '+' ""'+check_string+' ""',...
+ ReportFileName,'file','y');
+ // #RNU_RES_E
+ FunTypeAnnot(cntout) = ...
+ stripblanks(part(check_string,length(tmpannstring)+1:length(check_string)));
+ end
+ else
+ PrintStringInfo(' ',ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: Line '+string(line_position)+' Function type annotation not found in file: '+SCI2CClassFileName,ReportFileName,'both','y');
+ PrintStringInfo(' ',ReportFileName,'both','y');
+ SCI2Cerror(' ');
+ end
+
+ // #RNU_RES_B
+ // --- Read the Fun size annotation. ---
+ // #RNU_RES_E
+ SCI2C_nelem = 1; // Useful for eval.
+ line_position = line_position + 1;
+ if (isempty(check_string) == %F)
+ tmpannstring = eval(SharedInfo.Annotations.FUNSIZE);
+ check_string = stripblanks(mgetl(inclsfid,1));
+ if (SCI2Cstrncmps1size(tmpannstring,check_string))
+ // #RNU_RES_B
+ PrintStringInfo(' Line '+string(line_position)+' - Function Size Annotation: '+' ""'+check_string+' ""',...
+ ReportFileName,'file','y');
+ // #RNU_RES_E
+ FunSizeAnnot(cntout,1) = ...
+ stripblanks(part(check_string,length(tmpannstring)+1:length(check_string)));
+ end
+ else
+ PrintStringInfo(' ',ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: Line '+string(line_position)+' Function size annotation not found in file: '+SCI2CClassFileName,ReportFileName,'both','y');
+ PrintStringInfo(' ',ReportFileName,'both','y');
+ SCI2Cerror(' ');
+ end
+ SCI2C_nelem = 2; // Useful for eval.
+ line_position = line_position + 1;
+ if (isempty(check_string) == %F)
+ tmpannstring = eval(SharedInfo.Annotations.FUNSIZE);
+ check_string = stripblanks(mgetl(inclsfid,1));
+ if (SCI2Cstrncmps1size(tmpannstring,check_string))
+ PrintStringInfo(' Line '+string(line_position)+' - Function Size Annotation: '+' ""'+check_string+' ""',...
+ ReportFileName,'file','y');
+ FunSizeAnnot(cntout,2) = ...
+ stripblanks(part(check_string,length(tmpannstring)+1:length(check_string)));
+ end
+ else
+ PrintStringInfo(' ',ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: Line '+string(line_position)+' Function type annotation (//_SCI2C_FUNSIZE:) not found in file: '+SCI2CClassFileName,ReportFileName,'both','y');
+ PrintStringInfo(' ',ReportFileName,'both','y');
+ SCI2Cerror(' ');
+ end
+ end
+end
+// --- End loop over the lines of the input file. ---
+mclose(inclsfid);
+// -------------------------------------------------
+// --- End Read the annotations of the function. ---
+// -------------------------------------------------
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_GetOutArgInfo.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_GetOutArgInfo.sci index 6a4628de..6566b2ee 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_GetOutArgInfo.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_GetOutArgInfo.sci @@ -1,104 +1,142 @@ -function UpdatedOutArg = ... - FA_GetOutArgInfo(InArg,NInArg,OutArg,NOutArg,SharedInfo,FunPrecSpecifier,FunTypeAnnot,FunSizeAnnot,ReportFileName) -// function UpdatedOutArg = ... -// FA_GetOutArgInfo(InArg,NInArg,OutArg,NOutArg,SharedInfo,FunPrecSpecifier,FunTypeAnnot,FunSizeAnnot,ReportFileName) -// ----------------------------------------------------------------- -// -// Status: -// 25-Oct-2007 -- Raffaele Nutricato: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),9,9); - -UpdatedOutArg = OutArg; -for cntin = 1:NInArg - IN(cntin).TP = InArg(cntin).Type; - IN(cntin).SZ(1) = InArg(cntin).Size(1); - IN(cntin).SZ(2) = InArg(cntin).Size(2); - if ((isnan(InArg(cntin).Value)) & (GetSymbolDimension(InArg(cntin).Size) == 0)) - IN(cntin).VAL = InArg(cntin).Name; - else - IN(cntin).VAL = string(InArg(cntin).Value); - end -end -DefaultPrecision = SharedInfo.DefaultPrecision; - -if (mtlb_strcmp(FunTypeAnnot(1),'')) - NOutArg = 0; -else - NOutArg = max(size(FunTypeAnnot)); -end - -flagfindlike = 0; -for counterin = 1:NInArg - if (InArg(counterin).FindLike == 1 | InArg(counterin).FindLike == -1) - flagfindlike = -1; - end -end - -for counterout = 1:NOutArg - if(mtlb_strcmp(FunTypeAnnot,'FA_TP_USER')) - UpdatedOutArg(counterout).Type = FA_TP_USER(FunPrecSpecifier,DefaultPrecision); - else - UpdatedOutArg(counterout).Type = eval(FunTypeAnnot(counterout)); - end - UpdatedOutArg(counterout).FindLike = 0; - lengthFA_SZ_RTMAX = length('FA_SZ_RTMAX'); - - if (SCI2Cstrncmps1size('FA_SZ_RTMAX',FunSizeAnnot(counterout,1))) - UpdatedOutArg(counterout).FindLike = 1; - FunSizeAnnot(counterout,1) = part(FunSizeAnnot(counterout,1),lengthFA_SZ_RTMAX+1:length(FunSizeAnnot(counterout,1))); - end - - if (SCI2Cstrncmps1size('FA_SZ_RTMAX',FunSizeAnnot(counterout,2))) - UpdatedOutArg(counterout).FindLike = 1; - FunSizeAnnot(counterout,2) = part(FunSizeAnnot(counterout,2),lengthFA_SZ_RTMAX+1:length(FunSizeAnnot(counterout,2))); - end - - if (flagfindlike == -1) - UpdatedOutArg(counterout).FindLike = -1; - end - - tmpeval = eval(FunSizeAnnot(counterout,1)); - if (IsNanSize(tmpeval)) - if SharedInfo.ForExpr.OnExec == 0 - EM_NanSize(ReportFileName); - else - UpdatedOutArg(counterout).Size(1) = string(tmpeval); - end - elseif(SCI2Cisnum(tmpeval)) - if (eval(tmpeval) <= 0) - EM_ZeroSize(ReportFileName); - else - UpdatedOutArg(counterout).Size(1) = string(tmpeval); - end - else - UpdatedOutArg(counterout).Size(1) = string(tmpeval); - end - - tmpeval = eval(FunSizeAnnot(counterout,2)); - if (IsNanSize(tmpeval)) - if SharedInfo.ForExpr.OnExec == 0 - EM_NanSize(ReportFileName); - else - UpdatedOutArg(counterout).Size(2) = string(tmpeval); - end - elseif(SCI2Cisnum(tmpeval)) - if (eval(tmpeval) <= 0) - EM_ZeroSize(ReportFileName); - else - UpdatedOutArg(counterout).Size(2) = string(tmpeval); - end - else - UpdatedOutArg(counterout).Size(2) = string(tmpeval); - end - - UpdatedOutArg(counterout).Value = %nan; - UpdatedOutArg(counterout).Dimension = GetSymbolDimension(UpdatedOutArg(counterout).Size); - UpdatedOutArg(counterout).Scope = 'Temp';//NUT anche su questo si puo' ragionare verifica anche la handleoperation. -end - -endfunction +function UpdatedOutArg = ...
+ FA_GetOutArgInfo(InArg,NInArg,OutArg,NOutArg,SharedInfo,FunPrecSpecifier,FunTypeAnnot,FunSizeAnnot,ReportFileName)
+// function UpdatedOutArg = ...
+// FA_GetOutArgInfo(InArg,NInArg,OutArg,NOutArg,SharedInfo,FunPrecSpecifier,FunTypeAnnot,FunSizeAnnot,ReportFileName)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// InArg is used by eval don't remove it from the function call.
+//
+// #RNU_RES_E
+// Input data:
+// //NUT: Add description here
+//
+// Output data:
+// //NUT: Add description here
+//
+// Status:
+// 25-Oct-2007 -- Raffaele Nutricato: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),9,9);
+
+// -----------------------
+// --- Initialization. ---
+// -----------------------
+UpdatedOutArg = OutArg;
+for cntin = 1:NInArg
+ IN(cntin).TP = InArg(cntin).Type;
+ IN(cntin).SZ(1) = InArg(cntin).Size(1);
+ IN(cntin).SZ(2) = InArg(cntin).Size(2);
+ if ((isnan(InArg(cntin).Value)) & (GetSymbolDimension(InArg(cntin).Size) == 0))
+ // #RNU_RES_B
+ // IN(cntin).VAL = '__SCI2CNANSIZE'; //RNU: toglimi
+ //RNU: Replace the value of the variable with its name, in case it is a scalar variable.
+ // #RNU_RES_E
+ IN(cntin).VAL = InArg(cntin).Name;
+ else
+ IN(cntin).VAL = string(InArg(cntin).Value);
+ end
+end
+DefaultPrecision = SharedInfo.DefaultPrecision;
+
+// ---------------------------
+// --- End Initialization. ---
+// ---------------------------
+if (mtlb_strcmp(FunTypeAnnot(1),''))
+ NOutArg = 0;
+else
+ NOutArg = max(size(FunTypeAnnot));
+end
+
+flagfindlike = 0;
+for counterin = 1:NInArg
+ if (InArg(counterin).FindLike == 1 | InArg(counterin).FindLike == -1)
+ // #RNU_RES_B
+ // Then we must assume that the output will be findlike
+ // 0 = no find-like
+ // 1 = pure find-like
+ //-1 = similar to find-like (out=fun(in)) where in is find-like.
+ // #RNU_RES_E
+ flagfindlike = -1;
+ end
+end
+
+for counterout = 1:NOutArg
+ if(mtlb_strcmp(FunTypeAnnot,'FA_TP_USER'))
+ UpdatedOutArg(counterout).Type = FA_TP_USER(FunPrecSpecifier,DefaultPrecision);
+ else
+ UpdatedOutArg(counterout).Type = eval(FunTypeAnnot(counterout));
+ end
+ UpdatedOutArg(counterout).FindLike = 0;
+ lengthFA_SZ_RTMAX = length('FA_SZ_RTMAX');
+
+ if (SCI2Cstrncmps1size('FA_SZ_RTMAX',FunSizeAnnot(counterout,1)))
+ UpdatedOutArg(counterout).FindLike = 1;
+ FunSizeAnnot(counterout,1) = part(FunSizeAnnot(counterout,1),lengthFA_SZ_RTMAX+1:length(FunSizeAnnot(counterout,1)));
+ end
+
+ if (SCI2Cstrncmps1size('FA_SZ_RTMAX',FunSizeAnnot(counterout,2)))
+ UpdatedOutArg(counterout).FindLike = 1;
+ FunSizeAnnot(counterout,2) = part(FunSizeAnnot(counterout,2),lengthFA_SZ_RTMAX+1:length(FunSizeAnnot(counterout,2)));
+ end
+
+ if (flagfindlike == -1)
+ UpdatedOutArg(counterout).FindLike = -1;
+ end
+
+ // #RNU_RES_B
+ // When the size is given by e IN(x).VAL annotation we can have two cases:
+ // IN(x).VAL is a number or IN(x).VAL is %nan. When it is %nan the
+ // size is equal to the name of IN(x).
+ // This is a dynamic memory extension of a local variable and for the moment
+ // we issue an error according to SCI2C specifications
+ // #RNU_RES_E
+ tmpeval = eval(FunSizeAnnot(counterout,1));
+ if (IsNanSize(tmpeval))
+ if SharedInfo.ForExpr.OnExec == 0
+ EM_NanSize(ReportFileName);
+ else
+ UpdatedOutArg(counterout).Size(1) = string(tmpeval);
+ end
+ elseif(SCI2Cisnum(tmpeval))
+ if (eval(tmpeval) <= 0)
+ EM_ZeroSize(ReportFileName);
+ else
+ UpdatedOutArg(counterout).Size(1) = string(tmpeval);
+ end
+ else
+ UpdatedOutArg(counterout).Size(1) = string(tmpeval);
+ end
+
+ tmpeval = eval(FunSizeAnnot(counterout,2));
+ if (IsNanSize(tmpeval))
+ if SharedInfo.ForExpr.OnExec == 0
+ EM_NanSize(ReportFileName);
+ else
+ // #RNU_RES_B
+ // If we are in for expression I prefer to issue the error later.
+ // #RNU_RES_E
+ UpdatedOutArg(counterout).Size(2) = string(tmpeval);
+ end
+ elseif(SCI2Cisnum(tmpeval))
+ if (eval(tmpeval) <= 0)
+ EM_ZeroSize(ReportFileName);
+ else
+ UpdatedOutArg(counterout).Size(2) = string(tmpeval);
+ end
+ else
+ UpdatedOutArg(counterout).Size(2) = string(tmpeval);
+ end
+
+ UpdatedOutArg(counterout).Value = %nan;
+ UpdatedOutArg(counterout).Dimension = GetSymbolDimension(UpdatedOutArg(counterout).Size);
+ UpdatedOutArg(counterout).Scope = 'Temp';//NUT anche su questo si puo' ragionare verifica anche la handleoperation.
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_GetResizeApproach.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_GetResizeApproach.sci new file mode 100644 index 00000000..95427001 --- /dev/null +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_GetResizeApproach.sci @@ -0,0 +1,79 @@ +function ResizeApproach = FA_GetResizeApproach(scifilename,ReportFileName)
+
+// function ResizeApproach = FA_GetResizeApproach(scifilename,ReportFileName)
+// -----------------------------------------------------------------
+// Extracts the resize approach from the file .sci passed in input.
+// The following annotation will be searched in the scilab code:
+// //SCI2C: RESIZE_APPROACH= NO_RESIZE
+// //SCI2C: RESIZE_APPROACH= RESIZE_ALL
+// //SCI2C: RESIZE_APPROACH= REALLOC_ALL_RESIZE_ALL
+// //SCI2C: RESIZE_APPROACH= RESIZE_TEMP
+// //SCI2C: RESIZE_APPROACH= RESIZE_LOCAL
+// //SCI2C: RESIZE_APPROACH= RESIZE_GLOBAL
+// If the annotation is missing the default NO_RESIZE approach will be
+// implicitly used.
+//
+// Input data:
+// ---
+//
+// Output data:
+// ResizeApproach: string which specifies the resize approach
+// used in the translation of scifilename.
+//
+// Status:
+// 12-Jul-2008 -- Raffaele Nutricato: Author.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+// -----------------------
+// --- Initialization. ---
+// -----------------------
+ResizeApproach = 'NO_RESIZE';
+annotationstring = '//SCI2C: RESIZE_APPROACH='
+PrintStringInfo('***Get resize approach from: '+scifilename,ReportFileName,'file','y'); // #RNUREM_ME
+// ---------------------------
+// --- End Initialization. ---
+// ---------------------------
+
+// --- Open the .sci file (read only). ---
+scifid = SCI2COpenFileRead(scifilename);
+
+// --- Loop over the lines of the input file. ---
+// Position file pointer to the desired NInArg/NOutArg section,
+// and read the NOutArg annotation.
+foundannotation = 0;
+line_position = 0;
+
+while ((meof(scifid) == 0) & (foundannotation == 0))
+ check_string = stripblanks(mgetl(scifid,1));
+ line_position = line_position + 1;
+ if (~isempty(check_string))
+ if (SCI2Cstrncmps1size(annotationstring,check_string))
+ tmpresize = stripblanks(part(check_string,length(annotationstring)+1:length(check_string)));
+ // #RNU_RES_B
+ PrintStringInfo(' Line '+string(line_position)+...
+ ' - Found annotation for resize approach'+' ""'+check_string+' ""',...
+ ReportFileName,'file','y');
+ // #RNU_RES_E
+ foundannotation = 1;
+ end
+ end
+end
+
+if (foundannotation == 0)
+ // #RNU_RES_B
+ PrintStringInfo('Annotation for resize approach not found.',ReportFileName,'file','y');
+ PrintStringInfo('Using the ''NO_RESIZE'' resize approach.',ReportFileName,'file','y');
+ // #RNU_RES_E
+else
+ ResizeApproach = tmpresize;
+end
+mclose(scifid);
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_INT.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_INT.sci index 4bc2fde7..c4e2cc3d 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_INT.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_INT.sci @@ -1,25 +1,40 @@ -function opout = FA_INT(in1) -// function opout = FA_INT(in1) -// ----------------------------------------------------------------- -// -// Status: -// 26-Oct-2007 -- Raffaele Nutricato: Author. -// 26-Oct-2007 -- Alberto Morea: Test Ok. -// -// Copyright 2008 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),1,1); - -if (SCI2Cisnum(in1)) - outnum = int(eval(in1)); - if isnan(outnum) - opout = '__SCI2CNANSIZE'; - else - opout = string(outnum); - end -else - opout = in1; -end -endfunction +function opout = FA_INT(in1)
+// function opout = FA_INT(in1)
+// -----------------------------------------------------------------
+// Int function for Function Annotations.
+// When in1 is a number opout = int(in1); where int truncates in1
+// to integer. If in1 is string opout = in1.
+//
+// Input data:
+// in1: string specifying a number or a symbol.
+//
+// Output data:
+// opout: string containing the computed result.
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+// ------------------------
+// --- Generate Output. ---
+// ------------------------
+if (SCI2Cisnum(in1))
+ outnum = int(eval(in1));
+ if isnan(outnum)
+ opout = '__SCI2CNANSIZE';
+ else
+ opout = string(outnum);
+ end
+else
+ opout = in1;
+end
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_MAX.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_MAX.sci index 769ef5d2..8b947cec 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_MAX.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_MAX.sci @@ -1,35 +1,51 @@ -function opout = FA_MAX(in1,in2) -// function opout = FA_MAX(in1,in2) -// ----------------------------------------------------------------- -// -// Status: -// 26-Oct-2007 -- Raffaele Nutricato: Author. -// 26-Oct-2007 -- Alberto Morea: Test Ok. -// -// Copyright 2008 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),2,2); - -SCI2Cerror('Not allowed to use FA_MAX in this release.'); - -if (SCI2Cisnum(in1)) - in1num = eval(in1); - if (SCI2Cisnum(in2)) - in2num = eval(in2); - outnum = max(in1num,in2num); - if isnan(outnum) - opout = '__SCI2CNANSIZE'; - else - opout = string(outnum); - end - else - if (in1num == 1) - opout = string(in2); - end - end -else - opout = string(in1); -end -endfunction +function opout = FA_MAX(in1,in2)
+// function opout = FA_MAX(in1,in2)
+// -----------------------------------------------------------------
+// Maximum function for Function Annotations.
+// When in1 and in2 are both symbols this function returns
+// in1.
+//
+// Input data:
+// in1: string specifying a number or a symbol.
+// in2: string specifying a number or a symbol.
+//
+// Output data:
+// opout: string containing the computed result.
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+SCI2Cerror('Not allowed to use FA_MAX in this release.');
+
+// ------------------------
+// --- Generate Output. ---
+// ------------------------
+if (SCI2Cisnum(in1))
+ in1num = eval(in1);
+ if (SCI2Cisnum(in2))
+ in2num = eval(in2);
+ outnum = max(in1num,in2num);
+ if isnan(outnum)
+ opout = '__SCI2CNANSIZE';
+ else
+ opout = string(outnum);
+ end
+ else
+ if (in1num == 1)
+ opout = string(in2);
+ end
+ end
+else
+ opout = string(in1);
+end
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_MUL.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_MUL.sci index 750afc79..d3495a02 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_MUL.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_MUL.sci @@ -1,34 +1,42 @@ -function opout = FA_MUL(in1,in2) -// function opout = FA_MUL(in1,in2) -// ----------------------------------------------------------------- -// -// Status: -// 26-Oct-2007 -- Raffaele Nutricato: Author. -// 26-Oct-2007 -- Alberto Morea: Test Ok. -// -// Copyright 2007 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -// ------------------------------ -// --- Check input arguments. --- -// ------------------------------ -SCI2CNInArgCheck(argn(2),2,2); - - -// ------------------------ -// --- Generate Output. --- -// ------------------------ -if (SCI2Cisnum(in1) & SCI2Cisnum(in2)) - in1num = eval(in1); - in2num = eval(in2); - outnum = in1num*in2num; - if isnan(outnum) - opout = '__SCI2CNANSIZE'; - else - opout = string(outnum); - end -else - opout = string(in1)+'*'+string(in2); -end -endfunction +function opout = FA_MUL(in1,in2)
+// function opout = FA_MUL(in1,in2)
+// -----------------------------------------------------------------
+// Multiplication function for Function Annotations.
+//
+// Input data:
+// in1: string specifying a number or a symbol.
+// in2: string specifying a number or a symbol.
+//
+// Output data:
+// opout: string containing the computed result.
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+
+// ------------------------
+// --- Generate Output. ---
+// ------------------------
+if (SCI2Cisnum(in1) & SCI2Cisnum(in2))
+ in1num = eval(in1);
+ in2num = eval(in2);
+ outnum = in1num*in2num;
+ if isnan(outnum)
+ opout = '__SCI2CNANSIZE';
+ else
+ opout = string(outnum);
+ end
+else
+ opout = '('+string(in1)+'*'+string(in2)+')';
+end
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SUB.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SUB.sci index fc8c828a..039ff1af 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SUB.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SUB.sci @@ -1,33 +1,41 @@ -function opout = FA_SUB(in1,in2) -// function opout = FA_SUB(in1,in2) -// ----------------------------------------------------------------- -// -// Status: -// 26-Oct-2007 -- Raffaele Nutricato: Author. -// 26-Oct-2007 -- Alberto Morea: Test Ok. -// -// Copyright 2007 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -// ------------------------------ -// --- Check input arguments. --- -// ------------------------------ -SCI2CNInArgCheck(argn(2),2,2); - -// ------------------------ -// --- Generate Output. --- -// ------------------------ -if (SCI2Cisnum(in1) & SCI2Cisnum(in2)) - in1num = eval(in1); - in2num = eval(in2); - outnum = in1num-in2num; - if isnan(outnum) - opout = '__SCI2CNANSIZE'; - else - opout = string(outnum); - end -else - opout = string(in1)+'-'+string(in2); -end -endfunction +function opout = FA_SUB(in1,in2)
+// function opout = FA_SUB(in1,in2)
+// -----------------------------------------------------------------
+// Subtraction function for Function Annotations.
+//
+// Input data:
+// in1: string specifying a number or a symbol.
+// in2: string specifying a number or a symbol.
+//
+// Output data:
+// opout: string containing the computed result.
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+// ------------------------
+// --- Generate Output. ---
+// ------------------------
+if (SCI2Cisnum(in1) & SCI2Cisnum(in2))
+ in1num = eval(in1);
+ in2num = eval(in2);
+ outnum = in1num-in2num;
+ if isnan(outnum)
+ opout = '__SCI2CNANSIZE';
+ else
+ opout = string(outnum);
+ end
+else
+ opout = '('+string(in1)+'-'+string(in2)+')';
+end
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_1.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_1.sci index 9bbfe5bd..d9a481ce 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_1.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_1.sci @@ -1,6 +1,15 @@ function outsize = FA_SZ_1(insize)
// function outsize = FA_SZ_1(insize)
// -----------------------------------------------------------------
+// Returns the first element of the size array.
+//
+// Input data:
+// insize: size of input argument. It is an array of 2 strings.
+// The first string specifies the number of rows.
+// The second string specifies the number of columns.
+//
+// Output data:
+// outsize: first element of the insize array.
//
// Status:
// 08-Dec-2007 -- Raffaele Nutricato: Author.
@@ -8,4 +17,4 @@ function outsize = FA_SZ_1(insize) // -----------------------------------------------------------------
outsize = insize(1);
-endfunction
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_2.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_2.sci index 074d8404..64fdac10 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_2.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_2.sci @@ -1,6 +1,15 @@ function outsize = FA_SZ_2(insize)
// function outsize = FA_SZ_2(insize)
// -----------------------------------------------------------------
+// Returns the second element of the size array.
+//
+// Input data:
+// insize: size of input argument. It is an array of 2 strings.
+// The first string specifies the number of rows.
+// The second string specifies the number of columns.
+//
+// Output data:
+// outsize: second element of the insize array.
//
// Status:
// 08-Dec-2007 -- Raffaele Nutricato: Author.
@@ -8,4 +17,4 @@ function outsize = FA_SZ_2(insize) // -----------------------------------------------------------------
outsize = insize(2);
-endfunction
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPAPEX.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPAPEX.sci index 7f676b19..a93e8c50 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPAPEX.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPAPEX.sci @@ -1,24 +1,26 @@ -function opoutsize = FA_SZ_OPAPEX(in1size) -// function opoutsize = FA_SZ_OPAPEX(in1size) -// ----------------------------------------------------------------- -// -// Status: -// 08-Jan-2008 -- Raffaele Nutricato: Author. -// 08-Jan-2008 -- Alberto Morea: Test Ok. -// -// Copyright 2008 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -// ------------------------------ -// --- Check input arguments. --- -// ------------------------------ -SCI2CNInArgCheck(argn(2),1,1); - -// ------------------------ -// --- Generate Output. --- -// ------------------------ -opoutsize(1) = string(in1size(2)); -opoutsize(2) = string(in1size(1)); - -endfunction +function opoutsize = FA_SZ_OPAPEX(in1size)
+// function opoutsize = FA_SZ_OPAPEX(in1size)
+// -----------------------------------------------------------------
+// Returns the size of the output computed by OPAPEX operator.
+//
+//
+// Status:
+// 08-Jan-2008 -- Raffaele Nutricato: Author.
+// 08-Jan-2008 -- Alberto Morea: Test Ok.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+// ------------------------
+// --- Generate Output. ---
+// ------------------------
+opoutsize(1) = string(in1size(2));
+opoutsize(2) = string(in1size(1));
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPBACKSLASH.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPBACKSLASH.sci index 7338654a..9d0625bd 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPBACKSLASH.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPBACKSLASH.sci @@ -1,37 +1,39 @@ -function opoutsize = FA_SZ_OPBACKSLASH(in1size,in2size) -// function opoutsize = FA_SZ_OPBACKSLASH(in1size,in2size) -// ----------------------------------------------------------------- -// -// Status: -// 08-Mar-2008 -- Alberto Morea: Author. -// 08-Mar-2008 -- Raffaele Nutricato: Test Ok. -// -// Copyright 2008 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -// ------------------------------ -// --- Check input arguments. --- -// ------------------------------ -SCI2CNInArgCheck(argn(2),2,2); - -// ------------------------ -// --- Generate Output. --- -// ------------------------ -in1size=string(in1size); -in2size=string(in2size); - -// --- Get dimensions of input arguments. --- -in1dim = GetSymbolDimension(in1size); -in2dim = GetSymbolDimension(in2size); - -if (in1dim == 0) - opoutsize = in2size; -elseif (in2dim == 0) - opoutsize = in1size; -else - opoutsize(1) = in1size(2); - opoutsize(2) = in2size(2); -end - -endfunction +function opoutsize = FA_SZ_OPBACKSLASH(in1size,in2size)
+// function opoutsize = FA_SZ_OPBACKSLASH(in1size,in2size)
+// -----------------------------------------------------------------
+// Returns the size of the output computed by OPBACKSLASH operator.
+//
+//
+// Status:
+// 08-Mar-2008 -- Alberto Morea: Author.
+// 08-Mar-2008 -- Raffaele Nutricato: Test Ok.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+// ------------------------
+// --- Generate Output. ---
+// ------------------------
+in1size=string(in1size);
+in2size=string(in2size);
+
+// --- Get dimensions of input arguments. ---
+in1dim = GetSymbolDimension(in1size);
+in2dim = GetSymbolDimension(in2size);
+
+if (in1dim == 0)
+ opoutsize = in2size;
+elseif (in2dim == 0)
+ opoutsize = in1size;
+else
+ opoutsize(1) = in1size(2);
+ opoutsize(2) = in2size(2);
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPCC.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPCC.sci index 13809368..cc532e24 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPCC.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPCC.sci @@ -1,38 +1,40 @@ -function opoutsize = FA_SZ_OPCC(in1size,in2size) -// function opoutsize = FA_SZ_OPCC(in1size,in2size) -// ----------------------------------------------------------------- -// -// Status: -// 08-Mar-2008 -- Raffaele Nutricato: Author. -// 08-Mar-2008 -- Alberto Morea: Test Ok. -// -// Copyright 2008 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -// ------------------------------ -// --- Check input arguments. --- -// ------------------------------ -SCI2CNInArgCheck(argn(2),2,2); - -in1size = string(in1size); -in2size = string(in2size); - -// ------------------------ -// --- Generate Output. --- -// ------------------------ -// --- Get dimensions of input arguments. --- -in1dim = GetSymbolDimension(in1size); -in2dim = GetSymbolDimension(in2size); - -if (SCI2Cisnum(in1size(1)) & SCI2Cisnum(in2size(1))) - in1num = eval(in1size(1)); - in2num = eval(in2size(1)); - opoutsize(1) = string(in1num+in2num); -else - opoutsize(1) = string(in1size(1))+'+'+string(in2size(1)); -end - -opoutsize(2) = in1size(2); - -endfunction +function opoutsize = FA_SZ_OPCC(in1size,in2size)
+// function opoutsize = FA_SZ_OPCC(in1size,in2size)
+// -----------------------------------------------------------------
+// Returns the size of the output computed by OPCC operator.
+//
+//
+// Status:
+// 08-Mar-2008 -- Raffaele Nutricato: Author.
+// 08-Mar-2008 -- Alberto Morea: Test Ok.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+in1size = string(in1size);
+in2size = string(in2size);
+
+// ------------------------
+// --- Generate Output. ---
+// ------------------------
+// --- Get dimensions of input arguments. ---
+in1dim = GetSymbolDimension(in1size);
+in2dim = GetSymbolDimension(in2size);
+
+if (SCI2Cisnum(in1size(1)) & SCI2Cisnum(in2size(1)))
+ in1num = eval(in1size(1));
+ in2num = eval(in2size(1));
+ opoutsize(1) = string(in1num+in2num);
+else
+ opoutsize(1) = '('+string(in1size(1))+'+'+string(in2size(1))+')';
+end
+
+opoutsize(2) = in1size(2);
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPDOTAPEX.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPDOTAPEX.sci index 9e540bb9..64e8030e 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPDOTAPEX.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPDOTAPEX.sci @@ -1,13 +1,16 @@ -function opoutsize = FA_SZ_OPDOTAPEX(in1size) -// function opoutsize = FA_SZ_OPDOTAPEX(in1size) -// ----------------------------------------------------------------- -// Status: -// 08-Mar-2008 -- Raffaele Nutricato: Author. -// 08-Mar-2008 -- Alberto Morea: Test Ok. -// -// Copyright 2008 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -opoutsize = FA_SZ_OPDOTAPEX(in1size,in2size); -endfunction +function opoutsize = FA_SZ_OPDOTAPEX(in1size)
+// function opoutsize = FA_SZ_OPDOTAPEX(in1size)
+// -----------------------------------------------------------------
+// Alias of FA_SZ_OPDOTAPEX.
+//
+//
+// Status:
+// 08-Mar-2008 -- Raffaele Nutricato: Author.
+// 08-Mar-2008 -- Alberto Morea: Test Ok.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+opoutsize = FA_SZ_OPDOTAPEX(in1size,in2size);
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPDOTBACKSLASH.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPDOTBACKSLASH.sci index 66dd1abf..75f4d5c3 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPDOTBACKSLASH.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPDOTBACKSLASH.sci @@ -1,14 +1,16 @@ -function opoutsize = FA_SZ_OPDOTBACKSLASH(in1size,in2size) -// function opoutsize = FA_SZ_OPDOTBACKSLASH(in1size,in2size) -// ----------------------------------------------------------------- -// -// Status: -// 08-Mar-2008 -- Raffaele Nutricato: Author. -// 08-Mar-2008 -- Alberto Morea: Test Ok. -// -// Copyright 2008 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size); -endfunction +function opoutsize = FA_SZ_OPDOTBACKSLASH(in1size,in2size)
+// function opoutsize = FA_SZ_OPDOTBACKSLASH(in1size,in2size)
+// -----------------------------------------------------------------
+// Alias of FA_SZ_OPDOTSTAR.
+//
+//
+// Status:
+// 08-Mar-2008 -- Raffaele Nutricato: Author.
+// 08-Mar-2008 -- Alberto Morea: Test Ok.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size);
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPDOTHAT.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPDOTHAT.sci index 024284e2..af522bac 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPDOTHAT.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPDOTHAT.sci @@ -1,43 +1,43 @@ -function opoutsize = FA_SZ_OPDOTHAT(in1size,in2size) -// function opoutsize = FA_SZ_OPDOTHAT(in1size,in2size) -// ----------------------------------------------------------------- -// Returns the size of the output computed by OPDOTHAT operator. -// -// Assuming: -// size(in1) = [in1r,in1c] -// size(in2) = [in2r,in2c] -// size(out) = [outr,outc] -// -// we have the following combinations: -// in1 in2 outr outc -// ----------------------- -// S S in2r in2c -// S M in2r in2c -// M S in1r in1c -// M M in1r in1c -// -// Where S means that the input is a scalar -// and M means that the input is a matrix. -// -// Input data: -// in1size: size of input number 1. It is an array of 2 strings. -// The first string specifies the number of rows. -// The second string specifies the number of columns. -// -// in2size: size of input number 2. It is an array of 2 strings. -// The first string specifies the number of rows. -// The second string specifies the number of columns. -// -// Output data: -// opoutsize: size of output. It is an array of 2 strings. -// The first string specifies the number of rows. -// The second string specifies the number of columns. -// -// Status: -// 10-Dec-2007 -- Raffaele Nutricato: Author. -// 10-Dec-2007 -- Alberto Morea: Test Ok. -// ----------------------------------------------------------------- - -opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size); - -endfunction +function opoutsize = FA_SZ_OPDOTHAT(in1size,in2size)
+// function opoutsize = FA_SZ_OPDOTHAT(in1size,in2size)
+// -----------------------------------------------------------------
+// Returns the size of the output computed by OPDOTHAT operator.
+//
+// Assuming:
+// size(in1) = [in1r,in1c]
+// size(in2) = [in2r,in2c]
+// size(out) = [outr,outc]
+//
+// we have the following combinations:
+// in1 in2 outr outc
+// -----------------------
+// S S in2r in2c
+// S M in2r in2c
+// M S in1r in1c
+// M M in1r in1c
+//
+// Where S means that the input is a scalar
+// and M means that the input is a matrix.
+//
+// Input data:
+// in1size: size of input number 1. It is an array of 2 strings.
+// The first string specifies the number of rows.
+// The second string specifies the number of columns.
+//
+// in2size: size of input number 2. It is an array of 2 strings.
+// The first string specifies the number of rows.
+// The second string specifies the number of columns.
+//
+// Output data:
+// opoutsize: size of output. It is an array of 2 strings.
+// The first string specifies the number of rows.
+// The second string specifies the number of columns.
+//
+// Status:
+// 10-Dec-2007 -- Raffaele Nutricato: Author.
+// 10-Dec-2007 -- Alberto Morea: Test Ok.
+// -----------------------------------------------------------------
+
+opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size);
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPDOTSLASH.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPDOTSLASH.sci index c62196d8..2a071f27 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPDOTSLASH.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPDOTSLASH.sci @@ -1,15 +1,16 @@ -function opoutsize = FA_SZ_OPDOTSLASH(in1size,in2size) -// function opoutsize = FA_SZ_OPDOTSLASH(in1size,in2size) -// ----------------------------------------------------------------- -// -// -// Status: -// 08-Mar-2008 -- Raffaele Nutricato: Author. -// 08-Mar-2008 -- Alberto Morea: Test Ok. -// -// Copyright 2008 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size); -endfunction +function opoutsize = FA_SZ_OPDOTSLASH(in1size,in2size)
+// function opoutsize = FA_SZ_OPDOTSLASH(in1size,in2size)
+// -----------------------------------------------------------------
+// Alias of FA_SZ_OPDOTSTAR.
+//
+//
+// Status:
+// 08-Mar-2008 -- Raffaele Nutricato: Author.
+// 08-Mar-2008 -- Alberto Morea: Test Ok.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size);
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPDOTSTAR.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPDOTSTAR.sci index 805b3de8..3fbae19a 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPDOTSTAR.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPDOTSTAR.sci @@ -1,22 +1,32 @@ -function opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size) -// function opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size) -// ----------------------------------------------------------------- -// Status: -// 08-Jan-2008 -- Raffaele Nutricato: Author. -// 08-Jan-2008 -- Alberto Morea: Test Ok. -// -// Copyright 2008 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),2,2); - -in1dim = GetSymbolDimension(in1size); - -if (in1dim == 0) - opoutsize = string(in2size); -else - opoutsize = string(in1size); -end - -endfunction +function opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size)
+// function opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size)
+// -----------------------------------------------------------------
+// Returns the size of the output computed by OPDOTSTAR operator.
+//
+//
+// Status:
+// 08-Jan-2008 -- Raffaele Nutricato: Author.
+// 08-Jan-2008 -- Alberto Morea: Test Ok.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+// ------------------------
+// --- Generate Output. ---
+// ------------------------
+// --- Get dimensions of input arguments. ---
+in1dim = GetSymbolDimension(in1size);
+
+if (in1dim == 0)
+ opoutsize = string(in2size);
+else
+ opoutsize = string(in1size);
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPHAT.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPHAT.sci index 2e372508..31174511 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPHAT.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPHAT.sci @@ -1,12 +1,43 @@ -function opoutsize = FA_SZ_OPHAT(in1size,in2size) -// function opoutsize = FA_SZ_OPHAT(in1size,in2size) -// ----------------------------------------------------------------- -// -// Status: -// 10-Dec-2007 -- Raffaele Nutricato: Author. -// 10-Dec-2007 -- Alberto Morea: Test Ok. -// ----------------------------------------------------------------- - -opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size); - -endfunction +function opoutsize = FA_SZ_OPHAT(in1size,in2size)
+// function opoutsize = FA_SZ_OPHAT(in1size,in2size)
+// -----------------------------------------------------------------
+// Returns the size of the output computed by OPHAT operator.
+//
+// Assuming:
+// size(in1) = [in1r,in1c]
+// size(in2) = [in2r,in2c]
+// size(out) = [outr,outc]
+//
+// we have the following combinations:
+// in1 in2 outr outc
+// -----------------------
+// S S in2r in2c
+// S M in2r in2c
+// M S in1r in1c
+// M M in1r in1c
+//
+// Where S means that the input is a scalar
+// and M means that the input is a matrix.
+//
+// Input data:
+// in1size: size of input number 1. It is an array of 2 strings.
+// The first string specifies the number of rows.
+// The second string specifies the number of columns.
+//
+// in2size: size of input number 2. It is an array of 2 strings.
+// The first string specifies the number of rows.
+// The second string specifies the number of columns.
+//
+// Output data:
+// opoutsize: size of output. It is an array of 2 strings.
+// The first string specifies the number of rows.
+// The second string specifies the number of columns.
+//
+// Status:
+// 10-Dec-2007 -- Raffaele Nutricato: Author.
+// 10-Dec-2007 -- Alberto Morea: Test Ok.
+// -----------------------------------------------------------------
+
+opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size);
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGAND.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGAND.sci index 86ae5235..099bb9ac 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGAND.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGAND.sci @@ -1,15 +1,16 @@ -function opoutsize = FA_SZ_OPLOGAND(in1size,in2size) -// function opoutsize = FA_SZ_OPLOGAND(in1size,in2size) -// ----------------------------------------------------------------- -// -// -// Status: -// 08-Mar-2008 -- Raffaele Nutricato: Author. -// 08-Mar-2008 -- Alberto Morea: Test Ok. -// -// Copyright 2008 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size); -endfunction +function opoutsize = FA_SZ_OPLOGAND(in1size,in2size)
+// function opoutsize = FA_SZ_OPLOGAND(in1size,in2size)
+// -----------------------------------------------------------------
+// Alias of FA_SZ_OPDOTSTAR.
+//
+//
+// Status:
+// 08-Mar-2008 -- Raffaele Nutricato: Author.
+// 08-Mar-2008 -- Alberto Morea: Test Ok.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size);
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGEQ.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGEQ.sci index 19bcd47a..4ade6a0f 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGEQ.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGEQ.sci @@ -1,13 +1,16 @@ -function opoutsize = FA_SZ_OPLOGEQ(in1size,in2size) -// function opoutsize = FA_SZ_OPLOGEQ(in1size,in2size) -// ----------------------------------------------------------------- -// Status: -// 08-Mar-2008 -- Raffaele Nutricato: Author. -// 08-Mar-2008 -- Alberto Morea: Test Ok. -// -// Copyright 2008 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size); -endfunction +function opoutsize = FA_SZ_OPLOGEQ(in1size,in2size)
+// function opoutsize = FA_SZ_OPLOGEQ(in1size,in2size)
+// -----------------------------------------------------------------
+// Alias of FA_SZ_OPDOTSTAR.
+//
+//
+// Status:
+// 08-Mar-2008 -- Raffaele Nutricato: Author.
+// 08-Mar-2008 -- Alberto Morea: Test Ok.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size);
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGGE.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGGE.sci index 0391c4b4..c6d6ee3f 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGGE.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGGE.sci @@ -1,14 +1,16 @@ -function opoutsize = FA_SZ_OPLOGGE(in1size,in2size) -// function opoutsize = FA_SZ_OPLOGGE(in1size,in2size) -// ----------------------------------------------------------------- -// -// Status: -// 08-Mar-2008 -- Raffaele Nutricato: Author. -// 08-Mar-2008 -- Alberto Morea: Test Ok. -// -// Copyright 2008 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size); -endfunction +function opoutsize = FA_SZ_OPLOGGE(in1size,in2size)
+// function opoutsize = FA_SZ_OPLOGGE(in1size,in2size)
+// -----------------------------------------------------------------
+// Alias of FA_SZ_OPDOTSTAR.
+//
+//
+// Status:
+// 08-Mar-2008 -- Raffaele Nutricato: Author.
+// 08-Mar-2008 -- Alberto Morea: Test Ok.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size);
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGGT.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGGT.sci index 334448b4..0f6493c9 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGGT.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGGT.sci @@ -1,14 +1,16 @@ -function opoutsize = FA_SZ_OPLOGGT(in1size,in2size) -// function opoutsize = FA_SZ_OPLOGGT(in1size,in2size) -// ----------------------------------------------------------------- -// -// Status: -// 08-Mar-2008 -- Raffaele Nutricato: Author. -// 08-Mar-2008 -- Alberto Morea: Test Ok. -// -// Copyright 2008 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size); -endfunction +function opoutsize = FA_SZ_OPLOGGT(in1size,in2size)
+// function opoutsize = FA_SZ_OPLOGGT(in1size,in2size)
+// -----------------------------------------------------------------
+// Alias of FA_SZ_OPDOTSTAR.
+//
+//
+// Status:
+// 08-Mar-2008 -- Raffaele Nutricato: Author.
+// 08-Mar-2008 -- Alberto Morea: Test Ok.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size);
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGLE.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGLE.sci index 2e2e8621..edda359f 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGLE.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGLE.sci @@ -1,16 +1,16 @@ -function opoutsize = FA_SZ_OPLOGLE(in1size,in2size) -// function opoutsize = FA_SZ_OPLOGLE(in1size,in2size) -// ----------------------------------------------------------------- -// Alias of FA_SZ_OPDOTSTAR. -// -// -// Status: -// 08-Mar-2008 -- Raffaele Nutricato: Author. -// 08-Mar-2008 -- Alberto Morea: Test Ok. -// -// Copyright 2008 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size); -endfunction +function opoutsize = FA_SZ_OPLOGLE(in1size,in2size)
+// function opoutsize = FA_SZ_OPLOGLE(in1size,in2size)
+// -----------------------------------------------------------------
+// Alias of FA_SZ_OPDOTSTAR.
+//
+//
+// Status:
+// 08-Mar-2008 -- Raffaele Nutricato: Author.
+// 08-Mar-2008 -- Alberto Morea: Test Ok.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size);
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGLT.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGLT.sci index 92fe9305..81b1b256 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGLT.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGLT.sci @@ -1,16 +1,16 @@ -function opoutsize = FA_SZ_OPLOGLT(in1size,in2size) -// function opoutsize = FA_SZ_OPLOGLT(in1size,in2size) -// ----------------------------------------------------------------- -// Alias of FA_SZ_OPDOTSTAR. -// -// -// Status: -// 08-Mar-2008 -- Raffaele Nutricato: Author. -// 08-Mar-2008 -- Alberto Morea: Test Ok. -// -// Copyright 2008 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size); -endfunction +function opoutsize = FA_SZ_OPLOGLT(in1size,in2size)
+// function opoutsize = FA_SZ_OPLOGLT(in1size,in2size)
+// -----------------------------------------------------------------
+// Alias of FA_SZ_OPDOTSTAR.
+//
+//
+// Status:
+// 08-Mar-2008 -- Raffaele Nutricato: Author.
+// 08-Mar-2008 -- Alberto Morea: Test Ok.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size);
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGNE.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGNE.sci index 785c6b3c..ff62abbf 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGNE.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGNE.sci @@ -1,16 +1,16 @@ -function opoutsize = FA_SZ_OPLOGNE(in1size,in2size) -// function opoutsize = FA_SZ_OPLOGNE(in1size,in2size) -// ----------------------------------------------------------------- -// Alias of FA_SZ_OPDOTSTAR. -// -// -// Status: -// 08-Mar-2008 -- Raffaele Nutricato: Author. -// 08-Mar-2008 -- Alberto Morea: Test Ok. -// -// Copyright 2008 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size); -endfunction +function opoutsize = FA_SZ_OPLOGNE(in1size,in2size)
+// function opoutsize = FA_SZ_OPLOGNE(in1size,in2size)
+// -----------------------------------------------------------------
+// Alias of FA_SZ_OPDOTSTAR.
+//
+//
+// Status:
+// 08-Mar-2008 -- Raffaele Nutricato: Author.
+// 08-Mar-2008 -- Alberto Morea: Test Ok.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size);
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGNOT.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGNOT.sci index 540be9dc..3b0c6549 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGNOT.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGNOT.sci @@ -1,16 +1,16 @@ -function opoutsize = FA_SZ_OPLOGNOT(in1size) -// function opoutsize = FA_SZ_OPLOGNOT(in1size) -// ----------------------------------------------------------------- -// Alias of FA_SZ_OPDOTAPEX. -// -// -// Status: -// 08-Mar-2008 -- Raffaele Nutricato: Author. -// 08-Mar-2008 -- Alberto Morea: Test Ok. -// -// Copyright 2008 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -opoutsize = FA_SZ_OPDOTAPEX(in1size,in2size); -endfunction +function opoutsize = FA_SZ_OPLOGNOT(in1size)
+// function opoutsize = FA_SZ_OPLOGNOT(in1size)
+// -----------------------------------------------------------------
+// Alias of FA_SZ_OPDOTAPEX.
+//
+//
+// Status:
+// 08-Mar-2008 -- Raffaele Nutricato: Author.
+// 08-Mar-2008 -- Alberto Morea: Test Ok.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+opoutsize = FA_SZ_OPDOTAPEX(in1size,in2size);
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGOR.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGOR.sci index ccdf1e4a..f28eec2f 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGOR.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPLOGOR.sci @@ -1,14 +1,16 @@ -function opoutsize = FA_SZ_OPLOGOR(in1size,in2size) -// function opoutsize = FA_SZ_OPLOGOR(in1size,in2size) -// ----------------------------------------------------------------- -// -// Status: -// 08-Mar-2008 -- Raffaele Nutricato: Author. -// 08-Mar-2008 -- Alberto Morea: Test Ok. -// -// Copyright 2008 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size); -endfunction +function opoutsize = FA_SZ_OPLOGOR(in1size,in2size)
+// function opoutsize = FA_SZ_OPLOGOR(in1size,in2size)
+// -----------------------------------------------------------------
+// Alias of FA_SZ_OPDOTSTAR.
+//
+//
+// Status:
+// 08-Mar-2008 -- Raffaele Nutricato: Author.
+// 08-Mar-2008 -- Alberto Morea: Test Ok.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+opoutsize = FA_SZ_OPDOTSTAR(in1size,in2size);
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPMINUS.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPMINUS.sci index ca5dbb75..5f7fc96a 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPMINUS.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPMINUS.sci @@ -1,17 +1,51 @@ -function opoutsize = FA_SZ_OPMINUS(in1size,in2size) -// function opoutsize = FA_SZ_OPMINUS(in1size,in2size) -// ----------------------------------------------------------------- -// -// Status: -// 08-Dec-2007 -- Raffaele Nutricato: Author. -// 08-Dec-2007 -- Alberto Morea: Test Ok. -// -// Copyright 2007 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),2,2); - -opoutsize = FA_SZ_OPPLUSA(in1size,in2size); - -endfunction +function opoutsize = FA_SZ_OPMINUS(in1size,in2size)
+// function opoutsize = FA_SZ_OPMINUS(in1size,in2size)
+// -----------------------------------------------------------------
+// Returns the size of the output computed by OPMINUS operator.
+//
+// Assuming:
+// size(in1) = [in1r,in1c]
+// size(in2) = [in2r,in2c]
+// size(out) = [outr,outc]
+//
+// we have the following combinations:
+// in1 in2 outr outc
+// -----------------------
+// S S in2r in2c
+// S M in2r in2c
+// M S in1r in1c
+// M M in1r in1c
+//
+// Where S means that the input is a scalar
+// and M means that the input is a matrix.
+//
+// Input data:
+// in1size: size of input number 1. It is an array of 2 strings.
+// The first string specifies the number of rows.
+// The second string specifies the number of columns.
+//
+// in2size: size of input number 2. It is an array of 2 strings.
+// The first string specifies the number of rows.
+// The second string specifies the number of columns.
+//
+// Output data:
+// opoutsize: size of output. It is an array of 2 strings.
+// The first string specifies the number of rows.
+// The second string specifies the number of columns.
+//
+// Status:
+// 08-Dec-2007 -- Raffaele Nutricato: Author.
+// 08-Dec-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+opoutsize = FA_SZ_OPPLUSA(in1size,in2size);
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPPLUS.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPPLUS.sci index d93d3d96..d0df4c6c 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPPLUS.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPPLUS.sci @@ -1,50 +1,93 @@ -function opoutsize = FA_SZ_OPPLUS(in1size,in2size,in1type,in2type) -// function opoutsize = FA_SZ_OPPLUS(in1size,in2size,in1type,in2type) -// ----------------------------------------------------------------- -// Status: -// 08-Dec-2007 -- Raffaele Nutricato: Author. -// 08-Dec-2007 -- Alberto Morea: Test Ok. -// -// Copyright 2007 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -// ------------------------------ -// --- Check input arguments. --- -// ------------------------------ -SCI2CNInArgCheck(argn(2),4,4); - -in1size = string(in1size); -in2size = string(in2size); -in1type = string(in1type); -in2type = string(in2type); -in1dim = GetSymbolDimension(in1size); - -if ((in1type ~= 'g') & (in2type ~= 'g')) - opoutsize = FA_SZ_OPPLUSA(in1size,in2size); -elseif ((in1type == 'g') & (in2type == 'g')) - opoutsize(1) = '1'; - if (SCI2Cisnum(in1size(1)) & SCI2Cisnum(in2size(1))) - in1num = eval(in1size(1)); - in2num = eval(in2size(1)); - if (in1num > 1 | in2num > 1) - SCI2Cerror('String catenation can be performed only on strings of 1 x N size not N x 1 size'); - end - end - if (SCI2Cisnum(in1size(2)) & SCI2Cisnum(in2size(2))) - in1num = eval(in1size(2)); - in2num = eval(in2size(2)); - opoutsize(2) = string(in1num+in2num-1); - if isnan(opoutsize(2)) - opoutsize(2) = '__SCI2CNANSIZE'; - else - opoutsize(2) = string(opoutsize(2)); - end - else - opoutsize(2) = string(in1size(2))+'+'+string(in2size(2))+'-1'; - end -else - SCI2Cerror('Unexpected type combination for ""+"" operator (type1,type2): ('+in1type+in2type+').'); -end - -endfunction +function opoutsize = FA_SZ_OPPLUS(in1size,in2size,in1type,in2type)
+// function opoutsize = FA_SZ_OPPLUS(in1size,in2size,in1type,in2type)
+// -----------------------------------------------------------------
+// Returns the size of the output computed by OPPLUS operator,
+// including the string operations.
+//
+// Assuming:
+// size(in1) = [in1r,in1c]
+// size(in2) = [in2r,in2c]
+// size(out) = [outr,outc]
+//
+// we have the following combinations:
+// in1 in2 outr outc
+// -----------------------
+// S S in2r in2c
+// S M in2r in2c
+// M S in1r in1c
+// M M in1r in1c
+//
+// Where S means that the input is a scalar
+// and M means that the input is a matrix.
+// There is also the case related to the string catenation!
+// This is the main difference between - and + operators.
+//
+// Input data:
+// in1size: size of input number 1. It is an array of 2 strings.
+// The first string specifies the number of rows.
+// The second string specifies the number of columns.
+//
+// in2size: size of input number 2. It is an array of 2 strings.
+// The first string specifies the number of rows.
+// The second string specifies the number of columns.
+//
+// Output data:
+// opoutsize: size of output. It is an array of 2 strings.
+// The first string specifies the number of rows.
+// The second string specifies the number of columns.
+//
+// Status:
+// 08-Dec-2007 -- Raffaele Nutricato: Author.
+// 08-Dec-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),4,4);
+
+// ------------------------
+// --- Generate Output. ---
+// ------------------------
+// --- Get dimensions of input arguments. ---
+in1size = string(in1size);
+in2size = string(in2size);
+in1type = string(in1type);
+in2type = string(in2type);
+in1dim = GetSymbolDimension(in1size);
+
+if ((in1type ~= 'g') & (in2type ~= 'g'))
+ opoutsize = FA_SZ_OPPLUSA(in1size,in2size);
+elseif ((in1type == 'g') & (in2type == 'g'))
+ opoutsize(1) = '1';
+ if (SCI2Cisnum(in1size(1)) & SCI2Cisnum(in2size(1)))
+ in1num = eval(in1size(1));
+ in2num = eval(in2size(1));
+ if (in1num > 1 | in2num > 1)
+ SCI2Cerror('String catenation can be performed only on strings of 1 x N size not N x 1 size');
+ //NUT: mi pare che non possano proprio esistere stringe di dimensione Nx1 perche' in
+ //NUT: scilab esiste il tipo string che e' di size 1x1 e sono io a trasformarlo in
+ //NUT: 1xN per cui se uso sempre questa convenzione non sbaglio mai.
+ //NUT: ho provato in scilab a fare la trasposta di una stringa e ottengo sempre 1x1.
+ end
+ end
+ if (SCI2Cisnum(in1size(2)) & SCI2Cisnum(in2size(2)))
+ in1num = eval(in1size(2));
+ in2num = eval(in2size(2));
+ opoutsize(2) = string(in1num+in2num-1);
+ if isnan(opoutsize(2))
+ opoutsize(2) = '__SCI2CNANSIZE';
+ else
+ opoutsize(2) = string(opoutsize(2));
+ end
+ else
+ opoutsize(2) = '('+string(in1size(2))+'+'+string(in2size(2))+'-1)';
+ end
+else
+ SCI2Cerror('Unexpected type combination for ""+"" operator (type1,type2): ('+in1type+in2type+').');
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPPLUSA.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPPLUSA.sci index cdfdcf0a..42ba90d5 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPPLUSA.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPPLUSA.sci @@ -1,28 +1,66 @@ -function opoutsize = FA_SZ_OPPLUSA(in1size,in2size) -// function opoutsize = FA_SZ_OPPLUSA(in1size,in2size) -// ----------------------------------------------------------------- -// -// Status: -// 18-Mar-2008 -- Raffaele Nutricato: Author. -// 18-Mar-2008 -- Alberto Morea: Test Ok. -// -// Copyright 2008 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -// ------------------------------ -// --- Check input arguments. --- -// ------------------------------ -SCI2CNInArgCheck(argn(2),2,2); - -in1size = string(in1size); -in2size = string(in2size); -in1dim = GetSymbolDimension(in1size); - -if (in1dim == 0) - opoutsize = in2size; -else - opoutsize = in1size; -end - -endfunction +function opoutsize = FA_SZ_OPPLUSA(in1size,in2size)
+// function opoutsize = FA_SZ_OPPLUSA(in1size,in2size)
+// -----------------------------------------------------------------
+// Returns the size of the output computed by OPPLUS operator
+// restricted to arithmetic operations (string operations not supported.)
+//
+// Assuming:
+// size(in1) = [in1r,in1c]
+// size(in2) = [in2r,in2c]
+// size(out) = [outr,outc]
+//
+// we have the following combinations:
+// in1 in2 outr outc
+// -----------------------
+// S S in2r in2c
+// S M in2r in2c
+// M S in1r in1c
+// M M in1r in1c
+//
+// Where S means that the input is a scalar
+// and M means that the input is a matrix.
+// There is also the case related to the string catenation!
+// This is the main difference between - and + operators.
+//
+// Input data:
+// in1size: size of input number 1. It is an array of 2 strings.
+// The first string specifies the number of rows.
+// The second string specifies the number of columns.
+//
+// in2size: size of input number 2. It is an array of 2 strings.
+// The first string specifies the number of rows.
+// The second string specifies the number of columns.
+//
+// Output data:
+// opoutsize: size of output. It is an array of 2 strings.
+// The first string specifies the number of rows.
+// The second string specifies the number of columns.
+//
+// Status:
+// 18-Mar-2008 -- Raffaele Nutricato: Author.
+// 18-Mar-2008 -- Alberto Morea: Test Ok.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+// ------------------------
+// --- Generate Output. ---
+// ------------------------
+// --- Get dimensions of input arguments. ---
+in1size = string(in1size);
+in2size = string(in2size);
+in1dim = GetSymbolDimension(in1size);
+
+if (in1dim == 0)
+ opoutsize = in2size;
+else
+ opoutsize = in1size;
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPRC.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPRC.sci index e276f166..2c9f1c18 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPRC.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPRC.sci @@ -1,32 +1,40 @@ -function opoutsize = FA_SZ_OPRC(in1size,in2size) -// function opoutsize = FA_SZ_OPRC(in1size,in2size) -// ----------------------------------------------------------------- -// -// -// Status: -// 08-Mar-2008 -- Raffaele Nutricato: Author. -// 08-Mar-2008 -- Alberto Morea: Test Ok. -// -// Copyright 2008 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),2,2); - -in1size = string(in1size); -in2size = string(in2size); - -in1dim = GetSymbolDimension(in1size); -in2dim = GetSymbolDimension(in2size); - -opoutsize(1) = in1size(1); - -if (SCI2Cisnum(in1size(2)) & SCI2Cisnum(in2size(2))) - in1num = eval(in1size(2)); - in2num = eval(in2size(2)); - opoutsize(2) = string(in1num+in2num); -else - opoutsize(2) = string(in1size(2))+'+'+string(in2size(2)); -end - -endfunction +function opoutsize = FA_SZ_OPRC(in1size,in2size)
+// function opoutsize = FA_SZ_OPRC(in1size,in2size)
+// -----------------------------------------------------------------
+// Returns the size of the output computed by OPRC operator.
+//
+//
+// Status:
+// 08-Mar-2008 -- Raffaele Nutricato: Author.
+// 08-Mar-2008 -- Alberto Morea: Test Ok.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+in1size = string(in1size);
+in2size = string(in2size);
+
+// ------------------------
+// --- Generate Output. ---
+// ------------------------
+// --- Get dimensions of input arguments. ---
+in1dim = GetSymbolDimension(in1size);
+in2dim = GetSymbolDimension(in2size);
+
+opoutsize(1) = in1size(1);
+
+if (SCI2Cisnum(in1size(2)) & SCI2Cisnum(in2size(2)))
+ in1num = eval(in1size(2));
+ in2num = eval(in2size(2));
+ opoutsize(2) = string(in1num+in2num);
+else
+ opoutsize(2) = '('+string(in1size(2))+'+'+string(in2size(2))+')';
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPSLASH.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPSLASH.sci new file mode 100644 index 00000000..78ddecec --- /dev/null +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPSLASH.sci @@ -0,0 +1,45 @@ +function opoutsize = FA_SZ_OPSLASH(in1size,in2size)
+// function opoutsize = FA_SZ_OPSLASH(in1size,in2size)
+// -----------------------------------------------------------------
+// Returns the size of the output computed by OPSLASH operator.
+//
+//
+// Status:
+// 28-May-2008 -- Alberto Morea: Author.
+// 28-May-2008 -- Raffaele Nutricato: Test Ok.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+// ------------------------
+// --- Generate Output. ---
+// ------------------------
+in1size=string(in1size);
+in2size=string(in2size);
+
+// knowing that
+// b/a = (a' \ b')' +
+// a'
+in1sizetmp(1) = in1size(2);
+in1sizetmp(2) = in1size(1);
+
+// b'
+in2sizetmp(1) = in2size(2);
+in2sizetmp(2) = in2size(1);
+
+// a'\b'
+opoutsizetmp = FA_SZ_OPBACKSLASH(in2sizetmp,in1sizetmp);
+
+// (a'\b')'
+opoutsize(1) = opoutsizetmp(2);
+opoutsize(2) = opoutsizetmp(1);
+
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPSTAR.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPSTAR.sci index 7324ee69..12190d38 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPSTAR.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_OPSTAR.sci @@ -1,30 +1,68 @@ -function opoutsize = FA_SZ_OPSTAR(in1size,in2size) -// function opoutsize = FA_SZ_OPSTAR(in1size,in2size) -// ----------------------------------------------------------------- -// -// Status: -// 08-Dec-2007 -- Raffaele Nutricato: Author. -// 08-Dec-2007 -- Alberto Morea: Test Ok. -// -// Copyright 2007 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),2,2); - -in1size = string(in1size); -in2size = string(in2size); - -in1dim = GetSymbolDimension(in1size); -in2dim = GetSymbolDimension(in2size); - -if (in1dim == 0) - opoutsize = in2size; -elseif (in2dim == 0) - opoutsize = in1size; -else - opoutsize(1) = in1size(1); - opoutsize(2) = in2size(2); -end - -endfunction +function opoutsize = FA_SZ_OPSTAR(in1size,in2size)
+// function opoutsize = FA_SZ_OPSTAR(in1size,in2size)
+// -----------------------------------------------------------------
+// Returns the size of the output computed by OPSTAR operator.
+//
+// Assuming:
+// size(in1) = [in1r,in1c]
+// size(in2) = [in2r,in2c]
+// size(out) = [outr,outc]
+//
+// we have the following combinations:
+// in1 in2 outr outc
+// -----------------------
+// S S in2r in2c
+// S M in2r in2c
+// M S in1r in1c
+// M M in1r in2c
+//
+// Where S means that the input is a scalar
+// and M means that the input is a matrix.
+//
+// Input data:
+// in1size: size of input number 1. It is an array of 2 strings.
+// The first string specifies the number of rows.
+// The second string specifies the number of columns.
+//
+// in2size: size of input number 2. It is an array of 2 strings.
+// The first string specifies the number of rows.
+// The second string specifies the number of columns.
+//
+// Output data:
+// opoutsize: size of output. It is an array of 2 strings.
+// The first string specifies the number of rows.
+// The second string specifies the number of columns.
+//
+// Status:
+// 08-Dec-2007 -- Raffaele Nutricato: Author.
+// 08-Dec-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+in1size = string(in1size);
+in2size = string(in2size);
+
+// ------------------------
+// --- Generate Output. ---
+// ------------------------
+// --- Get dimensions of input arguments. ---
+in1dim = GetSymbolDimension(in1size);
+in2dim = GetSymbolDimension(in2size);
+
+if (in1dim == 0)
+ opoutsize = in2size;
+elseif (in2dim == 0)
+ opoutsize = in1size;
+else
+ opoutsize(1) = in1size(1);
+ opoutsize(2) = in2size(2);
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_SEL1.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_SEL1.sci index f2de8943..4f52c536 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_SEL1.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_SEL1.sci @@ -1,29 +1,44 @@ -function opout = FA_SZ_SEL1(in1,in2) -// function opout = FA_SZ_SEL1(in1,in2) -// ----------------------------------------------------------------- -// -// Status: -// 16-Mar-2008 -- Raffaele Nutricato: Author. -// 16-Mar-2008 -- Alberto Morea: Test Ok. -// -// Copyright 2008 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),2,2); -ReportFileName = ''; -in2 = string(in2); - -if (in2 == '1') - opout = '1'; -elseif (in2 == '2') - opout = in1; -else - PrintStringInfo(' ',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: Cannot associate the second input argument to a known specifier.',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: Please rearrange your code by using one of the following specifiers:',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: 1 or 2.',ReportFileName,'both','y'); - PrintStringInfo(' ',ReportFileName,'both','y'); - SCI2Cerror(' '); -end -endfunction +function opout = FA_SZ_SEL1(in1,in2)
+// function opout = FA_SZ_SEL1(in1,in2)
+// -----------------------------------------------------------------
+// Determines the number of rows of the output arguments
+// according to the number of rows of the first input argument and
+// the specifier in2 which can be 1,2 or 'r','c' and 'm'.
+// In this release the 'm' specifier is not supported so when it is
+// used SCI2C will issue an error.
+//
+// Input data:
+// in1: string specifying a number or a symbol.
+// in2: string specifying a number or a symbol.
+//
+// Output data:
+// opout: string containing the computed result.
+//
+// Status:
+// 16-Mar-2008 -- Raffaele Nutricato: Author.
+// 16-Mar-2008 -- Alberto Morea: Test Ok.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+ReportFileName = '';
+in2 = string(in2);
+
+if (in2 == '1')
+ opout = '1';
+elseif (in2 == '2')
+ opout = in1;
+else
+ PrintStringInfo(' ',ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: Cannot associate the second input argument to a known specifier.',ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: Please rearrange your code by using one of the following specifiers:',ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: 1 or 2.',ReportFileName,'both','y');
+ PrintStringInfo(' ',ReportFileName,'both','y');
+ SCI2Cerror(' ');
+end
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_SEL2.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_SEL2.sci index c33bbdb8..ebf74282 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_SEL2.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_SZ_SEL2.sci @@ -1,29 +1,44 @@ -function opout = FA_SZ_SEL2(in1,in2) -// function opout = FA_SZ_SEL2(in1,in2) -// ----------------------------------------------------------------- -// -// Status: -// 16-Mar-2008 -- Raffaele Nutricato: Author. -// 16-Mar-2008 -- Alberto Morea: Test Ok. -// -// Copyright 2008 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),2,2); -ReportFileName = ''; -in2 = string(in2); - -if (in2 == '1') - opout = in1; -elseif (in2 == '2') - opout = '1'; -else - PrintStringInfo(' ',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: Cannot associate the second input argument to a known specifier.',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: Please rearrange your code by using one of the following specifiers:',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: 1 or 2.',ReportFileName,'both','y'); - PrintStringInfo(' ',ReportFileName,'both','y'); - SCI2Cerror(' '); -end -endfunction +function opout = FA_SZ_SEL2(in1,in2)
+// function opout = FA_SZ_SEL2(in1,in2)
+// -----------------------------------------------------------------
+// Determines the number of columns of the output arguments
+// according to the number of columns of the first input argument and
+// the specifier in2 which can be 1,2 or 'r','c' and 'm'.
+// In this release the 'm' specifier is not supported so when it is
+// used SCI2C will issue an error.
+//
+// Input data:
+// in1: string specifying a number or a symbol.
+// in2: string specifying a number or a symbol.
+//
+// Output data:
+// opout: string containing the computed result.
+//
+// Status:
+// 16-Mar-2008 -- Raffaele Nutricato: Author.
+// 16-Mar-2008 -- Alberto Morea: Test Ok.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+ReportFileName = '';
+in2 = string(in2);
+
+if (in2 == '1')
+ opout = in1;
+elseif (in2 == '2')
+ opout = '1';
+else
+ PrintStringInfo(' ',ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: Cannot associate the second input argument to a known specifier.',ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: Please rearrange your code by using one of the following specifiers:',ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: 1 or 2.',ReportFileName,'both','y');
+ PrintStringInfo(' ',ReportFileName,'both','y');
+ SCI2Cerror(' ');
+end
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_C.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_C.sci index ffa797f1..b383b5ac 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_C.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_C.sci @@ -1,21 +1,32 @@ -function typeout = FA_TP_C() -// function typeout = FA_TP_C() -// ----------------------------------------------------------------- -// -// Status: -// 26-Oct-2007 -- Raffaele Nutricato: Author. -// 26-Oct-2007 -- Alberto Morea: Test Ok. -// -// Copyright 2007 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -// ------------------------------ -// --- Check input arguments. --- -// ------------------------------ -SCI2CNInArgCheck(argn(2),0,0); - - -typeout = 'c'; - -endfunction +function typeout = FA_TP_C()
+// function typeout = FA_TP_C()
+// -----------------------------------------------------------------
+// Returns the "single complex" type specifier
+// for Function Annotations.
+//
+// Input data:
+// ---
+//
+// Output data:
+// typeout: string containing the type specifier.
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),0,0);
+
+
+// ------------------------
+// --- Generate Output. ---
+// ------------------------
+typeout = 'c';
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_COMPLEX.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_COMPLEX.sci index be4100d3..bf3f2f9f 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_COMPLEX.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_COMPLEX.sci @@ -1,26 +1,42 @@ -function typeout = FA_TP_COMPLEX(in1) -// function typeout = FA_TP_COMPLEX(in1) -// ----------------------------------------------------------------- -// -// Status: -// 26-Jan-2008 -- Raffaele Nutricato: Author. -// 26-Jan-2008 -- Alberto Morea: Test Ok. -// -// Copyright 2008 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -// ------------------------------ -// --- Check input arguments. --- -// ------------------------------ -SCI2CNInArgCheck(argn(2),1,1); - - -if (in1 == 's') - typeout = 'c'; -elseif (in1 == 'd') - typeout = 'z'; -else - typeout = in1; -end -endfunction +function typeout = FA_TP_COMPLEX(in1)
+// function typeout = FA_TP_COMPLEX(in1)
+// -----------------------------------------------------------------
+// Converts into complex data type the input argument, by preserving
+// the precision of the input argument.
+// See following examples:
+// FA_TP_COMPLEX('s') = 'c'
+// FA_TP_COMPLEX('d') = 'z'
+// FA_TP_COMPLEX('c') = 'c'
+// FA_TP_COMPLEX('z') = 'z'
+//
+// Input data:
+// in1: string specifying the data type number 1.
+//
+// Output data:
+// typeout: string containing the type specifier.
+//
+// Status:
+// 26-Jan-2008 -- Raffaele Nutricato: Author.
+// 26-Jan-2008 -- Alberto Morea: Test Ok.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+
+// ------------------------
+// --- Generate Output. ---
+// ------------------------
+if (in1 == 's')
+ typeout = 'c';
+elseif (in1 == 'd')
+ typeout = 'z';
+else
+ typeout = in1;
+end
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_D.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_D.sci index 37c0bce0..788a03fe 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_D.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_D.sci @@ -1,21 +1,32 @@ -function typeout = FA_TP_D() -// function typeout = FA_TP_D() -// ----------------------------------------------------------------- -// -// Status: -// 26-Oct-2007 -- Raffaele Nutricato: Author. -// 26-Oct-2007 -- Alberto Morea: Test Ok. -// -// Copyright 2007 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -// ------------------------------ -// --- Check input arguments. --- -// ------------------------------ -SCI2CNInArgCheck(argn(2),0,0); - - -typeout = 'd'; - -endfunction +function typeout = FA_TP_D()
+// function typeout = FA_TP_D()
+// -----------------------------------------------------------------
+// Returns the "double" type specifier
+// for Function Annotations.
+//
+// Input data:
+// ---
+//
+// Output data:
+// typeout: string containing the type specifier.
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),0,0);
+
+
+// ------------------------
+// --- Generate Output. ---
+// ------------------------
+typeout = 'd';
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_I.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_I.sci index 5059abb9..94f383f4 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_I.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_I.sci @@ -1,21 +1,32 @@ -function typeout = FA_TP_I() -// function typeout = FA_TP_I() -// ----------------------------------------------------------------- -// -// Status: -// 26-Oct-2007 -- Raffaele Nutricato: Author. -// 26-Oct-2007 -- Alberto Morea: Test Ok. -// -// Copyright 2007 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -// ------------------------------ -// --- Check input arguments. --- -// ------------------------------ -SCI2CNInArgCheck(argn(2),0,0); - - -typeout = 'i'; - -endfunction +function typeout = FA_TP_I()
+// function typeout = FA_TP_I()
+// -----------------------------------------------------------------
+// Returns the "int" type specifier
+// for Function Annotations.
+//
+// Input data:
+// ---
+//
+// Output data:
+// typeout: string containing the type specifier.
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),0,0);
+
+
+// ------------------------
+// --- Generate Output. ---
+// ------------------------
+typeout = 'i';
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_MAX.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_MAX.sci index 6ac51616..0b78f9e3 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_MAX.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_MAX.sci @@ -1,43 +1,45 @@ -function opout = FA_TP_MAX(in1,in2) -// function opout = FA_TP_MAX(in1,in2) -// ----------------------------------------------------------------- -// -// Status: -// 26-Oct-2007 -- Raffaele Nutricato: Author. -// 26-Oct-2007 -- Alberto Morea: Test Ok. -// -// Copyright 2007 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -// ------------------------------ -// --- Check input arguments. --- -// ------------------------------ -SCI2CNInArgCheck(argn(2),1,2); - - -if (argn(2)==1) then -select (in1), - case 's' then opout = 'c' - case 'c' then opout = 'c' - else opout = 'z', -end -end - - -if (argn(2)==2) then -in1Pin2 = in1+in2; -opout = in1; - -if (in2 == 'z') - opout = 'z'; -elseif (in1Pin2 == 'sd') - opout = 'd'; -elseif (in1Pin2 == 'sc') - opout = 'c'; -elseif (in1Pin2 == 'dc') - opout = 'z'; -end -end - -endfunction +function opout = FA_TP_MAX(in1,in2)
+// function opout = FA_TP_MAX(in1,in2)
+// -----------------------------------------------------------------
+// Type-Maximum function for Function Annotations.
+// Returns the maximum between the two data types in input according
+// to a predefined priority. For example z(double complex) is
+// greater that c(single complex).
+//
+// Input data:
+// in1: string specifying the data type number 1.
+// in2: string specifying the data type number 2.
+//
+// Output data:
+// opout: string containing the computed result.
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+// ------------------------
+// --- Generate Output. ---
+// ------------------------
+in1Pin2 = in1+in2;
+opout = in1;
+
+if (in2 == 'z')
+ opout = 'z';
+elseif (in1Pin2 == 'sd')
+ opout = 'd';
+elseif (in1Pin2 == 'sc')
+ opout = 'c';
+elseif (in1Pin2 == 'dc')
+ opout = 'z';
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_MIN_REAL.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_MIN_REAL.sci new file mode 100644 index 00000000..43fc7926 --- /dev/null +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_MIN_REAL.sci @@ -0,0 +1,35 @@ +function opout = FA_TP_MIN_REAL(in1,in2) +// Status: +// 2009 -- Arnaud Torset: Author. +// +// ----------------------------------------------------------------- +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +//SCI2CNInArgCheck(argn(2),2,2); + +in1Pin2 = in1+in2; +opout = in1; + +if (opout == 'c') + opout = 's'; +elseif (opout == 'z') + opout = 'd'; +end + +if (in2 == 'c') + opout = 's'; +elseif (in2 == 's') + opout = 's'; +end + +endfunction diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_REAL.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_REAL.sci index b9c4069a..67a946dc 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_REAL.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_REAL.sci @@ -1,26 +1,38 @@ -function opout = FA_TP_REAL(in1) -// function opout = FA_TP_REAL(in1) -// ----------------------------------------------------------------- -// -// Status: -// 26-Mar-2008 -- Raffaele Nutricato: Author. -// 26-Mar-2008 -- Alberto Morea: Test Ok. -// -// Copyright 2008 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -// ------------------------------ -// --- Check input arguments. --- -// ------------------------------ -SCI2CNInArgCheck(argn(2),1,1); - -opout = in1; - -if (in1 == 'c') - opout = 's'; -elseif (in1 == 'z') - opout = 'd'; -end - -endfunction +function opout = FA_TP_REAL(in1)
+// function opout = FA_TP_REAL(in1)
+// -----------------------------------------------------------------
+// Type-Real function for Function Annotations.
+// Returns the real precision corresponding to the precision of
+// the input operand.
+//
+// Input data:
+// in1: string specifying the data type number 1.
+//
+// Output data:
+// opout: string containing the computed result.
+//
+// Status:
+// 26-Mar-2008 -- Raffaele Nutricato: Author.
+// 26-Mar-2008 -- Alberto Morea: Test Ok.
+//
+// Copyright 2008 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+// ------------------------
+// --- Generate Output. ---
+// ------------------------
+opout = in1;
+
+if (in1 == 'c')
+ opout = 's';
+elseif (in1 == 'z')
+ opout = 'd';
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_S.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_S.sci index 0bbdd03c..3de4c20c 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_S.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_S.sci @@ -1,20 +1,32 @@ -function typeout = FA_TP_S() -// function typeout = FA_TP_S() -// ----------------------------------------------------------------- -// Status: -// 26-Oct-2007 -- Raffaele Nutricato: Author. -// 26-Oct-2007 -- Alberto Morea: Test Ok. -// -// Copyright 2007 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -// ------------------------------ -// --- Check input arguments. --- -// ------------------------------ -SCI2CNInArgCheck(argn(2),0,0); - - -typeout = 's'; - -endfunction +function typeout = FA_TP_S()
+// function typeout = FA_TP_S()
+// -----------------------------------------------------------------
+// Returns the "float" type specifier
+// for Function Annotations.
+//
+// Input data:
+// ---
+//
+// Output data:
+// typeout: string containing the type specifier.
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),0,0);
+
+
+// ------------------------
+// --- Generate Output. ---
+// ------------------------
+typeout = 's';
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_USER.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_USER.sci index 6b295d95..3b306a9f 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_USER.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_USER.sci @@ -1,23 +1,38 @@ -function type_out = FA_TP_USER(PrecisionSpecifier,DefaultType) -// function type_out = FA_TP_USER(PrecisionSpecifier,DefaultType) -// ----------------------------------------------------------------- -// -// Status: -// 26-Oct-2007 -- Raffaele Nutricato: Author. -// 26-Oct-2007 -- Alberto Morea: Test Ok. -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),2,2); - -if (mtlb_strcmp(PrecisionSpecifier,'int')) - type_out = 'i'; -elseif (mtlb_strcmp(PrecisionSpecifier,'float')) - type_out = 's'; -elseif (mtlb_strcmp(PrecisionSpecifier,'double')) - type_out = 'd'; -elseif (mtlb_strcmp(PrecisionSpecifier,'default')) - type_out = DefaultType; -else - SCI2Cerror('Unknown precision function: ""'+AnnotationFnc+'"".'); -end -endfunction +function type_out = FA_TP_USER(PrecisionSpecifier,DefaultType)
+// function type_out = FA_TP_USER(PrecisionSpecifier,DefaultType)
+// -----------------------------------------------------------------
+// Generate the output type of the output argument by using the
+// output (AnnotationFnc) generated by CheckAnnotationFunction.
+// double and float functions can be used to specify the type
+// of the output argument. They are typically used in combination
+// with zeros-like function.
+//
+// Input data:
+// PrecisionSpecifier: it can be 'double' or 'float'.
+//
+// Output data:
+// type_out: specifies the type of the output argument. It can be
+// 's' for float precision or 'd' for double precision.
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+if (mtlb_strcmp(PrecisionSpecifier,'int'))
+ type_out = 'i';
+elseif (mtlb_strcmp(PrecisionSpecifier,'float'))
+ type_out = 's';
+elseif (mtlb_strcmp(PrecisionSpecifier,'double'))
+ type_out = 'd';
+elseif (mtlb_strcmp(PrecisionSpecifier,'default'))
+ type_out = DefaultType;
+else
+ SCI2Cerror('Unknown precision function: ""'+AnnotationFnc+'"".');
+end
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_Z.sci b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_Z.sci index 1c152d8d..2ac18dea 100644 --- a/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_Z.sci +++ b/src/Scilab2C/Scilab2C/FunctionAnnotation/FA_TP_Z.sci @@ -1,24 +1,32 @@ -function typeout = FA_TP_Z() -// function typeout = FA_TP_Z() -// ----------------------------------------------------------------- -// -// Status: -// 26-Oct-2007 -- Raffaele Nutricato: Author. -// 26-Oct-2007 -- Alberto Morea: Test Ok. -// -// Copyright 2007 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -// ------------------------------ -// --- Check input arguments. --- -// ------------------------------ -SCI2CNInArgCheck(argn(2),0,0); - - -// ------------------------ -// --- Generate Output. --- -// ------------------------ -typeout = 'z'; - -endfunction +function typeout = FA_TP_Z()
+// function typeout = FA_TP_Z()
+// -----------------------------------------------------------------
+// Returns the "double complex" type specifier
+// for Function Annotations.
+//
+// Input data:
+// ---
+//
+// Output data:
+// typeout: string containing the type specifier.
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),0,0);
+
+
+// ------------------------
+// --- Generate Output. ---
+// ------------------------
+typeout = 'z';
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionList/FL_ExistCFunction.sci b/src/Scilab2C/Scilab2C/FunctionList/FL_ExistCFunction.sci index 95e61ffa..5b63ec5b 100644 --- a/src/Scilab2C/Scilab2C/FunctionList/FL_ExistCFunction.sci +++ b/src/Scilab2C/Scilab2C/FunctionList/FL_ExistCFunction.sci @@ -1,73 +1,106 @@ -function flagexist = FL_ExistCFunction(CFunName,USER2CAvailableCDat,SCI2CAvailableCDat,ConvertedDat,ToBeConvertedDat,ReportFileName) -// function flagexist = FL_ExistCFunction(CFunName,USER2CAvailableCDat,SCI2CAvailableCDat,ConvertedDat,ToBeConvertedDat,ReportFileName) -// ----------------------------------------------------------------- -// -// Status: -// 30-Oct-2007 -- Raffaele Nutricato: Author. -// 30-Oct-2007 -- Alberto Morea: Test Ok. -// -// Copyright 2007 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),6,6); - -flagexist = %F; - - -AvailableDat = USER2CAvailableCDat; -load(AvailableDat,'Available'); -NAvail = size(Available,1); - -tmpcnt = 1; -while ((tmpcnt <=NAvail) & (flagexist == %F)) - if mtlb_strcmp(Available(tmpcnt),CFunName) - flagexist = %T; - end - tmpcnt = tmpcnt + 1; -end -clear Available - -if (flagexist == %F) - AvailableDat = SCI2CAvailableCDat; - load(AvailableDat,'Available'); - NAvail = size(Available,1); - - tmpcnt = 1; - while ((tmpcnt <=NAvail) & (flagexist == %F)) - if mtlb_strcmp(Available(tmpcnt),CFunName) - flagexist = %T; - end - tmpcnt = tmpcnt + 1; - end - clear Available -end - -if (flagexist == %F) - load(ConvertedDat,'Converted'); - NConv = size(Converted,1); - tmpcnt = 1; - while ((tmpcnt <=NConv) & (flagexist == %F)) - if mtlb_strcmp(Converted(tmpcnt),CFunName) - flagexist = %T; - end - tmpcnt = tmpcnt + 1; - end - clear Converted -end - -if (flagexist == %F) - load(ToBeConvertedDat,'ToBeConverted'); - NToBeConv = size(ToBeConverted,1); - tmpcnt = 1; - while ((tmpcnt <=NToBeConv) & (flagexist == %F)) - if mtlb_strcmp(ToBeConverted(tmpcnt).CFunctionName,CFunName) - flagexist = %T; - end - tmpcnt = tmpcnt + 1; - end - clear ToBeConverted -end - - -endfunction +function flagexist = FL_ExistCFunction(CFunName,USER2CAvailableCDat,SCI2CAvailableCDat,ConvertedDat,ToBeConvertedDat,ReportFileName)
+// function flagexist = FL_ExistCFunction(CFunName,USER2CAvailableCDat,SCI2CAvailableCDat,ConvertedDat,ToBeConvertedDat,ReportFileName)
+// -----------------------------------------------------------------
+// //NUT: add description here
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 30-Oct-2007 -- Raffaele Nutricato: Author.
+// 30-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),6,6);
+
+// -----------------------
+// --- Initialization. ---
+// -----------------------
+flagexist = %F;
+// ---------------------------
+// --- End Initialization. ---
+// ---------------------------
+
+
+AvailableDat = USER2CAvailableCDat;
+load(AvailableDat,'Available');
+NAvail = size(Available,1);
+
+tmpcnt = 1;
+while ((tmpcnt <=NAvail) & (flagexist == %F))
+ if mtlb_strcmp(Available(tmpcnt),CFunName)
+ flagexist = %T;
+ // #RNU_RES_B
+ PrintStringInfo(' Found C Function Name in : '+AvailableDat,ReportFileName,'file','y');
+ // #RNU_RES_E
+ end
+ tmpcnt = tmpcnt + 1;
+end
+clear Available
+
+if (flagexist == %F)
+ AvailableDat = SCI2CAvailableCDat;
+ load(AvailableDat,'Available');
+ NAvail = size(Available,1);
+
+ tmpcnt = 1;
+ while ((tmpcnt <=NAvail) & (flagexist == %F))
+ if mtlb_strcmp(Available(tmpcnt),CFunName)
+ flagexist = %T;
+ // #RNU_RES_B
+ PrintStringInfo(' Found C Function Name in : '+AvailableDat,ReportFileName,'file','y');
+ // #RNU_RES_E
+ end
+ tmpcnt = tmpcnt + 1;
+ end
+ clear Available
+end
+
+if (flagexist == %F)
+ load(ConvertedDat,'Converted');
+ NConv = size(Converted,1);
+ tmpcnt = 1;
+ while ((tmpcnt <=NConv) & (flagexist == %F))
+ if mtlb_strcmp(Converted(tmpcnt),CFunName)
+ flagexist = %T;
+ // #RNU_RES_B
+ PrintStringInfo(' Found C Function Name in : '+ConvertedDat,ReportFileName,'file','y');
+ // #RNU_RES_E
+ end
+ tmpcnt = tmpcnt + 1;
+ end
+ clear Converted
+end
+
+if (flagexist == %F)
+ load(ToBeConvertedDat,'ToBeConverted');
+ NToBeConv = size(ToBeConverted,1);
+ tmpcnt = 1;
+ while ((tmpcnt <=NToBeConv) & (flagexist == %F))
+ if mtlb_strcmp(ToBeConverted(tmpcnt).CFunctionName,CFunName)
+ flagexist = %T;
+ // #RNU_RES_B
+ PrintStringInfo(' Found C Function Name in : '+ToBeConvertedDat,ReportFileName,'file','y');
+ // #RNU_RES_E
+ end
+ tmpcnt = tmpcnt + 1;
+ end
+ clear ToBeConverted
+end
+
+if (flagexist == %F)
+ // #RNU_RES_B
+ PrintStringInfo(' C Function Name not found in the ""Available"" , ""Converted"" and ""ToBeConverted"" function lists.',ReportFileName,'file','y');
+ // #RNU_RES_E
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionList/FL_ExtractFuncList.sci b/src/Scilab2C/Scilab2C/FunctionList/FL_ExtractFuncList.sci index 120dc467..9e951d9c 100644 --- a/src/Scilab2C/Scilab2C/FunctionList/FL_ExtractFuncList.sci +++ b/src/Scilab2C/Scilab2C/FunctionList/FL_ExtractFuncList.sci @@ -1,37 +1,62 @@ -function [CFuncList,NElements] = FL_ExtractFuncList(FunctionDir,ClassDir,SCI2CClassSpecifier,ExtFLCls,ReportFileName) -// function [CFuncList,NElements] = FL_ExtractFuncList(FunctionDir,ClassDir,SCI2CClassSpecifier,ExtFLCls,ReportFileName) -// ----------------------------------------------------------------- -// -// Status: -// 05-Jan-2008 -- Nutricato Raffaele: Author. -// -// Copyright 2008 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - - -SCI2CNInArgCheck(argn(2),5,5); - -tmppwd = pwd(); -cd(FunctionDir); +function [CFuncList,NElements] = FL_ExtractFuncList(FunctionDir,ClassDir,SCI2CClassSpecifier,ExtFLCls,ReportFileName)
+// function [CFuncList,NElements] = FL_ExtractFuncList(FunctionDir,ClassDir,SCI2CClassSpecifier,ExtFLCls,ReportFileName)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// Extracts the list of the C functions available. To do that
+// this function enters in the directories where the .clst and
+// .lst files are stored.
+// #RNU_RES_E
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 05-Jan-2008 -- Nutricato Raffaele: Author.
+//
+// Copyright 2008 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),5,5);
+
+// #RNU_RES_B
+// ---------------------------------------------------------
+// --- Extract the list of files in Functions directory. ---
+// ---------------------------------------------------------
+// #RNU_RES_E
+tmppwd = pwd();
+cd(FunctionDir);
+// funfiles = ls();
funfiles = listfiles(); -cd(tmppwd); -NFunFiles = size(funfiles,1); - -CFuncList = ''; -NElements = 0; - -for cntfun = 1:NFunFiles - FunFileName = fullfile(FunctionDir,funfiles(cntfun)); - ClassName = FL_GetFunctionClass(FunFileName,SCI2CClassSpecifier,ReportFileName); - ClassFileName = fullfile(ClassDir,ClassName); - [tmpfunlist,tmpnelem] = File2StringArray(ClassFileName+ExtFLCls); - [tmppath,tmpfunname,tmpext] = fileparts(FunFileName); - tmpfunlist = FL_InOutArgs2CFunNames(tmpfunname,tmpfunlist,tmpnelem); - for cnttmpfun = 1:tmpnelem - NElements = NElements + 1; - CFuncList(NElements) = tmpfunlist(cnttmpfun); - end -end - -endfunction +cd(tmppwd);
+NFunFiles = size(funfiles,1);
+
+// #RNU_RES_B
+// -----------------------------------------------------------
+// --- Extract the C function list from Classes directory. ---
+// -----------------------------------------------------------
+// #RNU_RES_E
+CFuncList = '';
+NElements = 0;
+
+for cntfun = 1:NFunFiles
+ FunFileName = fullfile(FunctionDir,funfiles(cntfun));
+ ClassName = FL_GetFunctionClass(FunFileName,SCI2CClassSpecifier,ReportFileName);
+ ClassFileName = fullfile(ClassDir,ClassName);
+ [tmpfunlist,tmpnelem] = File2StringArray(ClassFileName+ExtFLCls);
+ [tmppath,tmpfunname,tmpext] = fileparts(FunFileName);
+ tmpfunlist = FL_InOutArgs2CFunNames(tmpfunname,tmpfunlist,tmpnelem);
+ for cnttmpfun = 1:tmpnelem
+ NElements = NElements + 1;
+ CFuncList(NElements) = tmpfunlist(cnttmpfun);
+ end
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionList/FL_GetFunctionClass.sci b/src/Scilab2C/Scilab2C/FunctionList/FL_GetFunctionClass.sci index 1d2185ad..41ec2ea4 100644 --- a/src/Scilab2C/Scilab2C/FunctionList/FL_GetFunctionClass.sci +++ b/src/Scilab2C/Scilab2C/FunctionList/FL_GetFunctionClass.sci @@ -1,6 +1,13 @@ function SCI2CClassName = FL_GetFunctionClass(FunFileName,SCI2CClassSpecifier,ReportFileName)
// function SCI2CClassName = FL_GetFunctionClass(FunFileName,SCI2CClassSpecifier,ReportFileName)
// -----------------------------------------------------------------
+// //NUT: add description here
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
//
// Status:
// 11-Jul-2007 -- Nutricato Raffaele: Author.
@@ -9,8 +16,15 @@ function SCI2CClassName = FL_GetFunctionClass(FunFileName,SCI2CClassSpecifier,Re // Contact: raffaele.nutricato@tiscali.it
// -----------------------------------------------------------------
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
SCI2CNInArgCheck(argn(2),3,3);
+// ---------------------------------------
+// --- Read the class of the function. ---
+// ---------------------------------------
+// --- Open the .sci file (read only). ---
inannfid = SCI2COpenFileRead(FunFileName);
FoundClass = 0;
@@ -19,6 +33,9 @@ if (meof(inannfid) == 0) if (~isempty(check_string))
if (SCI2Cstrncmps1size(SCI2CClassSpecifier,check_string))
SCI2CClassName = part(check_string,length(SCI2CClassSpecifier)+1:length(check_string));
+ // #RNU_RES_B
+ PrintStringInfo(' Function belongs to class: '+SCI2CClassName+'.',ReportFileName,'file','y');
+ // #RNU_RES_E
FoundClass = 1;
else
SCI2CerrorFile('Could not find ""'+SCI2CClassSpecifier+'"" in '+FunFileName+'.',ReportFileName);
@@ -30,5 +47,8 @@ if (FoundClass == 0) SCI2CerrorFile('Could not find ""'+SCI2CClassSpecifier+'"" specifier.',ReportFileName);
end
+// -------------------------------------------
+// --- End read the class of the function. ---
+// -------------------------------------------
endfunction
\ No newline at end of file diff --git a/src/Scilab2C/Scilab2C/FunctionList/FL_InOutArgs2CFunNames.sci b/src/Scilab2C/Scilab2C/FunctionList/FL_InOutArgs2CFunNames.sci index ce106318..9305c48e 100644 --- a/src/Scilab2C/Scilab2C/FunctionList/FL_InOutArgs2CFunNames.sci +++ b/src/Scilab2C/Scilab2C/FunctionList/FL_InOutArgs2CFunNames.sci @@ -1,37 +1,52 @@ -function FunNameCFuncList = FL_InOutArgs2CFunNames(FunctionName,CommaSepCFuncList,CFuncListNElem) -// function FunNameCFuncList = FL_InOutArgs2CFunNames(FunctionName,CommaSepCFuncList,CFuncListNElem) -// ----------------------------------------------------------------- -// -// Status: -// 05-Jan-2008 -- Nutricato Raffaele: Author. -// -// Copyright 2008 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - - -SCI2CNInArgCheck(argn(2),3,3); - - -FunNameCFuncList = ''; -SepChar = ','; -for cntelem = 1:CFuncListNElem - tmptokens = tokens(CommaSepCFuncList(cntelem),SepChar); - if (size(tmptokens,1) == 0) - FunNameCFuncList(cntelem) = FunctionName; - elseif (size(tmptokens,1) == 1) - if part(tmptokens,1:1) == ',' - FunNameCFuncList(cntelem) = FunctionName+tmptokens(2); - else - FunNameCFuncList(cntelem) = tmptokens(1)+FunctionName; - end - elseif (size(tmptokens,1) == 2) - FunNameCFuncList(cntelem) = tmptokens(1)+FunctionName+tmptokens(2); - else - disp('Incorrect format for the function list class.'); - disp('Check the following function list class item: ""'+CommaSepCFuncList(cntelem)+'"".'); - SCI2Cerror(' '); - end -end - -endfunction +function FunNameCFuncList = FL_InOutArgs2CFunNames(FunctionName,CommaSepCFuncList,CFuncListNElem)
+// function FunNameCFuncList = FL_InOutArgs2CFunNames(FunctionName,CommaSepCFuncList,CFuncListNElem)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// Reads a Comma Separated Function List and converts it into the
+// corresponding list of C function. In the Comma Separated
+// Function List only input and output arguments are specified
+// and they are separated by a comma.
+// #RNU_RES_E
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 05-Jan-2008 -- Nutricato Raffaele: Author.
+//
+// Copyright 2008 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),3,3);
+
+
+FunNameCFuncList = '';
+SepChar = ',';
+for cntelem = 1:CFuncListNElem
+ tmptokens = tokens(CommaSepCFuncList(cntelem),SepChar);
+ if (size(tmptokens,1) == 0)
+ FunNameCFuncList(cntelem) = FunctionName;
+ elseif (size(tmptokens,1) == 1)
+ if part(tmptokens,1:1) == ','
+ FunNameCFuncList(cntelem) = FunctionName+tmptokens(2);
+ else
+ FunNameCFuncList(cntelem) = tmptokens(1)+FunctionName;
+ end
+ elseif (size(tmptokens,1) == 2)
+ FunNameCFuncList(cntelem) = tmptokens(1)+FunctionName+tmptokens(2);
+ else
+ disp('Incorrect format for the function list class.');
+ disp('Check the following function list class item: ""'+CommaSepCFuncList(cntelem)+'"".');
+ SCI2Cerror(' ');
+ end
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionList/FL_UpdateConverted.sci b/src/Scilab2C/Scilab2C/FunctionList/FL_UpdateConverted.sci index b5d36d44..5f4637e8 100644 --- a/src/Scilab2C/Scilab2C/FunctionList/FL_UpdateConverted.sci +++ b/src/Scilab2C/Scilab2C/FunctionList/FL_UpdateConverted.sci @@ -1,21 +1,46 @@ -function Converted = FL_UpdateConverted(NFilesToTranslate,ConvertedDatFile) -// function Converted = FL_UpdateConverted(NFilesToTranslate,ConvertedDatFile) -// ----------------------------------------------------------------- -// -// Status: -// 27-Oct-2007 -- Raffaele Nutricato: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),2,2); - -load(ConvertedDatFile,'Converted'); - -if (NFilesToTranslate >= 1) - NConvP1 = size(Converted,1)+1; - Converted(NConvP1) = SharedInfo.NextCFunName; -end - -endfunction +function Converted = FL_UpdateConverted(NFilesToTranslate,ConvertedDatFile)
+// function Converted = FL_UpdateConverted(NFilesToTranslate,ConvertedDatFile)
+// -----------------------------------------------------------------
+// //NUT: add description here
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 27-Oct-2007 -- Raffaele Nutricato: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+// -----------------------
+// --- Initialization. ---
+// -----------------------
+// --- Load Converted .dat file. ---
+load(ConvertedDatFile,'Converted');
+// ---------------------------
+// --- End Initialization. ---
+// ---------------------------
+
+
+if (NFilesToTranslate >= 1)
+ // ---------------------------------------
+ // --- Update Converted Function List. ---
+ // ---------------------------------------
+ // --- Insert the current function into the converted function list. ---
+ NConvP1 = size(Converted,1)+1;
+ Converted(NConvP1) = SharedInfo.NextCFunName;
+ // -------------------------------------------
+ // --- End Update Converted Function List. ---
+ // -------------------------------------------
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/FunctionList/FL_UpdateToBeConv.sci b/src/Scilab2C/Scilab2C/FunctionList/FL_UpdateToBeConv.sci index 52f9cc7f..456467da 100644 --- a/src/Scilab2C/Scilab2C/FunctionList/FL_UpdateToBeConv.sci +++ b/src/Scilab2C/Scilab2C/FunctionList/FL_UpdateToBeConv.sci @@ -1,55 +1,114 @@ -function SharedInfo = FL_UpdateToBeConv(ASTFunName,CFunName,FunPrecSpecifier,FunTypeAnnot,FunSizeAnnot,InArg,NInArg,OutArg,NOutArg,FileInfo,SharedInfo) -// function SharedInfo = FL_UpdateToBeConv(ASTFunName,CFunName,FunPrecSpecifier,FunTypeAnnot,FunSizeAnnot,InArg,NInArg,OutArg,NOutArg,FileInfo,SharedInfo) -// ----------------------------------------------------------------- -// -// Status: -// 27-Oct-2007 -- Raffaele Nutricato: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),11,11); - -nxtscifunname = SharedInfo.NextSCIFunName; -nxtscifunnumber = SharedInfo.NextSCIFunNumber; - -ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; -SCI2CAvailableCDat = FileInfo.FunctionList.SCI2CAvailableCDat; -USER2CAvailableCDat = FileInfo.FunctionList.USER2CAvailableCDat; -ConvertedDat = FileInfo.FunctionList.ConvertedDat; -ToBeConvertedDat = FileInfo.FunctionList.ToBeConvertedDat; -FunInfoDatDir = FileInfo.FunctionList.FunInfoDatDir; - - -if (SharedInfo.SkipNextFun > 0) - PrintStringInfo(' Current function will not be inserted in the Function List.',ReportFileName,'file','y'); - return; -end - -if ((sum(mtlb_strcmp(ASTFunName,SharedInfo.Annotations.DataPrec)) > 0) & ... - (SharedInfo.SkipNextPrec == 1)) - return; -end - -if ((mtlb_strcmp(ASTFunName,'OpEqual')) & ... - (SharedInfo.SkipNextEqual == 1)) - return; -end - -flagexist = FL_ExistCFunction(CFunName,USER2CAvailableCDat,SCI2CAvailableCDat,ConvertedDat,ToBeConvertedDat,ReportFileName); - -if (flagexist == %F) - - load(ToBeConvertedDat,'ToBeConverted'); - - NToConvP1 = size(ToBeConverted,1)+1; - ToBeConverted(NToConvP1).SCIFunctionName = ASTFunName; - ToBeConverted(NToConvP1).CFunctionName = CFunName; - - save(ToBeConvertedDat,ToBeConverted); - SharedInfo.NFilesToTranslate = SharedInfo.NFilesToTranslate + 1; - -end - -endfunction +function SharedInfo = FL_UpdateToBeConv(ASTFunName,CFunName,FunPrecSpecifier,FunTypeAnnot,FunSizeAnnot,InArg,NInArg,OutArg,NOutArg,FileInfo,SharedInfo)
+// function SharedInfo = FL_UpdateToBeConv(ASTFunName,CFunName,FunPrecSpecifier,FunTypeAnnot,FunSizeAnnot,InArg,NInArg,OutArg,NOutArg,FileInfo,SharedInfo)
+// -----------------------------------------------------------------
+// //NUT: add description here
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 27-Oct-2007 -- Raffaele Nutricato: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),11,11);
+
+// -----------------------
+// --- Initialization. ---
+// -----------------------
+nxtscifunname = SharedInfo.NextSCIFunName;
+nxtscifunnumber = SharedInfo.NextSCIFunNumber;
+
+ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName;
+SCI2CAvailableCDat = FileInfo.FunctionList.SCI2CAvailableCDat;
+USER2CAvailableCDat = FileInfo.FunctionList.USER2CAvailableCDat;
+ConvertedDat = FileInfo.FunctionList.ConvertedDat;
+ToBeConvertedDat = FileInfo.FunctionList.ToBeConvertedDat;
+FunInfoDatDir = FileInfo.FunctionList.FunInfoDatDir;
+
+// #RNU_RES_B
+PrintStringInfo(' ',ReportFileName,'file','y');
+PrintStringInfo('***Updating C Function List***',ReportFileName,'file','y');
+PrintStringInfo(' C Function Name: '+CFunName,ReportFileName,'file','y');
+// #RNU_RES_E
+// ---------------------------
+// --- End Initialization. ---
+// ---------------------------
+
+// #RNU_RES_B
+// --------------------------------------------------
+// --- Manage anticipated exit from the function. ---
+// --------------------------------------------------
+//NUT: questo codice e' identico quasi a quello della CFunCall, si pu0 pensare di
+//NUT: di fare un'unica funzione.
+// #RNU_RES_E
+
+if (SharedInfo.SkipNextFun > 0)
+ // #RNU_RES_B
+ PrintStringInfo(' Current function will not be inserted in the Function List.',ReportFileName,'file','y');
+ // #RNU_RES_E
+ return;
+end
+
+// #RNU_RES_B
+// Exit if the function is a precision specifier and the corresponding flag is 1.
+// #RNU_RES_E
+if ((sum(mtlb_strcmp(ASTFunName,SharedInfo.Annotations.DataPrec)) > 0) & ...
+ (SharedInfo.SkipNextPrec == 1))
+ // #RNU_RES_B
+ PrintStringInfo(' Current function will not be inserted in the Function List.',ReportFileName,'file','y');
+ // #RNU_RES_E
+ return;
+end
+
+// #RNU_RES_B
+// Exit if the function is OpEqual and the corresponding skip flag is enabled.
+// #RNU_RES_E
+if ((mtlb_strcmp(ASTFunName,'OpEqual')) & ...
+ (SharedInfo.SkipNextEqual == 1))
+ // #RNU_RES_B
+ PrintStringInfo(' Current function will not be inserted in the Function List.',ReportFileName,'file','y');
+ // #RNU_RES_E
+ return;
+end
+
+// #RNU_RES_B
+// ---------------------------------------
+// --- If the function is not skipped. ---
+// ---------------------------------------
+// --- Check existence of the C function. ---
+// #RNU_RES_E
+flagexist = FL_ExistCFunction(CFunName,USER2CAvailableCDat,SCI2CAvailableCDat,ConvertedDat,ToBeConvertedDat,ReportFileName);
+
+// #RNU_RES_B
+// --- Update C function list and dat files. ---
+// #RNU_RES_E
+if (flagexist == %F)
+
+ // #RNU_RES_B
+ // --- 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);
+ SharedInfo.NFilesToTranslate = SharedInfo.NFilesToTranslate + 1;
+
+ // #RNU_RES_B
+ // --- Generate C Function dat file. ---
+ PrintStringInfo(' Add C Function ""'+CFunName+'"" to: '+ToBeConvertedDat,ReportFileName,'file','y');
+ // #RNU_RES_E
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/Array2String.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/Array2String.sci index 0430b0d7..27e9aa15 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/Array2String.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/Array2String.sci @@ -1,26 +1,40 @@ -function [StringArray] = Array2String(InArray); -// function [StringArray] = Array2String(InArray); -// ----------------------------------------------------------------- -// -// Status: -// 13-May-2007 -- Nutricato Raffaele: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- +function [StringArray] = Array2String(InArray);
+// function [StringArray] = Array2String(InArray);
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// Converts an input array into a string. Maximum 2D array are allowed.
+// Ex.: InArray = [10, 4];
+// StringArray = "[10, 4]";
+// #RNU_RES_E
+//
+// Input data:
+// InArray: Input array.
+//
+// Output data:
+// StringArray: array converted into a string.
+//
+// Status:
+// 13-May-2007 -- Nutricato Raffaele: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
-SCI2CNInArgCheck(argn(2),1,1); - -[Nrows,Ncols] = size(InArray); - -StringArray = '['; -for counterrows = 1:Nrows - for countercols = 1:Ncols - StringArray = StringArray + string(InArray(counterrows,countercols)) + ','; - end - StringArray = part(StringArray,1:(length(StringArray)-1)); // Remove the last ',' - StringArray = StringArray+';'; -end -StringArray = part(StringArray,1:(length(StringArray)-1)); // Remove the last ';' -StringArray = StringArray+']'; -endfunction +// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+[Nrows,Ncols] = size(InArray);
+
+StringArray = '[';
+for counterrows = 1:Nrows
+ for countercols = 1:Ncols
+ StringArray = StringArray + string(InArray(counterrows,countercols)) + ',';
+ end
+ StringArray = part(StringArray,1:(length(StringArray)-1)); // Remove the last ','
+ StringArray = StringArray+';';
+end
+StringArray = part(StringArray,1:(length(StringArray)-1)); // Remove the last ';'
+StringArray = StringArray+']';
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/ConvertPathMat2C.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/ConvertPathMat2C.sci index 9ba7152d..d73d22c7 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/ConvertPathMat2C.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/ConvertPathMat2C.sci @@ -1,48 +1,61 @@ -function OutPath = ConvertPathMat2C(InPath,CPathStyle) -// function OutPath = ConvertPathMat2C(InPath,CPathStyle) -// ----------------------------------------------------------------- -// -// Status: -// 26-Jan-2008 -- Nutricato Raffaele: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),2,2); -if (CPathStyle == 'windows') - OutPath=strsubst(InPath,'/','\'); -elseif (CPathStyle == 'unix') - OutPath=strsubst(InPath,'\','/'); -elseif (CPathStyle == 'cygwin') - OutPath=strsubst(InPath,'\','/'); - OutPath=strsubst(OutPath,'A:','/cygdrive/a'); - OutPath=strsubst(OutPath,'B:','/cygdrive/b'); - OutPath=strsubst(OutPath,'C:','/cygdrive/c'); - OutPath=strsubst(OutPath,'D:','/cygdrive/d'); - OutPath=strsubst(OutPath,'E:','/cygdrive/e'); - OutPath=strsubst(OutPath,'F:','/cygdrive/f'); - OutPath=strsubst(OutPath,'G:','/cygdrive/g'); - OutPath=strsubst(OutPath,'H:','/cygdrive/h'); - OutPath=strsubst(OutPath,'I:','/cygdrive/i'); - OutPath=strsubst(OutPath,'J:','/cygdrive/j'); - OutPath=strsubst(OutPath,'K:','/cygdrive/k'); - OutPath=strsubst(OutPath,'L:','/cygdrive/l'); - OutPath=strsubst(OutPath,'M:','/cygdrive/m'); - OutPath=strsubst(OutPath,'N:','/cygdrive/n'); - OutPath=strsubst(OutPath,'O:','/cygdrive/o'); - OutPath=strsubst(OutPath,'P:','/cygdrive/p'); - OutPath=strsubst(OutPath,'Q:','/cygdrive/q'); - OutPath=strsubst(OutPath,'R:','/cygdrive/r'); - OutPath=strsubst(OutPath,'S:','/cygdrive/s'); - OutPath=strsubst(OutPath,'T:','/cygdrive/t'); - OutPath=strsubst(OutPath,'U:','/cygdrive/u'); - OutPath=strsubst(OutPath,'V:','/cygdrive/v'); - OutPath=strsubst(OutPath,'W:','/cygdrive/w'); - OutPath=strsubst(OutPath,'X:','/cygdrive/x'); - OutPath=strsubst(OutPath,'Y:','/cygdrive/y'); - OutPath=strsubst(OutPath,'Z:','/cygdrive/z'); -else - OutPath = InPath; -end -endfunction +function OutPath = ConvertPathMat2C(InPath,CPathStyle)
+// function OutPath = ConvertPathMat2C(InPath,CPathStyle)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// Converts the input path InPath into a path by using the path
+// style specified by CPathStyle.
+// #RNU_RES_E
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 26-Jan-2008 -- Nutricato Raffaele: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+if (CPathStyle == 'windows')
+ OutPath=strsubst(InPath,'/','\');
+elseif (CPathStyle == 'unix')
+ OutPath=strsubst(InPath,'\','/');
+elseif (CPathStyle == 'cygwin')
+ OutPath=strsubst(InPath,'\','/');
+ OutPath=strsubst(OutPath,'A:','/cygdrive/a');
+ OutPath=strsubst(OutPath,'B:','/cygdrive/b');
+ OutPath=strsubst(OutPath,'C:','/cygdrive/c');
+ OutPath=strsubst(OutPath,'D:','/cygdrive/d');
+ OutPath=strsubst(OutPath,'E:','/cygdrive/e');
+ OutPath=strsubst(OutPath,'F:','/cygdrive/f');
+ OutPath=strsubst(OutPath,'G:','/cygdrive/g');
+ OutPath=strsubst(OutPath,'H:','/cygdrive/h');
+ OutPath=strsubst(OutPath,'I:','/cygdrive/i');
+ OutPath=strsubst(OutPath,'J:','/cygdrive/j');
+ OutPath=strsubst(OutPath,'K:','/cygdrive/k');
+ OutPath=strsubst(OutPath,'L:','/cygdrive/l');
+ OutPath=strsubst(OutPath,'M:','/cygdrive/m');
+ OutPath=strsubst(OutPath,'N:','/cygdrive/n');
+ OutPath=strsubst(OutPath,'O:','/cygdrive/o');
+ OutPath=strsubst(OutPath,'P:','/cygdrive/p');
+ OutPath=strsubst(OutPath,'Q:','/cygdrive/q');
+ OutPath=strsubst(OutPath,'R:','/cygdrive/r');
+ OutPath=strsubst(OutPath,'S:','/cygdrive/s');
+ OutPath=strsubst(OutPath,'T:','/cygdrive/t');
+ OutPath=strsubst(OutPath,'U:','/cygdrive/u');
+ OutPath=strsubst(OutPath,'V:','/cygdrive/v');
+ OutPath=strsubst(OutPath,'W:','/cygdrive/w');
+ OutPath=strsubst(OutPath,'X:','/cygdrive/x');
+ OutPath=strsubst(OutPath,'Y:','/cygdrive/y');
+ OutPath=strsubst(OutPath,'Z:','/cygdrive/z');
+else
+ OutPath = InPath;
+end
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/File2StringArray.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/File2StringArray.sci index 377cca6f..626cb6ce 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/File2StringArray.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/File2StringArray.sci @@ -1,27 +1,54 @@ -function [String_Array,N_Strings] = File2StringArray(InFileName) -// function [String_Array,N_Strings] = File2StringArray(InFileName) -// ----------------------------------------------------------------- -// -// Status: -// 10-Nov-2007 -- Raffaele Nutricato: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- +function [String_Array,N_Strings] = File2StringArray(InFileName)
+// function [String_Array,N_Strings] = File2StringArray(InFileName)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// Reads a text file and stores every line into a string array.
+// #RNU_RES_E
+//
+// Input data:
+// InFileName: path+filename of the input file.
+//
+// Output data:
+// String_Array: array of strings containing the lines of the input
+// text file.
+// N_Strings: number of strings stored in String_Array.
+//
+// Status:
+// 10-Nov-2007 -- Raffaele Nutricato: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
-SCI2CNInArgCheck(argn(2),1,1); - - -N_Strings = 0; -String_Array = ''; -fidfile = SCI2COpenFileRead(InFileName); - -tmpline = mgetl(fidfile,1); -while (meof(fidfile) == 0) - N_Strings = N_Strings + 1; - String_Array(N_Strings) = tmpline; - tmpline = mgetl(fidfile,1); -end - -mclose(fidfile); -endfunction +// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+
+// -----------------------
+// --- Initialization. ---
+// -----------------------
+N_Strings = 0;
+String_Array = '';
+// ---------------------------
+// --- End Initialization. ---
+// ---------------------------
+
+// --------------------
+// --- Open C file. ---
+// --------------------
+fidfile = SCI2COpenFileRead(InFileName);
+
+// -------------------
+// --- Read lines. ---
+// -------------------
+tmpline = mgetl(fidfile,1);
+while (meof(fidfile) == 0)
+ N_Strings = N_Strings + 1;
+ String_Array(N_Strings) = tmpline;
+ tmpline = mgetl(fidfile,1);
+end
+
+mclose(fidfile);
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/FunName2SciFileName.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/FunName2SciFileName.sci index 51e241d4..8c473001 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/FunName2SciFileName.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/FunName2SciFileName.sci @@ -1,37 +1,56 @@ -function ScilabFileName = FunName2SciFileName(DirList,InFunName); -// function ScilabFileName = FunName2SciFileName(DirList,InFunName); -// ----------------------------------------------------------------- -// Status: -// 16-Apr-2007 -- Nutricato Raffaele: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),2,2); - -if (prod(size(DirList)) == 0) - SCI2Cerror('Incorrect DirList parameter.'); -end - -if (prod(size(InFunName)) == 0) - SCI2Cerror('Incorrect InFunName parameter.'); -end - -for tmpcounter = 1:max(size(DirList)) - PathList(tmpcounter) = fullfile(DirList(tmpcounter),(InFunName+'.sci')); -end - -ScilabFileName = listfiles(PathList); - -if ((prod(size(ScilabFileName))) > 1) - disp(ScilabFileName); - SCI2Cerror('Found more than one scilab file.'); -end - -if ((prod(size(ScilabFileName))) < 1) - disp(ScilabFileName); - SCI2Cerror('Scilab file ""'+InFunName+'.sci"", not found'); -end - -endfunction +function ScilabFileName = FunName2SciFileName(DirList,InFunName);
+// function ScilabFileName = FunName2SciFileName(DirList,InFunName);
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// This function generates the full path of the scilab file
+// related to the function name (InFunName) specified.
+// In more detail the file "eval(InFunName).sci" file is searched
+// in the directories specified in DirList.
+// #RNU_RES_E
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 16-Apr-2007 -- Nutricato Raffaele: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+ +// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+if (prod(size(DirList)) == 0)
+ SCI2Cerror('Incorrect DirList parameter.');
+end
+
+if (prod(size(InFunName)) == 0)
+ SCI2Cerror('Incorrect InFunName parameter.');
+end
+
+// --- Generate the PathList. ---
+for tmpcounter = 1:max(size(DirList))
+ PathList(tmpcounter) = fullfile(DirList(tmpcounter),(InFunName+'.sci'));
+end
+
+// --- Search the .sci file. ---
+ScilabFileName = listfiles(PathList);
+
+// --- Check on the number of .sci files found. ---
+if ((prod(size(ScilabFileName))) > 1)
+ disp(ScilabFileName);
+ SCI2Cerror('Found more than one scilab file.');
+end
+
+if ((prod(size(ScilabFileName))) < 1)
+ disp(ScilabFileName);
+ SCI2Cerror('Scilab file ""'+InFunName+'.sci"", not found');
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/IsNanSize.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/IsNanSize.sci index 5e726060..486f6fcc 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/IsNanSize.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/IsNanSize.sci @@ -1,22 +1,39 @@ -function outbool = IsNanSize(instring) -// function outbool = IsNanSize(instring) -// ----------------------------------------------------------------- -// -// Status: -// 11-Feb-2008 -- Nutricato Raffaele: Author. -// -// Copyright 2008 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),1,1); - - -outbool = %F; -indexval = strindex(instring,'__SCI2CNANSIZE'); - -if(length(indexval)>=1) - outbool = %T; -end - -endfunction +function outbool = IsNanSize(instring)
+// function outbool = IsNanSize(instring)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// It searches for __SCI2CNANSIZE string in the string which specifies the
+// size of the argument. Useful to find if a given size contains
+// a nan value. In this case an error is issued.
+// IsNanSize = '__SCI2CNANSIZE' -> True
+// IsNanSize = 'c*__SCI2CNANSIZE' -> True
+// IsNanSize = 'c+b' -> False
+// #RNU_RES_E
+//
+// Input data:
+// instring: string to analyze.
+//
+// Output data:
+// outbool: %T if nan string has been found.
+//
+// Status:
+// 11-Feb-2008 -- Nutricato Raffaele: Author.
+//
+// Copyright 2008 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+
+outbool = %F;
+indexval = strindex(instring,'__SCI2CNANSIZE');
+
+if(length(indexval)>=1)
+ outbool = %T;
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/KeyStr2FileStrPos.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/KeyStr2FileStrPos.sci index 01eb212e..e9fb1c48 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/KeyStr2FileStrPos.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/KeyStr2FileStrPos.sci @@ -1,58 +1,83 @@ -function [flag_found,requested_line,line_position] = KeyStr2FileStrPos(filename,key_string,method) -// function [flag_found,requested_line,line_position] = KeyStr2FileStrPos(filename,key_string,method) -// -------------------------------------------------------------------------------- -// -// -// Status: -// 08-Jul-2002 -- Author: Raffaele Nutricato -// 08-Jul-2002 -- Raffaele Nutricato: Revision OK -// 23-Nov-2004 -- Raffaele Nutricato: Changed disp to warning in if (flag_found == 0). -// It allows to disable the message it generates -// by using warning off. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- +function [flag_found,requested_line,line_position] = KeyStr2FileStrPos(filename,key_string,method)
+// function [flag_found,requested_line,line_position] = KeyStr2FileStrPos(filename,key_string,method)
+// --------------------------------------------------------------------------------
+// #RNU_RES_B
+// This function returns a line and its position from a specified ASCII file.
+// The line and the position returned starts with a key string specified in the
+// input parameters.
+//
+// Input data:
+// filename: path + name of the ASCII file.
+// key_string: string that specifies the initial portion of the line to return.
+// method: 'cut': in the returned line will be removed the key_string
+// 'no_cut': (default), in the returned line will not be removed the key_string
+//
+// Output data:
+// flag_found: 0 if the line is not found or an error occured.
+// 1 if the search succeed.
+// requested_line: is the line in the file which contains as first characters those
+// specified in the key_string.
+// line_position: position of the line in the file; the first line in the file
+// is the line number 1.
+// #RNU_RES_E
+//
+//
+// Status:
+// 08-Jul-2002 -- Author: Raffaele Nutricato
+// 08-Jul-2002 -- Raffaele Nutricato: Revision OK
+// 23-Nov-2004 -- Raffaele Nutricato: Changed disp to warning in if (flag_found == 0).
+// It allows to disable the message it generates
+// by using warning off.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
-SCI2CNInArgCheck(argn(2),2,3); - - -if (argn(2) == 2) - method = 'no_cut'; -end -method = convstr(method, 'u'); - -flag_found = 0; -requested_line = ''; -line_position = 0; - -[fid,mess] = mopen(filename,'r'); -if ( fid == -1 ) - disp(['Cannot open: '+filename]) - disp(mess); - flag_found = 0; - return; -end - -num_chars = length(key_string); -while (meof(fid) == 0) - check_string = fgetl(fid); - line_position = line_position + 1; - if (key_string == check_string) & (key_string == num_chars) then - flag_found = 1; - requested_line = check_string; - if (method =='cut') then - requested_line(1:num_chars) = []; - end - mclose(fid); - return; - end -end - -if (flag_found == 0) - warning('Warning: string ' + key_string + ' not found in file: ' + filename); - mclose(fid); -end - -mclose(fid); -endfunction +// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,3);
+
+
+if (argn(2) == 2)
+ method = 'no_cut';
+end
+method = convstr(method, 'u');
+
+// Initialize output parameters
+flag_found = 0;
+requested_line = '';
+line_position = 0;
+
+// Open the text file (read only)
+[fid,mess] = mopen(filename,'r');
+if ( fid == -1 )
+ disp(['Cannot open: '+filename])
+ disp(mess);
+ flag_found = 0;
+ return;
+end
+
+// loop on the lines of the file
+num_chars = length(key_string);
+while (meof(fid) == 0)
+ check_string = fgetl(fid);
+ line_position = line_position + 1;
+ if (key_string == check_string) & (key_string == num_chars) then
+ flag_found = 1;
+ requested_line = check_string;
+ if (method =='cut') then
+ requested_line(1:num_chars) = [];
+ end
+ mclose(fid);
+ return;
+ end
+end
+
+if (flag_found == 0)
+ warning('Warning: string ' + key_string + ' not found in file: ' + filename);
+ mclose(fid);
+end
+
+mclose(fid);
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/PrintStepInfo.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/PrintStepInfo.sci index 1c9d2a45..f4a17926 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/PrintStepInfo.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/PrintStepInfo.sci @@ -1,54 +1,67 @@ -function PrintStepInfo(inputstring,filename,outputtype) -// function PrintStepInfo(inputstring,filename,outputtype) -// ----------------------------------------------------------------- -// Output data: -// -// Status: -// 02-Jan-2006 -- Nutricato Raffaele: Author. -// 02-Jan-2006 -- Nutricato Raffaele: TEST OK. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- +function PrintStepInfo(inputstring,filename,outputtype)
+// function PrintStepInfo(inputstring,filename,outputtype)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// Prints a string by using a predefined format into a file or on
+// the stdout.
+//
+// Input data:
+// filename: optional parameter, that specifies the output file.
+// If filename is '' or it is not provided to the function,
+// the string will be printed on the stdout.
+// outputtype: 'file' -> prints only on file.
+// 'stdout' -> prints only on the stdout.
+// 'both' -> prints on both file and stdoud.
+// Default is 'stdout'.
+// Output data:
+//
+// #RNU_RES_E
+// Status:
+// 02-Jan-2006 -- Nutricato Raffaele: Author.
+// 02-Jan-2006 -- Nutricato Raffaele: TEST OK.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
-// ------------------------------ -// --- Check input arguments. --- -// ------------------------------ -SCI2CNInArgCheck(argn(2),1,3); - - -if argn(2) < 3 - bothout = 'n'; - if argn(2) < 2 - filename = ''; - end -end -if (length(filename) == 0) - outputtype = 'stdout'; // Prints only on the stdout. -end - -Nstars = length(inputstring); -starstring = []; -for counterstars = 1:Nstars - starstring = starstring+'*'; -end -blankstring = [' ']; - -if ((outputtype=='both') | (outputtype=='stdout')) - // disp(' ') - // disp(' ') - disp(blankstring+' '+starstring); - disp(blankstring+'==> '+inputstring); - disp(blankstring+' '+starstring); - // disp(' ') -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',' '); -end -endfunction +// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,3);
+
+
+if argn(2) < 3
+ bothout = 'n';
+ if argn(2) < 2
+ filename = '';
+ end
+end
+if (length(filename) == 0)
+ outputtype = 'stdout'; // Prints only on the stdout.
+end
+
+Nstars = length(inputstring);
+starstring = [];
+for counterstars = 1:Nstars
+ starstring = starstring+'*';
+end
+blankstring = [' '];
+
+if ((outputtype=='both') | (outputtype=='stdout'))
+ // disp(' ')
+ // disp(' ')
+ disp(blankstring+' '+starstring);
+ disp(blankstring+'==> '+inputstring);
+ disp(blankstring+' '+starstring);
+ // disp(' ')
+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',' ');
+end
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/PrintStringInfo.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/PrintStringInfo.sci index 3c3dcce9..6fd4ec20 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/PrintStringInfo.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/PrintStringInfo.sci @@ -1,45 +1,65 @@ -function PrintStringInfo(str, filename, outputtype, ennewline) -// function PrintStringInfo(str,filename,outputtype,ennewline) -// ----------------------------------------------------------------- -// -// Status: -// 02-Jan-2006 -- Nutricato Raffaele: Author. -// 02-Jan-2006 -- Nutricato Raffaele: TEST OK. -// 02-May-2006 -- Nutricato Raffaele: Added ennewline. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- +function PrintStringInfo(str, filename, outputtype, ennewline)
+// function PrintStringInfo(str,filename,outputtype,ennewline)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// Prints a string into a file or on the stdout or on both.
+//
+// Input data:
+// filename: optional parameter, that specifies the output file.
+// If filename is '' or it is not provided to the function,
+// the string will be printed on the stdout.
+// outputtype: 'file' -> prints only on file.
+// 'stdout' -> prints only on the stdout.
+// 'both' -> prints on both file and stdout.
+// Default is 'stdout'.
+// ennewline: optional (default = 'y'); If y adds a newline character
+// at the end of the input string.
+//
+// Output data:
+// ---
+// #RNU_RES_E
+//
+// Status:
+// 02-Jan-2006 -- Nutricato Raffaele: Author.
+// 02-Jan-2006 -- Nutricato Raffaele: TEST OK.
+// 02-May-2006 -- Nutricato Raffaele: Added ennewline.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
-SCI2CNInArgCheck(argn(2),0,4); - - if argn(2) < 4 - ennewline = 'y'; - if argn(2) < 3 - outputtype = 'stdout'; - if argn(2) < 2 - filename = ''; - if argn(2) < 1 - str = ''; - end - end - end - 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=='file') - if (ennewline=='y') - filenamefprintf(filename,'y',str); - else - filenamefprintf(filename,'n',str); - end - end - -endfunction +// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),0,4);
+
+ if argn(2) < 4
+ ennewline = 'y';
+ if argn(2) < 3
+ outputtype = 'stdout';
+ if argn(2) < 2
+ filename = '';
+ if argn(2) < 1
+ str = '';
+ end
+ end
+ end
+ 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=='file')
+ if (ennewline=='y')
+ filenamefprintf(filename,'y',str);
+ else
+ filenamefprintf(filename,'n',str);
+ end
+ end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/ReadStringCard.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/ReadStringCard.sci index e9c7cd44..5d9358ba 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/ReadStringCard.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/ReadStringCard.sci @@ -1,39 +1,61 @@ -function cardvalue = ReadStringCard(filename,cardname,commentdelim,enableerror) -// function cardvalue = ReadStringCard(filename,cardname,commentdelim,enableerror) -// ----------------------------------------------------------------- -// -// Status: -// 06-Feb-2004 -- Nutricato Raffaele: Author. -// 06-Feb-2004 -- Nutricato Raffaele: TEST OK. -// 25-Jun-2004 -- Nutricato Raffaele: Added Comment delimiter -// and enableerror as input parameter. -// 13-Apr-2007 -- Intelligente Fabio: Rewritten from Matlab to Scilab. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- +function cardvalue = ReadStringCard(filename,cardname,commentdelim,enableerror)
+// function cardvalue = ReadStringCard(filename,cardname,commentdelim,enableerror)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// Reads the string associated to the card cardname placed
+// in filename.
+// The value of cardname is assumed to be a string.
+// If the card is not found an error will occur.
+//
+// Input data:
+// filename: full path + name of the file where the card
+// is being searched.
+// cardname: string with the name of the card.
+// commentdelim: specifies a character for an eventual comment
+// (to be discarded) after the card value.
+// enableerror: 'y' enable error message.
+// 'n' enable warning message.
+//
+// Output data:
+// cardvalue: string associated to the card. Blanks characters
+// are discarded.
+// #RNU_RES_E
+//
+// Status:
+// 06-Feb-2004 -- Nutricato Raffaele: Author.
+// 06-Feb-2004 -- Nutricato Raffaele: TEST OK.
+// 25-Jun-2004 -- Nutricato Raffaele: Added Comment delimiter
+// and enableerror as input parameter.
+// 13-Apr-2007 -- Intelligente Fabio: Rewritten from Matlab to Scilab.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
-SCI2CNInArgCheck(argn(2),2,3); - -if argn(2) == 2 then - commentdelim = ' '; - enableerror = 'y'; - -elseif argn(2) == 3 then - enableerror = 'y'; -end - -[flag_found,requested_line,dummy2] = ... - KeyString2FileStringPos(filename,cardname,'cut'); -cardvalue = stripblanks(strtok(requested_line,commentdelim)); -clear requested_line dummy2 - -if (flag_found == 0) then - if (enableerror == 'y') then - SCI2Cerror([cardname,' not found']); - else - warning([cardname,' not found']); - end -end - -endfunction +// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,3);
+
+if argn(2) == 2 then
+ commentdelim = ' ';
+ enableerror = 'y';
+
+elseif argn(2) == 3 then
+ enableerror = 'y';
+end
+
+[flag_found,requested_line,dummy2] = ...
+ KeyString2FileStringPos(filename,cardname,'cut');
+cardvalue = stripblanks(strtok(requested_line,commentdelim));
+clear requested_line dummy2
+
+if (flag_found == 0) then
+ if (enableerror == 'y') then
+ SCI2Cerror([cardname,' not found']);
+ else
+ warning([cardname,' not found']);
+ end
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2CCreateDir.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2CCreateDir.sci index 1ccb045a..cc152462 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2CCreateDir.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2CCreateDir.sci @@ -1,21 +1,31 @@ -function SCI2CCreateDir(OutDir) -// function SCI2CCreateDir(OutDir) -// ----------------------------------------------------------------- -// -// Status: -// 25-Jun-2007 -- Raffaele Nutricato: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- +function SCI2CCreateDir(OutDir)
+// function SCI2CCreateDir(OutDir)
+// -----------------------------------------------------------------
+// Create the dir OutDir.
+//
+// Input data:
+// OutDir: full path (absolute or relative) of the directory to be created.
+//
+// Output data:
+// ---
+//
+// Status:
+// 25-Jun-2007 -- Raffaele Nutricato: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
-SCI2CNInArgCheck(argn(2),1,1); - -[tmppath,tmpfname,tmpextension]=fileparts(OutDir) ; - -status_dir = mkdir(tmppath,tmpfname+tmpextension) ; -if (status_dir == 0) - SCI2Cerror('Cannot create: '+OutDir); -end - -endfunction +// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+[tmppath,tmpfname,tmpextension]=fileparts(OutDir) ;
+
+status_dir = mkdir(tmppath,tmpfname+tmpextension) ;
+if (status_dir == 0)
+ SCI2Cerror('Cannot create: '+OutDir);
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2CFindFile.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2CFindFile.sci index 96fd307a..912a72a8 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2CFindFile.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2CFindFile.sci @@ -1,28 +1,41 @@ -function [FlagFound,SCIFileName] = SCI2CFindFile(PathList,FileName) -// function [FlagFound,SCIFileName] = SCI2CFindFile(PathList,FileName) -// ----------------------------------------------------------------- -// Status: -// 11-Jul-2007 -- Nutricato Raffaele: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),2,2); - -FlagFound = 0; -SCIFileName = ''; - -Nscipaths = size(PathList,1); -counterscipaths = 1; -while ((FlagFound == 0) & (counterscipaths <= Nscipaths)) - dirscifilename = PathList(counterscipaths); - fullpathscifilename = fullfile(dirscifilename,FileName); - if (SCI2Cfileexist(dirscifilename,FileName)) - FlagFound = 1; - SCIFileName = fullpathscifilename; - end - counterscipaths = counterscipaths + 1; -end - -endfunction +function [FlagFound,SCIFileName] = SCI2CFindFile(PathList,FileName)
+// function [FlagFound,SCIFileName] = SCI2CFindFile(PathList,FileName)
+// -----------------------------------------------------------------
+// //NUT: add description here
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 11-Jul-2007 -- Nutricato Raffaele: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+FlagFound = 0;
+SCIFileName = '';
+
+// Perform the search in the user .sci files.
+Nscipaths = size(PathList,1);
+counterscipaths = 1;
+while ((FlagFound == 0) & (counterscipaths <= Nscipaths))
+ dirscifilename = PathList(counterscipaths);
+ fullpathscifilename = fullfile(dirscifilename,FileName);
+ if (SCI2Cfileexist(dirscifilename,FileName))
+ // It is a function of the USER2C library.
+ FlagFound = 1;
+ SCIFileName = fullpathscifilename;
+ end
+ counterscipaths = counterscipaths + 1;
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2CNInArgCheck.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2CNInArgCheck.sci index af21e289..23886fed 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2CNInArgCheck.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2CNInArgCheck.sci @@ -1,16 +1,28 @@ -function SCI2CNInArgCheck(NInArgs,MinNArgs,MaxNArgs) -// function SCI2CNInArgCheck(NInArgs,MinNArgs,MaxNArgs) -// ----------------------------------------------------------------- -// -// Status: -// 23-Nov-2007 -- Raffaele Nutricato: Author. -// -// Copyright 2007 Raffaele Nutricato -// ----------------------------------------------------------------- - -if ((NInArgs < MinNArgs) | (NInArgs > MaxNArgs)) - SCI2Cerror('Incorrect number of input arguments.'); -end - - -endfunction +function SCI2CNInArgCheck(NInArgs,MinNArgs,MaxNArgs)
+// function SCI2CNInArgCheck(NInArgs,MinNArgs,MaxNArgs)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// Check that NInArgs is in the range specified by MinNArgs and
+// MaxNArgs.
+//
+// Input data:
+// NInArgs: number of input arguments of the function under test.
+// MinNArgs: minimum number of input arguments allowed.
+// MaxNArgs: maximum number of input arguments allowed.
+//
+// Output data:
+// ---
+// #RNU_RES_E
+//
+// Status:
+// 23-Nov-2007 -- Raffaele Nutricato: Author.
+//
+// Copyright 2007 Raffaele Nutricato
+// -----------------------------------------------------------------
+
+if ((NInArgs < MinNArgs) | (NInArgs > MaxNArgs))
+ SCI2Cerror('Incorrect number of input arguments.');
+end
+
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2COpenFileRead.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2COpenFileRead.sci index a2d694e0..1ad60ce5 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2COpenFileRead.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2COpenFileRead.sci @@ -1,19 +1,30 @@ -function fidnumber = SCI2COpenFileRead(filename) -// function fidnumber = SCI2COpenFileRead(filename) -// -------------------------------------------------------------------------------- -// -// Status: -// 27-Oct-2007 -- Raffaele Nutricato: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),1,1); - -[fidnumber,fiderror] = mopen(filename,'r'); -if (fiderror < 0) - SCI2Cerror(['Cannot open (in read mode): '+filename]); -end - -endfunction +function fidnumber = SCI2COpenFileRead(filename)
+// function fidnumber = SCI2COpenFileRead(filename)
+// --------------------------------------------------------------------------------
+// Open a file in read mode.
+//
+// Input data:
+// filename: path + name of the file to read.
+//
+// Output data:
+// fidnumber: file identifier.
+//
+// Status:
+// 27-Oct-2007 -- Raffaele Nutricato: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+// --- Open the .sci file (read only). ---
+[fidnumber,fiderror] = mopen(filename,'r');
+if (fiderror < 0)
+ SCI2Cerror(['Cannot open (in read mode): '+filename]);
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2COpenFileWrite.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2COpenFileWrite.sci index f5eb3357..8a816b92 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2COpenFileWrite.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2COpenFileWrite.sci @@ -1,19 +1,30 @@ -function fidnumber = SCI2COpenFileWrite(filename) -// function fidnumber = SCI2COpenFileWrite(filename) -// -------------------------------------------------------------------------------- -// -// Status: -// 27-Oct-2007 -- Raffaele Nutricato: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),1,1); - -[fidnumber,fiderror] = mopen(filename,'w'); -if (fiderror < 0) - SCI2Cerror(['Cannot open (in write mode): '+filename]); -end - -endfunction +function fidnumber = SCI2COpenFileWrite(filename)
+// function fidnumber = SCI2COpenFileWrite(filename)
+// --------------------------------------------------------------------------------
+// Open a file in write mode.
+//
+// Input data:
+// filename: path + name of the file to be written.
+//
+// Output data:
+// fidnumber: file identifier.
+//
+// Status:
+// 27-Oct-2007 -- Raffaele Nutricato: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+// --- Open the .sci file (write mode). ---
+[fidnumber,fiderror] = mopen(filename,'w');
+if (fiderror < 0)
+ SCI2Cerror(['Cannot open (in write mode): '+filename]);
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2CTemplate.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2CTemplate.sci index 486ae0c2..e47bdd00 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2CTemplate.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2CTemplate.sci @@ -1,18 +1,32 @@ -function out = SCI2CTemplate(in1,in2) -// function out = SCI2CTemplate(in1,in2) -// ----------------------------------------------------------------- -// -// Status: -// 03-Jan-2008 -- Raffaele Nutricato: Author. -// -// Copyright 2008 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -// ------------------------------ -// --- Check input arguments. --- -// ------------------------------ -SCI2CNInArgCheck(argn(2),2,2); - - -endfunction +function out = SCI2CTemplate(in1,in2)
+// function out = SCI2CTemplate(in1,in2)
+// -----------------------------------------------------------------
+// This is a template function which shows how to comment functions.
+//
+// Input data:
+// in1: input argument number 1
+// in2: input argument number 2
+//
+// Output data:
+// out: output argument number 1
+//
+// Status:
+// 03-Jan-2008 -- Raffaele Nutricato: Author.
+//
+// Copyright 2008 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+// -----------------------
+// --- Initialization. ---
+// -----------------------
+// ---------------------------
+// --- End Initialization. ---
+// ---------------------------
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Ccopyfile.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Ccopyfile.sci index 16378d0f..f95c29ef 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Ccopyfile.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Ccopyfile.sci @@ -1,29 +1,49 @@ -function SCI2Ccopyfile(InFileName,OutFileName,CopyMode) -// function SCI2Ccopyfile(InFileName,OutFileName,CopyMode) -// ----------------------------------------------------------------- -// -// Status: -// 23-Nov-2007 -- Raffaele Nutricato: Author. -// -// Copyright 2007 Raffaele Nutricato -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),3,3); - -if (CopyMode == 'append') - fidIn = SCI2COpenFileRead(InFileName); - - tmpline = mgetl(fidIn,1); - while (meof(fidIn) == 0) - PrintStringInfo(tmpline, OutFileName, 'file', 'y'); - tmpline = mgetl(fidIn,1); - end - mclose(fidIn); -elseif (CopyMode == 'overwrite') - PrintStringInfo(' ', OutFileName, 'file', 'y'); // Cannot use scilab copyfile when the directory is empty!. - copyfile(InFileName,OutFileName); -else - SCI2Cerror('Unknown CopyMode: ""'+CopyMode+'""'); -end - -endfunction +function SCI2Ccopyfile(InFileName,OutFileName,CopyMode)
+// function SCI2Ccopyfile(InFileName,OutFileName,CopyMode)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// Copy the contents of infile into outfile. Append mode is used.
+//
+// Input data:
+// InFileName: path+filename of the input file.
+// OutFileName: path+filename of the input file.
+// CopyMode: 'append' or 'overwrite'
+// #RNU_RES_E
+//
+// Output data:
+// ---
+//
+// Status:
+// 23-Nov-2007 -- Raffaele Nutricato: Author.
+//
+// Copyright 2007 Raffaele Nutricato
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),3,3);
+
+if (CopyMode == 'append')
+ // ------------------------
+ // --- Open Input file. ---
+ // ------------------------
+ fidIn = SCI2COpenFileRead(InFileName);
+
+ // -------------------
+ // --- Read lines. ---
+ // -------------------
+ tmpline = mgetl(fidIn,1);
+ while (meof(fidIn) == 0)
+ PrintStringInfo(tmpline, OutFileName, 'file', 'y');
+ tmpline = mgetl(fidIn,1);
+ end
+ mclose(fidIn);
+elseif (CopyMode == 'overwrite')
+ PrintStringInfo(' ', OutFileName, 'file', 'y'); // Cannot use scilab copyfile when the directory is empty!.
+ copyfile(InFileName,OutFileName);
+else
+ SCI2Cerror('Unknown CopyMode: ""'+CopyMode+'""');
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cerror.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cerror.sci index 03b5ed9c..25851a2a 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cerror.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cerror.sci @@ -1,17 +1,28 @@ -function SCI2Cerror(errorstring) -// function SCI2Cerror(errorstring) -// ----------------------------------------------------------------- -// -// Status: -// 02-May-2007 -- Nutricato Raffaele: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- +function SCI2Cerror(errorstring)
+// function SCI2Cerror(errorstring)
+// -----------------------------------------------------------------
+// It is the error function but before issuing the error, performs
+// the mclose('all');
+//
+// Input data:
+// errorstring: string which specifies the error message.
+//
+// Output data:
+// ---
+//
+// Status:
+// 02-May-2007 -- Nutricato Raffaele: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
-SCI2CNInArgCheck(argn(2),1,1); - - -mclose('all') -error('###SCI2CERROR: '+errorstring); -endfunction +// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+
+mclose('all')
+error('###SCI2CERROR: '+errorstring);
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2CerrorFile.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2CerrorFile.sci index 24aec4df..29488876 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2CerrorFile.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2CerrorFile.sci @@ -1,17 +1,29 @@ -function SCI2CerrorFile(errorstring,filename); -// function SCI2CerrorFile(errorstring,filename); -// ----------------------------------------------------------------- -// -// Status: -// 02-May-2006 -- Nutricato Raffaele: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),2,2); - -mclose('all') -PrintStringInfo('Error: '+errorstring,filename,'both'); -error('####SCI2C_ERROR -> Read File: '+filename+'.'); -endfunction +function SCI2CerrorFile(errorstring,filename);
+// function SCI2CerrorFile(errorstring,filename);
+// -----------------------------------------------------------------
+// It is the error function but before issuing the error, performs
+// the mclose('all'); It also write the error string into the
+// file specified by filename.
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 02-May-2006 -- Nutricato Raffaele: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+mclose('all')
+PrintStringInfo('Error: '+errorstring,filename,'both');
+error('####SCI2C_ERROR -> Read File: '+filename+'.');
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cfileexist.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cfileexist.sci index 49dfd512..05dbf590 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cfileexist.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cfileexist.sci @@ -1,26 +1,38 @@ -function ExistTest = SCI2Cfileexist(InDir,FileName) -// function ExistTest = SCI2Cfileexist(InDir,FileName) -// ----------------------------------------------------------------- -// Status: -// 12-Jun-2007 -- Nutricato Raffaele: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),2,2); - -tmppwd = pwd(); -cd(InDir); -allfiles = ls(FileName); -cd(tmppwd); - -if (size(allfiles,1) == 0) - ExistTest = %F; -elseif (size(allfiles,1) == 1) - ExistTest = %T; -else - SCI2Cerror('Very Strange! Found more than one file with the same name.'); -end - -endfunction +function ExistTest = SCI2Cfileexist(InDir,FileName)
+// function ExistTest = SCI2Cfileexist(InDir,FileName)
+// -----------------------------------------------------------------
+// Searches for the file FileName in the directory InDir.
+// Return %F if it doesn't exist.
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 12-Jun-2007 -- Nutricato Raffaele: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+tmppwd = pwd();
+cd(InDir);
+allfiles = ls(FileName);
+cd(tmppwd);
+
+if (size(allfiles,1) == 0)
+ ExistTest = %F;
+elseif (size(allfiles,1) == 1)
+ ExistTest = %T;
+else
+ SCI2Cerror('Very Strange! Found more than one file with the same name.');
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cflipud.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cflipud.sci index 78e6f3d9..2e988c1b 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cflipud.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cflipud.sci @@ -1,19 +1,40 @@ -function OutputData = SCI2Cflipud(InputData) -// function OutputData = SCI2Cflipud(InputData) -// ----------------------------------------------------------------- -// -// Status: -// 12-May-2007 -- Nutricato Raffaele: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),1,1); - -NInputs = size(InputData,1); -OutputData = InputData; // To be sure that they will have the same structure. -for cnt = 1:NInputs - OutputData(cnt) = InputData(NInputs-cnt+1); -end -endfunction +function OutputData = SCI2Cflipud(InputData)
+// function OutputData = SCI2Cflipud(InputData)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// Inverts (flips) the position of the arguments of InputData.
+// Input data can be a struct or an array.
+// Ex.:
+// A(1) = 'one';
+// A(2) = 'two';
+// A(3) = 'three';
+// B = SCI2Cflipud(A);
+// B(1) = 'three';
+// B(2) = 'two';
+// B(3) = 'one';
+//
+// Input data:
+// InputData: input array or structure.
+//
+// Output data:
+// OutputData: flipped version of the input array.
+//
+// #RNU_RES_E
+// Status:
+// 12-May-2007 -- Nutricato Raffaele: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+NInputs = size(InputData,1);
+OutputData = InputData; // To be sure that they will have the same structure.
+for cnt = 1:NInputs
+ OutputData(cnt) = InputData(NInputs-cnt+1);
+end
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cisnum.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cisnum.sci index 716d3771..50a5c14e 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cisnum.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cisnum.sci @@ -1,19 +1,30 @@ -function outbool = SCI2Cisnum(instring) -// function outbool = SCI2Cisnum(instring) -// ----------------------------------------------------------------- -// Status: -// 12-Apr-2007 -- Nutricato Raffaele: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),1,1); - -instring = convstr(instring,'l'); -outbool = isnum(instring); -firstchar = part(instring,1:1); -if (firstchar == 'd' | firstchar == 'e') - outbool = %F; -end -endfunction +function outbool = SCI2Cisnum(instring)
+// function outbool = SCI2Cisnum(instring)
+// -----------------------------------------------------------------
+// It fixes the bug of isnum. isnum('d') -> %T!!!
+//
+// Input data:
+// instring: string to analyze.
+//
+// Output data:
+// outbool: %T if instring is a number.
+//
+// Status:
+// 12-Apr-2007 -- Nutricato Raffaele: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+instring = convstr(instring,'l');
+outbool = isnum(instring);
+firstchar = part(instring,1:1);
+if (firstchar == 'd' | firstchar == 'e')
+ outbool = %F;
+end
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cmdelete.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cmdelete.sci index 8ab14c29..d19233dc 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cmdelete.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cmdelete.sci @@ -1,19 +1,33 @@ -function SCI2Cmdelete(InFile) -// function SCI2Cmdelete(InFile) -// ----------------------------------------------------------------- -// -// Status: -// 12-Apr-2007 -- Nutricato Raffaele: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),1,1); - -[Inx,Inierr]=fileinfo(InFile); -if Inierr == 0 - mdelete(InFile);//NUT: questa stampa a video il file che sta cancellando. -end - -endfunction +function SCI2Cmdelete(InFile)
+// function SCI2Cmdelete(InFile)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// Deletes the input files only if the file really exists.
+// This avoids the issuing of the error generated by mdelete.
+//
+// Input data:
+// InFile: full path of the file to be deleted.
+//
+// Output data:
+// #RNU_RES_E
+//
+// Status:
+// 12-Apr-2007 -- Nutricato Raffaele: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+[Inx,Inierr]=fileinfo(InFile);
+if Inierr == 0
+ mdelete(InFile);//NUT: questa stampa a video il file che sta cancellando.
+ //NUT ho fatto delle altre prove e mi funzionava tutto. solo che quando
+ //NUT eseguo il codice scilab to c mi stampa a video tutto il nome del file.
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cresize.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cresize.sci new file mode 100644 index 00000000..ba78fde0 --- /dev/null +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cresize.sci @@ -0,0 +1,33 @@ +function out = SCI2Cresize(in)
+// function out = SCI2Cresize(in)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// It is a dummy function used by the programmer to specify at a given
+// point that a variable is changing its size. This will be translated
+// into C code by re-assigning the size array.
+// Next releases of this function will include check to avoid
+// increment of the size outside the limits specified by the first
+// initialization of the variable.
+//
+// Input data:
+// in: input variable to be resized
+//
+// Output data:
+// out: resized variable
+//
+// #RNU_RES_E
+// Status:
+// 10-Jun-2008 -- Nutricato Raffaele: Author.
+//
+// Copyright 2008 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+out = in;
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cstring.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cstring.sci index 5d7b73a9..cf6d4370 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cstring.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cstring.sci @@ -1,16 +1,34 @@ -function outstring = SCI2Cstring(innum) -// function outstring = SCI2Cstring(innum) -// ----------------------------------------------------------------- -// -// Status: -// 07-May-2008 -- Nutricato Raffaele: Author. -// -// Copyright 2008 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),1,1); - -outstring=strsubst(string(innum),'D','e'); - -endfunction +function outstring = SCI2Cstring(innum)
+// function outstring = SCI2Cstring(innum)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// It fixes the bug of string function when applied to
+// exponential formats:
+// Example:
+// -->string(10e-10)
+// ans =
+// 1.000D-09
+// Note how the "D" is syntactically wrong.
+//
+// Input data:
+// innnum: input number to be converted into string.
+//
+// Output data:
+// outstring: string containing the conversion.
+// #RNU_RES_E
+//
+// Status:
+// 07-May-2008 -- Nutricato Raffaele: Author.
+//
+// Copyright 2008 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+outstring=strsubst(string(innum),'D','e');
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cstrncmp.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cstrncmp.sci index 6ec5369e..54a5e148 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cstrncmp.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cstrncmp.sci @@ -1,16 +1,27 @@ -function res = SCI2Cstrncmp(s1,s2,n) -// function res = SCI2Cstrncmp(s1,s2,n) -// ----------------------------------------------------------------- -// -// Status: -// 16-Apr-2007 -- Nutricato Raffaele: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),3,3); - -res = (part(s1,1:n) == part(s2,1:n)); - -endfunction +function res = SCI2Cstrncmp(s1,s2,n)
+// function res = SCI2Cstrncmp(s1,s2,n)
+// -----------------------------------------------------------------
+// This function compares first n characters of strings s1 and s2.
+// SCI2Cstrncmp(s1,s2,n) returns 1logical T (true) if the first n characters of
+// the strings s1 and s2 are the same and logical 0 (false) otherwise.
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 16-Apr-2007 -- Nutricato Raffaele: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),3,3);
+
+res = (part(s1,1:n) == part(s2,1:n));
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cstrncmps1size.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cstrncmps1size.sci index b27b15b8..38e8c371 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cstrncmps1size.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/SCI2Cstrncmps1size.sci @@ -1,17 +1,32 @@ -function res = SCI2Cstrncmps1size(s1,s2); -// function res = SCI2Cstrncmps1size(s1,s2); -// ----------------------------------------------------------------- -// -// Status: -// 16-Apr-2007 -- Nutricato Raffaele: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),2,2); - -n = length(s1); -res = (part(s1,1:n) == part(s2,1:n)); - -endfunction +function res = SCI2Cstrncmps1size(s1,s2);
+// function res = SCI2Cstrncmps1size(s1,s2);
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// This function compares first n characters of strings s1 and s2.
+// n is the size of the string s1.
+// SCI2Cstrncmps1size returns logical T (true) if the first n characters of
+// the strings s1 and s2 are the same and logical 0 (false) otherwise.
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// #RNU_RES_E
+// Status:
+// 16-Apr-2007 -- Nutricato Raffaele: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+n = length(s1);
+res = (part(s1,1:n) == part(s2,1:n));
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/SizeInByte.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/SizeInByte.sci index 7ed8a512..fa2d4f94 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/SizeInByte.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/SizeInByte.sci @@ -1,24 +1,41 @@ -function SizeIn = SizeInByte(InDataType) -// function SizeIn = SizeInByte(InDataType) -// ----------------------------------------------------------------- -// Status: -// 12-May-2007 -- Nutricato Raffaele: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),1,1); - -if (InDataType == 'float') - SizeIn = 4; -elseif (InDataType == 'double') - SizeIn = 8; -elseif (InDataType == 'floatComplex*') - SizeIn = 8; -elseif (InDataType == 'doubleComplex*') - SizeIn = 16; -else - error('Unknown data type: '+InDataType); -end -endfunction +function SizeIn = SizeInByte(InDataType)
+// function SizeIn = SizeInByte(InDataType)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// Returns the size in bytes of the input data type.
+//
+// Input data:
+// InDataType: input data type. It can be:
+// 'float'
+// 'double'
+// 'floatComplex*'
+// 'doubleComplex*'
+//
+// Output data:
+// SizeIn: size in bytes of the input data type.
+//
+// #RNU_RES_E
+// Status:
+// 12-May-2007 -- Nutricato Raffaele: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+if (InDataType == 'float')
+ SizeIn = 4;
+elseif (InDataType == 'double')
+ SizeIn = 8;
+elseif (InDataType == 'floatComplex*')
+ SizeIn = 8;
+elseif (InDataType == 'doubleComplex*')
+ SizeIn = 16;
+else
+ error('Unknown data type: '+InDataType);
+end
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/dispina.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/dispina.sci index 6ce3c489..dc07cddc 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/dispina.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/dispina.sci @@ -1,31 +1,31 @@ -function dispina(instring); -// function dispina(instring); -// ----------------------------------------------------------------- -// Quista sacciu sulu iou comu funziona e a ce me serve. -// -// Input data: -// -// Output data: -// -// Status: -// 12-Apr-2007 -- Nutricato Raffaele: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- +function dispina(instring);
+// function dispina(instring);
+// -----------------------------------------------------------------
+// Quista sacciu sulu iou comu funziona e a ce me serve.
+//
+// Input data:
+//
+// Output data:
+//
+// Status:
+// 12-Apr-2007 -- Nutricato Raffaele: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
-// ------------------------------ -// --- Check input arguments. --- -// ------------------------------ -SCI2CNInArgCheck(argn(2),1,1); - -disp('++++++++++++++++++++++++++++++++++++++++++++++++++') -disp('++++++++++++++++++++++++++++++++++++++++++++++++++') -disp('++++++++++++++++++++++++++++++++++++++++++++++++++') -disp('++++++++++++++++++++++++++++++++++++++++++++++++++') -disp(instring); -disp('++++++++++++++++++++++++++++++++++++++++++++++++++') -disp('++++++++++++++++++++++++++++++++++++++++++++++++++') -disp('++++++++++++++++++++++++++++++++++++++++++++++++++') -disp('++++++++++++++++++++++++++++++++++++++++++++++++++') -endfunction +// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+disp('++++++++++++++++++++++++++++++++++++++++++++++++++')
+disp('++++++++++++++++++++++++++++++++++++++++++++++++++')
+disp('++++++++++++++++++++++++++++++++++++++++++++++++++')
+disp('++++++++++++++++++++++++++++++++++++++++++++++++++')
+disp(instring);
+disp('++++++++++++++++++++++++++++++++++++++++++++++++++')
+disp('++++++++++++++++++++++++++++++++++++++++++++++++++')
+disp('++++++++++++++++++++++++++++++++++++++++++++++++++')
+disp('++++++++++++++++++++++++++++++++++++++++++++++++++')
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/filenamefprintf.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/filenamefprintf.sci index dc08068f..99aeb81c 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/filenamefprintf.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/filenamefprintf.sci @@ -1,27 +1,43 @@ -function filenamefprintf(filename,ennewline,str) -// function filenamefprintf(filename,ennewline,str) -// -------------------------------------------------------------------------------- -// -// Status: -// 31-Jan-2006 -- Nutricato Raffaele: Author. -// 31-Jan-2006 -- Nutricato Raffaele: TEST OK. -// -// Copyright 2006 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- +function filenamefprintf(filename,ennewline,str)
+// function filenamefprintf(filename,ennewline,str)
+// --------------------------------------------------------------------------------
+// Uses the printf to print the string specified by varargin. filenamefprintf
+// uses the filename instead of the fid parameter used by fprintf.
+// Everytime filenamefprintf is called it
+// opens the file, prints the string in it and then closes it.
+// Opening is performed in read/append mode (at+).
+//
+// Input data:
+// filename: string that specifies the name of the file.
+// varargin are the input arguments for the printf.
+//
+// Output data:
+// ---
+//
+// Status:
+// 31-Jan-2006 -- Nutricato Raffaele: Author.
+// 31-Jan-2006 -- Nutricato Raffaele: TEST OK.
+//
+// Copyright 2006 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
-SCI2CNInArgCheck(argn(2),3,3); - - - [FidReportFile, mess] = mopen(filename,'a+'); - if (FidReportFile == -1) then - SCI2Cerror(mess); - end - if ennewline=='y' then - mfprintf(FidReportFile,'%s\n',str); - else - mfprintf(FidReportFile,'%s',str); - end - mclose(FidReportFile); - -endfunction +// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),3,3);
+
+
+// [FidReportFile, mess] = mopen(deblank(filename),'at+');
+ [FidReportFile, mess] = mopen(filename,'a+');
+ if (FidReportFile == -1) then
+ SCI2Cerror(mess);
+ end
+ if ennewline=='y' then
+ mfprintf(FidReportFile,'%s\n',str);
+ else
+ mfprintf(FidReportFile,'%s',str);
+ end
+ mclose(FidReportFile);
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/float.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/float.sci index b7c13aa1..634950b1 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/float.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/float.sci @@ -1,15 +1,26 @@ -function y = float(x) -// ----------------------------------------------------------------- -// Status: -// 12-Apr-2007 -- Nutricato Raffaele: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- +function y = float(x)
+// -----------------------------------------------------------------
+// Dummy function for float precision specifier.
+//
+// Input data:
+// x: input array or scalar.
+//
+// Output data:
+// y: output array or scalar.
+//
+// Status:
+// 12-Apr-2007 -- Nutricato Raffaele: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
-SCI2CNInArgCheck(argn(2),1,1); - - -y = x; - -endfunction +// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+
+y = x;
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/GeneralFunctions/squeezestrings.sci b/src/Scilab2C/Scilab2C/GeneralFunctions/squeezestrings.sci index 641262b0..049476d1 100644 --- a/src/Scilab2C/Scilab2C/GeneralFunctions/squeezestrings.sci +++ b/src/Scilab2C/Scilab2C/GeneralFunctions/squeezestrings.sci @@ -1,19 +1,31 @@ -function OutString = squeezestrings(InStringArray) -// function OutString = squeezestrings(InStringArray) -// ----------------------------------------------------------------- -// -// Status: -// 12-Apr-2007 -- Nutricato Raffaele: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),1,1); - -OutString = []; -for counterstrings = 1:max(size(InStringArray)) - OutString = OutString+InStringArray(counterstrings); -end - -endfunction +function OutString = squeezestrings(InStringArray)
+// function OutString = squeezestrings(InStringArray)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// Converts an array of strings into a single string.
+//
+// Input data:
+// InStringArray: Array of strings.
+//
+// Output data:
+// OutString: Output string.
+//
+// #RNU_RES_E
+// Status:
+// 12-Apr-2007 -- Nutricato Raffaele: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+OutString = [];
+for counterstrings = 1:max(size(InStringArray))
+ OutString = OutString+InStringArray(counterstrings);
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/LaunchRunSCI2C.sci b/src/Scilab2C/Scilab2C/LaunchRunSCI2C.sci index 04c468f0..70a500eb 100644 --- a/src/Scilab2C/Scilab2C/LaunchRunSCI2C.sci +++ b/src/Scilab2C/Scilab2C/LaunchRunSCI2C.sci @@ -5,7 +5,7 @@ // --- CLEAN WORKSPACE --- exec full_reset.sce; -//mode(-1); +mode(-1); // --- GENERAL SETTINGS (USER PARAMETERS) --- RunsDirectory = pwd(); // Path of the SCI2CRuns directory @@ -24,10 +24,10 @@ runscicode(SCI2CInputPrmFileName); userchoice = input('Start translation [y/n]?','s'); if (userchoice == 'y') // --- LAUNCH SCI2C --- - cd(SCI2CDirectory) + cd(SCI2CDirectory); getf("runsci2c.sci"); runsci2c(SCI2CInputPrmFileName); - cd(SCI2CDirectory) + cd(SCI2CDirectory); end // --- GO BACK TO THE ORIGINAL DIRECTORY. --- diff --git a/src/Scilab2C/Scilab2C/SymbolTable/ST_AnalyzeScope.sci b/src/Scilab2C/Scilab2C/SymbolTable/ST_AnalyzeScope.sci index 84b8ef4c..bb38ea73 100644 --- a/src/Scilab2C/Scilab2C/SymbolTable/ST_AnalyzeScope.sci +++ b/src/Scilab2C/Scilab2C/SymbolTable/ST_AnalyzeScope.sci @@ -1,60 +1,124 @@ -function OutArg = ST_AnalyzeScope(OldOutArg,NOutArg,FileInfo,SharedInfo); -// function OutArg = ST_AnalyzeScope(OldOutArg,NOutArg,FileInfo,SharedInfo); -// ----------------------------------------------------------------- -// Status: -// 26-Oct-2007 -- Raffaele Nutricato: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),4,4); - -nxtscifunname = SharedInfo.NextSCIFunName; -nxtscifunnumber = SharedInfo.NextSCIFunNumber; -ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; - - -OutArg = OldOutArg; -GlobalVarsFileName = FileInfo.GlobalVarFileName; -LocalVarsFileName = FileInfo.Funct(nxtscifunnumber).LocalVarFileName; -TempVarsFileName = FileInfo.Funct(nxtscifunnumber).TempVarFileName; - -for cntout = 1:NOutArg - TBName = OutArg(cntout).Name; - - SymbolTableFileName = TempVarsFileName; - [TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension] = ... - ST_Get(TBName,SymbolTableFileName); - if (TBFlagfound == 0) - else - SCI2CerrorFile('Found a temp symbol in '+SymbolTableFileName+... - ' with the same name of the equal output argument ""'+TBName+'"".',ReportFileName); - end - - SymbolTableFileName = LocalVarsFileName; - [TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension] = ... - ST_Get(TBName,SymbolTableFileName); - if (TBFlagfound == 0) - else - OutArg(cntout).Scope = 'Local'; - end - - if (TBFlagfound == 0) - SymbolTableFileName = GlobalVarsFileName; - [TBFlagfound2,TBType,TBSize,TBValue,TBFindLike,TBDimension] = ... - ST_Get(TBName,SymbolTableFileName); - if (TBFlagfound2 == 0) - if SCI2Cstrncmps1size(SharedInfo.ASTReader.TempVarsName,OutArg(cntout).Name) - OutArg(cntout).Scope = 'Temp'; - else - OutArg(cntout).Scope = 'Local'; - end - else - OutArg(cntout).Scope = 'Global'; - end - end - -end - -endfunction +function OutArg = ST_AnalyzeScope(OldOutArg,NOutArg,FileInfo,SharedInfo);
+// function OutArg = ST_AnalyzeScope(OldOutArg,NOutArg,FileInfo,SharedInfo);
+// -----------------------------------------------------------------
+// //NUT: add description here
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),4,4);
+
+// -----------------------
+// --- Initialization. ---
+// -----------------------
+nxtscifunname = SharedInfo.NextSCIFunName;
+nxtscifunnumber = SharedInfo.NextSCIFunNumber;
+ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName;
+
+// #RNU_RES_B
+PrintStringInfo(' ',ReportFileName,'file','y');
+PrintStringInfo('***Getting output arguments info from the symbol table***',ReportFileName,'file','y');
+// #RNU_RES_E
+
+OutArg = OldOutArg;
+GlobalVarsFileName = FileInfo.GlobalVarFileName;
+LocalVarsFileName = FileInfo.Funct(nxtscifunnumber).LocalVarFileName;
+TempVarsFileName = FileInfo.Funct(nxtscifunnumber).TempVarFileName;
+// ---------------------------
+// --- End Initialization. ---
+// ---------------------------
+
+// #RNU_RES_B
+// ------------------------------------------------------------------
+// --- Check if the out variables already exist in symbol tables. ---
+// ------------------------------------------------------------------
+// #RNU_RES_E
+for cntout = 1:NOutArg
+ // #RNU_RES_B
+ PrintStringInfo(' Symbol ""'+OutArg(cntout).Name+'""',ReportFileName,'file','y');
+ // #RNU_RES_E
+ TBName = OutArg(cntout).Name;
+
+ // #RNU_RES_B
+ // --- Check in temporary symbol table. ---
+ // #RNU_RES_E
+ SymbolTableFileName = TempVarsFileName;
+ [TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension] = ...
+ ST_Get(TBName,SymbolTableFileName);
+ if (TBFlagfound == 0)
+ // #RNU_RES_B
+ PrintStringInfo(' ...not found in: '+SymbolTableFileName+'.',ReportFileName,'file','y');
+ // #RNU_RES_E
+ else
+ SCI2CerrorFile('Found a temp symbol in '+SymbolTableFileName+...
+ ' with the same name of the equal output argument ""'+TBName+'"".',ReportFileName);
+ end
+
+ // #RNU_RES_B
+ // --- Check in local symbol table. ---
+ // #RNU_RES_E
+ SymbolTableFileName = LocalVarsFileName;
+ [TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension] = ...
+ ST_Get(TBName,SymbolTableFileName);
+ if (TBFlagfound == 0)
+ // #RNU_RES_B
+ PrintStringInfo(' ...not found in: '+SymbolTableFileName+'.',ReportFileName,'file','y');
+ // #RNU_RES_E
+ else
+ // #RNU_RES_B
+ PrintStringInfo(' ...found in: '+SymbolTableFileName+'.',ReportFileName,'file','y');
+ // #RNU_RES_E
+ OutArg(cntout).Scope = 'Local';
+ end
+
+ // #RNU_RES_B
+ // --- Check in global symbol table. ---
+ // #RNU_RES_E
+ if (TBFlagfound == 0)
+ // Local wins over global.
+ SymbolTableFileName = GlobalVarsFileName;
+ [TBFlagfound2,TBType,TBSize,TBValue,TBFindLike,TBDimension] = ...
+ ST_Get(TBName,SymbolTableFileName);
+ if (TBFlagfound2 == 0)
+ // #RNU_RES_B
+ PrintStringInfo(' ...not found in: '+SymbolTableFileName+'.',ReportFileName,'file','y');
+ // #RNU_RES_E
+ if SCI2Cstrncmps1size(SharedInfo.ASTReader.TempVarsName,OutArg(cntout).Name)
+ OutArg(cntout).Scope = 'Temp';
+ else
+ OutArg(cntout).Scope = 'Local';
+ end
+ else
+ // #RNU_RES_B
+ PrintStringInfo(' ...found in: '+SymbolTableFileName+'.',ReportFileName,'file','y');
+ // #RNU_RES_E
+ OutArg(cntout).Scope = 'Global';
+ end
+ end
+
+ // #RNU_RES_B
+ PrintStringInfo(' Type: '+OutArg(cntout).Type,ReportFileName,'file','y');
+ PrintStringInfo(' Size(1): '+string(OutArg(cntout).Size(1)),ReportFileName,'file','y');
+ PrintStringInfo(' Size(2): '+string(OutArg(cntout).Size(2)),ReportFileName,'file','y');
+ PrintStringInfo(' Value: '+string(OutArg(cntout).Value),ReportFileName,'file','y');
+ PrintStringInfo(' FindLike: '+string(OutArg(cntout).FindLike),ReportFileName,'file','y');
+ PrintStringInfo(' Dimension: '+string(OutArg(cntout).Dimension),ReportFileName,'file','y');
+ PrintStringInfo(' Scope: '+string(OutArg(cntout).Scope),ReportFileName,'file','y');
+ PrintStringInfo(' ',ReportFileName,'file','y');
+ // #RNU_RES_E
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/SymbolTable/ST_Del.sci b/src/Scilab2C/Scilab2C/SymbolTable/ST_Del.sci index 683ef06b..6401a2b5 100644 --- a/src/Scilab2C/Scilab2C/SymbolTable/ST_Del.sci +++ b/src/Scilab2C/Scilab2C/SymbolTable/ST_Del.sci @@ -1,27 +1,41 @@ -function ST_Del(TBName,SymbolTableFileName) -// function ST_Del(TBName,SymbolTableFileName) -// ----------------------------------------------------------------- -// -// Status: -// 26-Oct-2007 -- Raffaele Nutricato: Author. -// 26-Oct-2007 -- Alberto Morea: Test Ok. -// -// Copyright 2007 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),2,2); - -SCI2CSymbolTable = ST_Load(SymbolTableFileName); - -[TBFlagfound,TBPosition] = ST_FindPos(TBName,SymbolTableFileName); - -if (TBFlagfound == 0) - SCI2Cerror('Missing symbol: trying to del a non existing symbol ""'+TBName+'"".'); -elseif (TBFlagfound == 1) - SCI2CSymbolTable(TBPosition) = []; - - ST_Save(SymbolTableFileName,SCI2CSymbolTable); -end - -endfunction +function ST_Del(TBName,SymbolTableFileName)
+// function ST_Del(TBName,SymbolTableFileName)
+// -----------------------------------------------------------------
+// Delete function for the symbol table.
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+// --- Load symbol table. ---
+SCI2CSymbolTable = ST_Load(SymbolTableFileName);
+
+// --- Find symbol position. ---
+[TBFlagfound,TBPosition] = ST_FindPos(TBName,SymbolTableFileName);
+
+if (TBFlagfound == 0)
+ SCI2Cerror('Missing symbol: trying to del a non existing symbol ""'+TBName+'"".');
+elseif (TBFlagfound == 1)
+ // --- Update symbol table. ---
+ SCI2CSymbolTable(TBPosition) = [];
+
+ // --- Save symbol table. ---
+ ST_Save(SymbolTableFileName,SCI2CSymbolTable);
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/SymbolTable/ST_FindPos.sci b/src/Scilab2C/Scilab2C/SymbolTable/ST_FindPos.sci index 7ce0c1ec..bfba11d1 100644 --- a/src/Scilab2C/Scilab2C/SymbolTable/ST_FindPos.sci +++ b/src/Scilab2C/Scilab2C/SymbolTable/ST_FindPos.sci @@ -1,32 +1,46 @@ -function [TBFlagfound,TBPosition] = ST_FindPos(TBName,SymbolTableFileName) -// function [TBFlagfound,TBPosition] = ST_FindPos(TBName,SymbolTableFileName) -// ----------------------------------------------------------------- -// -// Status: -// 26-Oct-2007 -- Raffaele Nutricato: Author. -// 26-Oct-2007 -- Alberto Morea: Test Ok. -// -// Copyright 2007 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - - -SCI2CNInArgCheck(argn(2),2,2); - -SCI2CSymbolTable = ST_Load(SymbolTableFileName); - -TBFlagfound = 0; -TBPosition = 0; -NEntries = max(size(SCI2CSymbolTable)); -for countertable = 1:NEntries - if (mtlb_strcmp(TBName,SCI2CSymbolTable(countertable).Name)) - TBFlagfound = TBFlagfound + 1; - TBPosition = countertable; - end -end - -if (TBFlagfound > 1) - SCI2Cerror('Symbol table conflict: found two symbols with the same name ""'+TBName+'"".'); -end - -endfunction +function [TBFlagfound,TBPosition] = ST_FindPos(TBName,SymbolTableFileName)
+// function [TBFlagfound,TBPosition] = ST_FindPos(TBName,SymbolTableFileName)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// Finds position of symbol TBName in the symbol table.
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// #RNU_RES_E
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+// --- Load symbol table. ---
+SCI2CSymbolTable = ST_Load(SymbolTableFileName);
+
+// --- Find position of the line to be removed. ---
+TBFlagfound = 0;
+TBPosition = 0;
+NEntries = max(size(SCI2CSymbolTable));
+for countertable = 1:NEntries
+ if (mtlb_strcmp(TBName,SCI2CSymbolTable(countertable).Name))
+ TBFlagfound = TBFlagfound + 1;
+ TBPosition = countertable;
+ end
+end
+
+if (TBFlagfound > 1)
+ SCI2Cerror('Symbol table conflict: found two symbols with the same name ""'+TBName+'"".');
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/SymbolTable/ST_Get.sci b/src/Scilab2C/Scilab2C/SymbolTable/ST_Get.sci index 8713ad70..ca53fc07 100644 --- a/src/Scilab2C/Scilab2C/SymbolTable/ST_Get.sci +++ b/src/Scilab2C/Scilab2C/SymbolTable/ST_Get.sci @@ -1,48 +1,66 @@ -function [TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension] = ... - ST_Get(Field_Name,SymbolTableFileName) -// function [TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension] = ... -// ST_Get(Field_Name,SymbolTableFileName) -// ----------------------------------------------------------------- -// -// Status: -// 26-Oct-2007 -- Raffaele Nutricato: Author. -// 26-Oct-2007 -- Alberto Morea: Test Ok. -// -// Copyright 2007 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),2,2); - -[tmpnams,tmptyps,tmpdims,tmpvols]=listvarinfile(SymbolTableFileName); -if (max(size(tmpnams)) > 1) - SCI2Cerror('More than one variable found in ""'+SymbolTableFileName+'"".'); -end -load(SymbolTableFileName,tmpnams); -SCI2CSymbolTable = eval(tmpnams); - -TBFlagfound = 0; -TBType = ''; -TBSize(1) = ''; -TBSize(2) = ''; -TBValue = %nan; -TBFindLike = %nan; -TBDimension = %nan; -if (TBFlagfound == 0) - NEntries = max(size(SCI2CSymbolTable)); - for countertable = 1:NEntries - if (mtlb_strcmp(Field_Name,SCI2CSymbolTable(countertable).Name)) - TBFlagfound = TBFlagfound + 1; - TBType = SCI2CSymbolTable(countertable).Type; // String - TBSize = SCI2CSymbolTable(countertable).Size; // String - TBValue = SCI2CSymbolTable(countertable).Value; - TBFindLike = SCI2CSymbolTable(countertable).FindLike; // Number: 0 or 1. - TBDimension = SCI2CSymbolTable(countertable).Dimension; // Number: 0 or 1 or 2. - end - end -end - -if (TBFlagfound > 1) - SCI2Cerror('Symbol table conflict: found two symbols with the same name ""'+TBName+'"".'); -end -endfunction +function [TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension] = ...
+ ST_Get(Field_Name,SymbolTableFileName)
+// function [TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension] = ...
+// ST_Get(Field_Name,SymbolTableFileName)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// Get function for the symbol table.
+//
+// #RNU_RES_E
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+// --------------------------
+// --- Load Symbol Table. ---
+// --------------------------
+[tmpnams,tmptyps,tmpdims,tmpvols]=listvarinfile(SymbolTableFileName);
+if (max(size(tmpnams)) > 1)
+ SCI2Cerror('More than one variable found in ""'+SymbolTableFileName+'"".');
+end
+load(SymbolTableFileName,tmpnams);
+SCI2CSymbolTable = eval(tmpnams);
+// ------------------------------
+// --- End Load Symbol Table. ---
+// ------------------------------
+
+TBFlagfound = 0;
+TBType = '';
+TBSize(1) = '';
+TBSize(2) = '';
+TBValue = %nan;
+TBFindLike = %nan;
+TBDimension = %nan;
+if (TBFlagfound == 0)
+ NEntries = max(size(SCI2CSymbolTable));
+ for countertable = 1:NEntries
+ if (mtlb_strcmp(Field_Name,SCI2CSymbolTable(countertable).Name))
+ TBFlagfound = TBFlagfound + 1;
+ TBType = SCI2CSymbolTable(countertable).Type; // String
+ TBSize = SCI2CSymbolTable(countertable).Size; // String
+ TBValue = SCI2CSymbolTable(countertable).Value;
+ TBFindLike = SCI2CSymbolTable(countertable).FindLike; // Number: 0 or 1.
+ TBDimension = SCI2CSymbolTable(countertable).Dimension; // Number: 0 or 1 or 2.
+ end
+ end
+end
+
+if (TBFlagfound > 1)
+ SCI2Cerror('Symbol table conflict: found two symbols with the same name ""'+TBName+'"".');
+end
+endfunction
diff --git a/src/Scilab2C/Scilab2C/SymbolTable/ST_GetInArgInfo.sci b/src/Scilab2C/Scilab2C/SymbolTable/ST_GetInArgInfo.sci index f44ffb7e..9c93391c 100644 --- a/src/Scilab2C/Scilab2C/SymbolTable/ST_GetInArgInfo.sci +++ b/src/Scilab2C/Scilab2C/SymbolTable/ST_GetInArgInfo.sci @@ -1,105 +1,159 @@ -function [UpdatedInArg,SharedInfo] = ST_GetInArgInfo(InArg,NInArg,FileInfo,SharedInfo) -// function UpdatedInArg = ST_GetInArgInfo(InArg,NInArg,FileInfo,SharedInfo) -// ----------------------------------------------------------------- -// -// Status: -// 26-Oct-2007 -- Raffaele Nutricato: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),4,4); - -nxtscifunname = SharedInfo.NextSCIFunName; -nxtscifunnumber = SharedInfo.NextSCIFunNumber; -ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; - - -UpdatedInArg = InArg; - -for cntinarg = 1:NInArg - tmpname = InArg(cntinarg).Name; - tmpscope = InArg(cntinarg).Scope; - lengthNumber = length('Number_'); - if (part(tmpscope,1:lengthNumber) == 'Number_') - UpdatedInArg(cntinarg).Type = part(tmpscope,lengthNumber+1:lengthNumber+1); - if (UpdatedInArg(cntinarg).Type == 'x') - UpdatedInArg(cntinarg).Type = SharedInfo.DefaultPrecision; // It is the default. - elseif (UpdatedInArg(cntinarg).Type == 'X') - if (SharedInfo.DefaultPrecision == 's') - UpdatedInArg(cntinarg).Type = 'c'; // It is the default. - elseif (SharedInfo.DefaultPrecision == 'd') - UpdatedInArg(cntinarg).Type = 'z'; // It is the default. - else - SCI2Cerror('Unexpected value for SharedInfo.DefaultPrecision: ""'+SharedInfo.DefaultPrecision+'""'); - end - end - if (tmpname == '%pi') - UpdatedInArg(cntinarg).Name = 'SCI2C_PI'; - numvalue = %pi; - elseif (tmpname == '%T') - UpdatedInArg(cntinarg).Name = 'SCI2C_T'; - numvalue = 1; - elseif (tmpname == '%F') - UpdatedInArg(cntinarg).Name = 'SCI2C_F'; - numvalue = 0; - elseif (tmpname == '%nan') - UpdatedInArg(cntinarg).Name = 'SCI2C_NAN'; - numvalue = %nan; - elseif (tmpname == '%inf') - UpdatedInArg(cntinarg).Name = 'SCI2C_INF'; - numvalue = %nan; // Otherwise it will put in the C code Inf value. - elseif (tmpname == '%i') - UpdatedInArg(cntinarg).Name = 'SCI2C_IMG_'+convstr(UpdatedInArg(cntinarg).Type,'u'); - numvalue = %i; - else - numvalue = eval(tmpname); - end - - UpdatedInArg(cntinarg).Size(1) = '1'; - UpdatedInArg(cntinarg).Size(2) = '1'; - UpdatedInArg(cntinarg).Value = numvalue; - UpdatedInArg(cntinarg).FindLike = 0; - UpdatedInArg(cntinarg).Dimension = 0; - UpdatedInArg(cntinarg).Scope = 'Number'; - - elseif (tmpscope == 'String') - SharedInfo.ASTReader.UsedTempVars = SharedInfo.ASTReader.UsedTempVars + 1; - TmpOutArgName = strcat([SharedInfo.ASTReader.TempVarsName,string(SharedInfo.ASTReader.UsedTempVars)]); - - UpdatedInArg(cntinarg).Name = TmpOutArgName; // Change the name. - UpdatedInArg(cntinarg).Type = 'g'; // it is the default. - UpdatedInArg(cntinarg).Size(1) = '1'; - UpdatedInArg(cntinarg).Size(2) = string(length(tmpname)+1); //+1 = (\0) - UpdatedInArg(cntinarg).Value = '""'+tmpname+'""'; - UpdatedInArg(cntinarg).FindLike = 0; - UpdatedInArg(cntinarg).Dimension = 2; //NUT: in future releases you can set this field to 1. - UpdatedInArg(cntinarg).Scope = 'Temp'; - - ST_InsOutArg(UpdatedInArg(cntinarg),1,FileInfo,SharedInfo,'all'); - - elseif (tmpscope == 'Var' | tmpscope == 'Global' | tmpscope == 'Local' | tmpscope == 'Temp') - [TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension,TBScope] = ST_GetSymbolInfo(tmpname,FileInfo,SharedInfo); - if (TBFlagfound == 0) - PrintStringInfo(' ',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: Unknown symbol ""'+tmpname+'"".',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: Be sure to initialize every symbol you are using.',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: Before running the SCI2C translator, remember to run the code you are trying',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: to translate in order to check syntax errors.',ReportFileName,'both','y'); - PrintStringInfo(' ',ReportFileName,'both','y'); - SCI2Cerror(' '); - end - UpdatedInArg(cntinarg).Type = TBType; - UpdatedInArg(cntinarg).Size = TBSize; - UpdatedInArg(cntinarg).Value = TBValue; - UpdatedInArg(cntinarg).FindLike = TBFindLike; - UpdatedInArg(cntinarg).Dimension = TBDimension; - UpdatedInArg(cntinarg).Scope = TBScope; - - else - SCI2Cerror('Unknown scope identifier ""'+tmpscope+'"" for variable ""'+tmpname+'"".'); - end -end - -endfunction +function [UpdatedInArg,SharedInfo] = ST_GetInArgInfo(InArg,NInArg,FileInfo,SharedInfo)
+// function UpdatedInArg = ST_GetInArgInfo(InArg,NInArg,FileInfo,SharedInfo)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// Generate all the info concerning the input arguments.
+//
+// Input data:
+// InArg: InArg structure containing only the names of the input
+// arguments.
+// //NUT: add description here
+//
+// Output data:
+// UpdatedInArg: InArg structure with all the info on the input
+// arguments.
+// FileInfoDatFile: name of the .dat file containing the FileInfo
+// structure.
+// #RNU_RES_E
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),4,4);
+
+// -----------------------
+// --- Initialization. ---
+// -----------------------
+nxtscifunname = SharedInfo.NextSCIFunName;
+nxtscifunnumber = SharedInfo.NextSCIFunNumber;
+ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName;
+
+// #RNU_RES_B
+PrintStringInfo(' ',ReportFileName,'file','y');
+PrintStringInfo('***Analyzing Input Arguments***',ReportFileName,'file','y');
+// #RNU_RES_E
+
+UpdatedInArg = InArg;
+// ---------------------------
+// --- End Initialization. ---
+// ---------------------------
+
+for cntinarg = 1:NInArg
+ tmpname = InArg(cntinarg).Name;
+ tmpscope = InArg(cntinarg).Scope;
+ lengthNumber = length('Number_');
+ if (part(tmpscope,1:lengthNumber) == 'Number_')
+ // #RNU_RES_B
+ PrintStringInfo('Input Argument '+string(cntinarg)+' is a number: '+tmpname+'.',FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
+ // #RNU_RES_E
+ UpdatedInArg(cntinarg).Type = part(tmpscope,lengthNumber+1:lengthNumber+1);
+ if (UpdatedInArg(cntinarg).Type == 'x')
+ UpdatedInArg(cntinarg).Type = SharedInfo.DefaultPrecision; // It is the default.
+ elseif (UpdatedInArg(cntinarg).Type == 'X')
+ if (SharedInfo.DefaultPrecision == 's')
+ UpdatedInArg(cntinarg).Type = 'c'; // It is the default.
+ elseif (SharedInfo.DefaultPrecision == 'd')
+ UpdatedInArg(cntinarg).Type = 'z'; // It is the default.
+ else
+ SCI2Cerror('Unexpected value for SharedInfo.DefaultPrecision: ""'+SharedInfo.DefaultPrecision+'""');
+ end
+ end
+ if (tmpname == '%pi')
+ UpdatedInArg(cntinarg).Name = 'SCI2C_PI';
+ numvalue = %pi;
+ elseif (tmpname == '%T')
+ UpdatedInArg(cntinarg).Name = 'SCI2C_T';
+ numvalue = 1;
+ elseif (tmpname == '%F')
+ UpdatedInArg(cntinarg).Name = 'SCI2C_F';
+ numvalue = 0;
+ elseif (tmpname == '%nan')
+ UpdatedInArg(cntinarg).Name = 'SCI2C_NAN';
+ numvalue = %nan;
+ elseif (tmpname == '%inf')
+ UpdatedInArg(cntinarg).Name = 'SCI2C_INF';
+ numvalue = %nan; // Otherwise it will put in the C code Inf value.
+ elseif (tmpname == '%i')
+ // #RNU_RES_B
+ //NUT: Other complex numbers are always
+ //NUT: stored in variables, and don't appear as immediate numbers.
+ // #RNU_RES_E
+ UpdatedInArg(cntinarg).Name = 'SCI2C_IMG_'+convstr(UpdatedInArg(cntinarg).Type,'u');
+ numvalue = %i;
+ else
+ numvalue = eval(tmpname);
+ //UpdatedInArg(cntinarg).Type = 'd'; // it is the default.
+ end
+
+ UpdatedInArg(cntinarg).Size(1) = '1';
+ UpdatedInArg(cntinarg).Size(2) = '1';
+ UpdatedInArg(cntinarg).Value = numvalue;
+ UpdatedInArg(cntinarg).FindLike = 0;
+ UpdatedInArg(cntinarg).Dimension = 0;
+ UpdatedInArg(cntinarg).Scope = 'Number';
+
+ elseif (tmpscope == 'String')
+ // #RNU_RES_B
+ PrintStringInfo('Input Argument '+string(cntinarg)+' is a string: '+tmpname+'.',FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
+ // #RNU_RES_E
+ SharedInfo.ASTReader.UsedTempVars = SharedInfo.ASTReader.UsedTempVars + 1;
+ TmpOutArgName = strcat([SharedInfo.ASTReader.TempVarsName,string(SharedInfo.ASTReader.UsedTempVars)]);
+
+ UpdatedInArg(cntinarg).Name = TmpOutArgName; // Change the name.
+ UpdatedInArg(cntinarg).Type = 'g'; // it is the default.
+ UpdatedInArg(cntinarg).Size(1) = '1';
+ UpdatedInArg(cntinarg).Size(2) = string(length(tmpname)+1); //+1 = (\0)
+ UpdatedInArg(cntinarg).Value = '""'+tmpname+'""';
+ UpdatedInArg(cntinarg).FindLike = 0;
+ UpdatedInArg(cntinarg).Dimension = 2; //NUT: in future releases you can set this field to 1.
+ UpdatedInArg(cntinarg).Scope = 'Temp';
+
+ // #RNU_RES_B
+ // Add the new symbol in the symbol table.
+ // #RNU_RES_E
+ ST_InsOutArg(UpdatedInArg(cntinarg),1,FileInfo,SharedInfo,'all');
+
+ elseif (tmpscope == 'Variable' | tmpscope == 'Global' | tmpscope == 'Local' | tmpscope == 'Temp')
+ // #RNU_RES_B
+ //NUT: nelle future versioni qui si puo' fare una utile differenziazione per rendere piu' intelligente il tutto.
+ PrintStringInfo('Input Argument '+string(cntinarg)+' is a symbol: '+tmpname+'.',FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
+ // #RNU_RES_E
+ [TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension,TBScope] = ST_GetSymbolInfo(tmpname,FileInfo,SharedInfo);
+ if (TBFlagfound == 0)
+ PrintStringInfo(' ',ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: Unknown symbol ""'+tmpname+'"".',ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: Be sure to initialize every symbol you are using.',ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: Before running the SCI2C translator, remember to run the code you are trying',ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: to translate in order to check syntax errors.',ReportFileName,'both','y');
+ PrintStringInfo(' ',ReportFileName,'both','y');
+ SCI2Cerror(' ');
+ end
+ UpdatedInArg(cntinarg).Type = TBType;
+ UpdatedInArg(cntinarg).Size = TBSize;
+ UpdatedInArg(cntinarg).Value = TBValue;
+ UpdatedInArg(cntinarg).FindLike = TBFindLike;
+ UpdatedInArg(cntinarg).Dimension = TBDimension;
+ UpdatedInArg(cntinarg).Scope = TBScope;
+
+ else
+ SCI2Cerror('Unknown scope identifier ""'+tmpscope+'"" for variable ""'+tmpname+'"".');
+ end
+ // #RNU_RES_B
+ PrintStringInfo(' Type: '+UpdatedInArg(cntinarg).Type,FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
+ PrintStringInfo(' Size(1): '+string(UpdatedInArg(cntinarg).Size(1)),FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
+ PrintStringInfo(' Size(2): '+string(UpdatedInArg(cntinarg).Size(2)),FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
+ PrintStringInfo(' Value: '+string(UpdatedInArg(cntinarg).Value),FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
+ PrintStringInfo(' FindLike: '+string(UpdatedInArg(cntinarg).FindLike),FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
+ PrintStringInfo(' Dimension: '+string(UpdatedInArg(cntinarg).Dimension),FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
+ PrintStringInfo(' Scope: '+UpdatedInArg(cntinarg).Scope,FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
+ // #RNU_RES_E
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/SymbolTable/ST_GetSymbolInfo.sci b/src/Scilab2C/Scilab2C/SymbolTable/ST_GetSymbolInfo.sci index e19611d6..1fb2f3de 100644 --- a/src/Scilab2C/Scilab2C/SymbolTable/ST_GetSymbolInfo.sci +++ b/src/Scilab2C/Scilab2C/SymbolTable/ST_GetSymbolInfo.sci @@ -1,53 +1,99 @@ -function [TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension,TBScope] = ST_GetSymbolInfo(TBName,FileInfo,SharedInfo) -// function [TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension,TBScope] = ST_GetSymbolInfo(TBName,FileInfo,SharedInfo) -// ----------------------------------------------------------------- -// -// Status: -// 26-Oct-2007 -- Raffaele Nutricato: Author. -// 26-Oct-2007 -- Alberto Morea: Test Ok. -// -// Copyright 2007 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),3,3); - -nxtscifunname = SharedInfo.NextSCIFunName; -nxtscifunnumber = SharedInfo.NextSCIFunNumber; - -GlobalVarsFileName = FileInfo.GlobalVarFileName; -LocalVarsFileName = FileInfo.Funct(nxtscifunnumber).LocalVarFileName; -TempVarsFileName = FileInfo.Funct(nxtscifunnumber).TempVarFileName; - -TBFlagfound = 0; -TBType = ''; -TBSize(1) = ''; -TBSize(2) = ''; -TBValue = %nan -TBFindLike = %nan -TBDimension = %nan; -TBScope = ''; - -[TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension] = ... - ST_Get(TBName,TempVarsFileName); -if (TBFlagfound == 1); - TBScope = 'Temp'; -end - -if (TBFlagfound == 0); - [TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension] = ... - ST_Get(TBName,LocalVarsFileName); - if (TBFlagfound == 1); - TBScope = 'Local'; - end -end - -if (TBFlagfound == 0); - [TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension] = ... - ST_Get(TBName,GlobalVarsFileName); - if (TBFlagfound == 1); - TBScope = 'Global'; - end -end - -endfunction +function [TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension,TBScope] = ST_GetSymbolInfo(TBName,FileInfo,SharedInfo)
+// function [TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension,TBScope] = ST_GetSymbolInfo(TBName,FileInfo,SharedInfo)
+// -----------------------------------------------------------------
+// //NUT: add description here
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),3,3);
+
+// -----------------------
+// --- Initialization. ---
+// -----------------------
+// --- Extraction of the function name and number. ---
+nxtscifunname = SharedInfo.NextSCIFunName;
+nxtscifunnumber = SharedInfo.NextSCIFunNumber;
+
+GlobalVarsFileName = FileInfo.GlobalVarFileName;
+LocalVarsFileName = FileInfo.Funct(nxtscifunnumber).LocalVarFileName;
+TempVarsFileName = FileInfo.Funct(nxtscifunnumber).TempVarFileName;
+
+TBFlagfound = 0;
+TBType = '';
+TBSize(1) = '';
+TBSize(2) = '';
+TBValue = %nan
+TBFindLike = %nan
+TBDimension = %nan;
+TBScope = '';
+// ---------------------------
+// --- End Initialization. ---
+// ---------------------------
+
+// #RNU_RES_B
+// ------------------------------------------------
+// --- Search in the temporary variables table. ---
+// ------------------------------------------------
+PrintStringInfo('Searching ""'+TBName+'"" in '+FileInfo.Funct(nxtscifunnumber).TempVarFileName+'.',FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
+// #RNU_RES_E
+[TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension] = ...
+ ST_Get(TBName,TempVarsFileName);
+if (TBFlagfound == 1);
+ // #RNU_RES_B
+ PrintStringInfo('...Found in: ""'+FileInfo.Funct(nxtscifunnumber).TempVarFileName+'.',FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
+ // #RNU_RES_E
+ TBScope = 'Temp';
+end
+
+// --------------------------------------------
+// --- Search in the local variables table. ---
+// --------------------------------------------
+if (TBFlagfound == 0);
+ // #RNU_RES_B
+ PrintStringInfo('Searching ""'+TBName+'"" in '+FileInfo.Funct(nxtscifunnumber).LocalVarFileName+'.',FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
+ // #RNU_RES_E
+ [TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension] = ...
+ ST_Get(TBName,LocalVarsFileName);
+ if (TBFlagfound == 1);
+ // #RNU_RES_B
+ PrintStringInfo('...Found in: ""'+FileInfo.Funct(nxtscifunnumber).LocalVarFileName+'.',FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
+ // #RNU_RES_E
+ TBScope = 'Local';
+ end
+end
+
+// #RNU_RES_B
+// ---------------------------------------------
+// --- Search in the global variables table. ---
+// ---------------------------------------------
+// #RNU_RES_E
+if (TBFlagfound == 0);
+ // #RNU_RES_B
+ PrintStringInfo('Searching ""'+TBName+'"" in '+FileInfo.GlobalVarFileName+'.',FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
+ // #RNU_RES_E
+ [TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension] = ...
+ ST_Get(TBName,GlobalVarsFileName);
+ if (TBFlagfound == 1);
+ // #RNU_RES_B
+ PrintStringInfo('...Found in: ""'+FileInfo.GlobalVarFileName+'.',FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
+ // #RNU_RES_E
+ TBScope = 'Global';
+ end
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/SymbolTable/ST_InsForCntVars.sci b/src/Scilab2C/Scilab2C/SymbolTable/ST_InsForCntVars.sci index 907fa10f..b0e6f356 100644 --- a/src/Scilab2C/Scilab2C/SymbolTable/ST_InsForCntVars.sci +++ b/src/Scilab2C/Scilab2C/SymbolTable/ST_InsForCntVars.sci @@ -1,116 +1,191 @@ -function [OutArg,SharedInfo] = ST_InsForCntVars(InArg,NInArg,OutArg,NOutArg,FunctionName,FileInfo,SharedInfo) -// function [OutArg,SharedInfo] = ST_InsForCntVars(InArg,NInArg,OutArg,NOutArg,FunctionName,FileInfo,SharedInfo) -// ----------------------------------------------------------------- -// -// Status: -// 26-Oct-2007 -- Raffaele Nutricato: Author. -// 26-Oct-2007 -- Alberto Morea: Test Ok. -// -// Copyright 2007 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - - -SCI2CNInArgCheck(argn(2),7,7); - -nxtscifunname = SharedInfo.NextSCIFunName; -nxtscifunnumber = SharedInfo.NextSCIFunNumber; -ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; - - -if ((SharedInfo.ForExpr.OnExec > 0) & (NOutArg==1) & (OutArg.Scope~='Temp')) - - if (FunctionName == 'OpColon') - - SharedInfo.SkipNextFun = 1; - - OutArg.Size(1) = '1'; - OutArg.Size(2) = '1'; - OutArg.Value = %nan; - OutArg.FindLike = 0; - OutArg.Dimension = 0; - SharedInfo.ForExpr.OpColonInfoIn1 = InArg(1).Name; - - if (NInArg == 2) - SharedInfo.ForExpr.OpColonInfoIn2 = '1'; - SharedInfo.ForExpr.OpColonInfoIn3 = InArg(2).Name; - else - SharedInfo.ForExpr.OpColonInfoIn2 = InArg(2).Name; - if isnan(InArg(2).Value) - EM_UnknownStep(ReportFileName); - end - - SharedInfo.ForExpr.OpColonInfoIn3 = InArg(3).Name; - end - - SharedInfo.ForExpr.AssignmentFun = SharedInfo.CFunId.OpColon; - SharedInfo.ForExpr.IntCntArg = []; - SharedInfo.ForExpr.MtxValCntArg = []; - SharedInfo.ForExpr.SclValCntArg = OutArg; - - elseif ((FunctionName == 'OpEqual') & (SharedInfo.ForExpr.AssignmentFun == 0)) - if (OutArg.Dimension > 0) - SharedInfo.SkipNextFun = 1; - OutArg.Size(1) = '1'; - OutArg.Size(2) = '1'; - OutArg.Value = %nan; - OutArg.FindLike = 0; - OutArg.Dimension = 0; - - NNewArg = 1; - NewArg(NNewArg).Name = SharedInfo.ASTReader.TempForCntVarsName+string(SharedInfo.CountForTempVars); - SharedInfo.CountForTempVars = SharedInfo.CountForTempVars + 1; - NewArg(NNewArg).Size(1) = '1'; - NewArg(NNewArg).Size(2) = '1'; - NewArg(NNewArg).Type = 'i'; - NewArg(NNewArg).Value = 0; - NewArg(NNewArg).FindLike = 0; - NewArg(NNewArg).Dimension = 0; - NewArg(NNewArg).Scope = 'Temp'; - - NNewArg = 1; - ST_InsOutArg(NewArg,NNewArg,FileInfo,SharedInfo,'all'); - - SharedInfo.ForExpr.AssignmentFun = SharedInfo.CFunId.EqMatrix; - SharedInfo.ForExpr.IntCntArg = NewArg(1); - SharedInfo.ForExpr.MtxValCntArg = InArg(1); - SharedInfo.ForExpr.SclValCntArg = OutArg; - else - SharedInfo.ForExpr.AssignmentFun = SharedInfo.CFunId.EqScalar; - end - else - if (OutArg.Dimension > 0) - - NewArg = OutArg; - OutArg.Name = SharedInfo.ASTReader.TempForValVarsName+OutArg.Name; - - NNewArg = 1; - NewArg(NNewArg).Size(1) = '1'; - NewArg(NNewArg).Size(2) = '1'; - NewArg(NNewArg).Value = %nan; - NewArg(NNewArg).FindLike = 0; - NewArg(NNewArg).Dimension = 0; - - NNewArg = 2; - NewArg(NNewArg).Name = SharedInfo.ASTReader.TempForCntVarsName+string(SharedInfo.CountForTempVars); - SharedInfo.CountForTempVars = SharedInfo.CountForTempVars + 1; - NewArg(NNewArg).Size(1) = '1'; - NewArg(NNewArg).Size(2) = '1'; - NewArg(NNewArg).Type = 'i'; - NewArg(NNewArg).Value = 0; - NewArg(NNewArg).FindLike = 0; - NewArg(NNewArg).Dimension = 0; - NewArg(NNewArg).Scope = 'Temp'; - - NNewArg = 2; - ST_InsOutArg(NewArg,NNewArg,FileInfo,SharedInfo,'all'); - - SharedInfo.ForExpr.AssignmentFun = SharedInfo.CFunId.GenFunMtx; - SharedInfo.ForExpr.IntCntArg = NewArg(2); - SharedInfo.ForExpr.MtxValCntArg = OutArg(1); - SharedInfo.ForExpr.SclValCntArg = NewArg(1); - end - end -end - -endfunction +function [OutArg,SharedInfo] = ST_InsForCntVars(InArg,NInArg,OutArg,NOutArg,FunctionName,FileInfo,SharedInfo)
+// function [OutArg,SharedInfo] = ST_InsForCntVars(InArg,NInArg,OutArg,NOutArg,FunctionName,FileInfo,SharedInfo)
+// -----------------------------------------------------------------
+// //NUT: add description here
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),7,7);
+
+// -----------------------
+// --- Initialization. ---
+// -----------------------
+nxtscifunname = SharedInfo.NextSCIFunName;
+nxtscifunnumber = SharedInfo.NextSCIFunNumber;
+ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName;
+
+// #RNU_RES_B
+PrintStringInfo(' ',ReportFileName,'file','y');
+PrintStringInfo('***Checking if the current function is handling for counter variables.***',ReportFileName,'file','y');
+// #RNU_RES_E
+
+// ---------------------------
+// --- End Initialization. ---
+// ---------------------------
+
+// -----------------------------------------------
+// --- Initial Check on For counter variables. ---
+// -----------------------------------------------
+if ((SharedInfo.ForExpr.OnExec > 0) & (NOutArg==1) & (OutArg.Scope~='Temp'))
+ // #RNU_RES_B
+ // If we are here, for sure we are in the last assignment of a for loop expression.
+ //
+ // All the following cases must be handled:
+ // OpColon (1,10,cnt) or Opcolon (1,1,10,cnt) --> cnt must be redefined to dim=0
+ // cnt = a; where a is scalar
+ // OpEqual(TMP,cnt); where TMP is matrix --> cnt must be redefined to dim=0, a SCI2Cint counter must be generated
+ // Fun(TMP,cnt); where TMP is matrix.--> cnt must be redefined to dim=0, a SCI2Cint counter must be generated, CNT must be generated where CNT is a Matrix
+ // #RNU_RES_E
+ if (FunctionName == 'OpColon')
+ // #RNU_RES_B
+ PrintStringInfo(' The for expression is using an OpColon-based assignment',ReportFileName,'file','y');
+ // #RNU_RES_E
+ SharedInfo.SkipNextFun = 1;
+
+ OutArg.Size(1) = '1';
+ OutArg.Size(2) = '1';
+ OutArg.Value = %nan;
+ OutArg.FindLike = 0;
+ OutArg.Dimension = 0;
+ SharedInfo.ForExpr.OpColonInfoIn1 = InArg(1).Name;
+
+ if (NInArg == 2)
+ SharedInfo.ForExpr.OpColonInfoIn2 = '1';
+ SharedInfo.ForExpr.OpColonInfoIn3 = InArg(2).Name;
+ else
+ SharedInfo.ForExpr.OpColonInfoIn2 = InArg(2).Name;
+ if isnan(InArg(2).Value)
+ EM_UnknownStep(ReportFileName);
+ end
+
+ SharedInfo.ForExpr.OpColonInfoIn3 = InArg(3).Name;
+ end
+
+ // #RNU_RES_B
+ // Generate all info to generate the C for expression
+ // #RNU_RES_E
+ SharedInfo.ForExpr.AssignmentFun = SharedInfo.CFunId.OpColon;
+ SharedInfo.ForExpr.IntCntArg = [];
+ SharedInfo.ForExpr.MtxValCntArg = [];
+ SharedInfo.ForExpr.SclValCntArg = OutArg;
+
+ elseif ((FunctionName == 'OpEqual') & (SharedInfo.ForExpr.AssignmentFun == 0))
+ // #RNU_RES_B
+ //NUT: Test also that SharedInfo.ForExpr.AssignmentFun because sometimes Equal are dummy!
+ //NUT: verifica se e' giusta questa mia affermazione.
+ // #RNU_RES_E
+ if (OutArg.Dimension > 0)
+ // #RNU_RES_B
+ PrintStringInfo(' The for expression is using a Matrix-Equal-based assignment',ReportFileName,'file','y');
+ // #RNU_RES_E
+ SharedInfo.SkipNextFun = 1; //NUT: forse qui sarebbe meglio mettere uno skipnextequal per precisione.
+ // #RNU_RES_B
+ //NUT: a dire il vero occorre capire se c'e' differenza tra i vari skip.
+ // #RNU_RES_E
+ OutArg.Size(1) = '1';
+ OutArg.Size(2) = '1';
+ OutArg.Value = %nan;
+ OutArg.FindLike = 0;
+ OutArg.Dimension = 0;
+
+ // #RNU_RES_B
+ // Introduce the int counter variable.
+ // #RNU_RES_E
+ NNewArg = 1;
+ NewArg(NNewArg).Name = SharedInfo.ASTReader.TempForCntVarsName+string(SharedInfo.CountForTempVars);
+ SharedInfo.CountForTempVars = SharedInfo.CountForTempVars + 1;
+ NewArg(NNewArg).Size(1) = '1';
+ NewArg(NNewArg).Size(2) = '1';
+ NewArg(NNewArg).Type = 'i';
+ NewArg(NNewArg).Value = 0;
+ NewArg(NNewArg).FindLike = 0;
+ NewArg(NNewArg).Dimension = 0;
+ NewArg(NNewArg).Scope = 'Temp';
+
+ // #RNU_RES_B
+ // Insert New Arguments in the symbol table.
+ // #RNU_RES_E
+ NNewArg = 1;
+ ST_InsOutArg(NewArg,NNewArg,FileInfo,SharedInfo,'all');
+
+ // #RNU_RES_B
+ // Generate all info to generate the C for expression
+ // #RNU_RES_E
+ SharedInfo.ForExpr.AssignmentFun = SharedInfo.CFunId.EqMatrix;
+ SharedInfo.ForExpr.IntCntArg = NewArg(1);
+ SharedInfo.ForExpr.MtxValCntArg = InArg(1);
+ SharedInfo.ForExpr.SclValCntArg = OutArg;
+ else
+ // #RNU_RES_B
+ PrintStringInfo(' The for expression is using a Scalar-Equal-based assignment',ReportFileName,'file','y');
+ // #RNU_RES_E
+ SharedInfo.ForExpr.AssignmentFun = SharedInfo.CFunId.EqScalar;
+ end
+ else
+ if (OutArg.Dimension > 0)
+ // #RNU_RES_B
+ PrintStringInfo(' The for expression is using a Matrix-Function-based assignment',ReportFileName,'file','y');
+
+ // Introduce the val counter variable.
+ // #RNU_RES_E
+ NewArg = OutArg;
+ OutArg.Name = SharedInfo.ASTReader.TempForValVarsName+OutArg.Name;
+
+ // #RNU_RES_B
+ // Set the counter variable to scalar.
+ // #RNU_RES_E
+ NNewArg = 1;
+ NewArg(NNewArg).Size(1) = '1';
+ NewArg(NNewArg).Size(2) = '1';
+ NewArg(NNewArg).Value = %nan;
+ NewArg(NNewArg).FindLike = 0;
+ NewArg(NNewArg).Dimension = 0;
+
+ // #RNU_RES_B
+ // Introduce the int counter variable.
+ // #RNU_RES_E
+ NNewArg = 2;
+ NewArg(NNewArg).Name = SharedInfo.ASTReader.TempForCntVarsName+string(SharedInfo.CountForTempVars);
+ SharedInfo.CountForTempVars = SharedInfo.CountForTempVars + 1;
+ NewArg(NNewArg).Size(1) = '1';
+ NewArg(NNewArg).Size(2) = '1';
+ NewArg(NNewArg).Type = 'i';
+ NewArg(NNewArg).Value = 0;
+ NewArg(NNewArg).FindLike = 0;
+ NewArg(NNewArg).Dimension = 0;
+ NewArg(NNewArg).Scope = 'Temp';
+
+ // #RNU_RES_B
+ // Insert New Arguments in the symbol table.
+ // #RNU_RES_E
+ NNewArg = 2;
+ ST_InsOutArg(NewArg,NNewArg,FileInfo,SharedInfo,'all');
+
+ // #RNU_RES_B
+ // Generate all info to generate the C for expression
+ // #RNU_RES_E
+ SharedInfo.ForExpr.AssignmentFun = SharedInfo.CFunId.GenFunMtx;
+ SharedInfo.ForExpr.IntCntArg = NewArg(2);
+ SharedInfo.ForExpr.MtxValCntArg = OutArg(1);
+ SharedInfo.ForExpr.SclValCntArg = NewArg(1);
+ end
+ end
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/SymbolTable/ST_InsOutArg.sci b/src/Scilab2C/Scilab2C/SymbolTable/ST_InsOutArg.sci index d4817adb..f0df5388 100644 --- a/src/Scilab2C/Scilab2C/SymbolTable/ST_InsOutArg.sci +++ b/src/Scilab2C/Scilab2C/SymbolTable/ST_InsOutArg.sci @@ -1,114 +1,187 @@ -function ST_InsOutArg(OutArg,NOutArg,FileInfo,SharedInfo,MatchRule) -// function ST_InsOutArg(OutArg,NOutArg,FileInfo,SharedInfo,MatchRule) -// ----------------------------------------------------------------- -// -// Status: -// 26-Oct-2007 -- Raffaele Nutricato: Author. -// 26-Oct-2007 -- Alberto Morea: Test Ok. -// -// Copyright 2007 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - - -SCI2CNInArgCheck(argn(2),5,5); - -nxtscifunname = SharedInfo.NextSCIFunName; -nxtscifunnumber = SharedInfo.NextSCIFunNumber; -ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; -CDeclarationFileName = FileInfo.Funct(nxtscifunnumber).CDeclarationFileName; -CGblDeclarFileName = FileInfo.Funct(nxtscifunnumber).CGblDeclarFileName; - -GlobalVarsFileName = FileInfo.GlobalVarFileName; -LocalVarsFileName = FileInfo.Funct(nxtscifunnumber).LocalVarFileName; -TempVarsFileName = FileInfo.Funct(nxtscifunnumber).TempVarFileName; - -CPass1FileName = FileInfo.Funct(nxtscifunnumber).CPass1FileName; -CPass1FreeFileName = FileInfo.Funct(nxtscifunnumber).CPass1FreeFileName; - - - - -for counteroutput = 1:NOutArg - - if mtlb_strcmp(OutArg(counteroutput).Scope,'Temp') - SymbTableFileName = TempVarsFileName; - elseif mtlb_strcmp(OutArg(counteroutput).Scope,'Local') - SymbTableFileName = LocalVarsFileName; - elseif mtlb_strcmp(OutArg(counteroutput).Scope,'Global') - SymbTableFileName = GlobalVarsFileName; - else - SCI2Cerror('Unknown scope ""'+OutArg(counteroutput).Scope+'"" for symbol: '+OutArg(counteroutput).Name); - end - - - [TBFlagfound,TBFlagEqualSymbols] = ... - ST_MatchSymbol(OutArg(counteroutput).Name,... - OutArg(counteroutput).Type,... - OutArg(counteroutput).Size,... - OutArg(counteroutput).Value,... - OutArg(counteroutput).FindLike,... - OutArg(counteroutput).Dimension,... - SymbTableFileName,MatchRule); - - if (TBFlagfound == 1) - if (TBFlagEqualSymbols == 0) - PrintStringInfo(' ',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: Symbol Table Conflict. Trying to insert again symbol ""'+... - OutArg(counteroutput).Name+'"" with different settings',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: Please check that you are not using variable ""'+OutArg(counteroutput).Name+'""',ReportFileName,'both','y'); - PrintStringInfo('SCI2CERROR: with different sizes and/or types.',ReportFileName,'both','y'); - PrintStringInfo(' ',ReportFileName,'both','y'); - SCI2Cerror(' '); - else - if ((GetSymbolDimension(OutArg(counteroutput).Size)) == 0) - ST_Set(OutArg(counteroutput).Name,... - OutArg(counteroutput).Type,... - OutArg(counteroutput).Size,... - OutArg(counteroutput).Value,... - OutArg(counteroutput).FindLike,... - OutArg(counteroutput).Dimension,... - SymbTableFileName); - end - if (OutArg(counteroutput).Scope=='Global') - IndentLevelGlobal = 0; //NUT: forced always to 1 - FlagExt = 1; - C_GenDeclarations(OutArg(counteroutput),CGblDeclarFileName,IndentLevelGlobal,ReportFileName,FlagExt); - end - end - elseif (TBFlagfound == 2) - ST_Set(OutArg(counteroutput).Name,... - OutArg(counteroutput).Type,... - OutArg(counteroutput).Size,... - OutArg(counteroutput).Value,... - OutArg(counteroutput).FindLike,... - OutArg(counteroutput).Dimension,... - SymbTableFileName); - IndentLevel = 0; //NUT: forced always to 1 - FlagExt = 0; - C_GenDeclarations(OutArg(counteroutput),CGblDeclarFileName,IndentLevel,ReportFileName,FlagExt); - else - if (OutArg(counteroutput).FindLike == 1) - TmpOutArgSize(1) = '__'+OutArg(counteroutput).Name+'Size[0]'; - TmpOutArgSize(2) = '__'+OutArg(counteroutput).Name+'Size[1]'; - else - TmpOutArgSize(1) = OutArg(counteroutput).Size(1); - TmpOutArgSize(2) = OutArg(counteroutput).Size(2); - end - ST_Set(OutArg(counteroutput).Name,... - OutArg(counteroutput).Type,... - TmpOutArgSize,... - OutArg(counteroutput).Value,... - OutArg(counteroutput).FindLike,... - OutArg(counteroutput).Dimension,... - SymbTableFileName); - IndentLevelDeclaration = 1; //NUT: per ora lo forzo sempre a 1 - IndentLevelMalloc = SharedInfo.NIndent; - FlagExt = 0; - C_GenDeclarations(OutArg(counteroutput),CDeclarationFileName,IndentLevelDeclaration,ReportFileName,FlagExt); - C_MemAllocOutTempVars(OutArg(counteroutput),1,CPass1FileName,CPass1FreeFileName,IndentLevelMalloc,ReportFileName); - end - -end - -endfunction +function ST_InsOutArg(OutArg,NOutArg,FileInfo,SharedInfo,MatchRule)
+// function ST_InsOutArg(OutArg,NOutArg,FileInfo,SharedInfo,MatchRule)
+// -----------------------------------------------------------------
+// //NUT: add description here
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),5,5);
+
+// -----------------------
+// --- Initialization. ---
+// -----------------------
+nxtscifunname = SharedInfo.NextSCIFunName;
+nxtscifunnumber = SharedInfo.NextSCIFunNumber;
+ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName;
+CDeclarationFileName = FileInfo.Funct(nxtscifunnumber).CDeclarationFileName;
+CGblDeclarFileName = FileInfo.Funct(nxtscifunnumber).CGblDeclarFileName;
+
+GlobalVarsFileName = FileInfo.GlobalVarFileName;
+LocalVarsFileName = FileInfo.Funct(nxtscifunnumber).LocalVarFileName;
+TempVarsFileName = FileInfo.Funct(nxtscifunnumber).TempVarFileName;
+
+CPass1FileName = FileInfo.Funct(nxtscifunnumber).CPass1FileName;
+CPass1FreeFileName = FileInfo.Funct(nxtscifunnumber).CPass1FreeFileName;
+
+
+// #RNU_RES_B
+PrintStringInfo(' ',ReportFileName,'file','y');
+PrintStringInfo('***Putting output arguments in the symbol table***',ReportFileName,'file','y');
+// #RNU_RES_E
+// ---------------------------
+// --- End Initialization. ---
+// ---------------------------
+
+
+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');
+ // #RNU_RES_E
+
+ if mtlb_strcmp(OutArg(counteroutput).Scope,'Temp')
+ SymbTableFileName = TempVarsFileName;
+ elseif mtlb_strcmp(OutArg(counteroutput).Scope,'Local')
+ SymbTableFileName = LocalVarsFileName;
+ elseif mtlb_strcmp(OutArg(counteroutput).Scope,'Global')
+ SymbTableFileName = GlobalVarsFileName;
+ else
+ SCI2Cerror('Unknown scope ""'+OutArg(counteroutput).Scope+'"" for symbol: '+OutArg(counteroutput).Name);
+ end
+ // #RNU_RES_B
+ PrintStringInfo(' Setting symbol ""'+OutArg(counteroutput).Name+'"" in '+SymbTableFileName+'.',ReportFileName,'file','y');
+ // #RNU_RES_E
+
+ // #RNU_RES_B
+ // Check existence and conflicts in the symbol table.
+ // Here we have four possibilities:
+ // 1. the symbol is a global variable not initialized yet -> we have to initialize it.
+ // 2. the symbol already exists with different settings -> we have to issue an error.
+ // 3. the symbol already exists with the same settings -> ok, we don't have to do nothing.
+ // 4. the symbol doesn't exist -> we have to insert it into the table.
+ // #RNU_RES_E
+ [TBFlagfound,TBFlagEqualSymbols] = ...
+ ST_MatchSymbol(OutArg(counteroutput).Name,...
+ OutArg(counteroutput).Type,...
+ OutArg(counteroutput).Size,...
+ OutArg(counteroutput).Value,...
+ OutArg(counteroutput).FindLike,...
+ OutArg(counteroutput).Dimension,...
+ SymbTableFileName,MatchRule);
+
+ if (TBFlagfound == 1)
+ if (TBFlagEqualSymbols == 0)
+ PrintStringInfo(' ',ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: Symbol Table Conflict. Trying to insert again symbol ""'+...
+ OutArg(counteroutput).Name+'"" with different settings',ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: Please check that you are not using variable ""'+OutArg(counteroutput).Name+'""',ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: with different sizes and/or types.',ReportFileName,'both','y');
+ PrintStringInfo(' ',ReportFileName,'both','y');
+ SCI2Cerror(' ');
+ else
+ // #RNU_RES_B
+ // It's ok symbols do match.
+ //NUT: forse occorre un altro check sulla size per capire se occore fare il malloc.
+ //NUT: qui entro anche quando ho una variabile global gia' dichiarata tale in un altro
+ //NUT: per cui devo dichiararala come external.
+ //RNU qui ci puoi mettere una warning quando stai riallocando uno stesso simbolo con size simbolica.
+ //RNU puoi anche aggiungere del codice in c o un semplice commento. per esempio una funzione c del tipo checksize che controlla il valore
+ //RNU prima dopo delle size di una data variabile. Cosa succede se cambio la size anche nel caso di array e approccio
+ //RNU di resize non attivo? L'unica cosa e' che molte size numeriche scompaiono e incomincio a creare numerose variabili
+ //RNU con size simbolica.
+
+ // If the symbol is scalar we update its value if it is an array we update its size
+ // only in case we are using the 'REALLOC_ALL_RESIZE_ALL' resize approach
+ // #RNU_RES_E
+ if ((GetSymbolDimension(OutArg(counteroutput).Size)) == 0 | (SharedInfo.ResizeApproach=='REALLOC_ALL_RESIZE_ALL'))
+ ST_Set(OutArg(counteroutput).Name,...
+ OutArg(counteroutput).Type,...
+ OutArg(counteroutput).Size,...
+ OutArg(counteroutput).Value,...
+ OutArg(counteroutput).FindLike,...
+ OutArg(counteroutput).Dimension,...
+ SymbTableFileName);
+ end
+ end
+ elseif (TBFlagfound == 2)
+ // #RNU_RES_B
+ // We have a non-initialized global variable.
+ // Set the non-initialized global variable.
+ PrintStringInfo(' Found a non-initialized global variable.',ReportFileName,'file','y');
+ // #RNU_RES_E
+ ST_Set(OutArg(counteroutput).Name,...
+ OutArg(counteroutput).Type,...
+ OutArg(counteroutput).Size,...
+ OutArg(counteroutput).Value,...
+ OutArg(counteroutput).FindLike,...
+ OutArg(counteroutput).Dimension,...
+ SymbTableFileName);
+ IndentLevel = 0; //NUT: forced always to 1
+ FlagExt = 0;
+ C_GenDeclarations(OutArg(counteroutput),CGblDeclarFileName,IndentLevel,ReportFileName,FlagExt,SharedInfo.ResizeApproach);
+ IndentLevelMalloc = SharedInfo.NIndent;
+ // #RNU_RES_B
+ //RNU da verificare bene qui. Cio' che si verifica e' che se la size della globale e' simbolica
+ //RNU allora si assume che essa sia da allocare come puntatore e poi realloc.
+ // #RNU_RES_E
+ C_MemAllocOutTempVars(OutArg(counteroutput),1,CPass1FileName,CPass1FreeFileName,IndentLevelMalloc,ReportFileName,SharedInfo.ResizeApproach);
+ else
+ if (OutArg(counteroutput).FindLike == 1)
+ // #RNU_RES_B
+ // In presence of find-like functions the size must be always symbolic.
+ // Don't change here the value of OutArg.Size because the first time
+ // I need them to declare the OutArg variable with the values assumed by OutArg.Size.
+ // #RNU_RES_E
+ TmpOutArgSize(1) = '__'+OutArg(counteroutput).Name+'Size[0]';
+ TmpOutArgSize(2) = '__'+OutArg(counteroutput).Name+'Size[1]';
+ else
+ TmpOutArgSize(1) = OutArg(counteroutput).Size(1);
+ TmpOutArgSize(2) = OutArg(counteroutput).Size(2);
+ end
+ // #RNU_RES_B
+ // Set a new symbol.
+ // #RNU_RES_E
+ ST_Set(OutArg(counteroutput).Name,...
+ OutArg(counteroutput).Type,...
+ TmpOutArgSize,...
+ OutArg(counteroutput).Value,...
+ OutArg(counteroutput).FindLike,...
+ OutArg(counteroutput).Dimension,...
+ SymbTableFileName);
+ IndentLevelDeclaration = 1; //NUT: per ora lo forzo sempre a 1
+ IndentLevelMalloc = SharedInfo.NIndent;
+ FlagExt = 0;
+ C_GenDeclarations(OutArg(counteroutput),CDeclarationFileName,IndentLevelDeclaration,ReportFileName,FlagExt,SharedInfo.ResizeApproach);
+ // #RNU_RES_B
+ //RNU aggiunta qui in modo che le malloc saranno fatte una sola volta:
+ //RNU verifica che tutto funzioni e chi altro usa la C_MemAlloc per capire se si puo' ottimizzare per questo stadio.
+ // #RNU_RES_E
+ C_MemAllocOutTempVars(OutArg(counteroutput),1,CPass1FileName,CPass1FreeFileName,IndentLevelMalloc,ReportFileName,SharedInfo.ResizeApproach);
+ end
+
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/SymbolTable/ST_Load.sci b/src/Scilab2C/Scilab2C/SymbolTable/ST_Load.sci index c272375c..fc99ff3c 100644 --- a/src/Scilab2C/Scilab2C/SymbolTable/ST_Load.sci +++ b/src/Scilab2C/Scilab2C/SymbolTable/ST_Load.sci @@ -1,20 +1,36 @@ -function SCI2CSymbolTable = ST_Load(SymbolTableFileName) -// function SCI2CSymbolTable = ST_Load(SymbolTableFileName) -// ----------------------------------------------------------------- -// -// Status: -// 26-Oct-2007 -- Raffaele Nutricato: Author. -// 26-Oct-2007 -- Alberto Morea: Test Ok. -// -// Copyright 2007 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -[tmpnams,tmptyps,tmpdims,tmpvols]=listvarinfile(SymbolTableFileName); -if (max(size(tmpnams)) > 1) - SCI2Cerror('More than one variable found in ""'+SymbolTableFileName+'"".'); -end -load(SymbolTableFileName,tmpnams); -SCI2CSymbolTable = eval(tmpnams); - -endfunction +function SCI2CSymbolTable = ST_Load(SymbolTableFileName)
+// function SCI2CSymbolTable = ST_Load(SymbolTableFileName)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// Load a symbol table stored into a .dat file.
+// #RNU_RES_E
+//
+// Input data:
+// //NUT: add description here
+//
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// --------------------------
+// --- Load Symbol Table. ---
+// --------------------------
+[tmpnams,tmptyps,tmpdims,tmpvols]=listvarinfile(SymbolTableFileName);
+if (max(size(tmpnams)) > 1)
+ SCI2Cerror('More than one variable found in ""'+SymbolTableFileName+'"".');
+end
+load(SymbolTableFileName,tmpnams);
+SCI2CSymbolTable = eval(tmpnams);
+// ------------------------------
+// --- End Load Symbol Table. ---
+// ------------------------------
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/SymbolTable/ST_MatchSymbol.sci b/src/Scilab2C/Scilab2C/SymbolTable/ST_MatchSymbol.sci index d5273973..621739fb 100644 --- a/src/Scilab2C/Scilab2C/SymbolTable/ST_MatchSymbol.sci +++ b/src/Scilab2C/Scilab2C/SymbolTable/ST_MatchSymbol.sci @@ -1,51 +1,70 @@ -function [TBFlagfound,TBFlagEqualSymbols] = ST_MatchSymbol(TBName,TBType,TBSize,TBValue,TBFindLike,TBDimension,SymbolTableFileName,MatchRule) -// function [TBFlagfound,TBFlagEqualSymbols] = ST_MatchSymbol(TBName,TBType,TBSize,TBValue,TBFindLike,TBDimension,SymbolTableFileName,MatchRule) -// ----------------------------------------------------------------- -// -// Status: -// 26-Oct-2007 -- Raffaele Nutricato: Author. -// 26-Oct-2007 -- Alberto Morea: Test Ok. -// -// Copyright 2007 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - - -SCI2CNInArgCheck(argn(2),8,8); - -TBFlagfound = 0; -TBFlagEqualSymbols = 0; - -[TBFlagfound,tmpType,tmpSize,tmpValue,tmpFindLike,tmpDimension] = ... - ST_Get(TBName,SymbolTableFileName); - -if (TBFlagfound == 1) - if (tmpType == 'GBLToBeDefined') - TBFlagfound = 2; - TBFlagEqualSymbols = 0; - else - TBFlagEqualSymbols = 1; - if (MatchRule == 'type' | MatchRule == 'all') - if (mtlb_strcmp(tmpType,TBType) == %F) - TBFlagEqualSymbols = 0; - end - end - if (MatchRule == 'size' | MatchRule == 'all') - if (tmpDimension ~= TBDimension) - TBFlagEqualSymbols = 0; - end - if (SCI2Cisnum(tmpSize(1))) & (SCI2Cisnum(TBSize(1))) - if (mtlb_strcmp(tmpSize(1),TBSize(1)) == %F) - TBFlagEqualSymbols = 0; - end - end - if (SCI2Cisnum(tmpSize(2))) & (SCI2Cisnum(TBSize(2))) - if (mtlb_strcmp(tmpSize(2),TBSize(2)) == %F) - TBFlagEqualSymbols = 0; - end - end - end - end -end - -endfunction +function [TBFlagfound,TBFlagEqualSymbols] = ST_MatchSymbol(TBName,TBType,TBSize,TBValue,TBFindLike,TBDimension,SymbolTableFileName,MatchRule)
+// function [TBFlagfound,TBFlagEqualSymbols] = ST_MatchSymbol(TBName,TBType,TBSize,TBValue,TBFindLike,TBDimension,SymbolTableFileName,MatchRule)
+// -----------------------------------------------------------------
+// Match function for the symbol table.
+//
+// Input data:
+// MatchRule: can be 'all','type','size','none'
+// //NUT: add description here
+//
+// Output data:
+// TBFlagfound: 0 = if the symbol doesn't exits.
+// 1 = the symbol exits.
+// 2 = the symbol exists but it is a non-initialized global variable.
+// TBFlagEqualSymbols: 0 if the two symbols don't have the same settings,
+// 1 if the two symbols have the same settings.
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),8,8);
+
+TBFlagfound = 0;
+TBFlagEqualSymbols = 0;
+
+// --- Find symbol (If exists). ---
+[TBFlagfound,tmpType,tmpSize,tmpValue,tmpFindLike,tmpDimension] = ...
+ ST_Get(TBName,SymbolTableFileName);
+
+if (TBFlagfound == 1)
+ if (tmpType == 'GBLToBeDefined')
+ TBFlagfound = 2;
+ TBFlagEqualSymbols = 0; // I don't want to force the error issue in ST_InsOutArg.sci
+ else
+ // Symbol already exists. Check that it has the same settings of the current output argument.
+ TBFlagEqualSymbols = 1;
+ if (MatchRule == 'type' | MatchRule == 'all')
+ if (mtlb_strcmp(tmpType,TBType) == %F)
+ TBFlagEqualSymbols = 0;
+ end
+ end
+ if (MatchRule == 'size' | MatchRule == 'all')
+ // First check the dimension.
+ if (tmpDimension ~= TBDimension)
+ TBFlagEqualSymbols = 0;
+ end
+ // Then if the size is a number also its value is compared.
+ if (SCI2Cisnum(tmpSize(1))) & (SCI2Cisnum(TBSize(1)))
+ if (mtlb_strcmp(tmpSize(1),TBSize(1)) == %F)
+ TBFlagEqualSymbols = 0;
+ end
+ end
+ if (SCI2Cisnum(tmpSize(2))) & (SCI2Cisnum(TBSize(2)))
+ if (mtlb_strcmp(tmpSize(2),TBSize(2)) == %F)
+ TBFlagEqualSymbols = 0;
+ end
+ end
+ end
+ end
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/SymbolTable/ST_Save.sci b/src/Scilab2C/Scilab2C/SymbolTable/ST_Save.sci index 2f0cd241..f2109591 100644 --- a/src/Scilab2C/Scilab2C/SymbolTable/ST_Save.sci +++ b/src/Scilab2C/Scilab2C/SymbolTable/ST_Save.sci @@ -1,33 +1,44 @@ -function ST_Save(SymbolTableFileName,SCI2CSymbolTable) -// function ST_Save(SymbolTableFileName,SCI2CSymbolTable) -// ----------------------------------------------------------------- -// -// Status: -// 26-Oct-2007 -- Raffaele Nutricato: Author. -// 26-Oct-2007 -- Alberto Morea: Test Ok. -// -// Copyright 2007 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),2,2); - -[tmpnams,tmptyps,tmpdims,tmpvols]=listvarinfile(SymbolTableFileName); -if (max(size(tmpnams)) > 1) - SCI2Cerror('More than one variable found in ""'+SymbolTableFileName+'"".'); -end - -if (mtlb_strcmp(tmpnams,'GlobalVars')) - GlobalVars = SCI2CSymbolTable; - save(SymbolTableFileName,GlobalVars); -elseif (mtlb_strcmp(tmpnams,'LocalVars')) - LocalVars = SCI2CSymbolTable; - save(SymbolTableFileName,LocalVars); -elseif (mtlb_strcmp(tmpnams,'TempVars')) - TempVars = SCI2CSymbolTable; - save(SymbolTableFileName,TempVars); -else - SCI2Cerror('Unknow table: ""'+tmpnams+'"".'); -end - -endfunction +function ST_Save(SymbolTableFileName,SCI2CSymbolTable)
+// function ST_Save(SymbolTableFileName,SCI2CSymbolTable)
+// -----------------------------------------------------------------
+// Save into a .dat file a symbol table.
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+[tmpnams,tmptyps,tmpdims,tmpvols]=listvarinfile(SymbolTableFileName);
+if (max(size(tmpnams)) > 1)
+ SCI2Cerror('More than one variable found in ""'+SymbolTableFileName+'"".');
+end
+
+// Identifies the Table name and save it into the .dat file.
+if (mtlb_strcmp(tmpnams,'GlobalVars'))
+ GlobalVars = SCI2CSymbolTable;
+ save(SymbolTableFileName,GlobalVars);
+elseif (mtlb_strcmp(tmpnams,'LocalVars'))
+ LocalVars = SCI2CSymbolTable;
+ save(SymbolTableFileName,LocalVars);
+elseif (mtlb_strcmp(tmpnams,'TempVars'))
+ TempVars = SCI2CSymbolTable;
+ save(SymbolTableFileName,TempVars);
+else
+ SCI2Cerror('Unknow table: ""'+tmpnams+'"".');
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/SymbolTable/ST_Set.sci b/src/Scilab2C/Scilab2C/SymbolTable/ST_Set.sci index 158cccf0..778f91aa 100644 --- a/src/Scilab2C/Scilab2C/SymbolTable/ST_Set.sci +++ b/src/Scilab2C/Scilab2C/SymbolTable/ST_Set.sci @@ -1,35 +1,49 @@ -function ST_Set(TBName,TBType,TBSize,TBValue,TBFindLike,TBDimension,SymbolTableFileName) -// function ST_Set(TBName,TBType,TBSize,TBValue,TBFindLike,TBDimension,SymbolTableFileName) -// ----------------------------------------------------------------- -// -// Status: -// 26-Oct-2007 -- Raffaele Nutricato: Author. -// 26-Oct-2007 -- Alberto Morea: Test Ok. -// -// Copyright 2007 Raffaele Nutricato & Alberto Morea. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - - -SCI2CNInArgCheck(argn(2),7,7); - -SCI2CSymbolTable = ST_Load(SymbolTableFileName); - -[TBFlagfound,TBPosition] = ST_FindPos(TBName,SymbolTableFileName); - -if (TBFlagfound == 0) - TBPosition = max(size(SCI2CSymbolTable))+1; -end - -SCI2CSymbolTable(TBPosition).Name = TBName; // string. -SCI2CSymbolTable(TBPosition).Type = TBType; // char. -SCI2CSymbolTable(TBPosition).Size = TBSize; // structure of two strings (Size(1) and Size(2)). -SCI2CSymbolTable(TBPosition).Value = TBValue; // int/real/complex number. %nan when the value is not available or isn't a scalar. -SCI2CSymbolTable(TBPosition).FindLike = TBFindLike; // int number. FindLike = 1, when the symbol comes from a find-like function. - // FindLike = -1 when the function is not find-like but it is making use of input arguments that are find-like. - // FindLike = 0 in all other cases. -SCI2CSymbolTable(TBPosition).Dimension = TBDimension; // int number. - -ST_Save(SymbolTableFileName,SCI2CSymbolTable); - -endfunction +function ST_Set(TBName,TBType,TBSize,TBValue,TBFindLike,TBDimension,SymbolTableFileName)
+// function ST_Set(TBName,TBType,TBSize,TBValue,TBFindLike,TBDimension,SymbolTableFileName)
+// -----------------------------------------------------------------
+// Set function for the symbol table.
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),7,7);
+
+// --- Load symbol table. ---
+SCI2CSymbolTable = ST_Load(SymbolTableFileName);
+
+// --- Find symbol position (If exists). ---
+[TBFlagfound,TBPosition] = ST_FindPos(TBName,SymbolTableFileName);
+
+if (TBFlagfound == 0)
+ TBPosition = max(size(SCI2CSymbolTable))+1;
+end
+
+// --- Update symbol table. ---
+SCI2CSymbolTable(TBPosition).Name = TBName; // string.
+SCI2CSymbolTable(TBPosition).Type = TBType; // char.
+SCI2CSymbolTable(TBPosition).Size = TBSize; // structure of two strings (Size(1) and Size(2)).
+SCI2CSymbolTable(TBPosition).Value = TBValue; // int/real/complex number. %nan when the value is not available or isn't a scalar.
+SCI2CSymbolTable(TBPosition).FindLike = TBFindLike; // int number. FindLike = 1, when the symbol comes from a find-like function.
+ // FindLike = -1 when the function is not find-like but it is making use of input arguments that are find-like.
+ // FindLike = 0 in all other cases.
+SCI2CSymbolTable(TBPosition).Dimension = TBDimension; // int number.
+
+// --- Save symbol table. ---
+ST_Save(SymbolTableFileName,SCI2CSymbolTable);
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/ToolInitialization/INIT_CreateDirs.sci b/src/Scilab2C/Scilab2C/ToolInitialization/INIT_CreateDirs.sci index ea2d45ef..e6ef184e 100644 --- a/src/Scilab2C/Scilab2C/ToolInitialization/INIT_CreateDirs.sci +++ b/src/Scilab2C/Scilab2C/ToolInitialization/INIT_CreateDirs.sci @@ -1,48 +1,65 @@ -function INIT_CreateDirs(FileInfo) -// function INIT_CreateDirs(FileInfo) -// ----------------------------------------------------------------- -// -// Status: -// 03-Jan-2008 -- Raffaele Nutricato: Author. -// -// Copyright 2008 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),1,1); - -SCI2CCreateDir(FileInfo.WorkingDir); -SCI2CCreateDir(FileInfo.OutCCCodeDir); - -SCI2CCreateDir(FileInfo.SCI2CLibDir); -SCI2CCreateDir(FileInfo.SCI2CLibSCIAnnDir); -SCI2CCreateDir(FileInfo.SCI2CLibSCIAnnFun); -SCI2CCreateDir(FileInfo.SCI2CLibSCIAnnCls); -SCI2CCreateDir(FileInfo.SCI2CLibSCIFunListDir); -SCI2CCreateDir(FileInfo.SCI2CLibSCIFLFun); -SCI2CCreateDir(FileInfo.SCI2CLibSCIFLCls); -SCI2CCreateDir(FileInfo.SCI2CLibCAnnDir); -SCI2CCreateDir(FileInfo.SCI2CLibCAnnFun); -SCI2CCreateDir(FileInfo.SCI2CLibCAnnCls); -SCI2CCreateDir(FileInfo.SCI2CLibCFunListDir); -SCI2CCreateDir(FileInfo.SCI2CLibCFLFun); -SCI2CCreateDir(FileInfo.SCI2CLibCFLCls); - -SCI2CCreateDir(FileInfo.USER2CLibDir); -SCI2CCreateDir(FileInfo.USER2CLibSCIAnnDir); -SCI2CCreateDir(FileInfo.USER2CLibSCIAnnFun); -SCI2CCreateDir(FileInfo.USER2CLibSCIAnnCls); -SCI2CCreateDir(FileInfo.USER2CLibSCIFunListDir); -SCI2CCreateDir(FileInfo.USER2CLibSCIFLFun); -SCI2CCreateDir(FileInfo.USER2CLibSCIFLCls); -SCI2CCreateDir(FileInfo.USER2CLibCAnnDir); -SCI2CCreateDir(FileInfo.USER2CLibCAnnFun); -SCI2CCreateDir(FileInfo.USER2CLibCAnnCls); -SCI2CCreateDir(FileInfo.USER2CLibCFunListDir); -SCI2CCreateDir(FileInfo.USER2CLibCFLFun); -SCI2CCreateDir(FileInfo.USER2CLibCFLCls); - -SCI2CCreateDir(FileInfo.FunctionList.MainDir); -SCI2CCreateDir(FileInfo.FunctionList.FunInfoDatDir); - -endfunction +function INIT_CreateDirs(FileInfo)
+// function INIT_CreateDirs(FileInfo)
+// -----------------------------------------------------------------
+// Create directories.
+//
+// Input data:
+// FileInfo: structure containing all info about SCI2C files.
+//
+// Output data:
+// ---
+//
+// Status:
+// 03-Jan-2008 -- Raffaele Nutricato: Author.
+//
+// Copyright 2008 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+// ---------------------------
+// --- Create Directories. ---
+// ---------------------------
+// --- Main directories. ---
+SCI2CCreateDir(FileInfo.WorkingDir);
+SCI2CCreateDir(FileInfo.OutCCCodeDir);
+
+// --- SCI2C Library. ---
+SCI2CCreateDir(FileInfo.SCI2CLibDir);
+SCI2CCreateDir(FileInfo.SCI2CLibSCIAnnDir);
+SCI2CCreateDir(FileInfo.SCI2CLibSCIAnnFun);
+SCI2CCreateDir(FileInfo.SCI2CLibSCIAnnCls);
+SCI2CCreateDir(FileInfo.SCI2CLibSCIFunListDir);
+SCI2CCreateDir(FileInfo.SCI2CLibSCIFLFun);
+SCI2CCreateDir(FileInfo.SCI2CLibSCIFLCls);
+SCI2CCreateDir(FileInfo.SCI2CLibCAnnDir);
+SCI2CCreateDir(FileInfo.SCI2CLibCAnnFun);
+SCI2CCreateDir(FileInfo.SCI2CLibCAnnCls);
+SCI2CCreateDir(FileInfo.SCI2CLibCFunListDir);
+SCI2CCreateDir(FileInfo.SCI2CLibCFLFun);
+SCI2CCreateDir(FileInfo.SCI2CLibCFLCls);
+
+// --- USER2C Library. ---
+SCI2CCreateDir(FileInfo.USER2CLibDir);
+SCI2CCreateDir(FileInfo.USER2CLibSCIAnnDir);
+SCI2CCreateDir(FileInfo.USER2CLibSCIAnnFun);
+SCI2CCreateDir(FileInfo.USER2CLibSCIAnnCls);
+SCI2CCreateDir(FileInfo.USER2CLibSCIFunListDir);
+SCI2CCreateDir(FileInfo.USER2CLibSCIFLFun);
+SCI2CCreateDir(FileInfo.USER2CLibSCIFLCls);
+SCI2CCreateDir(FileInfo.USER2CLibCAnnDir);
+SCI2CCreateDir(FileInfo.USER2CLibCAnnFun);
+SCI2CCreateDir(FileInfo.USER2CLibCAnnCls);
+SCI2CCreateDir(FileInfo.USER2CLibCFunListDir);
+SCI2CCreateDir(FileInfo.USER2CLibCFLFun);
+SCI2CCreateDir(FileInfo.USER2CLibCFLCls);
+
+// --- Function List. ---
+SCI2CCreateDir(FileInfo.FunctionList.MainDir);
+SCI2CCreateDir(FileInfo.FunctionList.FunInfoDatDir);
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/ToolInitialization/INIT_GenAnnFLFunctions.sci b/src/Scilab2C/Scilab2C/ToolInitialization/INIT_GenAnnFLFunctions.sci index 0813141c..4f83814d 100644 --- a/src/Scilab2C/Scilab2C/ToolInitialization/INIT_GenAnnFLFunctions.sci +++ b/src/Scilab2C/Scilab2C/ToolInitialization/INIT_GenAnnFLFunctions.sci @@ -1,18 +1,28 @@ function INIT_GenAnnFLFunctions(FunctionName,FunctionsOutDir,ClassName,ReportFile,ExtensionCAnnFun) // function INIT_GenAnnFLFunctions(FunctionName,FunctionsOutDir,ClassName,ReportFile,ExtensionCAnnFun) -// ----------------------------------------------------------------- -// -// Status: -// 17-Jun-2007 -- Raffaele Nutricato: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),5,5); +// -----------------------------------------------------------------
+// Generates annotation or file list files.
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 17-Jun-2007 -- Raffaele Nutricato: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),5,5);
FunctionExtension = ExtensionCAnnFun; FunctionFileName = fullfile(FunctionsOutDir,FunctionName+FunctionExtension); PrintStringInfo('CLASS: '+ClassName,FunctionFileName,'file','y'); - +
endfunction diff --git a/src/Scilab2C/Scilab2C/ToolInitialization/INIT_GenFileInfo.sci b/src/Scilab2C/Scilab2C/ToolInitialization/INIT_GenFileInfo.sci index e5a92a9e..0b97af4d 100644 --- a/src/Scilab2C/Scilab2C/ToolInitialization/INIT_GenFileInfo.sci +++ b/src/Scilab2C/Scilab2C/ToolInitialization/INIT_GenFileInfo.sci @@ -1,74 +1,110 @@ -function FileInfo = INIT_GenFileInfo(WorkingDir,OutCCCodeDir,UserSciFilesPaths) -// function FileInfo = INIT_GenFileInfo(WorkingDir,OutCCCodeDir,UserSciFilesPaths) -// ----------------------------------------------------------------- -// -// Status: -// 03-Jan-2008 -- Raffaele Nutricato: Author. -// -// Copyright 2008 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),3,3); - -FileInfo.SCI2CMainDir = pwd(); -FileInfo.WorkingDir = WorkingDir; -FileInfo.OutCCCodeDir = OutCCCodeDir; -FileInfo.UserSciFilesPaths = UserSciFilesPaths; - -FileInfo.FileInfoDatFile = fullfile(FileInfo.WorkingDir,'FileInfo.dat'); -FileInfo.SharedInfoDatFile = fullfile(FileInfo.WorkingDir,'SharedInfo.dat'); -FileInfo.GlobalVarFileName = fullfile(FileInfo.WorkingDir,'GBLVAR.dat'); -FileInfo.ASTStackDataFile = fullfile(FileInfo.WorkingDir,'ASTStack.dat'); - -FileInfo.SCI2CLibDir = fullfile(FileInfo.WorkingDir,'SCI2CLib'); - -FileInfo.SCI2CLibSCIAnnDir = fullfile(FileInfo.SCI2CLibDir,'SCIAnnotations'); -FileInfo.SCI2CLibSCIAnnFun = fullfile(FileInfo.SCI2CLibSCIAnnDir,'Functions'); -FileInfo.SCI2CLibSCIAnnCls = fullfile(FileInfo.SCI2CLibSCIAnnDir,'Classes'); - -FileInfo.SCI2CLibSCIFunListDir = fullfile(FileInfo.SCI2CLibDir,'SCIFunctionList'); -FileInfo.SCI2CLibSCIFLFun = fullfile(FileInfo.SCI2CLibSCIFunListDir,'Functions'); -FileInfo.SCI2CLibSCIFLCls = fullfile(FileInfo.SCI2CLibSCIFunListDir,'Classes'); - -FileInfo.SCI2CLibCAnnDir = fullfile(FileInfo.SCI2CLibDir,'CAnnotations'); -FileInfo.SCI2CLibCAnnFun = fullfile(FileInfo.SCI2CLibCAnnDir,'Functions'); -FileInfo.SCI2CLibCAnnCls = fullfile(FileInfo.SCI2CLibCAnnDir,'Classes'); - -FileInfo.SCI2CLibCFunListDir = fullfile(FileInfo.SCI2CLibDir,'CFunctionList'); -FileInfo.SCI2CLibCFLFun = fullfile(FileInfo.SCI2CLibCFunListDir,'Functions'); -FileInfo.SCI2CLibCFLCls = fullfile(FileInfo.SCI2CLibCFunListDir,'Classes'); - - -FileInfo.USER2CLibDir = fullfile(FileInfo.WorkingDir,'USER2CLib'); - -FileInfo.USER2CLibSCIAnnDir = fullfile(FileInfo.USER2CLibDir,'SCIAnnotations'); -FileInfo.USER2CLibSCIAnnFun = fullfile(FileInfo.USER2CLibSCIAnnDir,'Functions'); -FileInfo.USER2CLibSCIAnnCls = fullfile(FileInfo.USER2CLibSCIAnnDir,'Classes'); - -FileInfo.USER2CLibSCIFunListDir = fullfile(FileInfo.USER2CLibDir,'SCIFunctionList'); -FileInfo.USER2CLibSCIFLFun = fullfile(FileInfo.USER2CLibSCIFunListDir,'Functions'); -FileInfo.USER2CLibSCIFLCls = fullfile(FileInfo.USER2CLibSCIFunListDir,'Classes'); - -FileInfo.USER2CLibCAnnDir = fullfile(FileInfo.USER2CLibDir,'CAnnotations'); -FileInfo.USER2CLibCAnnFun = fullfile(FileInfo.USER2CLibCAnnDir,'Functions'); -FileInfo.USER2CLibCAnnCls = fullfile(FileInfo.USER2CLibCAnnDir,'Classes'); - -FileInfo.USER2CLibCFunListDir = fullfile(FileInfo.USER2CLibDir,'CFunctionList'); -FileInfo.USER2CLibCFLFun = fullfile(FileInfo.USER2CLibCFunListDir,'Functions'); -FileInfo.USER2CLibCFLCls = fullfile(FileInfo.USER2CLibCFunListDir,'Classes'); - -FileInfo.FunctionList.MainDir = fullfile(FileInfo.WorkingDir,'FunctionList'); -FileInfo.FunctionList.SCI2CAvailableCDat = fullfile(FileInfo.FunctionList.MainDir,'SCI2CAvailableC.dat'); -FileInfo.FunctionList.USER2CAvailableCDat = fullfile(FileInfo.FunctionList.MainDir,'USER2CAvailableC.dat'); -FileInfo.FunctionList.ConvertedDat = fullfile(FileInfo.FunctionList.MainDir,'Converted.dat'); -FileInfo.FunctionList.ToBeConvertedDat = fullfile(FileInfo.FunctionList.MainDir,'ToBeConverted.dat'); -FileInfo.FunctionList.FunInfoDatDir = fullfile(FileInfo.FunctionList.MainDir,'FunInfoDatFiles'); - -FileInfo.GeneralReport = fullfile(FileInfo.WorkingDir,'SCI2CGeneralReport.txt'); - -FileInfo.CStyleSCI2CMainDir = ConvertPathMat2C(FileInfo.SCI2CMainDir,SharedInfo.CCompilerPathStyle); -FileInfo.CStyleOutCCCodeDir = ConvertPathMat2C(OutCCCodeDir,SharedInfo.CCompilerPathStyle); -FileInfo.MakefileFilename = fullfile(FileInfo.CStyleOutCCCodeDir,'Makefile'); -FileInfo.MakefileTemplate = fullfile(FileInfo.SCI2CMainDir,'CCodeGeneration','SCI2CMakefileTemplate.rc'); -endfunction +function FileInfo = INIT_GenFileInfo(WorkingDir,OutCCCodeDir,UserSciFilesPaths)
+// function FileInfo = INIT_GenFileInfo(WorkingDir,OutCCCodeDir,UserSciFilesPaths)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// This function creates and initializes FileInfo structure.
+//
+// Input data:
+// WorkingDir: see description in the SCI2CInputParameters.sce file.
+// OutCCCodeDir: see description in the SCI2CInputParameters.sce file.
+// UserSciFilesPaths: see description in the SCI2CInputParameters.sce file.
+//
+// Output data:
+// FileInfo: structure containing all info about SCI2C files.
+//
+// #RNU_RES_E
+// Status:
+// 03-Jan-2008 -- Raffaele Nutricato: Author.
+//
+// Copyright 2008 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),3,3);
+
+
+// -------------------------
+// --- Main directories. ---
+// -------------------------
+FileInfo.SCI2CMainDir = pwd();
+FileInfo.WorkingDir = WorkingDir;
+FileInfo.OutCCCodeDir = OutCCCodeDir;
+FileInfo.UserSciFilesPaths = UserSciFilesPaths;
+
+// -------------------
+// --- .dat Files. ---
+// -------------------
+FileInfo.FileInfoDatFile = fullfile(FileInfo.WorkingDir,'FileInfo.dat');
+FileInfo.SharedInfoDatFile = fullfile(FileInfo.WorkingDir,'SharedInfo.dat');
+FileInfo.GlobalVarFileName = fullfile(FileInfo.WorkingDir,'GBLVAR.dat');
+FileInfo.ASTStackDataFile = fullfile(FileInfo.WorkingDir,'ASTStack.dat');
+
+// ----------------------
+// --- SCI2C Library. ---
+// ----------------------
+FileInfo.SCI2CLibDir = fullfile(FileInfo.WorkingDir,'SCI2CLib');
+
+FileInfo.SCI2CLibSCIAnnDir = fullfile(FileInfo.SCI2CLibDir,'SCIAnnotations');
+FileInfo.SCI2CLibSCIAnnFun = fullfile(FileInfo.SCI2CLibSCIAnnDir,'Functions');
+FileInfo.SCI2CLibSCIAnnCls = fullfile(FileInfo.SCI2CLibSCIAnnDir,'Classes');
+
+FileInfo.SCI2CLibSCIFunListDir = fullfile(FileInfo.SCI2CLibDir,'SCIFunctionList');
+FileInfo.SCI2CLibSCIFLFun = fullfile(FileInfo.SCI2CLibSCIFunListDir,'Functions');
+FileInfo.SCI2CLibSCIFLCls = fullfile(FileInfo.SCI2CLibSCIFunListDir,'Classes');
+
+FileInfo.SCI2CLibCAnnDir = fullfile(FileInfo.SCI2CLibDir,'CAnnotations');
+FileInfo.SCI2CLibCAnnFun = fullfile(FileInfo.SCI2CLibCAnnDir,'Functions');
+FileInfo.SCI2CLibCAnnCls = fullfile(FileInfo.SCI2CLibCAnnDir,'Classes');
+
+FileInfo.SCI2CLibCFunListDir = fullfile(FileInfo.SCI2CLibDir,'CFunctionList');
+FileInfo.SCI2CLibCFLFun = fullfile(FileInfo.SCI2CLibCFunListDir,'Functions');
+FileInfo.SCI2CLibCFLCls = fullfile(FileInfo.SCI2CLibCFunListDir,'Classes');
+
+
+// -----------------------
+// --- USER2C Library. ---
+// -----------------------
+FileInfo.USER2CLibDir = fullfile(FileInfo.WorkingDir,'USER2CLib');
+
+FileInfo.USER2CLibSCIAnnDir = fullfile(FileInfo.USER2CLibDir,'SCIAnnotations');
+FileInfo.USER2CLibSCIAnnFun = fullfile(FileInfo.USER2CLibSCIAnnDir,'Functions');
+FileInfo.USER2CLibSCIAnnCls = fullfile(FileInfo.USER2CLibSCIAnnDir,'Classes');
+
+FileInfo.USER2CLibSCIFunListDir = fullfile(FileInfo.USER2CLibDir,'SCIFunctionList');
+FileInfo.USER2CLibSCIFLFun = fullfile(FileInfo.USER2CLibSCIFunListDir,'Functions');
+FileInfo.USER2CLibSCIFLCls = fullfile(FileInfo.USER2CLibSCIFunListDir,'Classes');
+
+FileInfo.USER2CLibCAnnDir = fullfile(FileInfo.USER2CLibDir,'CAnnotations');
+FileInfo.USER2CLibCAnnFun = fullfile(FileInfo.USER2CLibCAnnDir,'Functions');
+FileInfo.USER2CLibCAnnCls = fullfile(FileInfo.USER2CLibCAnnDir,'Classes');
+
+FileInfo.USER2CLibCFunListDir = fullfile(FileInfo.USER2CLibDir,'CFunctionList');
+FileInfo.USER2CLibCFLFun = fullfile(FileInfo.USER2CLibCFunListDir,'Functions');
+FileInfo.USER2CLibCFLCls = fullfile(FileInfo.USER2CLibCFunListDir,'Classes');
+
+// ----------------------
+// --- Function List. ---
+// ----------------------
+FileInfo.FunctionList.MainDir = fullfile(FileInfo.WorkingDir,'FunctionList');
+FileInfo.FunctionList.SCI2CAvailableCDat = fullfile(FileInfo.FunctionList.MainDir,'SCI2CAvailableC.dat');
+FileInfo.FunctionList.USER2CAvailableCDat = fullfile(FileInfo.FunctionList.MainDir,'USER2CAvailableC.dat');
+FileInfo.FunctionList.ConvertedDat = fullfile(FileInfo.FunctionList.MainDir,'Converted.dat');
+FileInfo.FunctionList.ToBeConvertedDat = fullfile(FileInfo.FunctionList.MainDir,'ToBeConverted.dat');
+FileInfo.FunctionList.FunInfoDatDir = fullfile(FileInfo.FunctionList.MainDir,'FunInfoDatFiles');
+
+// --------------------
+// --- Other Files. ---
+// --------------------
+FileInfo.GeneralReport = fullfile(FileInfo.WorkingDir,'SCI2CGeneralReport.txt');
+
+// -----------------------------------
+// --- C-Style paths and Makefile. ---
+// -----------------------------------
+FileInfo.CStyleSCI2CMainDir = ConvertPathMat2C(FileInfo.SCI2CMainDir,SharedInfo.CCompilerPathStyle);
+FileInfo.CStyleOutCCCodeDir = ConvertPathMat2C(OutCCCodeDir,SharedInfo.CCompilerPathStyle);
+FileInfo.MakefileFilename = fullfile(FileInfo.CStyleOutCCCodeDir,'Makefile');
+FileInfo.MakefileTemplate = fullfile(FileInfo.SCI2CMainDir,'CCodeGeneration','SCI2CMakefileTemplate.rc');
+endfunction
diff --git a/src/Scilab2C/Scilab2C/ToolInitialization/INIT_GenLibraries.sci b/src/Scilab2C/Scilab2C/ToolInitialization/INIT_GenLibraries.sci index a6e8be87..eb2c01b7 100644 --- a/src/Scilab2C/Scilab2C/ToolInitialization/INIT_GenLibraries.sci +++ b/src/Scilab2C/Scilab2C/ToolInitialization/INIT_GenLibraries.sci @@ -1,27 +1,61 @@ -function INIT_GenLibraries(FileInfoDatFile) -// function INIT_GenLibraries(FileInfoDatFile) -// ----------------------------------------------------------------- -// -// Status: -// 12-Jun-2007 -- Nutricato Raffaele: Author. -// 03-Jan-2008 -- Nutricato Raffaele: Changed directory structure. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),1,1); - -clear FileInfo -load(FileInfoDatFile,'FileInfo'); - -clear SharedInfo -load(FileInfo.SharedInfoDatFile,'SharedInfo'); - -PrintStepInfo('Initialize SCI2C and USER2C Libraries.',... - FileInfo.GeneralReport,'both'); - -INIT_FillSCI2LibCDirs(FileInfo,SharedInfo.Extension); - - -endfunction +function INIT_GenLibraries(FileInfoDatFile)
+// function INIT_GenLibraries(FileInfoDatFile)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// This function initializes the SCI2C and USER libraries.
+// For each Scilab function a .ann file is created where the function
+// annotations are listed into it.
+// #RNU_RES_E
+//
+// Input data:
+// FileInfoDatFile: name of the .dat file containing the FileInfo structure.
+//
+// Output data:
+// ---
+//
+// Status:
+// 12-Jun-2007 -- Nutricato Raffaele: Author.
+// 03-Jan-2008 -- Nutricato Raffaele: Changed directory structure.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+// -----------------------
+// --- Initialization. ---
+// -----------------------
+// --- Load File Info Structure. ---
+clear FileInfo
+load(FileInfoDatFile,'FileInfo');
+
+// --- Load Shared Info Structure. ---
+clear SharedInfo
+load(FileInfo.SharedInfoDatFile,'SharedInfo');
+
+PrintStepInfo('Initialize SCI2C and USER2C Libraries.',...
+ FileInfo.GeneralReport,'both');
+// ---------------------------
+// --- End Initialization. ---
+// ---------------------------
+
+// -----------------------------------------------------------
+// --- Fills SCI2C and USER2C libs with appropriate files. ---
+// -----------------------------------------------------------
+INIT_FillSCI2LibCDirs(FileInfo,SharedInfo.Extension);
+
+// #RNU_RES_B
+//NUT the following functions will be useful in next release
+//NUT for advanced use of SCI2C
+//INIT_FillSCI2LibSCIDirs(FileInfo,SharedInfo.Extension);
+//INIT_FillUSER2LibCDirs(FileInfo,SharedInfo.Extension);
+//INIT_FillUSER2LibSCIDirs(FileInfo,SharedInfo.Extension);
+// ---------------------------------------------------------------
+// --- End Fills SCI2C and USER2C libs with appropriate files. ---
+// ---------------------------------------------------------------
+// #RNU_RES_E
+endfunction
diff --git a/src/Scilab2C/Scilab2C/ToolInitialization/INIT_GenSharedInfo.sci b/src/Scilab2C/Scilab2C/ToolInitialization/INIT_GenSharedInfo.sci index d706c002..b9d8dcef 100644 --- a/src/Scilab2C/Scilab2C/ToolInitialization/INIT_GenSharedInfo.sci +++ b/src/Scilab2C/Scilab2C/ToolInitialization/INIT_GenSharedInfo.sci @@ -1,71 +1,118 @@ -function SharedInfo = INIT_GenSharedInfo(WorkingDir,OutCCCodeDir,UserSciFilesPaths,... - RunMode,UserScilabMainFile,TotTempScalarVars,EnableTempVarsReuse,Sci2CLibMainHeaderFName) -// function SharedInfo = INIT_GenSharedInfo(WorkingDir,OutCCCodeDir,UserSciFilesPaths,... -// RunMode,UserScilabMainFile,TotTempScalarVars,EnableTempVarsReuse,Sci2CLibMainHeaderFName) -// ----------------------------------------------------------------- -// -// Status: -// 03-Jan-2008 -- Raffaele Nutricato: Author. -// -// Copyright 2008 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),8,8); - -SharedInfo.CCompilerPathStyle = CCompilerPathStyle; -SharedInfo.RunMode = RunMode; -SharedInfo.Sci2CLibMainHeaderFName = ConvertPathMat2C(Sci2CLibMainHeaderFName,SharedInfo.CCompilerPathStyle); - -SharedInfo.NextSCIFileName = UserScilabMainFile; -[scipath,funname,sciext] = fileparts(UserScilabMainFile); -SharedInfo.SCIMainFunName = funname; -SharedInfo.CMainFunName = 'main'; -SharedInfo.NextSCIFunName = SharedInfo.SCIMainFunName; //NUT: per ora no so cosa metter -SharedInfo.NextCFunName = SharedInfo.CMainFunName; //NUT: per ora no so cosa metter //NUT: questo viene aggiornato dalla C_Funcall -SharedInfo.NextSCIFunNumber = 1; -SharedInfo.NFilesToTranslate = 1; - - -SharedInfo.Annotations.GBLVAR = 'global'; -SharedInfo.Annotations.DataPrec = {'SCI2Cint','float','double'}; -SharedInfo.Annotations.FUNNIN = 'NIN='; -SharedInfo.Annotations.FUNNOUT = 'NOUT='; -SharedInfo.Annotations.FUNTYPE = '''OUT(''+string(SCI2C_nout)+'').TP='''; // Type includes also precision. -SharedInfo.Annotations.FUNSIZE = '''OUT(''+string(SCI2C_nout)+'').SZ(''+string(SCI2C_nelem)+'')= '''; -SharedInfo.Annotations.FUNCLASS = 'CLASS: '; -SharedInfo.Annotations.USERFUN = '//SCI2C: '; - -SharedInfo.TotTempScalarVars = TotTempScalarVars; -SharedInfo.UsedTempScalarVars = 0; -SharedInfo.TempScalarVarsName = '__Scalar'; -SharedInfo.WorkAreaUsedBytes = WorkAreaSizeBytes; -SharedInfo.UsedTempScalarVars = WorkAreaSizeBytes; -SharedInfo.ASTReader.fidAST = -1; -SharedInfo.ASTReader.UsedTempVars = 0; -SharedInfo.ASTReader.TempVarsName = '__temp'; -SharedInfo.ASTReader.TempForCntVarsName = '__tmpcnt'; -SharedInfo.ASTReader.TempForValVarsName = '__TmpVal'; -SharedInfo.ASTReader.TempWhileCntVarsName = '__tmpWhilecnt';//NUT: vedi se serve. -SharedInfo.ASTReader.TempWhileValVarsName = '__TmpWhileVal'; //NUT: vedi se serve -SharedInfo.ASTReader.EnableTempVarsReuse = EnableTempVarsReuse; //NUT: non so se la devo rimuovere. -SharedInfo.ASTReader.ReusableTempVars = [];//NUT: to be removed - -SharedInfo.NIndent = 0; // Indentation Level. -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; -SharedInfo.CopySciCodeIntoCCode = CopySciCodeIntoCCode; -SharedInfo.CountNestedIf = 0; // Number of nested if. - -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); -SharedInfo.Extension.AnnotationFunctions = '.ann'; // Stands for annotation -SharedInfo.Extension.AnnotationClasses = '.acls'; // Stands for annotation class. -SharedInfo.Extension.FuncListFunctions = '.lst'; // Stands for list -SharedInfo.Extension.FuncListClasses = '.lcls'; // Stands for list class -endfunction +function SharedInfo = INIT_GenSharedInfo(WorkingDir,OutCCCodeDir,UserSciFilesPaths,...
+ RunMode,UserScilabMainFile,TotTempScalarVars,EnableTempVarsReuse,Sci2CLibMainHeaderFName)
+// function SharedInfo = INIT_GenSharedInfo(WorkingDir,OutCCCodeDir,UserSciFilesPaths,...
+// RunMode,UserScilabMainFile,TotTempScalarVars,EnableTempVarsReuse,Sci2CLibMainHeaderFName)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// This function creates and initializes SharedInfo structure.
+//
+// Input data:
+// WorkingDir: see description in the SCI2CInputParameters.sce file.
+// OutCCCodeDir: see description in the SCI2CInputParameters.sce file.
+// UserSciFilesPaths: see description in the SCI2CInputParameters.sce file.
+// RunMode: see description in the SCI2CInputParameters.sce file.
+// UserScilabMainFile: see description in the SCI2CInputParameters.sce file.
+// TotTempScalarVars: see description in the SCI2CInputParameters.sce file.
+// EnableTempVarsReuse: see description in the SCI2CInputParameters.sce file.
+//
+// Output data:
+// SharedInfo: structure containing all info about general parameters
+// used by SCI2C.
+//
+// #RNU_RES_E
+// Status:
+// 03-Jan-2008 -- Raffaele Nutricato: Author.
+//
+// Copyright 2008 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),8,8);
+
+
+// ------------------------------
+// --- Initialize SharedInfo. ---
+// ------------------------------
+SharedInfo.CCompilerPathStyle = CCompilerPathStyle;
+SharedInfo.RunMode = RunMode;
+SharedInfo.Sci2CLibMainHeaderFName = ConvertPathMat2C(Sci2CLibMainHeaderFName,SharedInfo.CCompilerPathStyle);
+
+// #RNU_RES_B
+// File names of the next .sci files to be converted in AST and
+// successively into C.
+// #RNU_RES_E
+SharedInfo.NextSCIFileName = UserScilabMainFile;
+[scipath,funname,sciext] = fileparts(UserScilabMainFile);
+SharedInfo.SCIMainFunName = funname;
+SharedInfo.CMainFunName = 'main';
+SharedInfo.NextSCIFunName = SharedInfo.SCIMainFunName; //NUT: per ora no so cosa metter
+SharedInfo.NextCFunName = SharedInfo.CMainFunName; //NUT: per ora no so cosa metter //NUT: questo viene aggiornato dalla C_Funcall
+SharedInfo.NextSCIFunNumber = 1;
+SharedInfo.NFilesToTranslate = 1;
+
+
+// --- Annotations. ---
+SharedInfo.Annotations.GBLVAR = 'global';
+SharedInfo.Annotations.DataPrec = {'SCI2Cint','float','double'};
+SharedInfo.Annotations.FUNNIN = 'NIN=';
+SharedInfo.Annotations.FUNNOUT = 'NOUT=';
+SharedInfo.Annotations.FUNTYPE = '''OUT(''+string(SCI2C_nout)+'').TP='''; // Type includes also precision.
+SharedInfo.Annotations.FUNSIZE = '''OUT(''+string(SCI2C_nout)+'').SZ(''+string(SCI2C_nelem)+'')= ''';
+SharedInfo.Annotations.FUNCLASS = 'CLASS: ';
+SharedInfo.Annotations.USERFUN = '//SCI2C: ';
+// #RNU_RES_B
+// Note when you execute the following code:
+ // SCI2C_nout=1;
+ // SCI2C_nelem=0;
+ // eval(SharedInfo.Annotations.FUNSIZE)
+ // you get:
+ // O1SIZE[0] =
+
+// Info related to temp variables used in the C code.
+// #RNU_RES_E
+SharedInfo.TotTempScalarVars = TotTempScalarVars;
+SharedInfo.UsedTempScalarVars = 0;
+SharedInfo.TempScalarVarsName = '__Scalar';
+//NUT: verificare se le seguenti due variabili sono utili. Le sto usando in AST2Ccode
+SharedInfo.WorkAreaUsedBytes = WorkAreaSizeBytes;
+SharedInfo.UsedTempScalarVars = WorkAreaSizeBytes;
+// Info related to temp variables used in the AST reading phase.
+SharedInfo.ASTReader.fidAST = -1;
+SharedInfo.ASTReader.UsedTempVars = 0;
+SharedInfo.ASTReader.TempVarsName = '__temp';
+SharedInfo.ASTReader.TempForCntVarsName = '__tmpcnt';
+SharedInfo.ASTReader.TempForValVarsName = '__TmpVal';
+SharedInfo.ASTReader.TempWhileCntVarsName = '__tmpWhilecnt';//NUT: vedi se serve.
+SharedInfo.ASTReader.TempWhileValVarsName = '__TmpWhileVal'; //NUT: vedi se serve
+SharedInfo.ASTReader.EnableTempVarsReuse = EnableTempVarsReuse; //NUT: non so se la devo rimuovere.
+SharedInfo.ASTReader.ReusableTempVars = [];//NUT: to be removed
+
+SharedInfo.NIndent = 0; // Indentation Level.
+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;
+SharedInfo.CopySciCodeIntoCCode = CopySciCodeIntoCCode;
+SharedInfo.CountNestedIf = 0; // Number of nested if.
+
+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);
+// ------------------------
+// --- File Extensions. ---
+// ------------------------
+SharedInfo.Extension.AnnotationFunctions = '.ann'; // Stands for annotation
+SharedInfo.Extension.AnnotationClasses = '.acls'; // Stands for annotation class.
+SharedInfo.Extension.FuncListFunctions = '.lst'; // Stands for list
+SharedInfo.Extension.FuncListClasses = '.lcls'; // Stands for list class
+
+// ------------------------
+// --- Resize Approach. ---
+// ------------------------
+SharedInfo.ResizeApproach = 'NO_RESIZE'; // 'NO_RESIZE', 'RESIZE_ALL', 'RESIZE_TEMP', 'RESIZE_LOCAL', 'RESIZE_GLOBAL', 'REALLOC_ALL_RESIZE_ALL'
+endfunction
diff --git a/src/Scilab2C/Scilab2C/ToolInitialization/INIT_LoadLibraries.sci b/src/Scilab2C/Scilab2C/ToolInitialization/INIT_LoadLibraries.sci index 4db6eaed..35ff18af 100644 --- a/src/Scilab2C/Scilab2C/ToolInitialization/INIT_LoadLibraries.sci +++ b/src/Scilab2C/Scilab2C/ToolInitialization/INIT_LoadLibraries.sci @@ -1,6 +1,13 @@ function INIT_LoadLibraries(FileInfoDatFile)
// function INIT_LoadLibraries(FileInfoDatFile)
// -----------------------------------------------------------------
+// This function loads the SCI2C and USER libraries.
+//
+// Input data:
+// FileInfoDatFile: name of the .dat file containing the FileInfo structure.
+//
+// Output data:
+// ---
//
// Status:
// 12-Jun-2007 -- Raffaele Nutricato: Author.
@@ -10,25 +17,43 @@ function INIT_LoadLibraries(FileInfoDatFile) // Contact: raffaele.nutricato@tiscali.it
// -----------------------------------------------------------------
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
SCI2CNInArgCheck(argn(2),1,1);
+// -----------------------
+// --- Initialization. ---
+// -----------------------
+// --- Load File Info Structure. ---
clear FileInfo
load(FileInfoDatFile,'FileInfo');
+// --- Load Shared Info Structure. ---
clear SharedInfo
load(FileInfo.SharedInfoDatFile,'SharedInfo');
PrintStepInfo('Load SCI2C and USER2C Libraries.',FileInfo.GeneralReport,'both');
+// ---------------------------
+// --- End Initialization. ---
+// ---------------------------
+
+// ----------------------------------
+// --- Initialize Function Lists. ---
+// ----------------------------------
SCI2CAvailableC = [];
USER2CAvailableC = [];
Converted = [];
ToBeConverted(1).SCIFunctionName = SharedInfo.NextSCIFunName;
ToBeConverted(1).CFunctionName = SharedInfo.NextCFunName;
+// --- Read the list of library functions available. ---
[SCI2CAvailableC,SCI2CNElem] = FL_ExtractFuncList(FileInfo.SCI2CLibCFLFun,FileInfo.SCI2CLibCFLCls,...
SharedInfo.Annotations.FUNCLASS,SharedInfo.Extension.FuncListClasses,FileInfo.GeneralReport);
[USER2CAvailableC,USER2CNElem] = FL_ExtractFuncList(FileInfo.USER2CLibCFLFun,FileInfo.USER2CLibCFLCls,...
SharedInfo.Annotations.FUNCLASS,SharedInfo.Extension.FuncListClasses,FileInfo.GeneralReport);
+
+// --- Save .dat files. ---
Available = SCI2CAvailableC;
save(FileInfo.FunctionList.SCI2CAvailableCDat,Available);
Available = USER2CAvailableC;
diff --git a/src/Scilab2C/Scilab2C/ToolInitialization/INIT_RemoveDirs.sci b/src/Scilab2C/Scilab2C/ToolInitialization/INIT_RemoveDirs.sci index 6d628471..0fa288bd 100644 --- a/src/Scilab2C/Scilab2C/ToolInitialization/INIT_RemoveDirs.sci +++ b/src/Scilab2C/Scilab2C/ToolInitialization/INIT_RemoveDirs.sci @@ -1,42 +1,65 @@ -function INIT_RemoveDirs(FileInfo,SharedInfoRunMode) -// function INIT_RemoveDirs(FileInfo,SharedInfoRunMode) -// ----------------------------------------------------------------- -// -// Output data: -// --- -// -// Status: -// 03-Jan-2008 -- Raffaele Nutricato: Author. -// -// Copyright 2008 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),2,2); - -if (SharedInfoRunMode == 'GenLibraryStructure' | SharedInfoRunMode == 'All') - disp('Removing directory: '+FileInfo.WorkingDir); - disp('Removing directory: '+FileInfo.OutCCCodeDir); - yesno = 'y'; - if (yesno=='y') - rmdir(FileInfo.WorkingDir,'s'); - rmdir(FileInfo.OutCCCodeDir,'s'); - 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); - end -elseif (SharedInfoRunMode == 'Translate') - disp('Removing directory: '+FileInfo.OutCCCodeDir); - yesno = 'y'; - if (yesno=='y') - rmdir(FileInfo.OutCCCodeDir,'s'); - else - SCI2Cerror('Cannot continue, because you don''t want to delete: '+FileInfo.OutCCCodeDir); - end -else - disp('Unknown RunMode: ""'+SharedInfoRunMode+'"".'); - disp('Please check RunMode parameter in the SCI2CInputParameters.sce file'); - SCI2Cerror(' '); -end - -endfunction +function INIT_RemoveDirs(FileInfo,SharedInfoRunMode)
+// function INIT_RemoveDirs(FileInfo,SharedInfoRunMode)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// Removes existing directories according to the RunMode
+// specified by the user.
+//
+// Input data:
+// FileInfo: structure containing all info about SCI2C files.
+// SharedInfoRunMode: execution mode specified by the user in
+// the SCI2CInputParameters.sce file.
+//
+// Output data:
+// ---
+//
+// #RNU_RES_E
+// Status:
+// 03-Jan-2008 -- Raffaele Nutricato: Author.
+//
+// Copyright 2008 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+// ----------------------------------------------------
+// --- Remove previous versions of SCI2C files/dir. ---
+// ----------------------------------------------------
+if (SharedInfoRunMode == 'GenLibraryStructure' | SharedInfoRunMode == 'All')
+ disp('Removing directory: '+FileInfo.WorkingDir);
+ disp('Removing directory: '+FileInfo.OutCCCodeDir);
+ // 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');
+ 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);
+ end
+elseif (SharedInfoRunMode == 'Translate')
+ // #RNU_RES_B
+ //NUT: non cancella le cartelle dei file C creati nella iterazione precedente
+ //NUT: occorre specificarlo bene nel manuale.
+ // #RNU_RES_E
+ disp('Removing directory: '+FileInfo.OutCCCodeDir);
+ // Remove software<->user interaction.
+ // yesno=input('Are you sure [y/n]?','string');
+ yesno = 'y';
+ if (yesno=='y')
+ rmdir(FileInfo.OutCCCodeDir,'s');
+ else
+ SCI2Cerror('Cannot continue, because you don''t want to delete: '+FileInfo.OutCCCodeDir);
+ end
+else
+ disp('Unknown RunMode: ""'+SharedInfoRunMode+'"".');
+ disp('Please check RunMode parameter in the SCI2CInputParameters.sce file');
+ SCI2Cerror(' ');
+end
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/ToolInitialization/INIT_SCI2C.sci b/src/Scilab2C/Scilab2C/ToolInitialization/INIT_SCI2C.sci index 8801573b..c7b7a6f8 100644 --- a/src/Scilab2C/Scilab2C/ToolInitialization/INIT_SCI2C.sci +++ b/src/Scilab2C/Scilab2C/ToolInitialization/INIT_SCI2C.sci @@ -1,77 +1,144 @@ -function [FileInfoDatFile,SharedInfoDatFile] = INIT_SCI2C(SCI2CInputPrmFile) -// function [FileInfoDatFile,SharedInfoDatFile] = INIT_SCI2C(SCI2CInputPrmFile) -// ----------------------------------------------------------------- -// Status: -// 13-Apr-2007 -- Raffaele Nutricato: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),1,1); - -exec(SCI2CInputPrmFile); -WorkAreaSizeBytes = 2000*8; // 2000 locations of double -TotTempScalarVars = 20; -EnableTempVarsReuse = 0; // 0 = Disable; 1 = Enable. - - -[SCI2CResultDir,tmpfile,tmpext] = fileparts(SCI2CInputPrmFile); - -WorkingDir = fullfile(SCI2CResultDir,'SCI2CTmpResultsReports'); -OutCCCodeDir = fullfile(SCI2CResultDir,'C_Code'); - -SharedInfo = INIT_GenSharedInfo(WorkingDir,OutCCCodeDir,UserSciFilesPaths,... - RunMode,UserScilabMainFile,TotTempScalarVars,EnableTempVarsReuse,Sci2CLibMainHeaderFName); - -FileInfo = INIT_GenFileInfo(WorkingDir,OutCCCodeDir,UserSciFilesPaths); -PrintStepInfo('SCI2C hArtes/POLIBA Tool!!!',FileInfo.GeneralReport,'stdout'); - -INIT_RemoveDirs(FileInfo,SharedInfo.RunMode); - -INIT_CreateDirs(FileInfo); -PrintStepInfo('SCI2C hArtes/POLIBA Tool!!!',FileInfo.GeneralReport,'file'); - -GlobalVars = []; -save(FileInfo.GlobalVarFileName,GlobalVars); - -clear FunInfo -FunInfo.SCIFunctionName = SharedInfo.NextSCIFunName; -FunInfo.CFunctionName = SharedInfo.NextCFunName; -FunInfo.FunPrecSpecifier = ''; //NUT: si riferiscono al main verifica se sono corrette -FunInfo.FunTypeAnnot = ''; //NUT: si riferiscono al main verifica se sono corrette -FunInfo.FunSizeAnnot = ''; //NUT: si riferiscono al main verifica se sono corrette -FunInfo.NInArg = 0;//NUT: si riferiscono al main verifica se sono corrette -FunInfo.InArg(1).Name = '';//NUT: si riferiscono al main verifica se sono corrette -FunInfo.InArg(1).Type = '';//NUT: si riferiscono al main verifica se sono corrette -FunInfo.InArg(1).Value = %nan;//NUT: si riferiscono al main verifica se sono corrette -FunInfo.InArg(1).Size(1) = '';//NUT: si riferiscono al main verifica se sono corrette -FunInfo.InArg(1).Dimension = '';//NUT: si riferiscono al main verifica se sono corrette -FunInfo.InArg(2).Size(2) = '';//NUT: si riferiscono al main verifica se sono corrette -FunInfo.NOutArg = 0;//NUT: si riferiscono al main verifica se sono corrette -FunInfo.OutArg(1).Name = ''; -FunInfo.OutArg(1).Type = ''; -FunInfo.OutArg(1).Size(1) = ''; -FunInfo.OutArg(1).Size(2) = ''; -FunInfo.OutArg(1).Dimension = ''; -FunInfo.PosFirstOutScalar = 0; -FunInfo.LibTypeInfo = 'USER2C'; -save(fullfile(FileInfo.FunctionList.FunInfoDatDir,FunInfo.CFunctionName+'.dat'),FunInfo); -clear FunInfo - -clear ASTStack -ASTStack.SCI2CSTACK = 'EMPTYSTACK'; -ASTStack.StackPosition = 1; -ASTStack.STACKDEDUG = 0; -save(FileInfo.ASTStackDataFile,ASTStack); -clear ASTStack - -save(FileInfo.FileInfoDatFile,FileInfo); -save(FileInfo.SharedInfoDatFile,SharedInfo); -FileInfoDatFile = FileInfo.FileInfoDatFile; -SharedInfoDatFile = FileInfo.SharedInfoDatFile; - -global anscounter; //NUT: just to fix problem with ans variables. -anscounter = 0; - -endfunction +function [FileInfoDatFile,SharedInfoDatFile] = INIT_SCI2C(SCI2CInputPrmFile)
+// function [FileInfoDatFile,SharedInfoDatFile] = INIT_SCI2C(SCI2CInputPrmFile)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// This function initializes the SCI2C tool according
+// to the input parameters recorded in the SCI2CParameters.
+// All info will be stored into FileInfoDatFile.
+//
+// Input data:
+// SCI2CInputPrmFile: name of the .sce file containing input parameters.
+//
+// Output data:
+// FileInfoDatFile: name of the .dat file containing the FileInfo structure.
+// SharedInfoDatFile: it is a buffer containing parameters that are exchanged by the
+// functions of the SCI2C tool.
+// #RNU_RES_E
+// Status:
+// 13-Apr-2007 -- Raffaele Nutricato: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// #RNU_RES_B
+//NUT: questo file e' da rivedere quando il tool funzionera al 50%
+// #RNU_RES_E
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+// ------------------------------
+// --- Read Input Parameters. ---
+// ------------------------------
+exec(SCI2CInputPrmFile);
+// #RNU_RES_B
+//NUT: queste variabili sono per usi futuri.
+//NUT: e saranno introdotti nel parameter file.
+// #RNU_RES_E
+WorkAreaSizeBytes = 2000*8; // 2000 locations of double
+// #RNU_RES_B
+// Maximum number of temporary scalar variables that can be used.
+// #RNU_RES_E
+TotTempScalarVars = 20;
+EnableTempVarsReuse = 0; // 0 = Disable; 1 = Enable.
+
+
+// #RNU_RES_B
+//NUT: I prefer to don't show this parameters to the user.
+// --- Directory where all the products of the SCI2C tool will be stored. ---
+// #RNU_RES_E
+[SCI2CResultDir,tmpfile,tmpext] = fileparts(SCI2CInputPrmFile);
+
+WorkingDir = fullfile(SCI2CResultDir,'SCI2CTmpResultsReports');
+// #RNU_RES_B
+// --- Directory where the generated C code will be stored. ---
+// #RNU_RES_E
+OutCCCodeDir = fullfile(SCI2CResultDir,'C_Code');
+
+// ------------------------------
+// --- Initialize SharedInfo. ---
+// ------------------------------
+SharedInfo = INIT_GenSharedInfo(WorkingDir,OutCCCodeDir,UserSciFilesPaths,...
+ RunMode,UserScilabMainFile,TotTempScalarVars,EnableTempVarsReuse,Sci2CLibMainHeaderFName);
+
+// ----------------------------
+// --- Initialize FileInfo. ---
+// ----------------------------
+FileInfo = INIT_GenFileInfo(WorkingDir,OutCCCodeDir,UserSciFilesPaths);
+PrintStepInfo('SCI2C hArtes/POLIBA Tool!!!',FileInfo.GeneralReport,'stdout');
+
+// ----------------------------------------------------
+// --- Remove previous versions of SCI2C files/dir. ---
+// ----------------------------------------------------
+INIT_RemoveDirs(FileInfo,SharedInfo.RunMode);
+
+// ---------------------------
+// --- Create Directories. ---
+// ---------------------------
+INIT_CreateDirs(FileInfo);
+PrintStepInfo('SCI2C hArtes/POLIBA Tool!!!',FileInfo.GeneralReport,'file');
+
+// ------------------------------
+// --- Initialize GlobalVars. ---
+// ------------------------------
+GlobalVars = [];
+save(FileInfo.GlobalVarFileName,GlobalVars);
+
+// ----------------------------------
+// --- Initialize Main .dat file. ---
+// ----------------------------------
+//NUT: qui va sistemata.
+clear FunInfo
+//NUT: qua conviene fare una unica funzione.
+FunInfo.SCIFunctionName = SharedInfo.NextSCIFunName;
+FunInfo.CFunctionName = SharedInfo.NextCFunName;
+FunInfo.FunPrecSpecifier = ''; //NUT: si riferiscono al main verifica se sono corrette
+FunInfo.FunTypeAnnot = ''; //NUT: si riferiscono al main verifica se sono corrette
+FunInfo.FunSizeAnnot = ''; //NUT: si riferiscono al main verifica se sono corrette
+FunInfo.NInArg = 0;//NUT: si riferiscono al main verifica se sono corrette
+FunInfo.InArg(1).Name = '';//NUT: si riferiscono al main verifica se sono corrette
+FunInfo.InArg(1).Type = '';//NUT: si riferiscono al main verifica se sono corrette
+FunInfo.InArg(1).Value = %nan;//NUT: si riferiscono al main verifica se sono corrette
+FunInfo.InArg(1).Size(1) = '';//NUT: si riferiscono al main verifica se sono corrette
+FunInfo.InArg(1).Dimension = '';//NUT: si riferiscono al main verifica se sono corrette
+FunInfo.InArg(2).Size(2) = '';//NUT: si riferiscono al main verifica se sono corrette
+FunInfo.NOutArg = 0;//NUT: si riferiscono al main verifica se sono corrette
+FunInfo.OutArg(1).Name = '';
+FunInfo.OutArg(1).Type = '';
+FunInfo.OutArg(1).Size(1) = '';
+FunInfo.OutArg(1).Size(2) = '';
+FunInfo.OutArg(1).Dimension = '';
+FunInfo.PosFirstOutScalar = 0;
+FunInfo.LibTypeInfo = 'USER2C';
+save(fullfile(FileInfo.FunctionList.FunInfoDatDir,FunInfo.CFunctionName+'.dat'),FunInfo);
+clear FunInfo
+
+// -------------------------------------
+// --- Initialize ASTStack.dat file. ---
+// -------------------------------------
+//NUT: questa struttura deve sostituire le variabili global usate per lo stack
+clear ASTStack
+ASTStack.SCI2CSTACK = 'EMPTYSTACK';
+ASTStack.StackPosition = 1;
+ASTStack.STACKDEDUG = 0;
+save(FileInfo.ASTStackDataFile,ASTStack);
+clear ASTStack
+
+// ---------------------------------------------
+// --- Generate new versions of SCI2C files. ---
+// ---------------------------------------------
+save(FileInfo.FileInfoDatFile,FileInfo);
+save(FileInfo.SharedInfoDatFile,SharedInfo);
+FileInfoDatFile = FileInfo.FileInfoDatFile;
+SharedInfoDatFile = FileInfo.SharedInfoDatFile;
+
+global anscounter; //NUT: just to fix problem with ans variables.
+anscounter = 0;
+
+endfunction
+// #RNU_RES_B
+//NUT: quando genero il c della funzione utente devo anche generare il corrispondente file delle includes.
+//NUT: perche' la main non la devo annotare, secondo me occorre annotarla.?
+// #RNU_RES_E
diff --git a/src/Scilab2C/Scilab2C/ToolInitialization/INIT_SCI2CLoader.sce b/src/Scilab2C/Scilab2C/ToolInitialization/INIT_SCI2CLoader.sce index 0e0261cd..bd07f892 100644 --- a/src/Scilab2C/Scilab2C/ToolInitialization/INIT_SCI2CLoader.sce +++ b/src/Scilab2C/Scilab2C/ToolInitialization/INIT_SCI2CLoader.sce @@ -1,72 +1,72 @@ -// ----------------------------------------------------------------- -// Load SCI2C directories and files. -// -// Input data: -// SCI2CLoaderMainDir: path of the directory where this script (main.sce) is stored. -// -// Output data: -// --- -// -// Status: -// 11-Apr-2007 -- Raffaele Nutricato: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CLoaderMainDir = '..'; - -// --------------------------- -// --- Define Directories. --- -// --------------------------- -// Directory containing functions related to the management of the Abstract Syntactic tree. -ASTManagement = 'ASTManagement'; - -// Directory containing functions that produce the C code. -CCodeGeneration = 'CCodeGeneration'; - -// Directory containing functions that perform general tasks. -GeneralFunctions = 'GeneralFunctions'; - -// Directory containing functions that perform the initialization of the SCI2C tool. -ToolInitialization = 'ToolInitialization'; - -// Directory containing functions that perform the function annotation. -FunctionAnnotation = 'FunctionAnnotation'; - -// Directory containing functions that handle symbol table. -SymbolTable = 'SymbolTable'; - -// Directory containing functions that handle function lists. -FunctionList = 'FunctionList'; - -// Directory containing functions that print SCI2C error messages. -ErrorMessages = 'ErrorMessages'; - - -// ------------------------------- -// --- End Define Directories. --- -// ------------------------------- - -// ------------- -// --- getd. --- -// ------------- -getd(fullfile(SCI2CLoaderMainDir,ASTManagement)); -getd(fullfile(SCI2CLoaderMainDir,CCodeGeneration)); -getd(fullfile(SCI2CLoaderMainDir,GeneralFunctions)); -getd(fullfile(SCI2CLoaderMainDir,ToolInitialization)); -getd(fullfile(SCI2CLoaderMainDir,FunctionAnnotation)); -getd(fullfile(SCI2CLoaderMainDir,SymbolTable)); -getd(fullfile(SCI2CLoaderMainDir,FunctionList)); -getd(fullfile(SCI2CLoaderMainDir,ErrorMessages)); -// ----------------- -// --- End getd. --- -// ----------------- - -// ------------- -// --- exec. --- -// ------------- -exec(fullfile(SCI2CLoaderMainDir,ASTManagement,'%program_p.sci')); -// ----------------- -// --- End exec. --- -// ----------------- +// -----------------------------------------------------------------
+// Load SCI2C directories and files.
+//
+// Input data:
+// SCI2CLoaderMainDir: path of the directory where this script (main.sce) is stored.
+//
+// Output data:
+// ---
+//
+// Status:
+// 11-Apr-2007 -- Raffaele Nutricato: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+SCI2CLoaderMainDir = '..';
+
+// ---------------------------
+// --- Define Directories. ---
+// ---------------------------
+// Directory containing functions related to the management of the Abstract Syntactic tree.
+ASTManagement = 'ASTManagement';
+
+// Directory containing functions that produce the C code.
+CCodeGeneration = 'CCodeGeneration';
+
+// Directory containing functions that perform general tasks.
+GeneralFunctions = 'GeneralFunctions';
+
+// Directory containing functions that perform the initialization of the SCI2C tool.
+ToolInitialization = 'ToolInitialization';
+
+// Directory containing functions that perform the function annotation.
+FunctionAnnotation = 'FunctionAnnotation';
+
+// Directory containing functions that handle symbol table.
+SymbolTable = 'SymbolTable';
+
+// Directory containing functions that handle function lists.
+FunctionList = 'FunctionList';
+
+// Directory containing functions that print SCI2C error messages.
+ErrorMessages = 'ErrorMessages';
+
+
+// -------------------------------
+// --- End Define Directories. ---
+// -------------------------------
+
+// -------------
+// --- getd. ---
+// -------------
+getd(fullfile(SCI2CLoaderMainDir,ASTManagement));
+getd(fullfile(SCI2CLoaderMainDir,CCodeGeneration));
+getd(fullfile(SCI2CLoaderMainDir,GeneralFunctions));
+getd(fullfile(SCI2CLoaderMainDir,ToolInitialization));
+getd(fullfile(SCI2CLoaderMainDir,FunctionAnnotation));
+getd(fullfile(SCI2CLoaderMainDir,SymbolTable));
+getd(fullfile(SCI2CLoaderMainDir,FunctionList));
+getd(fullfile(SCI2CLoaderMainDir,ErrorMessages));
+// -----------------
+// --- End getd. ---
+// -----------------
+
+// -------------
+// --- exec. ---
+// -------------
+exec(fullfile(SCI2CLoaderMainDir,ASTManagement,'%program_p.sci'));
+// -----------------
+// --- End exec. ---
+// -----------------
diff --git a/src/Scilab2C/Scilab2C/ToolInitialization/INIT_SharedInfoEqual.sci b/src/Scilab2C/Scilab2C/ToolInitialization/INIT_SharedInfoEqual.sci index a3632256..690a43f6 100644 --- a/src/Scilab2C/Scilab2C/ToolInitialization/INIT_SharedInfoEqual.sci +++ b/src/Scilab2C/Scilab2C/ToolInitialization/INIT_SharedInfoEqual.sci @@ -1,21 +1,43 @@ -function SharedInfo = INIT_SharedInfoEqual(SharedInfo) -// function SharedInfo = INIT_SharedInfoEqual(SharedInfo) -// ----------------------------------------------------------------- -// Status: -// 13-Apr-2007 -- Raffaele Nutricato: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),1,1); - -SharedInfo.Equal.Enabled = 0; // 1 means enabled -> we are inside an equal AST block. -SharedInfo.Equal.NInArg = 0; -SharedInfo.Equal.InArg(1).Name = ''; -SharedInfo.Equal.NOutArg = 0; -SharedInfo.Equal.OutArg(1).Name = ''; -SharedInfo.Equal.Lhs = 0; -SharedInfo.Equal.Nins = 0; // Counts the number of ins found in the lhs of the Equal. - -endfunction +function SharedInfo = INIT_SharedInfoEqual(SharedInfo)
+// function SharedInfo = INIT_SharedInfoEqual(SharedInfo)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// This function initializes the SCI2C tool according
+// to the input parameters recorded in the SCI2CParameters.
+// All info will be stored into FileInfoDatFile.
+//
+// Input data:
+// SCI2CInputPrmFile: name of the .sce file containing input parameters.
+//
+// Output data:
+// FileInfoDatFile: name of the .dat file containing the FileInfo structure.
+// SharedInfoDatFile: it is a buffer containing parameters that are exchanged by the
+// functions of the SCI2C tool.
+// #RNU_RES_E
+// Status:
+// 13-Apr-2007 -- Raffaele Nutricato: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// #RNU_RES_B
+//NUT: verifica se le variabili sotto elencate ti servono davvero.
+//NUT: Sarebbe interessante accorpare tutte le variabili usate per la equal sotto un'unica struttura
+//NUT: per esempio SharedInfo.SkipNextEqual
+// #RNU_RES_E
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+SharedInfo.Equal.Enabled = 0; // 1 means enabled -> we are inside an equal AST block.
+SharedInfo.Equal.NInArg = 0;
+SharedInfo.Equal.InArg(1).Name = '';
+SharedInfo.Equal.NOutArg = 0;
+SharedInfo.Equal.OutArg(1).Name = '';
+SharedInfo.Equal.Lhs = 0;
+SharedInfo.Equal.Nins = 0; // Counts the number of ins found in the lhs of the Equal.
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/ToolInitialization/ManageNextConversion.sci b/src/Scilab2C/Scilab2C/ToolInitialization/ManageNextConversion.sci index 8e712460..8b2546bf 100644 --- a/src/Scilab2C/Scilab2C/ToolInitialization/ManageNextConversion.sci +++ b/src/Scilab2C/Scilab2C/ToolInitialization/ManageNextConversion.sci @@ -1,47 +1,87 @@ -function FlagContinueTranslation = ManageNextConversion(FileInfoDatFile) -// function FlagContinueTranslation = ManageNextConversion(FileInfoDatFile) -// ----------------------------------------------------------------- -// -// Status: -// 27-Oct-2007 -- Raffaele Nutricato: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),1,1); - -load(FileInfoDatFile,'FileInfo'); - -load(FileInfo.SharedInfoDatFile,'SharedInfo'); - -load(FileInfo.FunctionList.ToBeConvertedDat,'ToBeConverted'); -FlagContinueTranslation = 0; - -C_FinalizeCode(FileInfo,SharedInfo); - -SharedInfo.NFilesToTranslate = SharedInfo.NFilesToTranslate - 1; -if (SharedInfo.NFilesToTranslate >= 1) - ToBeConverted(1) = []; - FlagContinueTranslation = 1; - SharedInfo.NextSCIFunName = ToBeConverted(1).SCIFunctionName; - SharedInfo.NextCFunName = ToBeConverted(1).CFunctionName; - SharedInfo.NextSCIFunNumber = SharedInfo.NextSCIFunNumber + 1; - [FlagFound,SharedInfo.NextSCIFileName] = ... - SCI2CFindFile(FileInfo.UserSciFilesPaths,SharedInfo.NextSCIFunName+'.sci'); - if (FlagFound == 0) - SCI2CerrorFile('Cannot find a scilab file to generate ""'+SharedInfo.NextCFunName+'"".',... - FileInfo.GeneralReport); - end -end - - -save(FileInfo.SharedInfoDatFile,SharedInfo); -clear SharedInfo - -save(FileInfo.FunctionList.ToBeConvertedDat,ToBeConverted); -clear ToBeConverted - -clear FileInfo - -endfunction +function FlagContinueTranslation = ManageNextConversion(FileInfoDatFile)
+// function FlagContinueTranslation = ManageNextConversion(FileInfoDatFile)
+// -----------------------------------------------------------------
+// //NUT: add description here
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 27-Oct-2007 -- Raffaele Nutricato: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+//NUT: verifica se update e managenexconversion possono essere integrate in un'unica funzione.
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+// ---------------------
+// --- Load section. ---
+// ---------------------
+// --- Load File Info Structure. ---
+load(FileInfoDatFile,'FileInfo');
+
+// --- Load Shared Info Structure. ---
+load(FileInfo.SharedInfoDatFile,'SharedInfo');
+
+// --- Load ToBeConverted .dat file. ---
+load(FileInfo.FunctionList.ToBeConvertedDat,'ToBeConverted');
+// -------------------------
+// --- End load section. ---
+// -------------------------
+
+FlagContinueTranslation = 0;
+
+// ------------------------------------
+// --- Finalize the current C code. ---
+// ------------------------------------
+C_FinalizeCode(FileInfo,SharedInfo);
+
+// ------------------------------------------------
+// --- Identify the next function to translate. ---
+// ------------------------------------------------
+SharedInfo.NFilesToTranslate = SharedInfo.NFilesToTranslate - 1;
+if (SharedInfo.NFilesToTranslate >= 1)
+ // Remove the translated C function from the ToBeConverted list
+ ToBeConverted(1) = [];
+ FlagContinueTranslation = 1;
+ SharedInfo.NextSCIFunName = ToBeConverted(1).SCIFunctionName;
+ SharedInfo.NextCFunName = ToBeConverted(1).CFunctionName;
+ SharedInfo.NextSCIFunNumber = SharedInfo.NextSCIFunNumber + 1;
+ [FlagFound,SharedInfo.NextSCIFileName] = ...
+ SCI2CFindFile(FileInfo.UserSciFilesPaths,SharedInfo.NextSCIFunName+'.sci');
+ if (FlagFound == 0)
+ SCI2CerrorFile('Cannot find a scilab file to generate ""'+SharedInfo.NextCFunName+'"".',...
+ FileInfo.GeneralReport);
+ end
+end
+// ----------------------------------------------------
+// --- End Identify the next function to translate. ---
+// ----------------------------------------------------
+
+
+// ---------------------
+// --- Save section. ---
+// ---------------------
+// --- Save Shared Info Structure. ---
+save(FileInfo.SharedInfoDatFile,SharedInfo);
+clear SharedInfo
+
+// --- Save ToBeConverted .dat file. ---
+save(FileInfo.FunctionList.ToBeConvertedDat,ToBeConverted);
+clear ToBeConverted
+
+clear FileInfo
+// -------------------------
+// --- End Save section. ---
+// -------------------------
+
+endfunction
diff --git a/src/Scilab2C/Scilab2C/ToolInitialization/SCI2CInputParameters.bkp b/src/Scilab2C/Scilab2C/ToolInitialization/SCI2CInputParameters.bkp index ea5a4b86..7af3343c 100644 --- a/src/Scilab2C/Scilab2C/ToolInitialization/SCI2CInputParameters.bkp +++ b/src/Scilab2C/Scilab2C/ToolInitialization/SCI2CInputParameters.bkp @@ -1,87 +1,87 @@ -// ----------------------------------------------------------------- -// === hArtes/PoliBa/GAP SCI2C tool === -// === Authors: === -// === Raffaele Nutricato === -// === raffaele.nutricato@tiscali.it === -// === Alberto Morea === -// === === -// === *************** === -// === USER PARAMETERS === -// === *************** === -// === === -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - - -// ------------------------------------------ -// --- Specify Paths of User Scilab code. --- -// ------------------------------------------ -UserSciCodeMainDir = 'C:\SCI2CTests\RegressionTests\test999'; - -// --- Path + filename of the .sci main file of the code to be translated. --- -// It is the entry point. -UserScilabMainFile = fullfile(UserSciCodeMainDir,'scilabcode\mainfun.sci'); - -// --- List of the paths containing the .sci files written by the user. --- -UserSciFilesPaths = ... - [... - fullfile(UserSciCodeMainDir,'scilabcode');... - ]; - -// -------------------------- -// --- End Specify paths. --- -// -------------------------- - - -// ---------------------------- -// --- Select the run mode. --- -// ---------------------------- -//RunMode = 'GenLibraryStructure'; -//RunMode = 'Translate'; -RunMode = 'All'; - -// --- Select one of the following options. --- - -// 'GenLibraryStructure'; -// Generates the library structure and exits. It is very -// useful when the user wants to manually change the files stored in that structure -// before running the translation. 'GenLibraryStructure' option forces SCI2C to remove -// the already existing WorkingDir and OutCCCodeDir directories. - -// 'Translate'; -// Performs the translation without generating the library structure. It means that the library -// structure must be already existing. This is useful when the user doesn't want to spend time -// to generate again that structure or when he wants to force the SCI2C tool to access to -// a manually-changed library structure. 'Translate' option forces SCI2C to don't remove -// the already existing WorkingDir. Only OutCCCodeDir directory will be removed. - -// 'All'; -// Performs all the actions listed above. - -// -------------------------------- -// --- End Select the run mode. --- -// -------------------------------- - - -// ---------------------------- -// --- Translation Options. --- -// ---------------------------- -// --- Enable (1) / Disable (0) copy of Scilab code into C code. --- -// If 1 the Scilab code will be copied into the C code in order to show -// how each Scilab code line has been translated into C code. -CopySciCodeIntoCCode = 1; - -// --- Select the path style for the C code. --- -// It can be: -// windows -// unix -// cygwin -CCompilerPathStyle = 'cygwin'; - -// --- Path + File name of the main SCI2C library header file. -Sci2CLibMainHeaderFName = 'C:\Nutricato\OpenProjects\FP6_hArtes\WP2_SCI2C\Software\Scilab2C\CFiles\sci2cincludes\sci2clib.h'; -// -------------------------------- -// --- End Translation Options. --- -// -------------------------------- +// -----------------------------------------------------------------
+// === hArtes/PoliBa/GAP SCI2C tool ===
+// === Authors: ===
+// === Raffaele Nutricato ===
+// === raffaele.nutricato@tiscali.it ===
+// === Alberto Morea ===
+// === ===
+// === *************** ===
+// === USER PARAMETERS ===
+// === *************** ===
+// === ===
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+
+// ------------------------------------------
+// --- Specify Paths of User Scilab code. ---
+// ------------------------------------------
+UserSciCodeMainDir = 'C:\SCI2CTests\RegressionTests\test999';
+
+// --- Path + filename of the .sci main file of the code to be translated. ---
+// It is the entry point.
+UserScilabMainFile = fullfile(UserSciCodeMainDir,'scilabcode\mainfun.sci');
+
+// --- List of the paths containing the .sci files written by the user. ---
+UserSciFilesPaths = ...
+ [...
+ fullfile(UserSciCodeMainDir,'scilabcode');...
+ ];
+
+// --------------------------
+// --- End Specify paths. ---
+// --------------------------
+
+
+// ----------------------------
+// --- Select the run mode. ---
+// ----------------------------
+//RunMode = 'GenLibraryStructure';
+//RunMode = 'Translate';
+RunMode = 'All';
+
+// --- Select one of the following options. ---
+
+// 'GenLibraryStructure';
+// Generates the library structure and exits. It is very
+// useful when the user wants to manually change the files stored in that structure
+// before running the translation. 'GenLibraryStructure' option forces SCI2C to remove
+// the already existing WorkingDir and OutCCCodeDir directories.
+
+// 'Translate';
+// Performs the translation without generating the library structure. It means that the library
+// structure must be already existing. This is useful when the user doesn't want to spend time
+// to generate again that structure or when he wants to force the SCI2C tool to access to
+// a manually-changed library structure. 'Translate' option forces SCI2C to don't remove
+// the already existing WorkingDir. Only OutCCCodeDir directory will be removed.
+
+// 'All';
+// Performs all the actions listed above.
+
+// --------------------------------
+// --- End Select the run mode. ---
+// --------------------------------
+
+
+// ----------------------------
+// --- Translation Options. ---
+// ----------------------------
+// --- Enable (1) / Disable (0) copy of Scilab code into C code. ---
+// If 1 the Scilab code will be copied into the C code in order to show
+// how each Scilab code line has been translated into C code.
+CopySciCodeIntoCCode = 1;
+
+// --- Select the path style for the C code. ---
+// It can be:
+// windows
+// unix
+// cygwin
+CCompilerPathStyle = 'cygwin';
+
+// --- Path + File name of the main SCI2C library header file.
+Sci2CLibMainHeaderFName = 'C:\Nutricato\OpenProjects\FP6_hArtes\WP2_SCI2C\Software\Scilab2C\CFiles\sci2cincludes\sci2clib.h';
+// --------------------------------
+// --- End Translation Options. ---
+// --------------------------------
diff --git a/src/Scilab2C/Scilab2C/ToolInitialization/SCI2CInputParameters.sce b/src/Scilab2C/Scilab2C/ToolInitialization/SCI2CInputParameters.sce index ea5a4b86..7af3343c 100644 --- a/src/Scilab2C/Scilab2C/ToolInitialization/SCI2CInputParameters.sce +++ b/src/Scilab2C/Scilab2C/ToolInitialization/SCI2CInputParameters.sce @@ -1,87 +1,87 @@ -// ----------------------------------------------------------------- -// === hArtes/PoliBa/GAP SCI2C tool === -// === Authors: === -// === Raffaele Nutricato === -// === raffaele.nutricato@tiscali.it === -// === Alberto Morea === -// === === -// === *************** === -// === USER PARAMETERS === -// === *************** === -// === === -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - - -// ------------------------------------------ -// --- Specify Paths of User Scilab code. --- -// ------------------------------------------ -UserSciCodeMainDir = 'C:\SCI2CTests\RegressionTests\test999'; - -// --- Path + filename of the .sci main file of the code to be translated. --- -// It is the entry point. -UserScilabMainFile = fullfile(UserSciCodeMainDir,'scilabcode\mainfun.sci'); - -// --- List of the paths containing the .sci files written by the user. --- -UserSciFilesPaths = ... - [... - fullfile(UserSciCodeMainDir,'scilabcode');... - ]; - -// -------------------------- -// --- End Specify paths. --- -// -------------------------- - - -// ---------------------------- -// --- Select the run mode. --- -// ---------------------------- -//RunMode = 'GenLibraryStructure'; -//RunMode = 'Translate'; -RunMode = 'All'; - -// --- Select one of the following options. --- - -// 'GenLibraryStructure'; -// Generates the library structure and exits. It is very -// useful when the user wants to manually change the files stored in that structure -// before running the translation. 'GenLibraryStructure' option forces SCI2C to remove -// the already existing WorkingDir and OutCCCodeDir directories. - -// 'Translate'; -// Performs the translation without generating the library structure. It means that the library -// structure must be already existing. This is useful when the user doesn't want to spend time -// to generate again that structure or when he wants to force the SCI2C tool to access to -// a manually-changed library structure. 'Translate' option forces SCI2C to don't remove -// the already existing WorkingDir. Only OutCCCodeDir directory will be removed. - -// 'All'; -// Performs all the actions listed above. - -// -------------------------------- -// --- End Select the run mode. --- -// -------------------------------- - - -// ---------------------------- -// --- Translation Options. --- -// ---------------------------- -// --- Enable (1) / Disable (0) copy of Scilab code into C code. --- -// If 1 the Scilab code will be copied into the C code in order to show -// how each Scilab code line has been translated into C code. -CopySciCodeIntoCCode = 1; - -// --- Select the path style for the C code. --- -// It can be: -// windows -// unix -// cygwin -CCompilerPathStyle = 'cygwin'; - -// --- Path + File name of the main SCI2C library header file. -Sci2CLibMainHeaderFName = 'C:\Nutricato\OpenProjects\FP6_hArtes\WP2_SCI2C\Software\Scilab2C\CFiles\sci2cincludes\sci2clib.h'; -// -------------------------------- -// --- End Translation Options. --- -// -------------------------------- +// -----------------------------------------------------------------
+// === hArtes/PoliBa/GAP SCI2C tool ===
+// === Authors: ===
+// === Raffaele Nutricato ===
+// === raffaele.nutricato@tiscali.it ===
+// === Alberto Morea ===
+// === ===
+// === *************** ===
+// === USER PARAMETERS ===
+// === *************** ===
+// === ===
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+
+// ------------------------------------------
+// --- Specify Paths of User Scilab code. ---
+// ------------------------------------------
+UserSciCodeMainDir = 'C:\SCI2CTests\RegressionTests\test999';
+
+// --- Path + filename of the .sci main file of the code to be translated. ---
+// It is the entry point.
+UserScilabMainFile = fullfile(UserSciCodeMainDir,'scilabcode\mainfun.sci');
+
+// --- List of the paths containing the .sci files written by the user. ---
+UserSciFilesPaths = ...
+ [...
+ fullfile(UserSciCodeMainDir,'scilabcode');...
+ ];
+
+// --------------------------
+// --- End Specify paths. ---
+// --------------------------
+
+
+// ----------------------------
+// --- Select the run mode. ---
+// ----------------------------
+//RunMode = 'GenLibraryStructure';
+//RunMode = 'Translate';
+RunMode = 'All';
+
+// --- Select one of the following options. ---
+
+// 'GenLibraryStructure';
+// Generates the library structure and exits. It is very
+// useful when the user wants to manually change the files stored in that structure
+// before running the translation. 'GenLibraryStructure' option forces SCI2C to remove
+// the already existing WorkingDir and OutCCCodeDir directories.
+
+// 'Translate';
+// Performs the translation without generating the library structure. It means that the library
+// structure must be already existing. This is useful when the user doesn't want to spend time
+// to generate again that structure or when he wants to force the SCI2C tool to access to
+// a manually-changed library structure. 'Translate' option forces SCI2C to don't remove
+// the already existing WorkingDir. Only OutCCCodeDir directory will be removed.
+
+// 'All';
+// Performs all the actions listed above.
+
+// --------------------------------
+// --- End Select the run mode. ---
+// --------------------------------
+
+
+// ----------------------------
+// --- Translation Options. ---
+// ----------------------------
+// --- Enable (1) / Disable (0) copy of Scilab code into C code. ---
+// If 1 the Scilab code will be copied into the C code in order to show
+// how each Scilab code line has been translated into C code.
+CopySciCodeIntoCCode = 1;
+
+// --- Select the path style for the C code. ---
+// It can be:
+// windows
+// unix
+// cygwin
+CCompilerPathStyle = 'cygwin';
+
+// --- Path + File name of the main SCI2C library header file.
+Sci2CLibMainHeaderFName = 'C:\Nutricato\OpenProjects\FP6_hArtes\WP2_SCI2C\Software\Scilab2C\CFiles\sci2cincludes\sci2clib.h';
+// --------------------------------
+// --- End Translation Options. ---
+// --------------------------------
diff --git a/src/Scilab2C/Scilab2C/ToolInitialization/UpdateSCI2CInfo.sci b/src/Scilab2C/Scilab2C/ToolInitialization/UpdateSCI2CInfo.sci index f10dff8f..32085475 100644 --- a/src/Scilab2C/Scilab2C/ToolInitialization/UpdateSCI2CInfo.sci +++ b/src/Scilab2C/Scilab2C/ToolInitialization/UpdateSCI2CInfo.sci @@ -1,129 +1,203 @@ -function UpdateSCI2CInfo(FileInfoDatFile) -// function UpdateSCI2CInfo(FileInfoDatFile) -// ----------------------------------------------------------------- -// -// Status: -// 13-Apr-2007 -- Raffaele Nutricato: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),1,1); - -clear FileInfo -load(FileInfoDatFile,'FileInfo'); - -clear SharedInfo -load(FileInfo.SharedInfoDatFile,'SharedInfo'); - -funname = SharedInfo.NextSCIFunName; -funnumber = SharedInfo.NextSCIFunNumber; - -PrintStepInfo('Start translation of function ""'+funname+'""',... - FileInfo.GeneralReport,'both'); -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'); - - -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; - - -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); - - -Converted = FL_UpdateConverted(SharedInfo.NFilesToTranslate,FileInfo.FunctionList.ConvertedDat); - -rmdir(fullfile(FileInfo.WorkingDir,funname),'s'); -mkdir(FileInfo.WorkingDir,funname); - -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); -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)) - 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'); - -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'); - -LocalVars = []; -TempVars = []; - -SharedInfo.DefaultPrecision = ... - FA_GetDefaultPrecision(FileInfo.Funct(funnumber).SCICopyFileName,FileInfo.Funct(funnumber).ReportFileName); - -save(FileInfoDatFile,FileInfo); - -save(FileInfo.SharedInfoDatFile,SharedInfo); -save(FileInfo.Funct(funnumber).LocalVarFileName,LocalVars); -save(FileInfo.Funct(funnumber).TempVarFileName,TempVars); - -save(FileInfo.FunctionList.ConvertedDat,Converted); - +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 diff --git a/src/Scilab2C/Scilab2C/ToolInitialization/doublecomplex.sci b/src/Scilab2C/Scilab2C/ToolInitialization/doublecomplex.sci index a36e7983..8b36bf65 100644 --- a/src/Scilab2C/Scilab2C/ToolInitialization/doublecomplex.sci +++ b/src/Scilab2C/Scilab2C/ToolInitialization/doublecomplex.sci @@ -1,16 +1,26 @@ -function y = doublecomplex(x) -// function y = doublecomplex(x) -// ----------------------------------------------------------------- -// -// Status: -// 27-Oct-2007 -- Raffaele Nutricato: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),1,1); - -y = x+0*%i; - +function y = doublecomplex(x)
+// function y = doublecomplex(x)
+// -----------------------------------------------------------------
+// //NUT: add description here
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 27-Oct-2007 -- Raffaele Nutricato: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+y = x+0*%i;
+
endfunction
\ No newline at end of file diff --git a/src/Scilab2C/Scilab2C/ToolInitialization/floatcomplex.sci b/src/Scilab2C/Scilab2C/ToolInitialization/floatcomplex.sci index d07667c5..eedae766 100644 --- a/src/Scilab2C/Scilab2C/ToolInitialization/floatcomplex.sci +++ b/src/Scilab2C/Scilab2C/ToolInitialization/floatcomplex.sci @@ -1,16 +1,26 @@ -function y = floatcomplex(x) -// function y = floatcomplex(x) -// ----------------------------------------------------------------- -// -// Status: -// 27-Oct-2007 -- Raffaele Nutricato: Author. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),1,1); - -y = x+0*%i; - +function y = floatcomplex(x)
+// function y = floatcomplex(x)
+// -----------------------------------------------------------------
+// //NUT: add description here
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 27-Oct-2007 -- Raffaele Nutricato: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),1,1);
+
+y = x+0*%i;
+
endfunction
\ No newline at end of file |