diff options
Diffstat (limited to '2.3-1/macros/ASTManagement')
22 files changed, 103 insertions, 833 deletions
diff --git a/2.3-1/macros/ASTManagement/%equal_string.sci b/2.3-1/macros/ASTManagement/%equal_string.sci index 041fb84a..9678f0e0 100644 --- a/2.3-1/macros/ASTManagement/%equal_string.sci +++ b/2.3-1/macros/ASTManagement/%equal_string.sci @@ -13,4 +13,4 @@ function txt=%equal_string(e) ' '+objectlist2string(e.lhs) 'EndEqual' ] -endfunction +endfunction
\ No newline at end of file diff --git a/2.3-1/macros/ASTManagement/%funcall_string.sci b/2.3-1/macros/ASTManagement/%funcall_string.sci index 0ee97016..faeb81d9 100644 --- a/2.3-1/macros/ASTManagement/%funcall_string.sci +++ b/2.3-1/macros/ASTManagement/%funcall_string.sci @@ -6,19 +6,10 @@ function txt=%funcall_string(F) // name : string, the name of the function // lhsnb: number, the number of function lhs -if F.name <> 'disp' txt=['Funcall : '+F.name ' #lhs : '+string(F.lhsnb) ' Rhs : ' ' '+objectlist2string(F.rhs) 'EndFuncall' ] -else -txt=['Funcall : '+F.name - ' #lhs : '+'0' - ' Rhs : ' - ' '+objectlist2string(F.rhs) - 'EndFuncall' - ] -end endfunction diff --git a/2.3-1/macros/ASTManagement/%operatio_string.sci b/2.3-1/macros/ASTManagement/%operatio_string.sci index cc18e919..8421a3f4 100644 --- a/2.3-1/macros/ASTManagement/%operatio_string.sci +++ b/2.3-1/macros/ASTManagement/%operatio_string.sci @@ -4,22 +4,10 @@ function txt=%operatio_string(O) //fields: // operands: a list // operator: a string -if O.operator <> 'rc' & O.operator <> 'cc' txt=['Operation' ' Operands:' ' '+objectlist2string(O.operands) ' Operator: '+O.operator 'EndOperation' ] -elseif O.operator == 'rc' - txt=[' Operands:' - ' '+objectlist2string(O.operands) - 'Endrc' - ] -elseif O.operator == 'cc' - txt=[' Begin:' - ' '+objectlist2string(O.operands) - 'Endcc' - ] -end -endfunction +endfunction
\ No newline at end of file diff --git a/2.3-1/macros/ASTManagement/%operation_string.sci b/2.3-1/macros/ASTManagement/%operation_string.sci index c9282f67..84f5ce3c 100644 --- a/2.3-1/macros/ASTManagement/%operation_string.sci +++ b/2.3-1/macros/ASTManagement/%operation_string.sci @@ -10,4 +10,4 @@ function txt=%operation_string(O) ' Operator: '+O.operator 'EndOperation' ] -endfunction +endfunction
\ No newline at end of file diff --git a/2.3-1/macros/ASTManagement/AST2Ccode.sci b/2.3-1/macros/ASTManagement/AST2Ccode.sci index 563f3133..8076d7e2 100644 --- a/2.3-1/macros/ASTManagement/AST2Ccode.sci +++ b/2.3-1/macros/ASTManagement/AST2Ccode.sci @@ -46,13 +46,6 @@ ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; // --------------------------------- // --- Parameter Initialization. --- // --------------------------------- - -global cc_count -cc_count = 0; - -global rc_count -rc_count = 0; - global SCI2CSTACK SCI2CSTACK = ['EMPTYSTACK']; @@ -61,9 +54,6 @@ StackPosition = 1; global STACKDEDUG STACKDEDUG = 0; // 1 -> Every Pop and Push operation on the stack, the stack content will be printed on screen. - -global disp_isthere -disp_isthere = 0; // ------------------------------------- // --- End parameter Initialization. --- // ------------------------------------- @@ -142,10 +132,9 @@ while ~meof(fidAST) //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 - [disp_isthere,FileInfo,SharedInfo] = AST_HandleEndGenFun(disp_isthere,FileInfo,SharedInfo,'Operation'); + [FileInfo,SharedInfo] = AST_HandleEndGenFun(FileInfo,SharedInfo,'Operation'); case 'EndFuncall' then - [disp_isthere,FileInfo,SharedInfo] = AST_HandleEndGenFun(disp_isthere,FileInfo,SharedInfo,'Funcall'); - disp(disp_isthere); + [FileInfo,SharedInfo] = AST_HandleEndGenFun(FileInfo,SharedInfo,'Funcall'); // -------------- // --- Equal. --- @@ -155,60 +144,25 @@ while ~meof(fidAST) //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. - if rc_count > 0 & cc_count == 0 - [FileInfo,SharedInfo] = AST_HandleFunRC(FileInfo,SharedInfo); - rc_count = 0; - elseif cc_count > 0 - [FileInfo,SharedInfo] = AST_HandleFunCC(cc_count,FileInfo,SharedInfo); - rc_count = 0; - cc_count = 0; - else - if disp_isthere == 0 - [disp_isthere,FileInfo,SharedInfo] = AST_HandleEndGenFun(disp_isthere,FileInfo,SharedInfo,'Equal'); - SharedInfo = INIT_SharedInfoEqual(SharedInfo); - end - end - disp_isthere = 0; - + [FileInfo,SharedInfo] = AST_HandleEndGenFun(FileInfo,SharedInfo,'Equal'); + SharedInfo = INIT_SharedInfoEqual(SharedInfo); case 'Equal' then SharedInfo.Equal.Enabled = 1; // 1 means enabled -> we are inside an equal AST block. AST_PushASTStack(treeline); case 'Lhs :' then - disp(disp_isthere); - if rc_count > 0 & cc_count == 0 - SharedInfo.Equal.Lhs = 1; - [EqualInArgName,EqualInArgScope,EqualNInArg] = AST_HandleRC(FileInfo,SharedInfo); - SharedInfo.Equal.NInArg = EqualNInArg - rc_count -1; - AST_PushASTStack(treeline); - for tmpcnt = 1:SharedInfo.Equal.NInArg - SharedInfo.Equal.InArg(tmpcnt).Name = EqualInArgName(tmpcnt); - SharedInfo.Equal.InArg(tmpcnt).Scope = EqualInArgScope(tmpcnt); - end - elseif cc_count > 0 - SharedInfo.Equal.Lhs = 1; - [EqualInArgName,EqualInArgScope,EqualNInArg] = AST_HandleCC(FileInfo,SharedInfo); - AST_PushASTStack(treeline); - else - SharedInfo.Equal.Lhs = 1; // 1 means that we are inside the Lhs block of the Equal - //if SharedInfo.Equal.NOutArg > 0 - if disp_isthere == 0 - [EqualInArgName,EqualInArgScope,EqualNInArg] = AST_ReadEqualRhsNames(FileInfo,SharedInfo); - SharedInfo.Equal.NInArg = EqualNInArg; - //end - - // lengthNumber = length('Number_'); - // if (part(EqualInArgScope,1:lengthNumber) == 'Number_') - // SharedInfo.SkipNextEqual = 1 - // end - - for tmpcnt = 1:SharedInfo.Equal.NInArg - SharedInfo.Equal.InArg(tmpcnt).Name = EqualInArgName(tmpcnt); - SharedInfo.Equal.InArg(tmpcnt).Scope = EqualInArgScope(tmpcnt); - end - //end - end - AST_PushASTStack(treeline); - end + SharedInfo.Equal.Lhs = 1; // 1 means that we are inside the Lhs block of the Equal + [EqualInArgName,EqualInArgScope,EqualNInArg] = AST_ReadEqualRhsNames(FileInfo,SharedInfo); + + // lengthNumber = length('Number_'); + // if (part(EqualInArgScope,1:lengthNumber) == 'Number_') + // SharedInfo.SkipNextEqual = 1 + // end + SharedInfo.Equal.NInArg = EqualNInArg; + for tmpcnt = 1:SharedInfo.Equal.NInArg + SharedInfo.Equal.InArg(tmpcnt).Name = EqualInArgName(tmpcnt); + SharedInfo.Equal.InArg(tmpcnt).Scope = EqualInArgScope(tmpcnt); + end + AST_PushASTStack(treeline); // ---------------- // --- If/Else. --- @@ -242,7 +196,6 @@ while ~meof(fidAST) // ----------------- case 'EndProgram' SharedInfo = AST_HandleEndProgram(FileInfo,SharedInfo); - disp_isthere = 0; //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 @@ -276,15 +229,6 @@ while ~meof(fidAST) SharedInfo = AST_HandleEndWhile(FileInfo,SharedInfo); SharedInfo.While.Level = SharedInfo.While.Level - 1; - - case 'Endrc' then - rc_count = rc_count + 1; - - case 'Endcc' then - cc_count = cc_count + 1; - - //[FileInfo,SharedInfo] = AST_HandleRC(FileInfo,SharedInfo); - // ---------------- // --- Default. --- // ---------------- diff --git a/2.3-1/macros/ASTManagement/AST_HandleCC.sci b/2.3-1/macros/ASTManagement/AST_HandleCC.sci deleted file mode 100644 index cc411549..00000000 --- a/2.3-1/macros/ASTManagement/AST_HandleCC.sci +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (C) 2017 - IIT Bombay - FOSSEE - -// 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 -// Author: Ukasha Noor -// Organization: FOSSEE, IIT Bombay -// Email: toolbox@scilab.in - -function [RhsNames,RhsScope,NRhs] = AST_HandleCC(FileInfo,SharedInfo) - -SCI2CNInArgCheck(argn(2),2,2) - -ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; - -// ------------------------------ -// --- Check input arguments. --- -// ------------------------------ - - -global SCI2CSTACK -global StackPosition; -global STACKDEDUG -// --------------------------- -// --- End Initialization. --- -// --------------------------- - - -// ------------------------------ -// --- Read input parameters. --- -// ------------------------------ -cntpop = 1; -NRhs = 0; -RhsField(cntpop) = AST_PopASTStack(); -RhsNames = []; -while (RhsField(cntpop) ~= 'Expression:') - if RhsField(cntpop) <> 'Operands:' & RhsField(cntpop) <> 'Begin:' - NRhs = NRhs + 1; - - [RhsNames(NRhs),RhsScope(NRhs)] = AST_ExtractNameAndScope(RhsField(cntpop)); - end - cntpop = cntpop + 1; - RhsField(cntpop) = AST_PopASTStack(); -end -RhsNames = SCI2Cflipud(RhsNames); -RhsScope = SCI2Cflipud(RhsScope); - -// --- Repush everything into the stack. --- -for cntpush = cntpop:-1:1 - if RhsField(cntpush) <> 'Operands:' & RhsField(cntpush) <> 'Begin:' - PrintStringInfo(' ' + RhsField(cntpush),ReportFileName,'file','y'); - AST_PushASTStack(RhsField(cntpush)); - end -end - - -//for counterinputargs = 1:NRhs - //#RNU_RES_B - //disp(counterinputargs); - //PrintStringInfo('Input Argument Number '+string(counterinputargs)+': '+RhsNames(counterinputargs).Name,... - // ReportFileName,'file','y'); - //PrintStringInfo(' Scope: '+RhsNames(counterinputargs).Scope,... - // ReportFileName,'file','y'); - //#RNU_RES_E -//end - -endfunction diff --git a/2.3-1/macros/ASTManagement/AST_HandleEndGenFun.sci b/2.3-1/macros/ASTManagement/AST_HandleEndGenFun.sci index 96830aa9..5ff7181f 100644 --- a/2.3-1/macros/ASTManagement/AST_HandleEndGenFun.sci +++ b/2.3-1/macros/ASTManagement/AST_HandleEndGenFun.sci @@ -1,5 +1,5 @@ -function [disp_isthere,FileInfo,SharedInfo] = AST_HandleEndGenFun(disp_isthere,FileInfo,SharedInfo,ASTFunType) +function [FileInfo,SharedInfo] = AST_HandleEndGenFun(FileInfo,SharedInfo,ASTFunType) // function [FileInfo,SharedInfo] = AST_HandleEndGenFun(FileInfo,SharedInfo,ASTFunType) // ----------------------------------------------------------------- // #RNU_RES_B @@ -36,7 +36,7 @@ function [disp_isthere,FileInfo,SharedInfo] = AST_HandleEndGenFun(disp_isthere,F // ------------------------------ // --- Check input arguments. --- // ------------------------------ -SCI2CNInArgCheck(argn(2),4,4); +SCI2CNInArgCheck(argn(2),3,3); // ----------------------- // --- Initialization. --- @@ -61,8 +61,6 @@ PrintStepInfo('Handling Funcall/Operation/Equal',FileInfo.Funct(nxtscifunnumber) global SCI2CSTACK global StackPosition; global STACKDEDUG - -disp_isthere = 0; // --------------------------- // --- End Initialization. --- // --------------------------- @@ -75,19 +73,6 @@ disp_isthere = 0; // #RNU_RES_E [ASTFunName,InArg,NInArg,OutArg,NOutArg] = AST_GetFuncallPrm(FileInfo,SharedInfo,ASTFunType); NOutArg_mod = NOutArg - if ASTFunName == 'OpLogAnd' - AST_PushASTStack('&&'); - return ; - end - if ASTFunName == 'OpLogOr' - AST_PushASTStack('||'); - return; - end - - if ASTFunName == 'disp' - disp_isthere = 1; - end - if(mtlb_strcmp(part(ASTFunName,1:2),'CV') == %T) SharedInfo.OpenCVUsed = %T; end @@ -127,8 +112,6 @@ NOutArg_mod = NOutArg PrintStringInfo(' ',ReportFileName,'both','y'); error(9999, 'SCI2CERROR: Unexpected number of output arguments for global function.'); end - elseif(ASTFunName == 'raspi' | ASTFunName == 'raspi_close') - SharedInfo.SkipNextFun = 1; end // #RNU_RES_B @@ -136,13 +119,6 @@ NOutArg_mod = NOutArg // --- Read the function annotations. --- // -------------------------------------- // #RNU_RES_E - if ASTFunName == '%k' - ASTFunName='modk'; - end - - if ASTFunName == '%sn' - ASTFunName='modsn'; - end if (ASTFunName == 'OpEqual') FunTypeAnnot = ''; @@ -156,7 +132,6 @@ NOutArg_mod = NOutArg // --- Search for Equal Lhs and precision specifier to be applied to the current function. --- // ------------------------------------------------------------------------------------------- // #RNU_RES_E - PrintStringInfo(' no of out arguments' + string(NOutArg),ReportFileName,'file','y'); [LhsArg,NLhsArg,FunPrecSpecifier,SharedInfo] = AST_GetPrecAndLhsArg(OutArg,NOutArg,ASTFunName,FunTypeAnnot,FunSizeAnnot,ASTFunType,FileInfo,SharedInfo); //NUT: questa funzione contiene troppi parametri e mi sembra disordinata. @@ -354,13 +329,8 @@ NOutArg_mod = NOutArg OutArg(1).Name = string(OutArg(1).Value); elseif ((ASTFunName == 'double') & (NInArg == 1) & (InArg(1).Dimension == 0) & (InArg(1).Scope == 'Number')) OutArg(1).Name = string(OutArg(1).Value); - //elseif ASTFunName == 'disp' else [OutArg,SharedInfo] = GenOutArgNames(ASTFunName,InArg,NInArg,OutArg,NOutArg,LhsArg,NLhsArg,FileInfo,SharedInfo); - if ( ASTFunName == 'OpLogGt' | ASTFunName == 'OpLogLt' | ASTFunName == 'OpLogLe' | ASTFunName == 'OpLogGe' | ASTFunName == 'OpLogNe' | ASTFunName == 'OpLogEq') - PrintStringInfo(' returning back due logical function',ReportFileName,'file','y'); - return; - end end if ((ASTFunName == 'uint8') & (NInArg == 1) & (InArg(1).Dimension == 0) & (InArg(1).Scope == 'Number')) @@ -404,8 +374,6 @@ NOutArg_mod = NOutArg // Scope already set above. elseif (ASTFunName == 'double' & NInArg == 1 & (InArg(1).Dimension == 0) & (InArg(1).Scope == 'Number')) // Scope already set above. - //elseif ASTFunName == 'disp' - //do nothing else OutArg = ST_AnalyzeScope(OutArg,NOutArg,FileInfo,SharedInfo); end @@ -424,8 +392,6 @@ NOutArg_mod = NOutArg //#RNUREM_ME A number is not inserted in the symbol table. elseif ((ASTFunName == 'double') & (NInArg == 1) & (InArg(1).Dimension == 0) & (InArg(1).Scope == 'Number')) //#RNUREM_ME A number is not inserted in the symbol table. - //elseif ASTFunName == 'disp' - //do nothing else ST_InsOutArg(OutArg,NOutArg,FileInfo,SharedInfo,'all'); end @@ -458,10 +424,8 @@ NOutArg_mod = NOutArg // -------------------------------------------- //#RNU_RES_E //disp(OutArg,InArg,ASTFunName) - - CFunName = C_GenerateFunName(ASTFunName,InArg,NInArg,OutArg,NOutArg_mod); - + //#RNU_RES_B PrintStringInfo(' C Function Name: '+CFunName,ReportFileName,'file','y'); if(IsArduinoFunction(ASTFunName)) @@ -485,8 +449,7 @@ NOutArg_mod = NOutArg else LibTypeInfo = 'USER2C'; end - - + //#RNU_RES_B // ------------------------------------------------------------------------------------ // --- Check whether the function has been already called in the current .sci file. --- @@ -533,8 +496,6 @@ NOutArg_mod = NOutArg SharedInfo.SkipNextFun > 0 | ... ((sum(mtlb_strcmp(ASTFunName,SharedInfo.Annotations.DataPrec)) > 0) & (SharedInfo.SkipNextPrec == 1))) // Do nothing - //elseif ASTFunName == 'disp' - // Do nothing else AST_CheckCommonInOutArgs(InArg,NInArg,OutArg,NOutArg,ReportFileName); end diff --git a/2.3-1/macros/ASTManagement/AST_HandleFunCC.sci b/2.3-1/macros/ASTManagement/AST_HandleFunCC.sci deleted file mode 100644 index 1942c749..00000000 --- a/2.3-1/macros/ASTManagement/AST_HandleFunCC.sci +++ /dev/null @@ -1,176 +0,0 @@ -// Copyright (C) 2017 - IIT Bombay - FOSSEE - -// 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 -// Author: Ukasha Noor -// Organization: FOSSEE, IIT Bombay -// Email: toolbox@scilab.in - - -function [FileInfo,SharedInfo] = AST_HandleFunCC(NCol,FileInfo,SharedInfo) - -SCI2CNInArgCheck(argn(2),3,3) - -// ------------------------------ -// --- Check input arguments. --- -// ------------------------------ - -// ----------------------- -// --- Initialization. --- -// ----------------------- -nxtscifunname = SharedInfo.NextSCIFunName; -nxtscifunnumber = SharedInfo.NextSCIFunNumber; -ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; - -global SCI2CSTACK -global StackPosition; -global STACKDEDUG -// --------------------------- -// --- End Initialization. --- -// --------------------------- - -// ------------------------------ -// --- Read output parameters. -- -// ------------------------------ -LhsField = AST_PopASTStack(); -NOutArg = 0; -OutputArgumentNames = []; -OutputArgumentScope = []; -while (LhsField ~= 'Lhs :') - NOutArg = NOutArg + 1; - [OutputArgumentNames(NOutArg),OutputArgumentScope(NOutArg)] = AST_ExtractNameAndScope(LhsField); - LhsField = AST_PopASTStack(); - if (LhsField == 'Expression:') - error(9999, 'Found Expression: before Lhs'); - elseif (LhsField == 'Equal') - error(9999, 'Found Equal before Lhs'); - end -end - -// ------------------------------ -// --- Read input parameters. --- -// ------------------------------ - - -RhsField = AST_PopASTStack(); -InputArgumentNames = []; -InputArgumentScope = []; -NInArg = 0; -InArg = []; -while (RhsField ~= 'Expression:') - NInArg = NInArg + 1; - if RhsField <> 'Operands:' - [InputArgumentNames(NInArg),InputArgumentScope(NInArg)] = AST_ExtractNameAndScope(RhsField); - end - //InArg(NInArg) = RhsField; - RhsField = AST_PopASTStack(); -end -InputArgumentNames = SCI2Cflipud(InputArgumentNames); -InputArgumentScope = SCI2Cflipud(InputArgumentScope); - - -// ------------------------------------- -// --- Generate the InArg structure. --- -// ------------------------------------- -//#RNU_RES_E -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); - OutArg(counteroutputargs).Scope=OutputArgumentScope(counteroutputargs); -end - -// ------------------------ -// --- Print Some Info. --- -// ------------------------ - -PrintStringInfo('N Input Arguments: '+string(NInArg),ReportFileName,'file','y','n'); -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','n'); - PrintStringInfo(' Scope: '+InArg(counterinputargs).Scope,... - ReportFileName,'file','y','n'); - //#RNU_RES_E - end - for counteroutputargs = 1:NOutArg - //#RNU_RES_B - PrintStringInfo('Output Argument Number '+string(counteroutputargs)+': '+OutArg(counteroutputargs).Name,... - ReportFileName,'file','y','n'); - //PrintStringInfo(' Scope: '+ OutArg(counterinputargs).Scope,ReportFileName,'file','y','n'); - //#RNU_RES_E - end - -NOutArg_mod = NOutArg; - -FunTypeAnnot = ''; -FunSizeAnnot = ''; -NLhsArg = 0; -LhsArg = []; -PrintStringInfo('...Equal not found.',ReportFileName,'file','y'); - -PrintStringInfo('***Analyzing Input Arguments***',ReportFileName,'file','y'); -UpdatedInArg = InArg; -[InArg,SharedInfo] = ST_GetInArgInfo(InArg,NInArg,FileInfo,SharedInfo,'OpEqual'); - -NCol = NCol + 1; -NRow = NInArg/NCol; - -com_type = 0; -for i = 1:NInArg - if InArg(i).Type == 'z' - com_type = 1; - elseif InArg(i).Type == 'c' - com_type = 2; - end -end - - -if com_type == 0 - PrintStringInfo(' Generating Out Arg names.',ReportFileName,'file','y'); - OutArg(1).Type = InArg(1).Type; - OutArg(1).Size(1) = string(NCol); - OutArg(1).Size(2) = string(NRow); - OutArg(1).Dimension = 2; - OutArg(1).Value = InArg(1).Value; - OutArg(1).FindLike = InArg(1).FindLike; -elseif com_type == 1 - PrintStringInfo(' Generating Out Arg names.',ReportFileName,'file','y'); - OutArg(1).Type = 'z'; - OutArg(1).Size(1) = string(NCol); - OutArg(1).Size(2) = string(NRow); - OutArg(1).Dimension = 2; - OutArg(1).Value = InArg(1).Value; - OutArg(1).FindLike = InArg(1).FindLike; -else - PrintStringInfo(' Generating Out Arg names.',ReportFileName,'file','y'); - OutArg(1).Type = 'c'; - OutArg(1).Size(1) = string(NCol); - OutArg(1).Size(2) = string(NRow); - OutArg(1).Dimension = 2; - OutArg(1).Value = InArg(1).Value; - OutArg(1).FindLike = InArg(1).FindLike; -end - -//--- Check for output Argument in symbol table ---// -OutArg = ST_AnalyzeScope(OutArg,NOutArg,FileInfo,SharedInfo); - -//--- Put the output Argument in symbol table ---// -ST_InsOutArg_Dup(InArg,NInArg,OutArg,NOutArg,com_type,FileInfo,SharedInfo,'all'); - - -endfunction diff --git a/2.3-1/macros/ASTManagement/AST_HandleFunRC.sci b/2.3-1/macros/ASTManagement/AST_HandleFunRC.sci deleted file mode 100644 index d3169249..00000000 --- a/2.3-1/macros/ASTManagement/AST_HandleFunRC.sci +++ /dev/null @@ -1,178 +0,0 @@ -// Copyright (C) 2017 - IIT Bombay - FOSSEE - -// 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 -// Author: Ukasha Noor -// Organization: FOSSEE, IIT Bombay -// Email: toolbox@scilab.in - -function [FileInfo,SharedInfo] = AST_HandleFunRC(FileInfo,SharedInfo) - -SCI2CNInArgCheck(argn(2),2,2) - -// ------------------------------ -// --- Check input arguments. --- -// ------------------------------ - -// ----------------------- -// --- Initialization. --- -// ----------------------- -nxtscifunname = SharedInfo.NextSCIFunName; -nxtscifunnumber = SharedInfo.NextSCIFunNumber; -ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; - -global SCI2CSTACK -global StackPosition; -global STACKDEDUG -// --------------------------- -// --- End Initialization. --- -// --------------------------- - -// ------------------------------ -// --- Read output parameters. -- -// ------------------------------ -LhsField = AST_PopASTStack(); -NOutArg = 0; -OutputArgumentNames = []; -OutputArgumentScope = []; -while (LhsField ~= 'Lhs :') - NOutArg = NOutArg + 1; - [OutputArgumentNames(NOutArg),OutputArgumentScope(NOutArg)] = AST_ExtractNameAndScope(LhsField); - LhsField = AST_PopASTStack(); - if (LhsField == 'Expression:') - error(9999, 'Found Expression: before Lhs'); - elseif (LhsField == 'Equal') - error(9999, 'Found Equal before Lhs'); - end -end - -// ------------------------------ -// --- Read input parameters. --- -// ------------------------------ - - -RhsField = AST_PopASTStack(); -InputArgumentNames = []; -InputArgumentScope = []; -NInArg = 0; -InArg = []; -while (RhsField ~= 'Expression:') - NInArg = NInArg + 1; - if RhsField <> 'Operands:' - [InputArgumentNames(NInArg),InputArgumentScope(NInArg)] = AST_ExtractNameAndScope(RhsField); - end - //InArg(NInArg) = RhsField; - RhsField = AST_PopASTStack(); -end -InputArgumentNames = SCI2Cflipud(InputArgumentNames); -InputArgumentScope = SCI2Cflipud(InputArgumentScope); - - -// ------------------------------------- -// --- Generate the InArg structure. --- -// ------------------------------------- -//#RNU_RES_E -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); - OutArg(counteroutputargs).Scope=OutputArgumentScope(counteroutputargs); -end - - -// ------------------------ -// --- Print Some Info. --- -// ------------------------ - -PrintStringInfo('N Input Arguments: '+string(NInArg),ReportFileName,'file','y','n'); -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','n'); - PrintStringInfo(' Scope: '+InArg(counterinputargs).Scope,... - ReportFileName,'file','y','n'); - //#RNU_RES_E - end - for counteroutputargs = 1:NOutArg - //#RNU_RES_B - PrintStringInfo('Output Argument Number '+string(counteroutputargs)+': '+OutArg(counteroutputargs).Name,... - ReportFileName,'file','y','n'); - //PrintStringInfo(' Scope: '+ OutArg(counterinputargs).Scope,ReportFileName,'file','y','n'); - //#RNU_RES_E - end - -NOutArg_mod = NOutArg; - -FunTypeAnnot = ''; -FunSizeAnnot = ''; -NLhsArg = 0; -LhsArg = []; -PrintStringInfo('...Equal not found.',ReportFileName,'file','y'); - -PrintStringInfo('***Analyzing Input Arguments***',ReportFileName,'file','y'); -UpdatedInArg = InArg; -[InArg,SharedInfo] = ST_GetInArgInfo(InArg,NInArg,FileInfo,SharedInfo,'OpEqual'); - -size_count = 0; -for i = 1:NInArg - size_count = size_count + eval(InArg(i).Size(2)); -end - -com_type = 0; -for i = 1:NInArg - if InArg(i).Type == 'z' - com_type = 1; - elseif InArg(i).Type == 'c' - com_type = 2; - end -end - - -if com_type == 0 - PrintStringInfo(' Generating Out Arg names.',ReportFileName,'file','y'); - OutArg(1).Type = InArg(1).Type; - OutArg(1).Size(1) = '1' - OutArg(1).Size(2) = string(size_count); - OutArg(1).Dimension = 2; - OutArg(1).Value = InArg(1).Value; - OutArg(1).FindLike = InArg(1).FindLike; -elseif com_type == 1 - PrintStringInfo(' Generating Out Arg names.',ReportFileName,'file','y'); - OutArg(1).Type = 'z'; - OutArg(1).Size(1) = '1' - OutArg(1).Size(2) = string(size_count); - OutArg(1).Dimension = 2; - OutArg(1).Value = InArg(1).Value; - OutArg(1).FindLike = InArg(1).FindLike; -else - PrintStringInfo(' Generating Out Arg names.',ReportFileName,'file','y'); - OutArg(1).Type = 'c'; - OutArg(1).Size(1) = '1' - OutArg(1).Size(2) = string(size_count); - OutArg(1).Dimension = 2; - OutArg(1).Value = InArg(1).Value; - OutArg(1).FindLike = InArg(1).FindLike; -end - -//--- Check for output Argument in symbol table ---// -OutArg = ST_AnalyzeScope(OutArg,NOutArg,FileInfo,SharedInfo); - -//--- Put the output Argument in symbol table ---// -ST_InsOutArg_Dup(InArg,NInArg,OutArg,NOutArg,com_type,FileInfo,SharedInfo,'all'); - - -endfunction diff --git a/2.3-1/macros/ASTManagement/AST_HandleIfElse.sci b/2.3-1/macros/ASTManagement/AST_HandleIfElse.sci index 2b549ed6..5373adf6 100644 --- a/2.3-1/macros/ASTManagement/AST_HandleIfElse.sci +++ b/2.3-1/macros/ASTManagement/AST_HandleIfElse.sci @@ -74,13 +74,11 @@ global STACKDEDUG // --------------------------------------------------- //#RNU_RES_E if (ASTIfExpType~='else') - [IfCondArg,NIfCondArg,Op,NOp] = AST_ParseIfExprStruct(FileInfo,SharedInfo,ASTIfExpType); + [IfCondArg,NIfCondArg] = AST_ParseIfExprStruct(FileInfo,SharedInfo,ASTIfExpType); else // "else" type doesn't contain any condition to test. IfCondArg = ''; NIfCondArg = 0; - Op = ''; - NOp = 0; end //#RNU_RES_B @@ -89,6 +87,6 @@ end // ----------------------------- // --- Generate the C code for if/elseif Expression. --- //#RNU_RES_E -SharedInfo = C_IfExpression(IfCondArg,NIfCondArg,Op,NOp,ASTIfExpType,FileInfo,SharedInfo); +SharedInfo = C_IfExpression(IfCondArg,NIfCondArg,ASTIfExpType,FileInfo,SharedInfo); endfunction diff --git a/2.3-1/macros/ASTManagement/AST_HandleRC.sci b/2.3-1/macros/ASTManagement/AST_HandleRC.sci deleted file mode 100644 index 2a6cbc3f..00000000 --- a/2.3-1/macros/ASTManagement/AST_HandleRC.sci +++ /dev/null @@ -1,88 +0,0 @@ -function [RhsNames,RhsScope,NRhs] = AST_HandleRC(FileInfo,SharedInfo) -// 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. -// -// Copyright 2007 Raffaele Nutricato. -// Contact: raffaele.nutricato@tiscali.it -// ----------------------------------------------------------------- - -SCI2CNInArgCheck(argn(2),2,2) - -ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; - -// ------------------------------ -// --- Check input arguments. --- -// ------------------------------ - - -global SCI2CSTACK -global StackPosition; -global STACKDEDUG -// --------------------------- -// --- End Initialization. --- -// --------------------------- - - -// ------------------------------ -// --- Read input parameters. --- -// ------------------------------ -cntpop = 1; -NRhs = 0; -RhsField(cntpop) = AST_PopASTStack(); -RhsNames = []; -while (RhsField(cntpop) ~= 'Expression:') - NRhs = NRhs + 1; - if RhsField(cntpop) <> 'Operands:' - [RhsNames(NRhs),RhsScope(NRhs)] = AST_ExtractNameAndScope(RhsField(cntpop)); - end - cntpop = cntpop + 1; - RhsField(cntpop) = AST_PopASTStack(); -end -RhsNames = SCI2Cflipud(RhsNames); -RhsScope = SCI2Cflipud(RhsScope); - -// --- Repush everything into the stack. --- -for cntpush = cntpop:-1:1 - if RhsField(cntpush) <> 'Operands:' - AST_PushASTStack(RhsField(cntpush)); - end -end - - -//for counterinputargs = 1:NRhs - //#RNU_RES_B - //disp(counterinputargs); - // PrintStringInfo('Input Argument Number '+string(counterinputargs)+': '+RhsNames(counterinputargs).Name,... - // ReportFileName,'file','y'); - //PrintStringInfo(' Scope: '+RhsNames(counterinputargs).Scope,... - // ReportFileName,'file','y'); - //#RNU_RES_E -//end - -endfunction diff --git a/2.3-1/macros/ASTManagement/AST_HandleWhileStatem.sci b/2.3-1/macros/ASTManagement/AST_HandleWhileStatem.sci index d8c2f73c..79fb516d 100644 --- a/2.3-1/macros/ASTManagement/AST_HandleWhileStatem.sci +++ b/2.3-1/macros/ASTManagement/AST_HandleWhileStatem.sci @@ -36,8 +36,6 @@ global SCI2CSTACK global StackPosition; global STACKDEDUG -IfCondArg = []; -NIfCondArg = 0; // ------------------------------ // --- Check input arguments. --- @@ -72,40 +70,36 @@ PrintStringInfo(' Redirecting C code to: '+FileInfo.Funct(nxtscifunnumber).CPa // --- Generate C code. --- // ------------------------ //#RNU_RES_E -flagendpop = 0; -IfExprField = AST_PopASTStack(); - -NOp=0; -Op=[]; -while (flagendpop == 0) - if (IfExprField~='<EOL>') - if (IfExprField=='WhileExpression:') - flagendpop = 1; - // Pop Again the If tag from the AST. - IfExprField = AST_PopASTStack(); - elseif (IfExprField=='Operands:') - flagendpop = 0; - g = AST_PopASTStack(); - else - if (IfExprField=='&&' | IfExprField=='||') - NOp = NOp + 1; - Op(NOp) = IfExprField; - //PrintStringInfo('operators are '+Op(NOp),ReportFileName,'file','y'); - else - NIfCondArg = NIfCondArg + 1; - IfCondArg(NIfCondArg) = IfExprField; - end - //[IfCondArg(NIfCondArg),tmpscope] = AST_ExtractNameAndScope(IfExprField); - //[IfCondArg(NIfCondArg),tmpscope] = AST_ExtractNameAndScope(IfExprField); - end +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 http://forge.scilab.org/index.php/p/scilab2c/issues/.','','stdout','y'); + PrintStringInfo(' ',ReportFileName,'both','y'); + error(9999, 'Expected a conditional variable in the while expression'); end - IfExprField = AST_PopASTStack(); - PrintStringInfo('operators are '+IfExprField,ReportFileName,'file','y'); -end -IfCondArg = SCI2Cflipud(IfCondArg); + SharedInfo.WhileExpr.CondVar = ArgName; + //#RNU_RES_B + // --- Repush strings into the AST stack. --- + //#RNU_RES_E -SharedInfo = C_WhileExpression(IfCondArg,NIfCondArg,Op,NOp,FileInfo,SharedInfo); + AST_PushASTStack(Pop1); + +elseif (SharedInfo.WhileExpr.DimCondVar > 0) + error(9999, 'Cannot manage while with matrix conditions'); +end +SharedInfo = C_WhileExpression(FileInfo,SharedInfo); // -------------------------- // --- Update SharedInfo. --- diff --git a/2.3-1/macros/ASTManagement/AST_ParseEqualStruct.sci b/2.3-1/macros/ASTManagement/AST_ParseEqualStruct.sci index 68bc3da7..fa76a01d 100644 --- a/2.3-1/macros/ASTManagement/AST_ParseEqualStruct.sci +++ b/2.3-1/macros/ASTManagement/AST_ParseEqualStruct.sci @@ -123,7 +123,7 @@ end // ------------------------ //#RNU_RES_B PrintStringInfo('Function Name: '+FunctionName,ReportFileName,'file','y','n'); -PrintStringInfo('N Input Arguments: '+string(NInArg),ReportFileName,'file','y','n'); +PrintStringInfo('N Intput Arguments: '+string(NInArg),ReportFileName,'file','y','n'); //#RNU_RES_E if (SharedInfo.Equal.Nins > 0) //#RNU_RES_B diff --git a/2.3-1/macros/ASTManagement/AST_ParseFuncallStruct.sci b/2.3-1/macros/ASTManagement/AST_ParseFuncallStruct.sci index 3c322dd5..647a70d7 100644 --- a/2.3-1/macros/ASTManagement/AST_ParseFuncallStruct.sci +++ b/2.3-1/macros/ASTManagement/AST_ParseFuncallStruct.sci @@ -87,10 +87,6 @@ NOutArg = eval(stripblanks(part(buffstring,10:length(buffstring)))); buffstring = AST_PopASTStack(); FunctionName = stripblanks(part(buffstring,12:length(buffstring))); -//if (FunctionName == 'disp') - // NOutArg = 0; -//end - // ------------------------------------- // --- Generate the InArg structure. --- // ------------------------------------- diff --git a/2.3-1/macros/ASTManagement/AST_ParseIfExprStruct.sci b/2.3-1/macros/ASTManagement/AST_ParseIfExprStruct.sci index 2bfb08dd..a7da0128 100644 --- a/2.3-1/macros/ASTManagement/AST_ParseIfExprStruct.sci +++ b/2.3-1/macros/ASTManagement/AST_ParseIfExprStruct.sci @@ -1,4 +1,4 @@ -function [IfCondArg,NIfCondArg,Op,NOp] = AST_ParseIfExprStruct(FileInfo,SharedInfo,ASTIfExpType) +function [IfCondArg,NIfCondArg] = AST_ParseIfExprStruct(FileInfo,SharedInfo,ASTIfExpType) // function [IfCondArg,NIfCondArg] = AST_ParseIfExprStruct(FileInfo,SharedInfo,ASTIfExpType) // ----------------------------------------------------------------- //#RNU_RES_B @@ -63,26 +63,13 @@ global STACKDEDUG // ------------------------------------ // --- Read if condition variables. --- // ------------------------------------ -//OutArgOld=[]; -//OutArgNew=[]; - -//for i = 1:3 - // OutArgOld(i)=AST_PopASTStack(); - //PrintStringInfo(' '+OutArgOld(i),ReportFileName,'file','y'); -//end -//x = AST_PopASTStack(); - -//OutArgNew = SCI2Cflipud(OutArgOld); - flagendpop = 0; IfExprField = AST_PopASTStack(); -PrintStringInfo(' '+IfExprField+' '+ASTIfExpType,ReportFileName,'file','y'); if (ASTIfExpType=='if') if (IfExprField=='Expression:') flagendpop = 1; // Pop Again the If tag from the AST. IfExprField = AST_PopASTStack(); - PrintStringInfo(' '+IfExprField,ReportFileName,'file','y'); end elseif (ASTIfExpType=='elseif') if (IfExprField=='Else If Expression') @@ -91,57 +78,31 @@ elseif (ASTIfExpType=='elseif') else error(9999, 'Unknown ASTIfExpType ""'+ASTIfExpType+'"".'); end -NOp=0; -Op=[]; + while (flagendpop == 0) if (IfExprField~='<EOL>') if (ASTIfExpType=='if') if (IfExprField=='Expression:') flagendpop = 1; - //PrintStringInfo('hello dere '+IfExprField,ReportFileName,'file','y'); // Pop Again the If tag from the AST. IfExprField = AST_PopASTStack(); - elseif (IfExprField=='Operands:') - flagendpop = 0; - g = AST_PopASTStack(); else - if (IfExprField=='&&' | IfExprField=='||') - NOp = NOp + 1; - Op(NOp) = IfExprField; - //PrintStringInfo('operators are '+Op(NOp),ReportFileName,'file','y'); - else NIfCondArg = NIfCondArg + 1; - IfCondArg(NIfCondArg) = IfExprField; - end - //[IfCondArg(NIfCondArg),tmpscope] = AST_ExtractNameAndScope(IfExprField); + [IfCondArg(NIfCondArg),tmpscope] = AST_ExtractNameAndScope(IfExprField); end elseif (ASTIfExpType=='elseif') if (IfExprField=='Else If Expression') flagendpop = 1; - //IfExprField = AST_PopASTStack(); else - if (IfExprField=='&&' | IfExprField=='||') - NOp = NOp + 1; - Op(NOp) = IfExprField; - elseif (IfExprField=='Operands:') - flagendpop = 0; - g = AST_PopASTStack(); - else - NIfCondArg = NIfCondArg + 1; - IfCondArg(NIfCondArg) = IfExprField; - end - //[IfCondArg(NIfCondArg),tmpscope] = AST_ExtractNameAndScope(IfExprField); + NIfCondArg = NIfCondArg + 1; + IfCondArg(NIfCondArg) = IfExprField; + [IfCondArg(NIfCondArg),tmpscope] = AST_ExtractNameAndScope(IfExprField); end end end - if flagendpop == 0 IfExprField = AST_PopASTStack(); - end - PrintStringInfo('operators are '+IfExprField,ReportFileName,'file','y'); end -IfCondArg = SCI2Cflipud(IfCondArg); - //#RNU_RES_B // ------------------------------------------- // --- Print some info in the report file. --- diff --git a/2.3-1/macros/ASTManagement/AST_ParseOperStruct.sci b/2.3-1/macros/ASTManagement/AST_ParseOperStruct.sci index 903f0958..a77317bd 100644 --- a/2.3-1/macros/ASTManagement/AST_ParseOperStruct.sci +++ b/2.3-1/macros/ASTManagement/AST_ParseOperStruct.sci @@ -61,17 +61,6 @@ LabelFunctName = 'Operator: '; FunctionName = stripblanks(part(buffstring,length(LabelFunctName)+1:length(buffstring))); // Generate the proper function name. FunctionName = Operator2FunName(FunctionName); -PrintStringInfo(' '+FunctionName,ReportFileName,'file','y'); - -if (FunctionName == 'OpLogAnd' | FunctionName=='OpLogOr') - NInArg = 0; - NOutArg = 0; - InArg=[]; - //RhsField = AST_PopASTStack(); - //PrintStringInfo('hello'+RhsField,ReportFileName,'file','y'); - //RhsField = AST_PopASTStack(); - return ; -end // ------------------------------ // --- Read input parameters. --- diff --git a/2.3-1/macros/ASTManagement/GenOutArgNames.sci b/2.3-1/macros/ASTManagement/GenOutArgNames.sci index 7b62c794..0e683835 100644 --- a/2.3-1/macros/ASTManagement/GenOutArgNames.sci +++ b/2.3-1/macros/ASTManagement/GenOutArgNames.sci @@ -32,12 +32,6 @@ SCI2CNInArgCheck(argn(2),9,9); nxtscifunname = SharedInfo.NextSCIFunName; nxtscifunnumber = SharedInfo.NextSCIFunNumber; ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; - - -global SCI2CSTACK -global StackPosition; -global STACKDEDUG - // #RNU_RES_B PrintStringInfo(' Generating Out Arg names.',ReportFileName,'file','y'); // #RNU_RES_E @@ -49,69 +43,47 @@ OutArg = OldOutArg; // --------------------------------------------------------------------------------------- // At this step only the name of the output arguments can be generated. --- //#RNU_RES_E -if (FunctionName ~= 'OpLogGt' & FunctionName ~= 'OpLogLt' & FunctionName ~= 'OpLogGe' & FunctionName ~= 'OpLogLe' & FunctionName ~= 'OpLogNe' & FunctionName ~= 'OpLogEq') - 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) - error(9999, 'NLhsArg='+string(NLhsArg)+' must be equal to NOutArg='+string(NOutArg)+'.'); - end - for counteroutputargs = 1:NOutArg - OutArg(counteroutputargs).Name=LhsArg(counteroutputargs).Name; - 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) & ... - (length(SharedInfo.ASTReader.ReusableTempVars) > 0)) - TmpOutArgName = strcat([SharedInfo.ASTReader.TempVarsName,string(SharedInfo.ASTReader.ReusableTempVars(1))]); - SharedInfo.ASTReader.ReusableTempVars = SharedInfo.ASTReader.ReusableTempVars(2:$); - else - SharedInfo.ASTReader.UsedTempVars = SharedInfo.ASTReader.UsedTempVars + 1; - TmpOutArgName = strcat([SharedInfo.ASTReader.TempVarsName,string(SharedInfo.ASTReader.UsedTempVars)]); - end - OutArg(counteroutputargs).Name=TmpOutArgName; - end - end - end +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) + error(9999, 'NLhsArg='+string(NLhsArg)+' must be equal to NOutArg='+string(NOutArg)+'.'); + end + for counteroutputargs = 1:NOutArg + OutArg(counteroutputargs).Name=LhsArg(counteroutputargs).Name; + OutArg(counteroutputargs).Scope=LhsArg(counteroutputargs).Scope; + end else - for counterinputargs = 1:NInArg - tmppushstack=InArg(counterinputargs).Name; - PrintStringInfo(' Pushing in the AST stack: ""'+tmppushstack+'"".',ReportFileName,'file','y'); - AST_PushASTStack(tmppushstack); - if FunctionName=='OpLogGt' - AST_PushASTStack('>'); - elseif FunctionName=='OpLogGe' - AST_PushASTStack('>='); - elseif FunctionName=='OpLogLt' - AST_PushASTStack('<'); - elseif FunctionName=='OpLogLe' - AST_PushASTStack('<='); - elseif FunctionName=='OpLogEq' - AST_PushASTStack('=='); - elseif FunctionName=='OpLogNe' - AST_PushASTStack('!='); - end - end - s = AST_PopASTStack(); - PrintStringInfo(' Pushing in the AST stack: ""'+s+'"".',ReportFileName,'file','y'); + //#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) & ... + (length(SharedInfo.ASTReader.ReusableTempVars) > 0)) + TmpOutArgName = strcat([SharedInfo.ASTReader.TempVarsName,string(SharedInfo.ASTReader.ReusableTempVars(1))]); + SharedInfo.ASTReader.ReusableTempVars = SharedInfo.ASTReader.ReusableTempVars(2:$); + else + SharedInfo.ASTReader.UsedTempVars = SharedInfo.ASTReader.UsedTempVars + 1; + TmpOutArgName = strcat([SharedInfo.ASTReader.TempVarsName,string(SharedInfo.ASTReader.UsedTempVars)]); + end + OutArg(counteroutputargs).Name=TmpOutArgName; + end + end end + endfunction diff --git a/2.3-1/macros/ASTManagement/_funcall_string.sci b/2.3-1/macros/ASTManagement/_funcall_string.sci index 0ee97016..faeb81d9 100644 --- a/2.3-1/macros/ASTManagement/_funcall_string.sci +++ b/2.3-1/macros/ASTManagement/_funcall_string.sci @@ -6,19 +6,10 @@ function txt=%funcall_string(F) // name : string, the name of the function // lhsnb: number, the number of function lhs -if F.name <> 'disp' txt=['Funcall : '+F.name ' #lhs : '+string(F.lhsnb) ' Rhs : ' ' '+objectlist2string(F.rhs) 'EndFuncall' ] -else -txt=['Funcall : '+F.name - ' #lhs : '+'0' - ' Rhs : ' - ' '+objectlist2string(F.rhs) - 'EndFuncall' - ] -end endfunction diff --git a/2.3-1/macros/ASTManagement/_operatio_string.sci b/2.3-1/macros/ASTManagement/_operatio_string.sci index e9332337..8421a3f4 100644 --- a/2.3-1/macros/ASTManagement/_operatio_string.sci +++ b/2.3-1/macros/ASTManagement/_operatio_string.sci @@ -10,4 +10,4 @@ function txt=%operatio_string(O) ' Operator: '+O.operator 'EndOperation' ] -endfunction +endfunction
\ No newline at end of file diff --git a/2.3-1/macros/ASTManagement/_operation_string.sci b/2.3-1/macros/ASTManagement/_operation_string.sci index c9282f67..84f5ce3c 100644 --- a/2.3-1/macros/ASTManagement/_operation_string.sci +++ b/2.3-1/macros/ASTManagement/_operation_string.sci @@ -10,4 +10,4 @@ function txt=%operation_string(O) ' Operator: '+O.operator 'EndOperation' ] -endfunction +endfunction
\ No newline at end of file diff --git a/2.3-1/macros/ASTManagement/lib b/2.3-1/macros/ASTManagement/lib Binary files differindex 2ef9e23b..b3633d55 100644 --- a/2.3-1/macros/ASTManagement/lib +++ b/2.3-1/macros/ASTManagement/lib diff --git a/2.3-1/macros/ASTManagement/names b/2.3-1/macros/ASTManagement/names index 6deb883d..a1aafbc1 100644 --- a/2.3-1/macros/ASTManagement/names +++ b/2.3-1/macros/ASTManagement/names @@ -21,7 +21,6 @@ AST_ExtractNameAndScope AST_GetASTFile AST_GetFuncallPrm AST_GetPrecAndLhsArg -AST_HandleCC AST_HandleEOL AST_HandleEndFor AST_HandleEndGenFun @@ -29,11 +28,8 @@ AST_HandleEndProgram AST_HandleEndWhile AST_HandleFor AST_HandleForStatem -AST_HandleFunCC -AST_HandleFunRC AST_HandleHeader AST_HandleIfElse -AST_HandleRC AST_HandleWhileExpr AST_HandleWhileStatem AST_ParseEqualStruct |