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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
function [UpdatedInArg,SharedInfo] = ST_GetInArgInfo(InArg,NInArg,FileInfo,SharedInfo)
// function UpdatedInArg = ST_GetInArgInfo(InArg,NInArg,FileInfo,SharedInfo)
// -----------------------------------------------------------------
// #RNU_RES_B
// Generate all the info concerning the input arguments.
//
// Input data:
// InArg: InArg structure containing only the names of the input
// arguments.
// //NUT: add description here
//
// Output data:
// UpdatedInArg: InArg structure with all the info on the input
// arguments.
// FileInfoDatFile: name of the .dat file containing the FileInfo
// structure.
// #RNU_RES_E
//
// Status:
// 26-Oct-2007 -- Raffaele Nutricato: Author.
//
// Copyright 2007 Raffaele Nutricato.
// Contact: raffaele.nutricato@tiscali.it
// -----------------------------------------------------------------
// ------------------------------
// --- Check input arguments. ---
// ------------------------------
SCI2CNInArgCheck(argn(2),4,4);
// -----------------------
// --- Initialization. ---
// -----------------------
nxtscifunname = SharedInfo.NextSCIFunName;
nxtscifunnumber = SharedInfo.NextSCIFunNumber;
ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName;
// #RNU_RES_B
PrintStringInfo(' ',ReportFileName,'file','y');
PrintStringInfo('***Analyzing Input Arguments***',ReportFileName,'file','y');
// #RNU_RES_E
UpdatedInArg = InArg;
// ---------------------------
// --- End Initialization. ---
// ---------------------------
for cntinarg = 1:NInArg
tmpname = InArg(cntinarg).Name;
tmpscope = InArg(cntinarg).Scope;
lengthNumber = length('Number_');
if (part(tmpscope,1:lengthNumber) == 'Number_')
// #RNU_RES_B
PrintStringInfo('Input Argument '+string(cntinarg)+' is a number: '+tmpname+'.',FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
// #RNU_RES_E
UpdatedInArg(cntinarg).Type = part(tmpscope,lengthNumber+1:lengthNumber+1);
if (UpdatedInArg(cntinarg).Type == 'x')
UpdatedInArg(cntinarg).Type = SharedInfo.DefaultPrecision; // It is the default.
elseif (UpdatedInArg(cntinarg).Type == 'X')
if (SharedInfo.DefaultPrecision == 's')
UpdatedInArg(cntinarg).Type = 'c'; // It is the default.
elseif (SharedInfo.DefaultPrecision == 'd')
UpdatedInArg(cntinarg).Type = 'z'; // It is the default.
else
error(9999, 'Unexpected value for SharedInfo.DefaultPrecision: ""'+SharedInfo.DefaultPrecision+'""');
end
end
if (tmpname == '%pi')
UpdatedInArg(cntinarg).Name = 'SCI2C_PI';
numvalue = %pi;
elseif (tmpname == '%e')
UpdatedInArg(cntinarg).Name = 'SCI2C_E';
numvalue = %e;
elseif (tmpname == '%T' | tmpname == '%t')
UpdatedInArg(cntinarg).Name = 'SCI2C_T';
numvalue = 1;
elseif (tmpname == '%F' | tmpname == '%f')
UpdatedInArg(cntinarg).Name = 'SCI2C_F';
numvalue = 0;
elseif (tmpname == '%nan')
UpdatedInArg(cntinarg).Name = 'SCI2C_NAN';
numvalue = %nan;
elseif (tmpname == '%inf')
UpdatedInArg(cntinarg).Name = 'SCI2C_INF';
numvalue = %nan; // Otherwise it will put in the C code Inf value.
elseif (tmpname == '%i')
// #RNU_RES_B
//NUT: Other complex numbers are always
//NUT: stored in variables, and don't appear as immediate numbers.
// #RNU_RES_E
UpdatedInArg(cntinarg).Name = 'SCI2C_IMG_'+convstr(UpdatedInArg(cntinarg).Type,'u');
numvalue = %i;
else
numvalue = eval(tmpname);
//UpdatedInArg(cntinarg).Type = 'd'; // it is the default.
end
UpdatedInArg(cntinarg).Size(1) = '1';
UpdatedInArg(cntinarg).Size(2) = '1';
UpdatedInArg(cntinarg).Value = numvalue;
UpdatedInArg(cntinarg).FindLike = 0;
UpdatedInArg(cntinarg).Dimension = 0;
UpdatedInArg(cntinarg).Scope = 'Number';
elseif (tmpscope == 'String')
// #RNU_RES_B
PrintStringInfo('Input Argument '+string(cntinarg)+' is a string: '+tmpname+'.',FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
// #RNU_RES_E
SharedInfo.ASTReader.UsedTempVars = SharedInfo.ASTReader.UsedTempVars + 1;
TmpOutArgName = strcat([SharedInfo.ASTReader.TempVarsName,string(SharedInfo.ASTReader.UsedTempVars)]);
UpdatedInArg(cntinarg).Name = TmpOutArgName; // Change the name.
UpdatedInArg(cntinarg).Type = 'g'; // it is the default.
UpdatedInArg(cntinarg).Size(1) = '1';
UpdatedInArg(cntinarg).Size(2) = string(length(tmpname)+1); //+1 = (\0)
UpdatedInArg(cntinarg).Value = '""'+tmpname+'""';
UpdatedInArg(cntinarg).FindLike = 0;
UpdatedInArg(cntinarg).Dimension = 2; //NUT: in future releases you can set this field to 1.
UpdatedInArg(cntinarg).Scope = 'Temp';
// #RNU_RES_B
// Add the new symbol in the symbol table.
// #RNU_RES_E
ST_InsOutArg(UpdatedInArg(cntinarg),1,FileInfo,SharedInfo,'all');
elseif (tmpscope == 'Variable' | tmpscope == 'Global' | tmpscope == 'Local' | tmpscope == 'Temp')
// #RNU_RES_B
//NUT: nelle future versioni qui si puo' fare una utile differenziazione per rendere piu' intelligente il tutto.
PrintStringInfo('Input Argument '+string(cntinarg)+' is a symbol: '+tmpname+'.',FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
// #RNU_RES_E
[TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension,TBScope] = ST_GetSymbolInfo(tmpname,FileInfo,SharedInfo);
if (TBFlagfound == 0)
PrintStringInfo(' ',ReportFileName,'both','y');
PrintStringInfo('SCI2CERROR: Unknown symbol ""'+tmpname+'"".',ReportFileName,'both','y');
PrintStringInfo('SCI2CERROR: Be sure to initialize every symbol you are using.',ReportFileName,'both','y');
PrintStringInfo('SCI2CERROR: Before running the SCI2C translator, remember to run the code you are trying',ReportFileName,'both','y');
PrintStringInfo('SCI2CERROR: to translate in order to check syntax errors.',ReportFileName,'both','y');
PrintStringInfo(' ',ReportFileName,'both','y');
error(9999, 'SCI2CERROR: Unknown symbol ""'+tmpname+'"".');
end
UpdatedInArg(cntinarg).Type = TBType;
UpdatedInArg(cntinarg).Size = TBSize;
UpdatedInArg(cntinarg).Value = TBValue;
UpdatedInArg(cntinarg).FindLike = TBFindLike;
UpdatedInArg(cntinarg).Dimension = TBDimension;
UpdatedInArg(cntinarg).Scope = TBScope;
else
error(9999, 'Unknown scope identifier ""'+tmpscope+'"" for variable ""'+tmpname+'"".');
end
// #RNU_RES_B
PrintStringInfo(' Type: '+UpdatedInArg(cntinarg).Type,FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
PrintStringInfo(' Size(1): '+string(UpdatedInArg(cntinarg).Size(1)),FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
PrintStringInfo(' Size(2): '+string(UpdatedInArg(cntinarg).Size(2)),FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
PrintStringInfo(' Value: '+string(UpdatedInArg(cntinarg).Value),FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
PrintStringInfo(' FindLike: '+string(UpdatedInArg(cntinarg).FindLike),FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
PrintStringInfo(' Dimension: '+string(UpdatedInArg(cntinarg).Dimension),FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
PrintStringInfo(' Scope: '+UpdatedInArg(cntinarg).Scope,FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
// #RNU_RES_E
end
endfunction
|