summaryrefslogtreecommitdiff
path: root/2.3-1/macros/ASTManagement/AST_HandleIfElse.sci
blob: 449586f7efd36f2a0b38da1b88251b663695242f (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
95
96
97
98
99
100
101
102
103
104
105
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')
<<<<<<< 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
// -----------------------------
// --- C Generation Section. ---
// -----------------------------
// --- 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