diff options
Diffstat (limited to 'macros/ASTManagement')
-rw-r--r-- | macros/ASTManagement/%funcall_string.sci | 9 | ||||
-rw-r--r-- | macros/ASTManagement/%operatio_string.sci | 9 | ||||
-rw-r--r-- | macros/ASTManagement/%operation_string.sci | 2 | ||||
-rw-r--r-- | macros/ASTManagement/AST2Ccode.sci | 46 | ||||
-rw-r--r-- | macros/ASTManagement/AST_HandleCC.sci | 69 | ||||
-rw-r--r-- | macros/ASTManagement/AST_HandleEndGenFun.sci | 11 | ||||
-rw-r--r-- | macros/ASTManagement/AST_HandleFunCC.sci | 176 | ||||
-rw-r--r-- | macros/ASTManagement/AST_HandleFunRC.sci | 105 | ||||
-rw-r--r-- | macros/ASTManagement/AST_HandleRC.sci | 23 | ||||
-rw-r--r-- | macros/ASTManagement/AST_ParseIfExprStruct.sci | 9 | ||||
-rw-r--r-- | macros/ASTManagement/_funcall_string.sci | 9 | ||||
-rw-r--r-- | macros/ASTManagement/_operatio_string.sci | 2 | ||||
-rw-r--r-- | macros/ASTManagement/_operation_string.sci | 2 | ||||
-rw-r--r-- | macros/ASTManagement/lib | bin | 2263 -> 2136 bytes | |||
-rw-r--r-- | macros/ASTManagement/names | 4 |
15 files changed, 403 insertions, 73 deletions
diff --git a/macros/ASTManagement/%funcall_string.sci b/macros/ASTManagement/%funcall_string.sci index faeb81d..0ee9701 100644 --- a/macros/ASTManagement/%funcall_string.sci +++ b/macros/ASTManagement/%funcall_string.sci @@ -6,10 +6,19 @@ 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/macros/ASTManagement/%operatio_string.sci b/macros/ASTManagement/%operatio_string.sci index c0ecb47..cc18e91 100644 --- a/macros/ASTManagement/%operatio_string.sci +++ b/macros/ASTManagement/%operatio_string.sci @@ -4,17 +4,22 @@ function txt=%operatio_string(O) //fields: // operands: a list // operator: a string -if O.operator <> 'rc' +if O.operator <> 'rc' & O.operator <> 'cc' txt=['Operation' ' Operands:' ' '+objectlist2string(O.operands) ' Operator: '+O.operator 'EndOperation' ] -else +elseif O.operator == 'rc' txt=[' Operands:' ' '+objectlist2string(O.operands) 'Endrc' ] +elseif O.operator == 'cc' + txt=[' Begin:' + ' '+objectlist2string(O.operands) + 'Endcc' + ] end endfunction diff --git a/macros/ASTManagement/%operation_string.sci b/macros/ASTManagement/%operation_string.sci index 84f5ce3..c9282f6 100644 --- a/macros/ASTManagement/%operation_string.sci +++ b/macros/ASTManagement/%operation_string.sci @@ -10,4 +10,4 @@ function txt=%operation_string(O) ' Operator: '+O.operator 'EndOperation' ] -endfunction
\ No newline at end of file +endfunction diff --git a/macros/ASTManagement/AST2Ccode.sci b/macros/ASTManagement/AST2Ccode.sci index 19cf00c..563f313 100644 --- a/macros/ASTManagement/AST2Ccode.sci +++ b/macros/ASTManagement/AST2Ccode.sci @@ -46,6 +46,10 @@ ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; // --------------------------------- // --- Parameter Initialization. --- // --------------------------------- + +global cc_count +cc_count = 0; + global rc_count rc_count = 0; @@ -57,6 +61,9 @@ 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. --- // ------------------------------------- @@ -135,9 +142,10 @@ 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 - [FileInfo,SharedInfo] = AST_HandleEndGenFun(FileInfo,SharedInfo,'Operation'); + [disp_isthere,FileInfo,SharedInfo] = AST_HandleEndGenFun(disp_isthere,FileInfo,SharedInfo,'Operation'); case 'EndFuncall' then - [FileInfo,SharedInfo] = AST_HandleEndGenFun(FileInfo,SharedInfo,'Funcall'); + [disp_isthere,FileInfo,SharedInfo] = AST_HandleEndGenFun(disp_isthere,FileInfo,SharedInfo,'Funcall'); + disp(disp_isthere); // -------------- // --- Equal. --- @@ -147,29 +155,43 @@ 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 + 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 - [FileInfo,SharedInfo] = AST_HandleEndGenFun(FileInfo,SharedInfo,'Equal'); + if disp_isthere == 0 + [disp_isthere,FileInfo,SharedInfo] = AST_HandleEndGenFun(disp_isthere,FileInfo,SharedInfo,'Equal'); SharedInfo = INIT_SharedInfoEqual(SharedInfo); + end end + disp_isthere = 0; + case 'Equal' then SharedInfo.Equal.Enabled = 1; // 1 means enabled -> we are inside an equal AST block. AST_PushASTStack(treeline); case 'Lhs :' then - disp(rc_count); - if rc_count > 0 + 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; + 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 + 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 @@ -184,6 +206,7 @@ while ~meof(fidAST) SharedInfo.Equal.InArg(tmpcnt).Scope = EqualInArgScope(tmpcnt); end //end + end AST_PushASTStack(treeline); end @@ -219,6 +242,7 @@ 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 @@ -254,7 +278,11 @@ while ~meof(fidAST) case 'Endrc' then - rc_count = rc_count + 1; + rc_count = rc_count + 1; + + case 'Endcc' then + cc_count = cc_count + 1; + //[FileInfo,SharedInfo] = AST_HandleRC(FileInfo,SharedInfo); // ---------------- diff --git a/macros/ASTManagement/AST_HandleCC.sci b/macros/ASTManagement/AST_HandleCC.sci new file mode 100644 index 0000000..cc41154 --- /dev/null +++ b/macros/ASTManagement/AST_HandleCC.sci @@ -0,0 +1,69 @@ +// 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/macros/ASTManagement/AST_HandleEndGenFun.sci b/macros/ASTManagement/AST_HandleEndGenFun.sci index 32685de..807b8ba 100644 --- a/macros/ASTManagement/AST_HandleEndGenFun.sci +++ b/macros/ASTManagement/AST_HandleEndGenFun.sci @@ -1,5 +1,5 @@ -function [FileInfo,SharedInfo] = AST_HandleEndGenFun(FileInfo,SharedInfo,ASTFunType) +function [disp_isthere,FileInfo,SharedInfo] = AST_HandleEndGenFun(disp_isthere,FileInfo,SharedInfo,ASTFunType) // function [FileInfo,SharedInfo] = AST_HandleEndGenFun(FileInfo,SharedInfo,ASTFunType) // ----------------------------------------------------------------- // #RNU_RES_B @@ -36,7 +36,7 @@ function [FileInfo,SharedInfo] = AST_HandleEndGenFun(FileInfo,SharedInfo,ASTFunT // ------------------------------ // --- Check input arguments. --- // ------------------------------ -SCI2CNInArgCheck(argn(2),3,3); +SCI2CNInArgCheck(argn(2),4,4); // ----------------------- // --- Initialization. --- @@ -61,6 +61,8 @@ PrintStepInfo('Handling Funcall/Operation/Equal',FileInfo.Funct(nxtscifunnumber) global SCI2CSTACK global StackPosition; global STACKDEDUG + +disp_isthere = 0; // --------------------------- // --- End Initialization. --- // --------------------------- @@ -81,6 +83,11 @@ NOutArg_mod = NOutArg AST_PushASTStack('||'); return; end + + if ASTFunName == 'disp' + disp_isthere = 1; + end + if(mtlb_strcmp(part(ASTFunName,1:2),'CV') == %T) SharedInfo.OpenCVUsed = %T; end diff --git a/macros/ASTManagement/AST_HandleFunCC.sci b/macros/ASTManagement/AST_HandleFunCC.sci new file mode 100644 index 0000000..1942c74 --- /dev/null +++ b/macros/ASTManagement/AST_HandleFunCC.sci @@ -0,0 +1,176 @@ +// 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/macros/ASTManagement/AST_HandleFunRC.sci b/macros/ASTManagement/AST_HandleFunRC.sci index a70155a..d316924 100644 --- a/macros/ASTManagement/AST_HandleFunRC.sci +++ b/macros/ASTManagement/AST_HandleFunRC.sci @@ -1,36 +1,17 @@ -function [FileInfo,SharedInfo] = AST_HandleEndGenFun(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 -// ----------------------------------------------------------------- +// 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. --- @@ -74,11 +55,16 @@ end RhsField = AST_PopASTStack(); +InputArgumentNames = []; +InputArgumentScope = []; NInArg = 0; InArg = []; while (RhsField ~= 'Expression:') NInArg = NInArg + 1; - InArg(NInArg) = RhsField; + if RhsField <> 'Operands:' + [InputArgumentNames(NInArg),InputArgumentScope(NInArg)] = AST_ExtractNameAndScope(RhsField); + end + //InArg(NInArg) = RhsField; RhsField = AST_PopASTStack(); end InputArgumentNames = SCI2Cflipud(InputArgumentNames); @@ -89,7 +75,6 @@ InputArgumentScope = SCI2Cflipud(InputArgumentScope); // --- Generate the InArg structure. --- // ------------------------------------- //#RNU_RES_E -InArg = []; for counterinputargs = 1:NInArg InArg(counterinputargs).Name=InputArgumentNames(counterinputargs); InArg(counterinputargs).Scope=InputArgumentScope(counterinputargs); @@ -106,6 +91,7 @@ for counteroutputargs = 1:NOutArg OutArg(counteroutputargs).Scope=OutputArgumentScope(counteroutputargs); end + // ------------------------ // --- Print Some Info. --- // ------------------------ @@ -125,8 +111,7 @@ PrintStringInfo('N Output Arguments: '+string(NOutArg),ReportFileName,'file','y' //#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'); + //PrintStringInfo(' Scope: '+ OutArg(counterinputargs).Scope,ReportFileName,'file','y','n'); //#RNU_RES_E end @@ -144,22 +129,50 @@ UpdatedInArg = InArg; size_count = 0; for i = 1:NInArg - size_count = size_count + InArg(i).Size(2); + size_count = size_count + eval(InArg(i).Size(2)); end -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 = InArg(1).Dimension; -OutArg(1).Value = InArg(1).Value; -OutArg(1).FindLike = InArg(1).FindLike; +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(OutArg,NOutArg,FileInfo,SharedInfo,'all'); +ST_InsOutArg_Dup(InArg,NInArg,OutArg,NOutArg,com_type,FileInfo,SharedInfo,'all'); endfunction diff --git a/macros/ASTManagement/AST_HandleRC.sci b/macros/ASTManagement/AST_HandleRC.sci index b1a1003..2a6cbc3 100644 --- a/macros/ASTManagement/AST_HandleRC.sci +++ b/macros/ASTManagement/AST_HandleRC.sci @@ -1,4 +1,4 @@ -function [RhsNames,RhsScope,NRhs] = AST_ReadEqualRhsNames(FileInfo,SharedInfo) +function [RhsNames,RhsScope,NRhs] = AST_HandleRC(FileInfo,SharedInfo) // function [FileInfo,SharedInfo] = AST_HandleEndGenFun(FileInfo,SharedInfo,ASTFunType) // ----------------------------------------------------------------- // #RNU_RES_B @@ -32,6 +32,8 @@ function [RhsNames,RhsScope,NRhs] = AST_ReadEqualRhsNames(FileInfo,SharedInfo) // Contact: raffaele.nutricato@tiscali.it // ----------------------------------------------------------------- +SCI2CNInArgCheck(argn(2),2,2) + ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; // ------------------------------ @@ -54,9 +56,11 @@ cntpop = 1; NRhs = 0; RhsField(cntpop) = AST_PopASTStack(); RhsNames = []; -while (RhsField(cntpop) ~= 'Operands:') +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 @@ -65,17 +69,20 @@ 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 +//for counterinputargs = 1:NRhs //#RNU_RES_B - PrintStringInfo('Input Argument Number '+string(counterinputargs)+': '+InArg(counterinputargs).Name,... - ReportFileName,'file','y'); - PrintStringInfo(' Scope: '+InArg(counterinputargs).Scope,... - ReportFileName,'file','y'); + //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 +//end endfunction diff --git a/macros/ASTManagement/AST_ParseIfExprStruct.sci b/macros/ASTManagement/AST_ParseIfExprStruct.sci index 3ed1b5b..2bfb08d 100644 --- a/macros/ASTManagement/AST_ParseIfExprStruct.sci +++ b/macros/ASTManagement/AST_ParseIfExprStruct.sci @@ -98,6 +98,7 @@ while (flagendpop == 0) 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:') @@ -117,10 +118,14 @@ while (flagendpop == 0) elseif (ASTIfExpType=='elseif') if (IfExprField=='Else If Expression') flagendpop = 1; + //IfExprField = AST_PopASTStack(); else - if (IfExprField=='&&') + if (IfExprField=='&&' | IfExprField=='||') NOp = NOp + 1; Op(NOp) = IfExprField; + elseif (IfExprField=='Operands:') + flagendpop = 0; + g = AST_PopASTStack(); else NIfCondArg = NIfCondArg + 1; IfCondArg(NIfCondArg) = IfExprField; @@ -129,7 +134,9 @@ while (flagendpop == 0) end end end + if flagendpop == 0 IfExprField = AST_PopASTStack(); + end PrintStringInfo('operators are '+IfExprField,ReportFileName,'file','y'); end diff --git a/macros/ASTManagement/_funcall_string.sci b/macros/ASTManagement/_funcall_string.sci index faeb81d..0ee9701 100644 --- a/macros/ASTManagement/_funcall_string.sci +++ b/macros/ASTManagement/_funcall_string.sci @@ -6,10 +6,19 @@ 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/macros/ASTManagement/_operatio_string.sci b/macros/ASTManagement/_operatio_string.sci index 8421a3f..e933233 100644 --- a/macros/ASTManagement/_operatio_string.sci +++ b/macros/ASTManagement/_operatio_string.sci @@ -10,4 +10,4 @@ function txt=%operatio_string(O) ' Operator: '+O.operator 'EndOperation' ] -endfunction
\ No newline at end of file +endfunction diff --git a/macros/ASTManagement/_operation_string.sci b/macros/ASTManagement/_operation_string.sci index 84f5ce3..c9282f6 100644 --- a/macros/ASTManagement/_operation_string.sci +++ b/macros/ASTManagement/_operation_string.sci @@ -10,4 +10,4 @@ function txt=%operation_string(O) ' Operator: '+O.operator 'EndOperation' ] -endfunction
\ No newline at end of file +endfunction diff --git a/macros/ASTManagement/lib b/macros/ASTManagement/lib Binary files differindex 7b6a162..4e309a2 100644 --- a/macros/ASTManagement/lib +++ b/macros/ASTManagement/lib diff --git a/macros/ASTManagement/names b/macros/ASTManagement/names index 26edaf7..6deb883 100644 --- a/macros/ASTManagement/names +++ b/macros/ASTManagement/names @@ -21,6 +21,7 @@ AST_ExtractNameAndScope AST_GetASTFile AST_GetFuncallPrm AST_GetPrecAndLhsArg +AST_HandleCC AST_HandleEOL AST_HandleEndFor AST_HandleEndGenFun @@ -28,6 +29,7 @@ AST_HandleEndProgram AST_HandleEndWhile AST_HandleFor AST_HandleForStatem +AST_HandleFunCC AST_HandleFunRC AST_HandleHeader AST_HandleIfElse @@ -59,5 +61,3 @@ _program_string _variable_string _while_string objectlist2string -AST_HandleRC -AST_HandleFunRC |