summaryrefslogtreecommitdiff
path: root/macros/ASTManagement/AST_HandleForStatem.sci
blob: f47538a61ffdf58f0bd6cbbe572e2322db38ef52 (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
function [FileInfo,SharedInfo] = AST_HandleForStatem(FileInfo,SharedInfo)
// -----------------------------------------------------------------
//#RNU_RES_B
// Handles the ForStatements tag of the AST.
// overloading function for "for" type tlist string function
// this is a node of the AST
// fields:  
//    expression : "expression" type tlist (the loop expression)
//    statements : list of "equal" type tlist and list('EOL') (the
//                           for instructions list)
//   txt=['For'
//         '  ForExpression:'
//         '    '+string(F.expression)
//         '  ForStatements:'
//         '    '+objectlist2string(F.statements)
//         'EndFor']
//
//#RNU_RES_E
// Input data:
// //NUT: add description here
//
// Output data:
// //NUT: add description here
//
// Status:
// 15-Nov-2007 -- Raffaele Nutricato: Author.
//
// Copyright 2007 Raffaele Nutricato.
// Contact: raffaele.nutricato@tiscali.it
// -----------------------------------------------------------------

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

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

//#RNU_RES_B
// ---------------------------------------------
// --- Resume the correct name for CPass1V1. ---
// ---------------------------------------------
//#RNU_RES_E
tmpfilename = FileInfo.Funct(nxtscifunnumber).CPass1FileName;
FileInfo.Funct(nxtscifunnumber).CPass1FileName = FileInfo.Funct(nxtscifunnumber).CPass1ForProlFileName(SharedInfo.For.Level);
FileInfo.Funct(nxtscifunnumber).CPass1ForProlFileName(SharedInfo.For.Level) = tmpfilename;
PrintStringInfo('   Redirecting C code to: '+FileInfo.Funct(nxtscifunnumber).CPass1FileName,FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');

//#RNU_RES_B
// ------------------------
// --- Generate C code. ---
// ------------------------
//#RNU_RES_E
SharedInfo = C_ForExpression(FileInfo,SharedInfo);

//#RNU_RES_B
// --------------------------
// --- Update SharedInfo. ---
// --------------------------
// Signal the exit from a for expression.
//#RNU_RES_E
SharedInfo.ForExpr.OnExec = SharedInfo.ForExpr.OnExec - 1;
SharedInfo.ForExpr.IntCntArg     = [];
SharedInfo.ForExpr.MtxValCntArg  = [];
SharedInfo.ForExpr.SclValCntArg  = [];
SharedInfo.ForExpr.OpColonInfoIn1 = '';
SharedInfo.ForExpr.OpColonInfoIn2 = '';
SharedInfo.ForExpr.OpColonInfoIn3 = '';


SharedInfo.ForExpr.AssignmentFun = 0;

// -------------------------------
// --- Delete temporary files. ---
// -------------------------------
SCI2Cmdelete(FileInfo.Funct(nxtscifunnumber).CPass1ForProlFileName(SharedInfo.For.Level));

endfunction