diff options
Diffstat (limited to '2.3-1/macros/ASTManagement/AST_HandleWhileStatem.sci')
-rw-r--r-- | 2.3-1/macros/ASTManagement/AST_HandleWhileStatem.sci | 60 |
1 files changed, 27 insertions, 33 deletions
diff --git a/2.3-1/macros/ASTManagement/AST_HandleWhileStatem.sci b/2.3-1/macros/ASTManagement/AST_HandleWhileStatem.sci index d8c2f73c..79fb516d 100644 --- a/2.3-1/macros/ASTManagement/AST_HandleWhileStatem.sci +++ b/2.3-1/macros/ASTManagement/AST_HandleWhileStatem.sci @@ -36,8 +36,6 @@ global SCI2CSTACK global StackPosition; global STACKDEDUG -IfCondArg = []; -NIfCondArg = 0; // ------------------------------ // --- Check input arguments. --- @@ -72,40 +70,36 @@ PrintStringInfo(' Redirecting C code to: '+FileInfo.Funct(nxtscifunnumber).CPa // --- Generate C code. --- // ------------------------ //#RNU_RES_E -flagendpop = 0; -IfExprField = AST_PopASTStack(); - -NOp=0; -Op=[]; -while (flagendpop == 0) - if (IfExprField~='<EOL>') - if (IfExprField=='WhileExpression:') - flagendpop = 1; - // Pop Again the If tag from the AST. - IfExprField = AST_PopASTStack(); - elseif (IfExprField=='Operands:') - flagendpop = 0; - g = AST_PopASTStack(); - else - if (IfExprField=='&&' | IfExprField=='||') - NOp = NOp + 1; - Op(NOp) = IfExprField; - //PrintStringInfo('operators are '+Op(NOp),ReportFileName,'file','y'); - else - NIfCondArg = NIfCondArg + 1; - IfCondArg(NIfCondArg) = IfExprField; - end - //[IfCondArg(NIfCondArg),tmpscope] = AST_ExtractNameAndScope(IfExprField); - //[IfCondArg(NIfCondArg),tmpscope] = AST_ExtractNameAndScope(IfExprField); - end +if(SharedInfo.WhileExpr.CondVar == '') + //#RNU_RES_B + // It means that we are handling something like while(a) or while(1) + // The while condition variable is generated by the HandleEndGenFun. + //#RNU_RES_E + + // --- Pop the name of the condition variable or number. --- + Pop1 = AST_PopASTStack(); + + [ArgName,ArgScope] = AST_ExtractNameAndScope(Pop1); + if (length(ArgName) == 0) + PrintStringInfo(' ',ReportFileName,'both','y'); + PrintStringInfo('SCI2CERROR: Expected while(variable) or while(number).','','stdout','y'); + PrintStringInfo('SCI2CERROR: Expected a variable or number in the AST while expression.','','stdout','y'); + PrintStringInfo('SCI2CERROR: Report this error to http://forge.scilab.org/index.php/p/scilab2c/issues/.','','stdout','y'); + PrintStringInfo(' ',ReportFileName,'both','y'); + error(9999, 'Expected a conditional variable in the while expression'); end - IfExprField = AST_PopASTStack(); - PrintStringInfo('operators are '+IfExprField,ReportFileName,'file','y'); -end -IfCondArg = SCI2Cflipud(IfCondArg); + SharedInfo.WhileExpr.CondVar = ArgName; + //#RNU_RES_B + // --- Repush strings into the AST stack. --- + //#RNU_RES_E -SharedInfo = C_WhileExpression(IfCondArg,NIfCondArg,Op,NOp,FileInfo,SharedInfo); + AST_PushASTStack(Pop1); + +elseif (SharedInfo.WhileExpr.DimCondVar > 0) + error(9999, 'Cannot manage while with matrix conditions'); +end +SharedInfo = C_WhileExpression(FileInfo,SharedInfo); // -------------------------- // --- Update SharedInfo. --- |