diff options
Diffstat (limited to '2.3-1/macros/SymbolTable')
-rw-r--r-- | 2.3-1/macros/SymbolTable/ST_AnalyzeScope.sci | 125 | ||||
-rw-r--r-- | 2.3-1/macros/SymbolTable/ST_Del.sci | 41 | ||||
-rw-r--r-- | 2.3-1/macros/SymbolTable/ST_FindPos.sci | 46 | ||||
-rw-r--r-- | 2.3-1/macros/SymbolTable/ST_Get.sci | 64 | ||||
-rw-r--r-- | 2.3-1/macros/SymbolTable/ST_GetInArgInfo.sci | 220 | ||||
-rw-r--r-- | 2.3-1/macros/SymbolTable/ST_GetSymbolInfo.sci | 99 | ||||
-rw-r--r-- | 2.3-1/macros/SymbolTable/ST_InsForCntVars.sci | 191 | ||||
-rw-r--r-- | 2.3-1/macros/SymbolTable/ST_InsOutArg.sci | 192 | ||||
-rw-r--r-- | 2.3-1/macros/SymbolTable/ST_Load.sci | 36 | ||||
-rw-r--r-- | 2.3-1/macros/SymbolTable/ST_MatchSymbol.sci | 69 | ||||
-rw-r--r-- | 2.3-1/macros/SymbolTable/ST_Save.sci | 44 | ||||
-rw-r--r-- | 2.3-1/macros/SymbolTable/ST_Set.sci | 49 | ||||
-rw-r--r-- | 2.3-1/macros/SymbolTable/buildmacros.sce | 15 | ||||
-rw-r--r-- | 2.3-1/macros/SymbolTable/lib | bin | 0 -> 752 bytes | |||
-rw-r--r-- | 2.3-1/macros/SymbolTable/names | 12 |
15 files changed, 1203 insertions, 0 deletions
diff --git a/2.3-1/macros/SymbolTable/ST_AnalyzeScope.sci b/2.3-1/macros/SymbolTable/ST_AnalyzeScope.sci new file mode 100644 index 00000000..6ce94820 --- /dev/null +++ b/2.3-1/macros/SymbolTable/ST_AnalyzeScope.sci @@ -0,0 +1,125 @@ +function OutArg = ST_AnalyzeScope(OldOutArg,NOutArg,FileInfo,SharedInfo);
+// function OutArg = ST_AnalyzeScope(OldOutArg,NOutArg,FileInfo,SharedInfo);
+// -----------------------------------------------------------------
+// //NUT: add description here
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// 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('***Getting output arguments info from the symbol table***',ReportFileName,'file','y');
+// #RNU_RES_E
+
+OutArg = OldOutArg;
+GlobalVarsFileName = FileInfo.GlobalVarFileName;
+LocalVarsFileName = FileInfo.Funct(nxtscifunnumber).LocalVarFileName;
+TempVarsFileName = FileInfo.Funct(nxtscifunnumber).TempVarFileName;
+// ---------------------------
+// --- End Initialization. ---
+// ---------------------------
+
+// #RNU_RES_B
+// ------------------------------------------------------------------
+// --- Check if the out variables already exist in symbol tables. ---
+// ------------------------------------------------------------------
+// #RNU_RES_E
+for cntout = 1:NOutArg
+
+ // #RNU_RES_B
+ PrintStringInfo(' Symbol ""'+OutArg(cntout).Name+'""',ReportFileName,'file','y');
+ // #RNU_RES_E
+ TBName = OutArg(cntout).Name;
+
+ // #RNU_RES_B
+ // --- Check in temporary symbol table. ---
+ // #RNU_RES_E
+ SymbolTableFileName = TempVarsFileName;
+ [TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension] = ...
+ ST_Get(TBName,SymbolTableFileName);
+ if (TBFlagfound == 0)
+ // #RNU_RES_B
+ PrintStringInfo(' ...not found in: '+SymbolTableFileName+'.',ReportFileName,'file','y');
+ // #RNU_RES_E
+ else
+ error(9999, 'Found a temp symbol in '+SymbolTableFileName+...
+ ' with the same name of the equal output argument ""'+TBName+'"".');
+ end
+
+ // #RNU_RES_B
+ // --- Check in local symbol table. ---
+ // #RNU_RES_E
+ SymbolTableFileName = LocalVarsFileName;
+ [TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension] = ...
+ ST_Get(TBName,SymbolTableFileName);
+ if (TBFlagfound == 0)
+ // #RNU_RES_B
+ PrintStringInfo(' ...not found in: '+SymbolTableFileName+'.',ReportFileName,'file','y');
+ // #RNU_RES_E
+ else
+ // #RNU_RES_B
+ PrintStringInfo(' ...found in: '+SymbolTableFileName+'.',ReportFileName,'file','y');
+ // #RNU_RES_E
+ OutArg(cntout).Scope = 'Local';
+ end
+
+ // #RNU_RES_B
+ // --- Check in global symbol table. ---
+ // #RNU_RES_E
+ if (TBFlagfound == 0)
+ // Local wins over global.
+ SymbolTableFileName = GlobalVarsFileName;
+ [TBFlagfound2,TBType,TBSize,TBValue,TBFindLike,TBDimension] = ...
+ ST_Get(TBName,SymbolTableFileName);
+ if (TBFlagfound2 == 0)
+ // #RNU_RES_B
+ PrintStringInfo(' ...not found in: '+SymbolTableFileName+'.',ReportFileName,'file','y');
+ // #RNU_RES_E
+ if SCI2Cstrncmps1size(SharedInfo.ASTReader.TempVarsName,OutArg(cntout).Name)
+ OutArg(cntout).Scope = 'Temp';
+ else
+ OutArg(cntout).Scope = 'Local';
+ end
+ else
+ // #RNU_RES_B
+ PrintStringInfo(' ...found in: '+SymbolTableFileName+'.',ReportFileName,'file','y');
+ // #RNU_RES_E
+ OutArg(cntout).Scope = 'Global';
+ end
+ end
+
+ // #RNU_RES_B
+ PrintStringInfo(' Type: '+OutArg(cntout).Type,ReportFileName,'file','y');
+ PrintStringInfo(' Size(1): '+string(OutArg(cntout).Size(1)),ReportFileName,'file','y');
+ PrintStringInfo(' Size(2): '+string(OutArg(cntout).Size(2)),ReportFileName,'file','y');
+ PrintStringInfo(' Value: '+string(OutArg(cntout).Value),ReportFileName,'file','y');
+ PrintStringInfo(' FindLike: '+string(OutArg(cntout).FindLike),ReportFileName,'file','y');
+ PrintStringInfo(' Dimension: '+string(OutArg(cntout).Dimension),ReportFileName,'file','y');
+ PrintStringInfo(' Scope: '+string(OutArg(cntout).Scope),ReportFileName,'file','y');
+ PrintStringInfo(' ',ReportFileName,'file','y');
+ // #RNU_RES_E
+end
+
+endfunction
diff --git a/2.3-1/macros/SymbolTable/ST_Del.sci b/2.3-1/macros/SymbolTable/ST_Del.sci new file mode 100644 index 00000000..7eda874d --- /dev/null +++ b/2.3-1/macros/SymbolTable/ST_Del.sci @@ -0,0 +1,41 @@ +function ST_Del(TBName,SymbolTableFileName)
+// function ST_Del(TBName,SymbolTableFileName)
+// -----------------------------------------------------------------
+// Delete function for the symbol table.
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+// --- Load symbol table. ---
+SCI2CSymbolTable = ST_Load(SymbolTableFileName);
+
+// --- Find symbol position. ---
+[TBFlagfound,TBPosition] = ST_FindPos(TBName,SymbolTableFileName);
+
+if (TBFlagfound == 0)
+ error(9999, 'Missing symbol: trying to del a non existing symbol ""'+TBName+'"".');
+elseif (TBFlagfound == 1)
+ // --- Update symbol table. ---
+ SCI2CSymbolTable(TBPosition) = [];
+
+ // --- Save symbol table. ---
+ ST_Save(SymbolTableFileName,SCI2CSymbolTable);
+end
+
+endfunction
diff --git a/2.3-1/macros/SymbolTable/ST_FindPos.sci b/2.3-1/macros/SymbolTable/ST_FindPos.sci new file mode 100644 index 00000000..737b7de4 --- /dev/null +++ b/2.3-1/macros/SymbolTable/ST_FindPos.sci @@ -0,0 +1,46 @@ +function [TBFlagfound,TBPosition] = ST_FindPos(TBName,SymbolTableFileName)
+// function [TBFlagfound,TBPosition] = ST_FindPos(TBName,SymbolTableFileName)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// Finds position of symbol TBName in the symbol table.
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// #RNU_RES_E
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+// --- Load symbol table. ---
+SCI2CSymbolTable = ST_Load(SymbolTableFileName);
+
+// --- Find position of the line to be removed. ---
+TBFlagfound = 0;
+TBPosition = 0;
+NEntries = max(size(SCI2CSymbolTable));
+for countertable = 1:NEntries
+ if (mtlb_strcmp(TBName,SCI2CSymbolTable(countertable).Name))
+ TBFlagfound = TBFlagfound + 1;
+ TBPosition = countertable;
+ end
+end
+
+if (TBFlagfound > 1)
+ error(9999, 'Symbol table conflict: found two symbols with the same name ""'+TBName+'"".');
+end
+
+endfunction
diff --git a/2.3-1/macros/SymbolTable/ST_Get.sci b/2.3-1/macros/SymbolTable/ST_Get.sci new file mode 100644 index 00000000..636a873a --- /dev/null +++ b/2.3-1/macros/SymbolTable/ST_Get.sci @@ -0,0 +1,64 @@ +function [TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension] = ...
+ ST_Get(Field_Name,SymbolTableFileName)
+// function [TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension] = ...
+// ST_Get(Field_Name,SymbolTableFileName)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// Get function for the symbol table.
+//
+// #RNU_RES_E
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+// --------------------------
+// --- Load Symbol Table. ---
+// --------------------------
+[tmpnams,tmptyps,tmpdims,tmpvols]=listvarinfile(SymbolTableFileName);
+if (max(size(tmpnams)) > 1)
+ error(9999, 'More than one variable found in ""'+SymbolTableFileName+'"".');
+end
+load(SymbolTableFileName,tmpnams);
+SCI2CSymbolTable = eval(tmpnams);
+// ------------------------------
+// --- End Load Symbol Table. ---
+// ------------------------------
+
+TBFlagfound = 0;
+TBType = '';
+TBSize(1) = '';
+TBSize(2) = '';
+TBValue = %nan;
+TBFindLike = %nan;
+TBDimension = %nan;
+NEntries = max(size(SCI2CSymbolTable));
+for countertable = 1:NEntries
+ if (mtlb_strcmp(Field_Name,SCI2CSymbolTable(countertable).Name))
+ TBFlagfound = TBFlagfound + 1;
+ TBType = SCI2CSymbolTable(countertable).Type; // String
+ TBSize = SCI2CSymbolTable(countertable).Size; // String
+ TBValue = SCI2CSymbolTable(countertable).Value;
+ TBFindLike = SCI2CSymbolTable(countertable).FindLike; // Number: 0 or 1.
+ TBDimension = SCI2CSymbolTable(countertable).Dimension; // Number: 0 or 1 or 2.
+ end
+end
+
+if (TBFlagfound > 1)
+ error(9999, 'Symbol table conflict: found two symbols with the same name ""'+TBName+'"".');
+end
+endfunction
diff --git a/2.3-1/macros/SymbolTable/ST_GetInArgInfo.sci b/2.3-1/macros/SymbolTable/ST_GetInArgInfo.sci new file mode 100644 index 00000000..4c85408c --- /dev/null +++ b/2.3-1/macros/SymbolTable/ST_GetInArgInfo.sci @@ -0,0 +1,220 @@ +function [UpdatedInArg,SharedInfo] = ST_GetInArgInfo(InArg,NInArg,FileInfo,SharedInfo,ASTFunName)
+// 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),5,5);
+
+// -----------------------
+// --- 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';
+ if((ASTFunName == 'cmd_analog_in' | ASTFunName == 'cmd_analog_in_volt' ) & cntinarg == 2)
+ numvalue = eval(tmpname);
+ if (SharedInfo.Board_name == 'mega' | SharedInfo.Board_name == 'mega2560') then
+ tmpname = string(numvalue + 54)
+ UpdatedInArg(cntinarg).Value = 54 + numvalue;
+ else
+ tmpname = string(numvalue + 14)
+ UpdatedInArg(cntinarg).Value = 14 + numvalue;
+ end
+ UpdatedInArg(cntinarg).Name = tmpname; // Change the name.
+ end
+
+ 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; //Keep it zero to avoid extra argument 'funcnameSize'.
+ 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)
+ if(ASTFunName == 'ode')
+ if((NInArg == 4 & cntinarg == 4) | (NInArg == 6 & cntinarg == 6))
+ //incase of 4 arguments, fourth argument is function name
+ UpdatedInArg(cntinarg).Name = tmpname; // Change the name.
+ UpdatedInArg(cntinarg).Type = 'fn'; //it is a function name
+ UpdatedInArg(cntinarg).Size(1) = '1';
+ UpdatedInArg(cntinarg).Size(2) = '1'; //+1 = (\0)
+ UpdatedInArg(cntinarg).Value = '&'+tmpname;
+ UpdatedInArg(cntinarg).FindLike = 0;
+ UpdatedInArg(cntinarg).Dimension = 0; //NUT: in future releases you can set this field to 1.
+ UpdatedInArg(cntinarg).Scope = 'Temp';
+ ST_InsOutArg(UpdatedInArg(cntinarg),1,FileInfo,SharedInfo,'all');
+ elseif (NInArg == 5 & cntinarg == 5) then
+ //incase of 5 arguments, fifth argument is function name
+ UpdatedInArg(cntinarg).Name = tmpname; // Change the name.
+ UpdatedInArg(cntinarg).Type = 'fn'; //it is a function name
+ UpdatedInArg(cntinarg).Size(1) = '1';
+ UpdatedInArg(cntinarg).Size(2) = '1'; //+1 = (\0)
+ UpdatedInArg(cntinarg).Value = '&'+tmpname;
+ UpdatedInArg(cntinarg).FindLike = 0;
+ UpdatedInArg(cntinarg).Dimension = 0; //NUT: in future releases you can set this field to 1.
+ UpdatedInArg(cntinarg).Scope = 'Temp';
+ ST_InsOutArg(UpdatedInArg(cntinarg),1,FileInfo,SharedInfo,'all');
+ end
+ elseif (ASTFunName == 'RPI_ThreadCreate')
+ UpdatedInArg(cntinarg).Name = tmpname; // Change the name.
+ UpdatedInArg(cntinarg).Type = 'fn'; //it is a function name
+ UpdatedInArg(cntinarg).Size(1) = '1';
+ UpdatedInArg(cntinarg).Size(2) = '1'; //+1 = (\0)
+ UpdatedInArg(cntinarg).Value = '&'+tmpname;
+ UpdatedInArg(cntinarg).FindLike = 0;
+ UpdatedInArg(cntinarg).Dimension = 0; //NUT: in future releases you can set this field to 1.
+ UpdatedInArg(cntinarg).Scope = 'Temp';
+ ST_InsOutArg(UpdatedInArg(cntinarg),1,FileInfo,SharedInfo,'all');
+ elseif (ASTFunName == 'RPI_PinISR')
+ UpdatedInArg(cntinarg).Name = tmpname; // Change the name.
+ UpdatedInArg(cntinarg).Type = 'fn'; //it is a function name
+ UpdatedInArg(cntinarg).Size(1) = '1';
+ UpdatedInArg(cntinarg).Size(2) = '1'; //+1 = (\0)
+ UpdatedInArg(cntinarg).Value = '&'+tmpname;
+ UpdatedInArg(cntinarg).FindLike = 0;
+ UpdatedInArg(cntinarg).Dimension = 0; //NUT: in future releases you can set this field to 1.
+ UpdatedInArg(cntinarg).Scope = 'Temp';
+ ST_InsOutArg(UpdatedInArg(cntinarg),1,FileInfo,SharedInfo,'all');
+ else
+ 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
+ else
+ UpdatedInArg(cntinarg).Type = TBType;
+ UpdatedInArg(cntinarg).Size = TBSize;
+ UpdatedInArg(cntinarg).Value = TBValue;
+ UpdatedInArg(cntinarg).FindLike = TBFindLike;
+ UpdatedInArg(cntinarg).Dimension = TBDimension;
+ UpdatedInArg(cntinarg).Scope = TBScope;
+ end
+ 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
diff --git a/2.3-1/macros/SymbolTable/ST_GetSymbolInfo.sci b/2.3-1/macros/SymbolTable/ST_GetSymbolInfo.sci new file mode 100644 index 00000000..1fb2f3de --- /dev/null +++ b/2.3-1/macros/SymbolTable/ST_GetSymbolInfo.sci @@ -0,0 +1,99 @@ +function [TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension,TBScope] = ST_GetSymbolInfo(TBName,FileInfo,SharedInfo)
+// function [TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension,TBScope] = ST_GetSymbolInfo(TBName,FileInfo,SharedInfo)
+// -----------------------------------------------------------------
+// //NUT: add description here
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),3,3);
+
+// -----------------------
+// --- Initialization. ---
+// -----------------------
+// --- Extraction of the function name and number. ---
+nxtscifunname = SharedInfo.NextSCIFunName;
+nxtscifunnumber = SharedInfo.NextSCIFunNumber;
+
+GlobalVarsFileName = FileInfo.GlobalVarFileName;
+LocalVarsFileName = FileInfo.Funct(nxtscifunnumber).LocalVarFileName;
+TempVarsFileName = FileInfo.Funct(nxtscifunnumber).TempVarFileName;
+
+TBFlagfound = 0;
+TBType = '';
+TBSize(1) = '';
+TBSize(2) = '';
+TBValue = %nan
+TBFindLike = %nan
+TBDimension = %nan;
+TBScope = '';
+// ---------------------------
+// --- End Initialization. ---
+// ---------------------------
+
+// #RNU_RES_B
+// ------------------------------------------------
+// --- Search in the temporary variables table. ---
+// ------------------------------------------------
+PrintStringInfo('Searching ""'+TBName+'"" in '+FileInfo.Funct(nxtscifunnumber).TempVarFileName+'.',FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
+// #RNU_RES_E
+[TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension] = ...
+ ST_Get(TBName,TempVarsFileName);
+if (TBFlagfound == 1);
+ // #RNU_RES_B
+ PrintStringInfo('...Found in: ""'+FileInfo.Funct(nxtscifunnumber).TempVarFileName+'.',FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
+ // #RNU_RES_E
+ TBScope = 'Temp';
+end
+
+// --------------------------------------------
+// --- Search in the local variables table. ---
+// --------------------------------------------
+if (TBFlagfound == 0);
+ // #RNU_RES_B
+ PrintStringInfo('Searching ""'+TBName+'"" in '+FileInfo.Funct(nxtscifunnumber).LocalVarFileName+'.',FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
+ // #RNU_RES_E
+ [TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension] = ...
+ ST_Get(TBName,LocalVarsFileName);
+ if (TBFlagfound == 1);
+ // #RNU_RES_B
+ PrintStringInfo('...Found in: ""'+FileInfo.Funct(nxtscifunnumber).LocalVarFileName+'.',FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
+ // #RNU_RES_E
+ TBScope = 'Local';
+ end
+end
+
+// #RNU_RES_B
+// ---------------------------------------------
+// --- Search in the global variables table. ---
+// ---------------------------------------------
+// #RNU_RES_E
+if (TBFlagfound == 0);
+ // #RNU_RES_B
+ PrintStringInfo('Searching ""'+TBName+'"" in '+FileInfo.GlobalVarFileName+'.',FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
+ // #RNU_RES_E
+ [TBFlagfound,TBType,TBSize,TBValue,TBFindLike,TBDimension] = ...
+ ST_Get(TBName,GlobalVarsFileName);
+ if (TBFlagfound == 1);
+ // #RNU_RES_B
+ PrintStringInfo('...Found in: ""'+FileInfo.GlobalVarFileName+'.',FileInfo.Funct(nxtscifunnumber).ReportFileName,'file');
+ // #RNU_RES_E
+ TBScope = 'Global';
+ end
+end
+
+endfunction
diff --git a/2.3-1/macros/SymbolTable/ST_InsForCntVars.sci b/2.3-1/macros/SymbolTable/ST_InsForCntVars.sci new file mode 100644 index 00000000..b0e6f356 --- /dev/null +++ b/2.3-1/macros/SymbolTable/ST_InsForCntVars.sci @@ -0,0 +1,191 @@ +function [OutArg,SharedInfo] = ST_InsForCntVars(InArg,NInArg,OutArg,NOutArg,FunctionName,FileInfo,SharedInfo)
+// function [OutArg,SharedInfo] = ST_InsForCntVars(InArg,NInArg,OutArg,NOutArg,FunctionName,FileInfo,SharedInfo)
+// -----------------------------------------------------------------
+// //NUT: add description here
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),7,7);
+
+// -----------------------
+// --- Initialization. ---
+// -----------------------
+nxtscifunname = SharedInfo.NextSCIFunName;
+nxtscifunnumber = SharedInfo.NextSCIFunNumber;
+ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName;
+
+// #RNU_RES_B
+PrintStringInfo(' ',ReportFileName,'file','y');
+PrintStringInfo('***Checking if the current function is handling for counter variables.***',ReportFileName,'file','y');
+// #RNU_RES_E
+
+// ---------------------------
+// --- End Initialization. ---
+// ---------------------------
+
+// -----------------------------------------------
+// --- Initial Check on For counter variables. ---
+// -----------------------------------------------
+if ((SharedInfo.ForExpr.OnExec > 0) & (NOutArg==1) & (OutArg.Scope~='Temp'))
+ // #RNU_RES_B
+ // If we are here, for sure we are in the last assignment of a for loop expression.
+ //
+ // All the following cases must be handled:
+ // OpColon (1,10,cnt) or Opcolon (1,1,10,cnt) --> cnt must be redefined to dim=0
+ // cnt = a; where a is scalar
+ // OpEqual(TMP,cnt); where TMP is matrix --> cnt must be redefined to dim=0, a SCI2Cint counter must be generated
+ // Fun(TMP,cnt); where TMP is matrix.--> cnt must be redefined to dim=0, a SCI2Cint counter must be generated, CNT must be generated where CNT is a Matrix
+ // #RNU_RES_E
+ if (FunctionName == 'OpColon')
+ // #RNU_RES_B
+ PrintStringInfo(' The for expression is using an OpColon-based assignment',ReportFileName,'file','y');
+ // #RNU_RES_E
+ SharedInfo.SkipNextFun = 1;
+
+ OutArg.Size(1) = '1';
+ OutArg.Size(2) = '1';
+ OutArg.Value = %nan;
+ OutArg.FindLike = 0;
+ OutArg.Dimension = 0;
+ SharedInfo.ForExpr.OpColonInfoIn1 = InArg(1).Name;
+
+ if (NInArg == 2)
+ SharedInfo.ForExpr.OpColonInfoIn2 = '1';
+ SharedInfo.ForExpr.OpColonInfoIn3 = InArg(2).Name;
+ else
+ SharedInfo.ForExpr.OpColonInfoIn2 = InArg(2).Name;
+ if isnan(InArg(2).Value)
+ EM_UnknownStep(ReportFileName);
+ end
+
+ SharedInfo.ForExpr.OpColonInfoIn3 = InArg(3).Name;
+ end
+
+ // #RNU_RES_B
+ // Generate all info to generate the C for expression
+ // #RNU_RES_E
+ SharedInfo.ForExpr.AssignmentFun = SharedInfo.CFunId.OpColon;
+ SharedInfo.ForExpr.IntCntArg = [];
+ SharedInfo.ForExpr.MtxValCntArg = [];
+ SharedInfo.ForExpr.SclValCntArg = OutArg;
+
+ elseif ((FunctionName == 'OpEqual') & (SharedInfo.ForExpr.AssignmentFun == 0))
+ // #RNU_RES_B
+ //NUT: Test also that SharedInfo.ForExpr.AssignmentFun because sometimes Equal are dummy!
+ //NUT: verifica se e' giusta questa mia affermazione.
+ // #RNU_RES_E
+ if (OutArg.Dimension > 0)
+ // #RNU_RES_B
+ PrintStringInfo(' The for expression is using a Matrix-Equal-based assignment',ReportFileName,'file','y');
+ // #RNU_RES_E
+ SharedInfo.SkipNextFun = 1; //NUT: forse qui sarebbe meglio mettere uno skipnextequal per precisione.
+ // #RNU_RES_B
+ //NUT: a dire il vero occorre capire se c'e' differenza tra i vari skip.
+ // #RNU_RES_E
+ OutArg.Size(1) = '1';
+ OutArg.Size(2) = '1';
+ OutArg.Value = %nan;
+ OutArg.FindLike = 0;
+ OutArg.Dimension = 0;
+
+ // #RNU_RES_B
+ // Introduce the int counter variable.
+ // #RNU_RES_E
+ NNewArg = 1;
+ NewArg(NNewArg).Name = SharedInfo.ASTReader.TempForCntVarsName+string(SharedInfo.CountForTempVars);
+ SharedInfo.CountForTempVars = SharedInfo.CountForTempVars + 1;
+ NewArg(NNewArg).Size(1) = '1';
+ NewArg(NNewArg).Size(2) = '1';
+ NewArg(NNewArg).Type = 'i';
+ NewArg(NNewArg).Value = 0;
+ NewArg(NNewArg).FindLike = 0;
+ NewArg(NNewArg).Dimension = 0;
+ NewArg(NNewArg).Scope = 'Temp';
+
+ // #RNU_RES_B
+ // Insert New Arguments in the symbol table.
+ // #RNU_RES_E
+ NNewArg = 1;
+ ST_InsOutArg(NewArg,NNewArg,FileInfo,SharedInfo,'all');
+
+ // #RNU_RES_B
+ // Generate all info to generate the C for expression
+ // #RNU_RES_E
+ SharedInfo.ForExpr.AssignmentFun = SharedInfo.CFunId.EqMatrix;
+ SharedInfo.ForExpr.IntCntArg = NewArg(1);
+ SharedInfo.ForExpr.MtxValCntArg = InArg(1);
+ SharedInfo.ForExpr.SclValCntArg = OutArg;
+ else
+ // #RNU_RES_B
+ PrintStringInfo(' The for expression is using a Scalar-Equal-based assignment',ReportFileName,'file','y');
+ // #RNU_RES_E
+ SharedInfo.ForExpr.AssignmentFun = SharedInfo.CFunId.EqScalar;
+ end
+ else
+ if (OutArg.Dimension > 0)
+ // #RNU_RES_B
+ PrintStringInfo(' The for expression is using a Matrix-Function-based assignment',ReportFileName,'file','y');
+
+ // Introduce the val counter variable.
+ // #RNU_RES_E
+ NewArg = OutArg;
+ OutArg.Name = SharedInfo.ASTReader.TempForValVarsName+OutArg.Name;
+
+ // #RNU_RES_B
+ // Set the counter variable to scalar.
+ // #RNU_RES_E
+ NNewArg = 1;
+ NewArg(NNewArg).Size(1) = '1';
+ NewArg(NNewArg).Size(2) = '1';
+ NewArg(NNewArg).Value = %nan;
+ NewArg(NNewArg).FindLike = 0;
+ NewArg(NNewArg).Dimension = 0;
+
+ // #RNU_RES_B
+ // Introduce the int counter variable.
+ // #RNU_RES_E
+ NNewArg = 2;
+ NewArg(NNewArg).Name = SharedInfo.ASTReader.TempForCntVarsName+string(SharedInfo.CountForTempVars);
+ SharedInfo.CountForTempVars = SharedInfo.CountForTempVars + 1;
+ NewArg(NNewArg).Size(1) = '1';
+ NewArg(NNewArg).Size(2) = '1';
+ NewArg(NNewArg).Type = 'i';
+ NewArg(NNewArg).Value = 0;
+ NewArg(NNewArg).FindLike = 0;
+ NewArg(NNewArg).Dimension = 0;
+ NewArg(NNewArg).Scope = 'Temp';
+
+ // #RNU_RES_B
+ // Insert New Arguments in the symbol table.
+ // #RNU_RES_E
+ NNewArg = 2;
+ ST_InsOutArg(NewArg,NNewArg,FileInfo,SharedInfo,'all');
+
+ // #RNU_RES_B
+ // Generate all info to generate the C for expression
+ // #RNU_RES_E
+ SharedInfo.ForExpr.AssignmentFun = SharedInfo.CFunId.GenFunMtx;
+ SharedInfo.ForExpr.IntCntArg = NewArg(2);
+ SharedInfo.ForExpr.MtxValCntArg = OutArg(1);
+ SharedInfo.ForExpr.SclValCntArg = NewArg(1);
+ end
+ end
+end
+
+endfunction
diff --git a/2.3-1/macros/SymbolTable/ST_InsOutArg.sci b/2.3-1/macros/SymbolTable/ST_InsOutArg.sci new file mode 100644 index 00000000..fd6b426c --- /dev/null +++ b/2.3-1/macros/SymbolTable/ST_InsOutArg.sci @@ -0,0 +1,192 @@ +function ST_InsOutArg(OutArg,NOutArg,FileInfo,SharedInfo,MatchRule)
+// function ST_InsOutArg(OutArg,NOutArg,FileInfo,SharedInfo,MatchRule)
+// -----------------------------------------------------------------
+// //NUT: add description here
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),5,5);
+
+// -----------------------
+// --- Initialization. ---
+// -----------------------
+nxtscifunname = SharedInfo.NextSCIFunName;
+nxtscifunnumber = SharedInfo.NextSCIFunNumber;
+ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName;
+CDeclarationFileName = FileInfo.Funct(nxtscifunnumber).CDeclarationFileName;
+CGblDeclarFileName = FileInfo.Funct(nxtscifunnumber).CGblDeclarFileName;
+
+GlobalVarsFileName = FileInfo.GlobalVarFileName;
+LocalVarsFileName = FileInfo.Funct(nxtscifunnumber).LocalVarFileName;
+TempVarsFileName = FileInfo.Funct(nxtscifunnumber).TempVarFileName;
+
+CPass1FileName = FileInfo.Funct(nxtscifunnumber).CPass1FileName;
+CPass1FreeFileName = FileInfo.Funct(nxtscifunnumber).CPass1FreeFileName;
+
+
+// #RNU_RES_B
+PrintStringInfo(' ',ReportFileName,'file','y');
+PrintStringInfo('***Putting output arguments in the symbol table***',ReportFileName,'file','y','n');
+// #RNU_RES_E
+// ---------------------------
+// --- End Initialization. ---
+// ---------------------------
+for counteroutput = 1:NOutArg
+ // #RNU_RES_B
+ PrintStringInfo(' Symbol ""'+OutArg(counteroutput).Name+'""',ReportFileName,'file','y','n');
+ PrintStringInfo(' Type: '+OutArg(counteroutput).Type,ReportFileName,'file','y','n');
+ PrintStringInfo(' Size(1): '+string(OutArg(counteroutput).Size(1)),ReportFileName,'file','y','n');
+ PrintStringInfo(' Size(2): '+string(OutArg(counteroutput).Size(2)),ReportFileName,'file','y','n');
+ PrintStringInfo(' Value: '+string(OutArg(counteroutput).Value),ReportFileName,'file','y','n');
+ PrintStringInfo(' FindLike: '+string(OutArg(counteroutput).FindLike),ReportFileName,'file','y','n');
+ PrintStringInfo(' Dimension: '+string(OutArg(counteroutput).Dimension),ReportFileName,'file','y','n');
+ PrintStringInfo(' Scope: '+string(OutArg(counteroutput).Scope),ReportFileName,'file','y','n');
+ PrintStringInfo(' ',ReportFileName,'file','y','n');
+ // #RNU_RES_E
+ if (OutArg(counteroutput).Scope == 'Temp')
+ SymbTableFileName = TempVarsFileName;
+ elseif (OutArg(counteroutput).Scope == 'Local')
+ SymbTableFileName = LocalVarsFileName;
+ elseif (OutArg(counteroutput).Scope == 'Global')
+ SymbTableFileName = GlobalVarsFileName;
+ else
+ error(9999, 'Unknown scope ""'+OutArg(counteroutput).Scope+'"" for symbol: '+OutArg(counteroutput).Name);
+ end
+ // #RNU_RES_B
+ PrintStringInfo(' Setting symbol ""'+OutArg(counteroutput).Name+'"" in '+SymbTableFileName+'.',ReportFileName,'file','y');
+ // #RNU_RES_E
+
+ // #RNU_RES_B
+ // Check existence and conflicts in the symbol table.
+ // Here we have four possibilities:
+ // 1. the symbol is a global variable not initialized yet -> we have to initialize it.
+ // 2. the symbol already exists with different settings -> we have to issue an error.
+ // 3. the symbol already exists with the same settings -> ok, we don't have to do nothing.
+ // 4. the symbol doesn't exist -> we have to insert it into the table.
+ // #RNU_RES_E
+ [TBFlagfound,TBFlagEqualSymbols] = ...
+ ST_MatchSymbol(OutArg(counteroutput).Name,...
+ OutArg(counteroutput).Type,...
+ OutArg(counteroutput).Size,...
+ OutArg(counteroutput).Value,...
+ OutArg(counteroutput).FindLike,...
+ OutArg(counteroutput).Dimension,...
+ SymbTableFileName,MatchRule);
+
+ if (TBFlagfound == 1)
+ if (TBFlagEqualSymbols == 0)
+ PrintStringInfo(' ',ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: Symbol Table Conflict. Trying to insert again symbol ""'+...
+ OutArg(counteroutput).Name+'"" with different settings',ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: Please check that you are not using variable ""'+OutArg(counteroutput).Name+'""',ReportFileName,'both','y');
+ PrintStringInfo('SCI2CERROR: with different sizes and/or types.',ReportFileName,'both','y');
+ PrintStringInfo(' ',ReportFileName,'both','y');
+ error(9999, 'SCI2CERROR: Symbol Table Conflict. Trying to insert again symbol ""'+...
+ OutArg(counteroutput).Name+'"" with different settings');
+ else
+ // #RNU_RES_B
+ // It's ok symbols do match.
+ //NUT: forse occorre un altro check sulla size per capire se occore fare il malloc.
+ //NUT: qui entro anche quando ho una variabile global gia' dichiarata tale in un altro
+ //NUT: per cui devo dichiararala come external.
+ //RNU qui ci puoi mettere una warning quando stai riallocando uno stesso simbolo con size simbolica.
+ //RNU puoi anche aggiungere del codice in c o un semplice commento. per esempio una funzione c del tipo checksize che controlla il valore
+ //RNU prima dopo delle size di una data variabile. Cosa succede se cambio la size anche nel caso di array e approccio
+ //RNU di resize non attivo? L'unica cosa e' che molte size numeriche scompaiono e incomincio a creare numerose variabili
+ //RNU con size simbolica.
+
+ // If the symbol is scalar we update its value if it is an array we update its size
+ // only in case we are using the 'REALLOC_ALL_RESIZE_ALL' resize approach
+ // #RNU_RES_E
+ if ((GetSymbolDimension(OutArg(counteroutput).Size)) == 0 | (SharedInfo.ResizeApproach=='REALLOC_ALL_RESIZE_ALL'))
+ ST_Set(OutArg(counteroutput).Name,...
+ OutArg(counteroutput).Type,...
+ OutArg(counteroutput).Size,...
+ OutArg(counteroutput).Value,...
+ OutArg(counteroutput).FindLike,...
+ OutArg(counteroutput).Dimension,...
+ SymbTableFileName);
+ end
+
+ // IndentLevelDeclaration = 1; //NUT: per ora lo forzo sempre a 1
+ // IndentLevelMalloc = SharedInfo.NIndent;
+ // FlagExt = 0;
+ // C_GenDeclarations(OutArg(counteroutput),CDeclarationFileName,IndentLevelDeclaration,ReportFileName,FlagExt,SharedInfo.ResizeApproach);
+
+
+ end
+ elseif (TBFlagfound == 2)
+ // #RNU_RES_B
+ // We have a non-initialized global variable.
+ // Set the non-initialized global variable.
+ PrintStringInfo(' Found a non-initialized global variable.',ReportFileName,'file','y');
+ // #RNU_RES_E
+ ST_Set(OutArg(counteroutput).Name,...
+ OutArg(counteroutput).Type,...
+ OutArg(counteroutput).Size,...
+ OutArg(counteroutput).Value,...
+ OutArg(counteroutput).FindLike,...
+ OutArg(counteroutput).Dimension,...
+ SymbTableFileName);
+ IndentLevel = 0; //NUT: forced always to 1
+ FlagExt = 0;
+ C_GenDeclarations(OutArg(counteroutput),CGblDeclarFileName,IndentLevel,ReportFileName,FlagExt,SharedInfo.ResizeApproach);
+ IndentLevelMalloc = SharedInfo.NIndent;
+ // #RNU_RES_B
+ //RNU da verificare bene qui. Cio' che si verifica e' che se la size della globale e' simbolica
+ //RNU allora si assume che essa sia da allocare come puntatore e poi realloc.
+ // #RNU_RES_E
+ C_MemAllocOutTempVars(OutArg(counteroutput),1,CPass1FileName,CPass1FreeFileName,IndentLevelMalloc,ReportFileName,SharedInfo.ResizeApproach);
+ else
+ if (OutArg(counteroutput).FindLike == 1)
+ // #RNU_RES_B
+ // In presence of find-like functions the size must be always symbolic.
+ // Don't change here the value of OutArg.Size because the first time
+ // I need them to declare the OutArg variable with the values assumed by OutArg.Size.
+ // #RNU_RES_E
+ TmpOutArgSize(1) = '__'+OutArg(counteroutput).Name+'Size[0]';
+ TmpOutArgSize(2) = '__'+OutArg(counteroutput).Name+'Size[1]';
+ else
+ TmpOutArgSize(1) = OutArg(counteroutput).Size(1);
+ TmpOutArgSize(2) = OutArg(counteroutput).Size(2);
+ end
+ // #RNU_RES_B
+ // Set a new symbol.
+ // #RNU_RES_E
+ ST_Set(OutArg(counteroutput).Name,...
+ OutArg(counteroutput).Type,...
+ TmpOutArgSize,...
+ OutArg(counteroutput).Value,...
+ OutArg(counteroutput).FindLike,...
+ OutArg(counteroutput).Dimension,...
+ SymbTableFileName);
+ IndentLevelDeclaration = 1; //NUT: per ora lo forzo sempre a 1
+ IndentLevelMalloc = SharedInfo.NIndent;
+ FlagExt = 0;
+ C_GenDeclarations(OutArg(counteroutput),CDeclarationFileName,IndentLevelDeclaration,ReportFileName,FlagExt,SharedInfo.ResizeApproach);
+ // #RNU_RES_B
+ //RNU aggiunta qui in modo che le malloc saranno fatte una sola volta:
+ //RNU verifica che tutto funzioni e chi altro usa la C_MemAlloc per capire se si puo' ottimizzare per questo stadio.
+ // #RNU_RES_E
+ C_MemAllocOutTempVars(OutArg(counteroutput),1,CPass1FileName,CPass1FreeFileName,IndentLevelMalloc,ReportFileName,SharedInfo.ResizeApproach);
+ end
+
+end
+
+endfunction
diff --git a/2.3-1/macros/SymbolTable/ST_Load.sci b/2.3-1/macros/SymbolTable/ST_Load.sci new file mode 100644 index 00000000..dbe53456 --- /dev/null +++ b/2.3-1/macros/SymbolTable/ST_Load.sci @@ -0,0 +1,36 @@ +function SCI2CSymbolTable = ST_Load(SymbolTableFileName)
+// function SCI2CSymbolTable = ST_Load(SymbolTableFileName)
+// -----------------------------------------------------------------
+// #RNU_RES_B
+// Load a symbol table stored into a .dat file.
+// #RNU_RES_E
+//
+// Input data:
+// //NUT: add description here
+//
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// --------------------------
+// --- Load Symbol Table. ---
+// --------------------------
+[tmpnams,tmptyps,tmpdims,tmpvols]=listvarinfile(SymbolTableFileName);
+if (max(size(tmpnams)) > 1)
+ error(9999, 'More than one variable found in ""'+SymbolTableFileName+'"".');
+end
+load(SymbolTableFileName,tmpnams);
+SCI2CSymbolTable = eval(tmpnams);
+// ------------------------------
+// --- End Load Symbol Table. ---
+// ------------------------------
+
+endfunction
diff --git a/2.3-1/macros/SymbolTable/ST_MatchSymbol.sci b/2.3-1/macros/SymbolTable/ST_MatchSymbol.sci new file mode 100644 index 00000000..504379c2 --- /dev/null +++ b/2.3-1/macros/SymbolTable/ST_MatchSymbol.sci @@ -0,0 +1,69 @@ +function [TBFlagfound,TBFlagEqualSymbols] = ST_MatchSymbol(TBName,TBType,TBSize,TBValue,TBFindLike,TBDimension,SymbolTableFileName,MatchRule)
+// function [TBFlagfound,TBFlagEqualSymbols] = ST_MatchSymbol(TBName,TBType,TBSize,TBValue,TBFindLike,TBDimension,SymbolTableFileName,MatchRule)
+// -----------------------------------------------------------------
+// Match function for the symbol table.
+//
+// Input data:
+// MatchRule: can be 'all','type','size','none'
+// //NUT: add description here
+//
+// Output data:
+// TBFlagfound: 0 = if the symbol doesn't exits.
+// 1 = the symbol exits.
+// 2 = the symbol exists but it is a non-initialized global variable.
+// TBFlagEqualSymbols: 0 if the two symbols don't have the same settings,
+// 1 if the two symbols have the same settings.
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),8,8);
+
+TBFlagfound = 0;
+TBFlagEqualSymbols = 0;
+
+// --- Find symbol (If exists). ---
+[TBFlagfound,tmpType,tmpSize,tmpValue,tmpFindLike,tmpDimension] = ...
+ ST_Get(TBName,SymbolTableFileName);
+if (TBFlagfound == 1)
+ if (tmpType == 'GBLToBeDefined')
+ TBFlagfound = 2;
+ TBFlagEqualSymbols = 0; // I don't want to force the error issue in ST_InsOutArg.sci
+ else
+ // Symbol already exists. Check that it has the same settings of the current output argument.
+ TBFlagEqualSymbols = 1;
+ if (MatchRule == 'type' | MatchRule == 'all')
+ if (mtlb_strcmp(tmpType,TBType) == %F)
+ TBFlagEqualSymbols = 0;
+ end
+ end
+ if (MatchRule == 'size' | MatchRule == 'all')
+ // First check the dimension.
+ if (tmpDimension ~= TBDimension)
+ TBFlagEqualSymbols = 0;
+ end
+ // Then if the size is a number also its value is compared.
+ if (isnum(tmpSize(1))) & (isnum(TBSize(1)))
+ if (mtlb_strcmp(tmpSize(1),TBSize(1)) == %F)
+ TBFlagEqualSymbols = 0;
+ end
+ end
+ if (isnum(tmpSize(2))) & (isnum(TBSize(2)))
+ if (mtlb_strcmp(tmpSize(2),TBSize(2)) == %F)
+ TBFlagEqualSymbols = 0;
+ end
+ end
+ end
+ end
+end
+
+endfunction
diff --git a/2.3-1/macros/SymbolTable/ST_Save.sci b/2.3-1/macros/SymbolTable/ST_Save.sci new file mode 100644 index 00000000..44e6e868 --- /dev/null +++ b/2.3-1/macros/SymbolTable/ST_Save.sci @@ -0,0 +1,44 @@ +function ST_Save(SymbolTableFileName,SCI2CSymbolTable)
+// function ST_Save(SymbolTableFileName,SCI2CSymbolTable)
+// -----------------------------------------------------------------
+// Save into a .dat file a symbol table.
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+[tmpnams,tmptyps,tmpdims,tmpvols]=listvarinfile(SymbolTableFileName);
+if (max(size(tmpnams)) > 1)
+ SCI2Cerror('More than one variable found in ""'+SymbolTableFileName+'"".');
+end
+
+// Identifies the Table name and save it into the .dat file.
+if (mtlb_strcmp(tmpnams,'GlobalVars'))
+ GlobalVars = SCI2CSymbolTable;
+ save(SymbolTableFileName, "GlobalVars");
+elseif (mtlb_strcmp(tmpnams,'LocalVars'))
+ LocalVars = SCI2CSymbolTable;
+ save(SymbolTableFileName, "LocalVars");
+elseif (mtlb_strcmp(tmpnams,'TempVars'))
+ TempVars = SCI2CSymbolTable;
+ save(SymbolTableFileName, "TempVars");
+else
+ SCI2Cerror('Unknow table: ""'+tmpnams+'"".');
+end
+
+endfunction
diff --git a/2.3-1/macros/SymbolTable/ST_Set.sci b/2.3-1/macros/SymbolTable/ST_Set.sci new file mode 100644 index 00000000..778f91aa --- /dev/null +++ b/2.3-1/macros/SymbolTable/ST_Set.sci @@ -0,0 +1,49 @@ +function ST_Set(TBName,TBType,TBSize,TBValue,TBFindLike,TBDimension,SymbolTableFileName)
+// function ST_Set(TBName,TBType,TBSize,TBValue,TBFindLike,TBDimension,SymbolTableFileName)
+// -----------------------------------------------------------------
+// Set function for the symbol table.
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),7,7);
+
+// --- Load symbol table. ---
+SCI2CSymbolTable = ST_Load(SymbolTableFileName);
+
+// --- Find symbol position (If exists). ---
+[TBFlagfound,TBPosition] = ST_FindPos(TBName,SymbolTableFileName);
+
+if (TBFlagfound == 0)
+ TBPosition = max(size(SCI2CSymbolTable))+1;
+end
+
+// --- Update symbol table. ---
+SCI2CSymbolTable(TBPosition).Name = TBName; // string.
+SCI2CSymbolTable(TBPosition).Type = TBType; // char.
+SCI2CSymbolTable(TBPosition).Size = TBSize; // structure of two strings (Size(1) and Size(2)).
+SCI2CSymbolTable(TBPosition).Value = TBValue; // int/real/complex number. %nan when the value is not available or isn't a scalar.
+SCI2CSymbolTable(TBPosition).FindLike = TBFindLike; // int number. FindLike = 1, when the symbol comes from a find-like function.
+ // FindLike = -1 when the function is not find-like but it is making use of input arguments that are find-like.
+ // FindLike = 0 in all other cases.
+SCI2CSymbolTable(TBPosition).Dimension = TBDimension; // int number.
+
+// --- Save symbol table. ---
+ST_Save(SymbolTableFileName,SCI2CSymbolTable);
+
+endfunction
diff --git a/2.3-1/macros/SymbolTable/buildmacros.sce b/2.3-1/macros/SymbolTable/buildmacros.sce new file mode 100644 index 00000000..60fd2843 --- /dev/null +++ b/2.3-1/macros/SymbolTable/buildmacros.sce @@ -0,0 +1,15 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009-2009 - DIGITEO - Bruno JOFRET +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +// +// + +tbx_build_macros(TOOLBOX_NAME, get_absolute_file_path('buildmacros.sce')); + +clear tbx_build_macros; diff --git a/2.3-1/macros/SymbolTable/lib b/2.3-1/macros/SymbolTable/lib Binary files differnew file mode 100644 index 00000000..59ce4653 --- /dev/null +++ b/2.3-1/macros/SymbolTable/lib diff --git a/2.3-1/macros/SymbolTable/names b/2.3-1/macros/SymbolTable/names new file mode 100644 index 00000000..b5a7d65f --- /dev/null +++ b/2.3-1/macros/SymbolTable/names @@ -0,0 +1,12 @@ +ST_AnalyzeScope +ST_Del +ST_FindPos +ST_Get +ST_GetInArgInfo +ST_GetSymbolInfo +ST_InsForCntVars +ST_InsOutArg +ST_Load +ST_MatchSymbol +ST_Save +ST_Set |