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
|
function [FunctionName,InArg,NInArg,NOutArg] = AST_ParseFuncallStruct(FileInfo,SharedInfo)
// function [FunctionName,InArg,NInArg,NOutArg] = AST_ParseFuncallStruct(FileInfo,SharedInfo)
// -----------------------------------------------------------------
//#RNU_RES_B
// Extracts Input Arguments, Output Arguments and Function Name
// from the AST.
//
// Structure of Funcall:
// overloading function for "funcall" type tlist string function
// this is a node of the AST
// fields:
// rhs : a list
// name : string, the name of the function
// lhsnb: number, the number of function lhs
// txt=['Funcall : '+F.name
// ' #lhs : '+string(F.lhsnb)
// ' Rhs : '
// ' '+objectlist2string(F.rhs)
// 'EndFuncall'
// ]
//
//#RNU_RES_E
// Input data:
// //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),2,2);
// -----------------------
// --- Initialization. ---
// -----------------------
nxtscifunname = SharedInfo.NextSCIFunName;
nxtscifunnumber = SharedInfo.NextSCIFunNumber;
ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName;
// #RNU_RES_B
PrintStringInfo(' Parsing Funcall structure',ReportFileName,'file','y');
// #RNU_RES_E
global SCI2CSTACK
global StackPosition;
global STACKDEDUG
// ------------------------------
// --- Read input parameters. ---
// ------------------------------
RhsField = AST_PopASTStack();
NInArg = 0;
while (RhsField ~= 'Rhs :')
NInArg = NInArg + 1;
[InputArgumentNames(NInArg),InputArgumentScope(NInArg)] = AST_ExtractNameAndScope(RhsField);
RhsField = AST_PopASTStack();
if (RhsField == '#lhs :')
error(9999, 'Found #lhs before Rhs');
elseif (RhsField == 'Funcall :')
error(9999, 'Found Funcall before Rhs');
end
end
if (stripblanks(InputArgumentNames(NInArg)) == '<empty>')
NInArg = 0;
InputArgumentNames = [];
InputArgumentScope = [];
end
InputArgumentNames = SCI2Cflipud(InputArgumentNames);
InputArgumentScope = SCI2Cflipud(InputArgumentScope);
// --------------------------------------------
// --- Extract number of output parameters. ---
// --------------------------------------------
buffstring = AST_PopASTStack();
NOutArg = eval(stripblanks(part(buffstring,10:length(buffstring))));
// ------------------------------
// --- Extract function name. ---
// ------------------------------
buffstring = AST_PopASTStack();
FunctionName = stripblanks(part(buffstring,12:length(buffstring)));
// -------------------------------------
// --- Generate the InArg structure. ---
// -------------------------------------
InArg = [];
for counterinputargs = 1:NInArg
if (InputArgumentNames(counterinputargs) == 'r')
InputArgumentNames(counterinputargs) = 'rr'; //NUT: per ora cerco di risolvere cosi' il baco sulla 'r'
end
InArg(counterinputargs).Name=InputArgumentNames(counterinputargs);
InArg(counterinputargs).Scope=InputArgumentScope(counterinputargs);
end
//#RNU_RES_B
PrintStringInfo('Function Name: '+FunctionName,ReportFileName,'file','y','n');
PrintStringInfo('N Intput Arguments: '+string(NInArg),ReportFileName,'file','y','n');
PrintStringInfo('N Output Arguments: '+string(NOutArg),ReportFileName,'file','y','n');
//#RNU_RES_E
for counterinputargs = 1:NInArg
//#RNU_RES_B
PrintStringInfo('Input Argument Number '+string(counterinputargs)+': '+InArg(counterinputargs).Name,...
ReportFileName,'file','y','n');
PrintStringInfo(' Scope: '+InArg(counterinputargs).Scope,...
ReportFileName,'file','y','n');
//#RNU_RES_E
end
endfunction
|