summaryrefslogtreecommitdiff
path: root/2.3-1/macros/FunctionAnnotation/FA_GetOutArgInfo.sci
blob: 4d1113eaa364879ace5f54346cae821fca254545 (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
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
function UpdatedOutArg = ...
   FA_GetOutArgInfo(InArg,NInArg,OutArg,NOutArg,SharedInfo,FunPrecSpecifier, ...
        FunTypeAnnot,FunSizeAnnot,ReportFileName,ASTFunName)
// function UpdatedOutArg = ...
//    FA_GetOutArgInfo(InArg,NInArg,OutArg,NOutArg,SharedInfo,FunPrecSpecifier,FunTypeAnnot,FunSizeAnnot,ReportFileName)
// -----------------------------------------------------------------
// #RNU_RES_B
// InArg is used by eval don't remove it from the function call.
//
// #RNU_RES_E
// Input data:
// //NUT: Add description here
//
// Output data:
// //NUT: Add description here
//
// Status:
// 25-Oct-2007 -- Raffaele Nutricato: Author.
//
// Copyright 2007 Raffaele Nutricato.
// Contact: raffaele.nutricato@tiscali.it
// -----------------------------------------------------------------

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


UpdatedOutArg   = OutArg;
for cntin = 1:NInArg
   IN(cntin).TP    = InArg(cntin).Type;
   for _InArgSize=1:size(InArg(cntin).Size, '*')
     IN(cntin).SZ(_InArgSize) = InArg(cntin).Size(_InArgSize);
   end
   if ((isnan(InArg(cntin).Value)) & (GetSymbolDimension(InArg(cntin).Size) == 0))
      // #RNU_RES_B
      // IN(cntin).VAL = '__SCI2CNANSIZE'; //RNU: toglimi
      //RNU: Replace the value of the variable with its name, in case it is a scalar variable.
      // #RNU_RES_E
      IN(cntin).VAL = InArg(cntin).Name;
   else
      IN(cntin).VAL = string(InArg(cntin).Value);
   end
end
DefaultPrecision = SharedInfo.DefaultPrecision;
// ---------------------------
// --- End Initialization. ---
// ---------------------------
if (FunTypeAnnot(1) == '')
   NOutArg = 0;
   
else
   NOutArg = max(size(FunTypeAnnot));
end

flagfindlike = 0;

for counterin = 1:NInArg
   if (InArg(counterin).FindLike == 1 | InArg(counterin).FindLike == -1)
      // #RNU_RES_B
      // Then we must assume that the output will be findlike
      // 0 = no find-like
      // 1 = pure find-like
      //-1 = similar to find-like (out=fun(in)) where in is find-like.
      // #RNU_RES_E
      flagfindlike = -1;
   end
end

for counterout = 1:NOutArg
   if(FunTypeAnnot == 'FA_TP_USER')
      UpdatedOutArg(counterout).Type   = FA_TP_USER(FunPrecSpecifier,DefaultPrecision);
   else
      UpdatedOutArg(counterout).Type   = eval(FunTypeAnnot(counterout));
   end
   UpdatedOutArg(counterout).FindLike  = 0;

   // This is just to remove the FA_SZ_RTMAX tag ???
   lengthFA_SZ_RTMAX = length('FA_SZ_RTMAX');
   if (SCI2Cstrncmps1size('FA_SZ_RTMAX',FunSizeAnnot(counterout,1)))
      UpdatedOutArg(counterout).FindLike = 1;
      FunSizeAnnot(counterout,1) = part(FunSizeAnnot(counterout,1),lengthFA_SZ_RTMAX+1:length(FunSizeAnnot(counterout,1)));
   end

   if (SCI2Cstrncmps1size('FA_SZ_RTMAX',FunSizeAnnot(counterout,2)))
      UpdatedOutArg(counterout).FindLike = 1;
      FunSizeAnnot(counterout,2) = part(FunSizeAnnot(counterout,2),lengthFA_SZ_RTMAX+1:length(FunSizeAnnot(counterout,2)));
   end

   if (flagfindlike == -1)
      UpdatedOutArg(counterout).FindLike = -1;
   end

   // #RNU_RES_B
   // When the size is given by e IN(x).VAL  annotation we can have two cases:
   // IN(x).VAL is a number or IN(x).VAL is %nan. When it is %nan the
   // size is equal to the name of IN(x).
   // This is a dynamic memory extension of a local variable and for the moment
   // we issue an error according to SCI2C specifications
   // #RNU_RES_E
   //disp(FunSizeAnnot(2),FunSizeAnnot(1))
	//Ukasha
//	if ASTFunName == svd
//		x=1;
//		for i=1:InArg(1).Size(1)
//			for j=1:InArg(1).Size(2)
//				A(i)(j)=InArg(1).Value(x);
//			end
//		end
//		[U,S,V]=svd(A,"e");
			

 
   for iterOutputPosition=1:size(FunSizeAnnot, 'c')
     tmpeval = eval(FunSizeAnnot(counterout, iterOutputPosition));
     if (IsNanSize(tmpeval))
       if SharedInfo.ForExpr.OnExec == 0
         EM_NanSize(ReportFileName);
       else
         UpdatedOutArg(counterout).Size(iterOutputPosition) = string(tmpeval);
       end
     elseif(isnum(tmpeval))
       if (eval(tmpeval) <= 0)
         EM_ZeroSize(ReportFileName);
       else
         UpdatedOutArg(counterout).Size(iterOutputPosition) = string(tmpeval);
       end
     else
       UpdatedOutArg(counterout).Size(iterOutputPosition) = string(tmpeval);
     end
   end
   if(ASTFunName == 'syslin')
    no_of_st = eval(InArg(2).Size(1))
    no_of_ip = eval(InArg(3).Size(2))
      UpdatedOutArg(counterout).Value     = no_of_st+no_of_ip*0.1;
   else 
      UpdatedOutArg(counterout).Value     = %nan;
   end
   UpdatedOutArg(counterout).Dimension = GetSymbolDimension(UpdatedOutArg(counterout).Size);
   UpdatedOutArg(counterout).Scope     = 'Temp';//NUT anche su questo si puo' ragionare verifica anche la handleoperation.
end
endfunction