summaryrefslogtreecommitdiff
path: root/2.3-1/macros/ASTManagement/AST_HandleIfElse.sci
blob: 2b549ed66b92d3fc0be08b68436ff98f028c977a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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,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
// -----------------------------
// --- C Generation Section. ---
// -----------------------------
// --- Generate the C code for if/elseif Expression. ---
//#RNU_RES_E
SharedInfo = C_IfExpression(IfCondArg,NIfCondArg,Op,NOp,ASTIfExpType,FileInfo,SharedInfo);

endfunction