summaryrefslogtreecommitdiff
path: root/2.3-1/macros/ASTManagement/AST_HandleWhileExpr.sci
blob: ffcf2f45aec5d7900615ef34a6ee79a8e3af0a5b (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
function [FileInfo,SharedInfo] = AST_HandleWhileExpr(FileInfo,SharedInfo)
// function [FileInfo,SharedInfo] = AST_HandleWhileExpr(FileInfo,SharedInfo)
// -----------------------------------------------------------------
//#RNU_RES_B
// Handles the WhileExpression tag of the AST.
//
//   txt=['While'
//        '  WhileExpression:'
//        '    '+string(W.expression)
//        '  WhileStatements:'
//        '    '+objectlist2string(W.statements)
//        'EndWhile']
//
//#RNU_RES_E
// Input data:
// //NUT: add description here
//
// Output data:
// //NUT: add description here
//
// Status:
// 29-Dec-2007 -- Raffaele Nutricato: Author.
//
// Copyright 2007 Raffaele Nutricato.
// Contact: raffaele.nutricato@tiscali.it
// -----------------------------------------------------------------

// ------------------------------
// --- Check input arguments. ---
// ------------------------------
SCI2CNInArgCheck(argn(2),2,2);

// -----------------------
// --- Initialization. ---
// -----------------------
nxtscifunname   = SharedInfo.NextSCIFunName;
nxtscifunnumber = SharedInfo.NextSCIFunNumber;
ReportFileName  = FileInfo.Funct(nxtscifunnumber).ReportFileName;
PfxP1WhileProlFileName = FileInfo.Funct(nxtscifunnumber).PfxP1WhileProlFileName;
PfxP1WhileEpilFileName = FileInfo.Funct(nxtscifunnumber).PfxP1WhileEpilFileName;
PrintStepInfo('Handling While',FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
// ---------------------------
// --- End Initialization. ---
// ---------------------------

//#RNU_RES_B
// --- Signal the entrance in a while expression. ---
//#RNU_RES_E
SharedInfo.WhileExpr.OnExec = SharedInfo.WhileExpr.OnExec + 1;

//#RNU_RES_B
// --- Generate the file names for the prologue and epilogue files. ---
//#RNU_RES_E
FileInfo.Funct(nxtscifunnumber).CPass1WhileProlFileName(SharedInfo.While.Level) = ...
   PfxP1WhileProlFileName+string(SharedInfo.While.Level)+'.c';
FileInfo.Funct(nxtscifunnumber).CPass1WhileEpilFileName(SharedInfo.While.Level) = ...
   PfxP1WhileEpilFileName+string(SharedInfo.While.Level)+'.c';

//#RNU_RES_B
// -----------------------------------------------------------
// --- Create a copy of the While Prologue/Epilogue Files. ---
// -----------------------------------------------------------
//#RNU_RES_E
PrintStringInfo(' ',FileInfo.Funct(nxtscifunnumber).CPass1WhileProlFileName(SharedInfo.While.Level),'file');
PrintStringInfo(' ',FileInfo.Funct(nxtscifunnumber).CPass1WhileEpilFileName(SharedInfo.While.Level),'file');

//#RNU_RES_B
// --------------------------------------------------------
// --- Replace the CPass1V1 file with a temp WhileFile. ---
// --------------------------------------------------------
// From now up to Expression: all the C code will be written in a while temporary file.
//#RNU_RES_E
tmpfilename = FileInfo.Funct(nxtscifunnumber).CPass1FileName;
FileInfo.Funct(nxtscifunnumber).CPass1FileName = FileInfo.Funct(nxtscifunnumber).CPass1WhileProlFileName(SharedInfo.While.Level);
FileInfo.Funct(nxtscifunnumber).CPass1WhileProlFileName(SharedInfo.While.Level) = tmpfilename;
//#RNU_RES_B
PrintStringInfo('Redirecting C code to: '+FileInfo.Funct(nxtscifunnumber).CPass1FileName,FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
//#RNU_RES_E

endfunction