diff options
author | Ankit Raj | 2017-06-21 10:26:59 +0530 |
---|---|---|
committer | Ankit Raj | 2017-06-21 10:26:59 +0530 |
commit | 958577cac90a99124cd673fde1926781d966d91f (patch) | |
tree | 134d9fe7f5b97a647cb055bb7b4c21820a749f49 /macros/ASTManagement/AST_HandleIfElse.sci | |
download | Scilab2C_fossee_old-958577cac90a99124cd673fde1926781d966d91f.tar.gz Scilab2C_fossee_old-958577cac90a99124cd673fde1926781d966d91f.tar.bz2 Scilab2C_fossee_old-958577cac90a99124cd673fde1926781d966d91f.zip |
Updated Scilab2C
Diffstat (limited to 'macros/ASTManagement/AST_HandleIfElse.sci')
-rw-r--r-- | macros/ASTManagement/AST_HandleIfElse.sci | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/macros/ASTManagement/AST_HandleIfElse.sci b/macros/ASTManagement/AST_HandleIfElse.sci new file mode 100644 index 0000000..5373adf --- /dev/null +++ b/macros/ASTManagement/AST_HandleIfElse.sci @@ -0,0 +1,92 @@ +function [FileInfo,SharedInfo] = AST_HandleIfElse(FileInfo,SharedInfo,ASTIfExpType) +// function [FileInfo,SharedInfo] = AST_HandleIfElse(FileInfo,SharedInfo,ASTIfExpType) +// ----------------------------------------------------------------- +//#RNU_RES_B +// Handles the Else If tag of the AST. +// +// overloading function for "ifthenel" type tlist string function +// this is a node of the AST +// fields: +// expression : "expression" type tlist (the if expression) +// then : list of "equal" type tlist and list('EOL') (the +// then instructions list) +// elseifs : a list of tlists +// else : list of "equal" type tlist and list('EOL') (the +// else instructions list) +// txt=['If ' +// ' Expression:' +// ' '+string(I.expression) +// ' If Statements' +// ' '+objectlist2string(I.then)] +// for e=I.elseifs +// txt=[txt; +// ' Else If Expression' +// ' '+string(e.expression) +// ' Else If Statements' +// ' '+objectlist2string(e.then)] +// end +// txt=[txt; +// ' Else Statements' +// ' '+objectlist2string(I.else) +// 'EndIf'] +// +// Input data: +// ASTIfExpType: it specifies if we are handling a if condition (ASTIfExpType='if') +// or an elseif condition (ASTIfExpType='elseif') or else statement (ASTIfExpType='else') +//#RNU_RES_E +// //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 +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),3,3); + +// ----------------------- +// --- Initialization. --- +// ----------------------- +nxtscifunname = SharedInfo.NextSCIFunName; +nxtscifunnumber = SharedInfo.NextSCIFunNumber; +ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; +PrintStepInfo('Handling If Statements',FileInfo.Funct(nxtscifunnumber).ReportFileName,'file'); + +global SCI2CSTACK +global StackPosition; +global STACKDEDUG +// --------------------------- +// --- End Initialization. --- +// --------------------------- + +//#RNU_RES_B +// --------------------------------------------------- +// --- Retrieve If Expression Parameters from AST. --- +// --------------------------------------------------- +//#RNU_RES_E +if (ASTIfExpType~='else') + [IfCondArg,NIfCondArg] = AST_ParseIfExprStruct(FileInfo,SharedInfo,ASTIfExpType); +else + // "else" type doesn't contain any condition to test. + IfCondArg = ''; + NIfCondArg = 0; +end + +//#RNU_RES_B +// ----------------------------- +// --- C Generation Section. --- +// ----------------------------- +// --- Generate the C code for if/elseif Expression. --- +//#RNU_RES_E +SharedInfo = C_IfExpression(IfCondArg,NIfCondArg,ASTIfExpType,FileInfo,SharedInfo); + +endfunction |