summaryrefslogtreecommitdiff
path: root/macros/ASTManagement
diff options
context:
space:
mode:
authorBrijeshcr2017-07-06 15:48:47 +0530
committerGitHub2017-07-06 15:48:47 +0530
commitea958d3c401761dcc24865d9639b2fab31038db8 (patch)
tree8cea93113a46d7015d1a10638778f92275a0ca94 /macros/ASTManagement
parentcb1d99232e521c34e9f0c271a6c4176cc7b9cbe4 (diff)
downloadScilab2C_fossee_old-ea958d3c401761dcc24865d9639b2fab31038db8.tar.gz
Scilab2C_fossee_old-ea958d3c401761dcc24865d9639b2fab31038db8.tar.bz2
Scilab2C_fossee_old-ea958d3c401761dcc24865d9639b2fab31038db8.zip
Revert "LinearAlgebra Function Added"
Diffstat (limited to 'macros/ASTManagement')
-rw-r--r--macros/ASTManagement/%equal_string.sci2
-rw-r--r--macros/ASTManagement/%funcall_string.sci9
-rw-r--r--macros/ASTManagement/%operatio_string.sci14
-rw-r--r--macros/ASTManagement/%operation_string.sci2
-rw-r--r--macros/ASTManagement/AST2Ccode.sci90
-rw-r--r--macros/ASTManagement/AST_HandleCC.sci69
-rw-r--r--macros/ASTManagement/AST_HandleEndGenFun.sci47
-rw-r--r--macros/ASTManagement/AST_HandleFunCC.sci176
-rw-r--r--macros/ASTManagement/AST_HandleFunRC.sci178
-rw-r--r--macros/ASTManagement/AST_HandleIfElse.sci6
-rw-r--r--macros/ASTManagement/AST_HandleRC.sci88
-rw-r--r--macros/ASTManagement/AST_HandleWhileStatem.sci60
-rw-r--r--macros/ASTManagement/AST_ParseEqualStruct.sci2
-rw-r--r--macros/ASTManagement/AST_ParseFuncallStruct.sci4
-rw-r--r--macros/ASTManagement/AST_ParseIfExprStruct.sci51
-rw-r--r--macros/ASTManagement/AST_ParseOperStruct.sci11
-rw-r--r--macros/ASTManagement/GenOutArgNames.sci110
-rw-r--r--macros/ASTManagement/_funcall_string.sci9
-rw-r--r--macros/ASTManagement/_operatio_string.sci2
-rw-r--r--macros/ASTManagement/_operation_string.sci2
-rw-r--r--macros/ASTManagement/libbin1896 -> 1936 bytes
-rw-r--r--macros/ASTManagement/names4
22 files changed, 833 insertions, 103 deletions
diff --git a/macros/ASTManagement/%equal_string.sci b/macros/ASTManagement/%equal_string.sci
index 9678f0e..041fb84 100644
--- a/macros/ASTManagement/%equal_string.sci
+++ b/macros/ASTManagement/%equal_string.sci
@@ -13,4 +13,4 @@ function txt=%equal_string(e)
' '+objectlist2string(e.lhs)
'EndEqual'
]
-endfunction \ No newline at end of file
+endfunction
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..cc18e91 100644
--- a/macros/ASTManagement/%operatio_string.sci
+++ b/macros/ASTManagement/%operatio_string.sci
@@ -4,10 +4,22 @@ 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'
]
-endfunction \ No newline at end of file
+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 8076d7e..563f313 100644
--- a/macros/ASTManagement/AST2Ccode.sci
+++ b/macros/ASTManagement/AST2Ccode.sci
@@ -46,6 +46,13 @@ ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName;
// ---------------------------------
// --- Parameter Initialization. ---
// ---------------------------------
+
+global cc_count
+cc_count = 0;
+
+global rc_count
+rc_count = 0;
+
global SCI2CSTACK
SCI2CSTACK = ['EMPTYSTACK'];
@@ -54,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. ---
// -------------------------------------
@@ -132,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. ---
@@ -144,25 +155,60 @@ 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.
- [FileInfo,SharedInfo] = AST_HandleEndGenFun(FileInfo,SharedInfo,'Equal');
- SharedInfo = INIT_SharedInfoEqual(SharedInfo);
+ 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;
+
case 'Equal' then
SharedInfo.Equal.Enabled = 1; // 1 means enabled -> we are inside an equal AST block.
AST_PushASTStack(treeline);
case 'Lhs :' then
- SharedInfo.Equal.Lhs = 1; // 1 means that we are inside the Lhs block of the Equal
- [EqualInArgName,EqualInArgScope,EqualNInArg] = AST_ReadEqualRhsNames(FileInfo,SharedInfo);
-
- // 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);
+ 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
// ----------------
// --- If/Else. ---
@@ -196,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
@@ -229,6 +276,15 @@ 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/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 5ff7181..96830aa 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. ---
// ---------------------------
@@ -73,6 +75,19 @@ global STACKDEDUG
// #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
@@ -112,6 +127,8 @@ 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
@@ -119,6 +136,13 @@ 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 = '';
@@ -132,6 +156,7 @@ 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.
@@ -329,8 +354,13 @@ 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'))
@@ -374,6 +404,8 @@ 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
@@ -392,6 +424,8 @@ 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
@@ -424,8 +458,10 @@ 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))
@@ -449,7 +485,8 @@ NOutArg_mod = NOutArg
else
LibTypeInfo = 'USER2C';
end
-
+
+
//#RNU_RES_B
// ------------------------------------------------------------------------------------
// --- Check whether the function has been already called in the current .sci file. ---
@@ -496,6 +533,8 @@ 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/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
new file mode 100644
index 0000000..d316924
--- /dev/null
+++ b/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/macros/ASTManagement/AST_HandleIfElse.sci b/macros/ASTManagement/AST_HandleIfElse.sci
index 5373adf..2b549ed 100644
--- a/macros/ASTManagement/AST_HandleIfElse.sci
+++ b/macros/ASTManagement/AST_HandleIfElse.sci
@@ -74,11 +74,13 @@ global STACKDEDUG
// ---------------------------------------------------
//#RNU_RES_E
if (ASTIfExpType~='else')
- [IfCondArg,NIfCondArg] = AST_ParseIfExprStruct(FileInfo,SharedInfo,ASTIfExpType);
+ [IfCondArg,NIfCondArg,Op,NOp] = 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
@@ -87,6 +89,6 @@ end
// -----------------------------
// --- Generate the C code for if/elseif Expression. ---
//#RNU_RES_E
-SharedInfo = C_IfExpression(IfCondArg,NIfCondArg,ASTIfExpType,FileInfo,SharedInfo);
+SharedInfo = C_IfExpression(IfCondArg,NIfCondArg,Op,NOp,ASTIfExpType,FileInfo,SharedInfo);
endfunction
diff --git a/macros/ASTManagement/AST_HandleRC.sci b/macros/ASTManagement/AST_HandleRC.sci
new file mode 100644
index 0000000..2a6cbc3
--- /dev/null
+++ b/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/macros/ASTManagement/AST_HandleWhileStatem.sci b/macros/ASTManagement/AST_HandleWhileStatem.sci
index 79fb516..d8c2f73 100644
--- a/macros/ASTManagement/AST_HandleWhileStatem.sci
+++ b/macros/ASTManagement/AST_HandleWhileStatem.sci
@@ -36,6 +36,8 @@ global SCI2CSTACK
global StackPosition;
global STACKDEDUG
+IfCondArg = [];
+NIfCondArg = 0;
// ------------------------------
// --- Check input arguments. ---
@@ -70,36 +72,40 @@ PrintStringInfo(' Redirecting C code to: '+FileInfo.Funct(nxtscifunnumber).CPa
// --- Generate C code. ---
// ------------------------
//#RNU_RES_E
-if(SharedInfo.WhileExpr.CondVar == '')
- //#RNU_RES_B
- // It means that we are handling something like while(a) or while(1)
- // The while condition variable is generated by the HandleEndGenFun.
- //#RNU_RES_E
-
- // --- Pop the name of the condition variable or number. ---
- Pop1 = AST_PopASTStack();
-
- [ArgName,ArgScope] = AST_ExtractNameAndScope(Pop1);
- if (length(ArgName) == 0)
- PrintStringInfo(' ',ReportFileName,'both','y');
- PrintStringInfo('SCI2CERROR: Expected while(variable) or while(number).','','stdout','y');
- PrintStringInfo('SCI2CERROR: Expected a variable or number in the AST while expression.','','stdout','y');
- PrintStringInfo('SCI2CERROR: Report this error to 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');
+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
- SharedInfo.WhileExpr.CondVar = ArgName;
- //#RNU_RES_B
- // --- Repush strings into the AST stack. ---
- //#RNU_RES_E
-
- AST_PushASTStack(Pop1);
+IfCondArg = SCI2Cflipud(IfCondArg);
-elseif (SharedInfo.WhileExpr.DimCondVar > 0)
- error(9999, 'Cannot manage while with matrix conditions');
-end
-SharedInfo = C_WhileExpression(FileInfo,SharedInfo);
+SharedInfo = C_WhileExpression(IfCondArg,NIfCondArg,Op,NOp,FileInfo,SharedInfo);
// --------------------------
// --- Update SharedInfo. ---
diff --git a/macros/ASTManagement/AST_ParseEqualStruct.sci b/macros/ASTManagement/AST_ParseEqualStruct.sci
index fa76a01..68bc3da 100644
--- a/macros/ASTManagement/AST_ParseEqualStruct.sci
+++ b/macros/ASTManagement/AST_ParseEqualStruct.sci
@@ -123,7 +123,7 @@ end
// ------------------------
//#RNU_RES_B
PrintStringInfo('Function Name: '+FunctionName,ReportFileName,'file','y','n');
-PrintStringInfo('N Intput Arguments: '+string(NInArg),ReportFileName,'file','y','n');
+PrintStringInfo('N Input Arguments: '+string(NInArg),ReportFileName,'file','y','n');
//#RNU_RES_E
if (SharedInfo.Equal.Nins > 0)
//#RNU_RES_B
diff --git a/macros/ASTManagement/AST_ParseFuncallStruct.sci b/macros/ASTManagement/AST_ParseFuncallStruct.sci
index 647a70d..3c322dd 100644
--- a/macros/ASTManagement/AST_ParseFuncallStruct.sci
+++ b/macros/ASTManagement/AST_ParseFuncallStruct.sci
@@ -87,6 +87,10 @@ 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/macros/ASTManagement/AST_ParseIfExprStruct.sci b/macros/ASTManagement/AST_ParseIfExprStruct.sci
index a7da012..2bfb08d 100644
--- a/macros/ASTManagement/AST_ParseIfExprStruct.sci
+++ b/macros/ASTManagement/AST_ParseIfExprStruct.sci
@@ -1,4 +1,4 @@
-function [IfCondArg,NIfCondArg] = AST_ParseIfExprStruct(FileInfo,SharedInfo,ASTIfExpType)
+function [IfCondArg,NIfCondArg,Op,NOp] = AST_ParseIfExprStruct(FileInfo,SharedInfo,ASTIfExpType)
// function [IfCondArg,NIfCondArg] = AST_ParseIfExprStruct(FileInfo,SharedInfo,ASTIfExpType)
// -----------------------------------------------------------------
//#RNU_RES_B
@@ -63,13 +63,26 @@ 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')
@@ -78,31 +91,57 @@ 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),tmpscope] = AST_ExtractNameAndScope(IfExprField);
+ IfCondArg(NIfCondArg) = IfExprField;
+ end
+ //[IfCondArg(NIfCondArg),tmpscope] = AST_ExtractNameAndScope(IfExprField);
end
elseif (ASTIfExpType=='elseif')
if (IfExprField=='Else If Expression')
flagendpop = 1;
+ //IfExprField = AST_PopASTStack();
else
- NIfCondArg = NIfCondArg + 1;
- IfCondArg(NIfCondArg) = IfExprField;
- [IfCondArg(NIfCondArg),tmpscope] = AST_ExtractNameAndScope(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;
+ 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);
+
//#RNU_RES_B
// -------------------------------------------
// --- Print some info in the report file. ---
diff --git a/macros/ASTManagement/AST_ParseOperStruct.sci b/macros/ASTManagement/AST_ParseOperStruct.sci
index a77317b..903f095 100644
--- a/macros/ASTManagement/AST_ParseOperStruct.sci
+++ b/macros/ASTManagement/AST_ParseOperStruct.sci
@@ -61,6 +61,17 @@ 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/macros/ASTManagement/GenOutArgNames.sci b/macros/ASTManagement/GenOutArgNames.sci
index 0e68383..7b62c79 100644
--- a/macros/ASTManagement/GenOutArgNames.sci
+++ b/macros/ASTManagement/GenOutArgNames.sci
@@ -32,6 +32,12 @@ 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
@@ -43,47 +49,69 @@ OutArg = OldOutArg;
// ---------------------------------------------------------------------------------------
// At this step only the name of the output arguments can be generated. ---
//#RNU_RES_E
-if (NLhsArg > 0)
- //#RNU_RES_B
- // Use the equal Lhs names.
- PrintStringInfo('Using Equal Lhs names.',ReportFileName,'file','y');
- //#RNU_RES_E
- if (NLhsArg ~= NOutArg)
- 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
+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
- //#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
+ 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
-
endfunction
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
index b3633d5..2ef9e23 100644
--- a/macros/ASTManagement/lib
+++ b/macros/ASTManagement/lib
Binary files differ
diff --git a/macros/ASTManagement/names b/macros/ASTManagement/names
index a1aafbc..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,8 +29,11 @@ AST_HandleEndProgram
AST_HandleEndWhile
AST_HandleFor
AST_HandleForStatem
+AST_HandleFunCC
+AST_HandleFunRC
AST_HandleHeader
AST_HandleIfElse
+AST_HandleRC
AST_HandleWhileExpr
AST_HandleWhileStatem
AST_ParseEqualStruct