diff options
Diffstat (limited to '2.3-1/macros/ASTManagement')
22 files changed, 1016 insertions, 5 deletions
diff --git a/2.3-1/macros/ASTManagement/%equal_string.sci b/2.3-1/macros/ASTManagement/%equal_string.sci index 9678f0e0..29e8cb6b 100644 --- a/2.3-1/macros/ASTManagement/%equal_string.sci +++ b/2.3-1/macros/ASTManagement/%equal_string.sci @@ -13,4 +13,8 @@ function txt=%equal_string(e) ' '+objectlist2string(e.lhs) 'EndEqual' ] -endfunction
\ No newline at end of file +<<<<<<< HEAD +endfunction +======= +endfunction +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 diff --git a/2.3-1/macros/ASTManagement/%funcall_string.sci b/2.3-1/macros/ASTManagement/%funcall_string.sci index faeb81d9..c3101cbe 100644 --- a/2.3-1/macros/ASTManagement/%funcall_string.sci +++ b/2.3-1/macros/ASTManagement/%funcall_string.sci @@ -6,10 +6,25 @@ function txt=%funcall_string(F) // name : string, the name of the function // lhsnb: number, the number of function lhs +<<<<<<< HEAD +if F.name <> 'disp' +======= +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 txt=['Funcall : '+F.name ' #lhs : '+string(F.lhsnb) ' Rhs : ' ' '+objectlist2string(F.rhs) 'EndFuncall' ] +<<<<<<< HEAD +else +txt=['Funcall : '+F.name + ' #lhs : '+'0' + ' Rhs : ' + ' '+objectlist2string(F.rhs) + 'EndFuncall' + ] +end +======= +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 endfunction diff --git a/2.3-1/macros/ASTManagement/%operatio_string.sci b/2.3-1/macros/ASTManagement/%operatio_string.sci index 8421a3f4..2a3554dc 100644 --- a/2.3-1/macros/ASTManagement/%operatio_string.sci +++ b/2.3-1/macros/ASTManagement/%operatio_string.sci @@ -4,10 +4,29 @@ function txt=%operatio_string(O) //fields: // operands: a list // operator: a string +<<<<<<< HEAD +if O.operator <> 'rc' & O.operator <> 'cc' +======= +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 txt=['Operation' ' Operands:' ' '+objectlist2string(O.operands) ' Operator: '+O.operator 'EndOperation' ] -endfunction
\ No newline at end of file +<<<<<<< HEAD +elseif O.operator == 'rc' + txt=[' Operands:' + ' '+objectlist2string(O.operands) + 'Endrc' + ] +elseif O.operator == 'cc' + txt=[' Begin:' + ' '+objectlist2string(O.operands) + 'Endcc' + ] +end +endfunction +======= +endfunction +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 diff --git a/2.3-1/macros/ASTManagement/%operation_string.sci b/2.3-1/macros/ASTManagement/%operation_string.sci index 84f5ce3c..2de021d9 100644 --- a/2.3-1/macros/ASTManagement/%operation_string.sci +++ b/2.3-1/macros/ASTManagement/%operation_string.sci @@ -10,4 +10,8 @@ function txt=%operation_string(O) ' Operator: '+O.operator 'EndOperation' ] -endfunction
\ No newline at end of file +<<<<<<< HEAD +endfunction +======= +endfunction +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 diff --git a/2.3-1/macros/ASTManagement/AST2Ccode.sci b/2.3-1/macros/ASTManagement/AST2Ccode.sci index 409eaab1..b1646df3 100644 --- a/2.3-1/macros/ASTManagement/AST2Ccode.sci +++ b/2.3-1/macros/ASTManagement/AST2Ccode.sci @@ -42,12 +42,25 @@ load(FileInfo.SharedInfoDatFile,'SharedInfo'); nxtscifunname = SharedInfo.NextSCIFunName; nxtscifunnumber = SharedInfo.NextSCIFunNumber; ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; +<<<<<<< HEAD +======= SharedInfo.Function_list = []; SharedInfo.Function_list_index = 1; +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 // --------------------------------- // --- Parameter Initialization. --- // --------------------------------- +<<<<<<< HEAD + +global cc_count +cc_count = 0; + +global rc_count +rc_count = 0; + +======= +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 global SCI2CSTACK SCI2CSTACK = ['EMPTYSTACK']; @@ -56,6 +69,12 @@ StackPosition = 1; global STACKDEDUG STACKDEDUG = 0; // 1 -> Every Pop and Push operation on the stack, the stack content will be printed on screen. +<<<<<<< HEAD + +global disp_isthere +disp_isthere = 0; +======= +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 // ------------------------------------- // --- End parameter Initialization. --- // ------------------------------------- @@ -134,9 +153,16 @@ 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 +<<<<<<< HEAD + [disp_isthere,FileInfo,SharedInfo] = AST_HandleEndGenFun(disp_isthere,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,'Operation'); case 'EndFuncall' then [FileInfo,SharedInfo] = AST_HandleEndGenFun(FileInfo,SharedInfo,'Funcall'); +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 // -------------- // --- Equal. --- @@ -146,12 +172,67 @@ 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. +<<<<<<< HEAD + 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); +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 case 'Equal' then SharedInfo.Equal.Enabled = 1; // 1 means enabled -> we are inside an equal AST block. AST_PushASTStack(treeline); case 'Lhs :' then +<<<<<<< HEAD + 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); @@ -165,6 +246,7 @@ while ~meof(fidAST) SharedInfo.Equal.InArg(tmpcnt).Scope = EqualInArgScope(tmpcnt); end AST_PushASTStack(treeline); +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 // ---------------- // --- If/Else. --- @@ -198,6 +280,10 @@ while ~meof(fidAST) // ----------------- case 'EndProgram' SharedInfo = AST_HandleEndProgram(FileInfo,SharedInfo); +<<<<<<< HEAD + disp_isthere = 0; +======= +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 //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 @@ -231,6 +317,18 @@ while ~meof(fidAST) SharedInfo = AST_HandleEndWhile(FileInfo,SharedInfo); SharedInfo.While.Level = SharedInfo.While.Level - 1; +<<<<<<< HEAD + + case 'Endrc' then + rc_count = rc_count + 1; + + case 'Endcc' then + cc_count = cc_count + 1; + + //[FileInfo,SharedInfo] = AST_HandleRC(FileInfo,SharedInfo); + +======= +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 // ---------------- // --- Default. --- // ---------------- @@ -238,6 +336,8 @@ while ~meof(fidAST) AST_PushASTStack(treeline); end end +<<<<<<< HEAD +======= // ------------------------------------ // -----List of functions Used-------- @@ -252,6 +352,7 @@ SharedInfo.Function_list = unique(SharedInfo.Function_list); SharedInfo.Function_list = SharedInfo.Function_list(1:SharedInfo.Function_list_index); +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 // -------------------------------------- // --- End main loop to read the AST. --- // -------------------------------------- diff --git a/2.3-1/macros/ASTManagement/AST_HandleCC.sci b/2.3-1/macros/ASTManagement/AST_HandleCC.sci new file mode 100644 index 00000000..cc411549 --- /dev/null +++ b/2.3-1/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/2.3-1/macros/ASTManagement/AST_HandleEndGenFun.sci b/2.3-1/macros/ASTManagement/AST_HandleEndGenFun.sci index fec79532..6c2abed3 100644 --- a/2.3-1/macros/ASTManagement/AST_HandleEndGenFun.sci +++ b/2.3-1/macros/ASTManagement/AST_HandleEndGenFun.sci @@ -1,5 +1,9 @@ +<<<<<<< HEAD +function [disp_isthere,FileInfo,SharedInfo] = AST_HandleEndGenFun(disp_isthere,FileInfo,SharedInfo,ASTFunType) +======= function [FileInfo,SharedInfo] = AST_HandleEndGenFun(FileInfo,SharedInfo,ASTFunType) +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 // function [FileInfo,SharedInfo] = AST_HandleEndGenFun(FileInfo,SharedInfo,ASTFunType) // ----------------------------------------------------------------- // #RNU_RES_B @@ -36,7 +40,11 @@ function [FileInfo,SharedInfo] = AST_HandleEndGenFun(FileInfo,SharedInfo,ASTFunT // ------------------------------ // --- Check input arguments. --- // ------------------------------ +<<<<<<< HEAD +SCI2CNInArgCheck(argn(2),4,4); +======= SCI2CNInArgCheck(argn(2),3,3); +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 // ----------------------- // --- Initialization. --- @@ -61,6 +69,11 @@ PrintStepInfo('Handling Funcall/Operation/Equal',FileInfo.Funct(nxtscifunnumber) global SCI2CSTACK global StackPosition; global STACKDEDUG +<<<<<<< HEAD + +disp_isthere = 0; +======= +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 // --------------------------- // --- End Initialization. --- // --------------------------- @@ -72,11 +85,28 @@ global STACKDEDUG //NUT: verifica se ASTFunType e' veramente importante // #RNU_RES_E [ASTFunName,InArg,NInArg,OutArg,NOutArg] = AST_GetFuncallPrm(FileInfo,SharedInfo,ASTFunType); +<<<<<<< HEAD +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 (ASTFunType=='Funcall') SharedInfo.Function_list(SharedInfo.Function_list_index) = ASTFunName; SharedInfo.Function_list_index = SharedInfo.Function_list_index + 1; end NOutArg_mod = NOutArg +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 if(mtlb_strcmp(part(ASTFunName,1:2),'CV') == %T) SharedInfo.OpenCVUsed = %T; end @@ -116,6 +146,11 @@ NOutArg_mod = NOutArg PrintStringInfo(' ',ReportFileName,'both','y'); error(9999, 'SCI2CERROR: Unexpected number of output arguments for global function.'); end +<<<<<<< HEAD + elseif(ASTFunName == 'raspi' | ASTFunName == 'raspi_close') + SharedInfo.SkipNextFun = 1; +======= +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 end // #RNU_RES_B @@ -123,6 +158,16 @@ NOutArg_mod = NOutArg // --- Read the function annotations. --- // -------------------------------------- // #RNU_RES_E +<<<<<<< HEAD + if ASTFunName == '%k' + ASTFunName='modk'; + end + + if ASTFunName == '%sn' + ASTFunName='modsn'; + end +======= +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 if (ASTFunName == 'OpEqual') FunTypeAnnot = ''; @@ -136,6 +181,10 @@ NOutArg_mod = NOutArg // --- Search for Equal Lhs and precision specifier to be applied to the current function. --- // ------------------------------------------------------------------------------------------- // #RNU_RES_E +<<<<<<< HEAD + PrintStringInfo(' no of out arguments' + string(NOutArg),ReportFileName,'file','y'); +======= +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 [LhsArg,NLhsArg,FunPrecSpecifier,SharedInfo] = AST_GetPrecAndLhsArg(OutArg,NOutArg,ASTFunName,FunTypeAnnot,FunSizeAnnot,ASTFunType,FileInfo,SharedInfo); //NUT: questa funzione contiene troppi parametri e mi sembra disordinata. @@ -333,8 +382,18 @@ 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); +<<<<<<< HEAD + //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 +======= + else + [OutArg,SharedInfo] = GenOutArgNames(ASTFunName,InArg,NInArg,OutArg,NOutArg,LhsArg,NLhsArg,FileInfo,SharedInfo); +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 end if ((ASTFunName == 'uint8') & (NInArg == 1) & (InArg(1).Dimension == 0) & (InArg(1).Scope == 'Number')) @@ -378,6 +437,11 @@ NOutArg_mod = NOutArg // Scope already set above. elseif (ASTFunName == 'double' & NInArg == 1 & (InArg(1).Dimension == 0) & (InArg(1).Scope == 'Number')) // Scope already set above. +<<<<<<< HEAD + //elseif ASTFunName == 'disp' + //do nothing +======= +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 else OutArg = ST_AnalyzeScope(OutArg,NOutArg,FileInfo,SharedInfo); end @@ -396,6 +460,11 @@ 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. +<<<<<<< HEAD + //elseif ASTFunName == 'disp' + //do nothing +======= +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 else ST_InsOutArg(OutArg,NOutArg,FileInfo,SharedInfo,'all'); end @@ -428,12 +497,22 @@ NOutArg_mod = NOutArg // -------------------------------------------- //#RNU_RES_E //disp(OutArg,InArg,ASTFunName) +<<<<<<< HEAD + + + CFunName = C_GenerateFunName(ASTFunName,InArg,NInArg,OutArg,NOutArg_mod); + + //#RNU_RES_B + PrintStringInfo(' C Function Name: '+CFunName,ReportFileName,'file','y'); + if(IsArduinoFunction(ASTFunName)) +======= CFunName = C_GenerateFunName(ASTFunName,InArg,NInArg,OutArg,NOutArg_mod); //#RNU_RES_B PrintStringInfo(' C Function Name: '+CFunName,ReportFileName,'file','y'); if(IsArduinoFunction(ASTFunName)) //disp(ASTFunName) +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 if(IsArduinoSetupFunction(ASTFunName)) //If current function is an arduino setup function (like 'dc_motor_setup'), it //should not be converted and inserted here. It is inserted in a list now and @@ -454,7 +533,12 @@ NOutArg_mod = NOutArg else LibTypeInfo = 'USER2C'; end +<<<<<<< HEAD + + +======= +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 //#RNU_RES_B // ------------------------------------------------------------------------------------ // --- Check whether the function has been already called in the current .sci file. --- @@ -501,6 +585,11 @@ NOutArg_mod = NOutArg SharedInfo.SkipNextFun > 0 | ... ((sum(mtlb_strcmp(ASTFunName,SharedInfo.Annotations.DataPrec)) > 0) & (SharedInfo.SkipNextPrec == 1))) // Do nothing +<<<<<<< HEAD + //elseif ASTFunName == 'disp' + // Do nothing +======= +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 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 new file mode 100644 index 00000000..1942c749 --- /dev/null +++ b/2.3-1/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/2.3-1/macros/ASTManagement/AST_HandleFunRC.sci b/2.3-1/macros/ASTManagement/AST_HandleFunRC.sci new file mode 100644 index 00000000..d3169249 --- /dev/null +++ b/2.3-1/macros/ASTManagement/AST_HandleFunRC.sci @@ -0,0 +1,178 @@ +// 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 5373adf6..449586f7 100644 --- a/2.3-1/macros/ASTManagement/AST_HandleIfElse.sci +++ b/2.3-1/macros/ASTManagement/AST_HandleIfElse.sci @@ -74,11 +74,20 @@ global STACKDEDUG // --------------------------------------------------- //#RNU_RES_E if (ASTIfExpType~='else') +<<<<<<< HEAD + [IfCondArg,NIfCondArg,Op,NOp] = AST_ParseIfExprStruct(FileInfo,SharedInfo,ASTIfExpType); +======= [IfCondArg,NIfCondArg] = AST_ParseIfExprStruct(FileInfo,SharedInfo,ASTIfExpType); +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 else // "else" type doesn't contain any condition to test. IfCondArg = ''; NIfCondArg = 0; +<<<<<<< HEAD + Op = ''; + NOp = 0; +======= +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 end //#RNU_RES_B @@ -87,6 +96,10 @@ end // ----------------------------- // --- Generate the C code for if/elseif Expression. --- //#RNU_RES_E +<<<<<<< HEAD +SharedInfo = C_IfExpression(IfCondArg,NIfCondArg,Op,NOp,ASTIfExpType,FileInfo,SharedInfo); +======= SharedInfo = C_IfExpression(IfCondArg,NIfCondArg,ASTIfExpType,FileInfo,SharedInfo); +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 endfunction diff --git a/2.3-1/macros/ASTManagement/AST_HandleRC.sci b/2.3-1/macros/ASTManagement/AST_HandleRC.sci new file mode 100644 index 00000000..2a6cbc3f --- /dev/null +++ b/2.3-1/macros/ASTManagement/AST_HandleRC.sci @@ -0,0 +1,88 @@ +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 79fb516d..9b5dce15 100644 --- a/2.3-1/macros/ASTManagement/AST_HandleWhileStatem.sci +++ b/2.3-1/macros/ASTManagement/AST_HandleWhileStatem.sci @@ -36,6 +36,11 @@ global SCI2CSTACK global StackPosition; global STACKDEDUG +<<<<<<< HEAD +IfCondArg = []; +NIfCondArg = 0; +======= +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 // ------------------------------ // --- Check input arguments. --- @@ -70,6 +75,42 @@ PrintStringInfo(' Redirecting C code to: '+FileInfo.Funct(nxtscifunnumber).CPa // --- Generate C code. --- // ------------------------ //#RNU_RES_E +<<<<<<< HEAD +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 + end + IfExprField = AST_PopASTStack(); + PrintStringInfo('operators are '+IfExprField,ReportFileName,'file','y'); +end + +IfCondArg = SCI2Cflipud(IfCondArg); + +SharedInfo = C_WhileExpression(IfCondArg,NIfCondArg,Op,NOp,FileInfo,SharedInfo); +======= if(SharedInfo.WhileExpr.CondVar == '') //#RNU_RES_B // It means that we are handling something like while(a) or while(1) @@ -100,6 +141,7 @@ elseif (SharedInfo.WhileExpr.DimCondVar > 0) error(9999, 'Cannot manage while with matrix conditions'); end SharedInfo = C_WhileExpression(FileInfo,SharedInfo); +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 // -------------------------- // --- Update SharedInfo. --- diff --git a/2.3-1/macros/ASTManagement/AST_ParseEqualStruct.sci b/2.3-1/macros/ASTManagement/AST_ParseEqualStruct.sci index fa76a01d..528ddaee 100644 --- a/2.3-1/macros/ASTManagement/AST_ParseEqualStruct.sci +++ b/2.3-1/macros/ASTManagement/AST_ParseEqualStruct.sci @@ -123,7 +123,11 @@ end // ------------------------ //#RNU_RES_B PrintStringInfo('Function Name: '+FunctionName,ReportFileName,'file','y','n'); +<<<<<<< HEAD +PrintStringInfo('N Input Arguments: '+string(NInArg),ReportFileName,'file','y','n'); +======= PrintStringInfo('N Intput Arguments: '+string(NInArg),ReportFileName,'file','y','n'); +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 //#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 647a70d7..ac9c4004 100644 --- a/2.3-1/macros/ASTManagement/AST_ParseFuncallStruct.sci +++ b/2.3-1/macros/ASTManagement/AST_ParseFuncallStruct.sci @@ -87,6 +87,13 @@ NOutArg = eval(stripblanks(part(buffstring,10:length(buffstring)))); buffstring = AST_PopASTStack(); FunctionName = stripblanks(part(buffstring,12:length(buffstring))); +<<<<<<< HEAD +//if (FunctionName == 'disp') + // NOutArg = 0; +//end + +======= +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 // ------------------------------------- // --- 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 a7da0128..81d7e80b 100644 --- a/2.3-1/macros/ASTManagement/AST_ParseIfExprStruct.sci +++ b/2.3-1/macros/ASTManagement/AST_ParseIfExprStruct.sci @@ -1,4 +1,8 @@ +<<<<<<< HEAD +function [IfCondArg,NIfCondArg,Op,NOp] = AST_ParseIfExprStruct(FileInfo,SharedInfo,ASTIfExpType) +======= function [IfCondArg,NIfCondArg] = AST_ParseIfExprStruct(FileInfo,SharedInfo,ASTIfExpType) +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 // function [IfCondArg,NIfCondArg] = AST_ParseIfExprStruct(FileInfo,SharedInfo,ASTIfExpType) // ----------------------------------------------------------------- //#RNU_RES_B @@ -63,13 +67,34 @@ global STACKDEDUG // ------------------------------------ // --- Read if condition variables. --- // ------------------------------------ +<<<<<<< HEAD +//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'); +======= +flagendpop = 0; +IfExprField = AST_PopASTStack(); +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 if (ASTIfExpType=='if') if (IfExprField=='Expression:') flagendpop = 1; // Pop Again the If tag from the AST. IfExprField = AST_PopASTStack(); +<<<<<<< HEAD + PrintStringInfo(' '+IfExprField,ReportFileName,'file','y'); +======= +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 end elseif (ASTIfExpType=='elseif') if (IfExprField=='Else If Expression') @@ -78,21 +103,71 @@ elseif (ASTIfExpType=='elseif') else error(9999, 'Unknown ASTIfExpType ""'+ASTIfExpType+'"".'); end +<<<<<<< HEAD +NOp=0; +Op=[]; +======= +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 while (flagendpop == 0) if (IfExprField~='<EOL>') if (ASTIfExpType=='if') if (IfExprField=='Expression:') flagendpop = 1; +<<<<<<< HEAD + //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); +======= // Pop Again the If tag from the AST. IfExprField = AST_PopASTStack(); else NIfCondArg = NIfCondArg + 1; [IfCondArg(NIfCondArg),tmpscope] = AST_ExtractNameAndScope(IfExprField); +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 end elseif (ASTIfExpType=='elseif') if (IfExprField=='Else If Expression') flagendpop = 1; +<<<<<<< HEAD + //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); + end + end + end + if flagendpop == 0 + IfExprField = AST_PopASTStack(); + end + PrintStringInfo('operators are '+IfExprField,ReportFileName,'file','y'); +end + +IfCondArg = SCI2Cflipud(IfCondArg); + +======= else NIfCondArg = NIfCondArg + 1; IfCondArg(NIfCondArg) = IfExprField; @@ -103,6 +178,7 @@ while (flagendpop == 0) IfExprField = AST_PopASTStack(); end +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 //#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 a77317bd..2bd45fbb 100644 --- a/2.3-1/macros/ASTManagement/AST_ParseOperStruct.sci +++ b/2.3-1/macros/ASTManagement/AST_ParseOperStruct.sci @@ -61,6 +61,20 @@ LabelFunctName = 'Operator: '; FunctionName = stripblanks(part(buffstring,length(LabelFunctName)+1:length(buffstring))); // Generate the proper function name. FunctionName = Operator2FunName(FunctionName); +<<<<<<< HEAD +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 +======= +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 // ------------------------------ // --- Read input parameters. --- diff --git a/2.3-1/macros/ASTManagement/GenOutArgNames.sci b/2.3-1/macros/ASTManagement/GenOutArgNames.sci index 0e683835..800b8d6d 100644 --- a/2.3-1/macros/ASTManagement/GenOutArgNames.sci +++ b/2.3-1/macros/ASTManagement/GenOutArgNames.sci @@ -32,6 +32,15 @@ SCI2CNInArgCheck(argn(2),9,9); nxtscifunname = SharedInfo.NextSCIFunName; nxtscifunnumber = SharedInfo.NextSCIFunNumber; ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; +<<<<<<< HEAD + + +global SCI2CSTACK +global StackPosition; +global STACKDEDUG + +======= +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 // #RNU_RES_B PrintStringInfo(' Generating Out Arg names.',ReportFileName,'file','y'); // #RNU_RES_E @@ -43,6 +52,73 @@ OutArg = OldOutArg; // --------------------------------------------------------------------------------------- // At this step only the name of the output arguments can be generated. --- //#RNU_RES_E +<<<<<<< HEAD +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 +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'); +end +======= if (NLhsArg > 0) //#RNU_RES_B // Use the equal Lhs names. @@ -86,4 +162,5 @@ else end end +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 endfunction diff --git a/2.3-1/macros/ASTManagement/_funcall_string.sci b/2.3-1/macros/ASTManagement/_funcall_string.sci index faeb81d9..c3101cbe 100644 --- a/2.3-1/macros/ASTManagement/_funcall_string.sci +++ b/2.3-1/macros/ASTManagement/_funcall_string.sci @@ -6,10 +6,25 @@ function txt=%funcall_string(F) // name : string, the name of the function // lhsnb: number, the number of function lhs +<<<<<<< HEAD +if F.name <> 'disp' +======= +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 txt=['Funcall : '+F.name ' #lhs : '+string(F.lhsnb) ' Rhs : ' ' '+objectlist2string(F.rhs) 'EndFuncall' ] +<<<<<<< HEAD +else +txt=['Funcall : '+F.name + ' #lhs : '+'0' + ' Rhs : ' + ' '+objectlist2string(F.rhs) + 'EndFuncall' + ] +end +======= +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 endfunction diff --git a/2.3-1/macros/ASTManagement/_operatio_string.sci b/2.3-1/macros/ASTManagement/_operatio_string.sci index 8421a3f4..76753868 100644 --- a/2.3-1/macros/ASTManagement/_operatio_string.sci +++ b/2.3-1/macros/ASTManagement/_operatio_string.sci @@ -10,4 +10,8 @@ function txt=%operatio_string(O) ' Operator: '+O.operator 'EndOperation' ] -endfunction
\ No newline at end of file +<<<<<<< HEAD +endfunction +======= +endfunction +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 diff --git a/2.3-1/macros/ASTManagement/_operation_string.sci b/2.3-1/macros/ASTManagement/_operation_string.sci index 84f5ce3c..2de021d9 100644 --- a/2.3-1/macros/ASTManagement/_operation_string.sci +++ b/2.3-1/macros/ASTManagement/_operation_string.sci @@ -10,4 +10,8 @@ function txt=%operation_string(O) ' Operator: '+O.operator 'EndOperation' ] -endfunction
\ No newline at end of file +<<<<<<< HEAD +endfunction +======= +endfunction +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 diff --git a/2.3-1/macros/ASTManagement/lib b/2.3-1/macros/ASTManagement/lib Binary files differindex 5d98a03d..51b54f6f 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 a1aafbc1..62b7d189 100644 --- a/2.3-1/macros/ASTManagement/names +++ b/2.3-1/macros/ASTManagement/names @@ -21,6 +21,10 @@ AST_ExtractNameAndScope AST_GetASTFile AST_GetFuncallPrm AST_GetPrecAndLhsArg +<<<<<<< HEAD +AST_HandleCC +======= +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 AST_HandleEOL AST_HandleEndFor AST_HandleEndGenFun @@ -28,8 +32,16 @@ AST_HandleEndProgram AST_HandleEndWhile AST_HandleFor AST_HandleForStatem +<<<<<<< HEAD +AST_HandleFunCC +AST_HandleFunRC AST_HandleHeader AST_HandleIfElse +AST_HandleRC +======= +AST_HandleHeader +AST_HandleIfElse +>>>>>>> 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 AST_HandleWhileExpr AST_HandleWhileStatem AST_ParseEqualStruct |