summaryrefslogtreecommitdiff
path: root/src/Scilab2C/SCI2CGeneral/InitializeSCI2C.sci
blob: db3a459c67ade8fffc4c30fc522fe9f21c6981ce (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
function [FileInfoDatFile,SharedInfoDatFile] = InitializeSCI2C(SCI2CInputPrmFile);
// function [FileInfoDatFile,SharedInfoDatFile] = InitializeSCI2C(SCI2CInputPrmFile);
// -----------------------------------------------------------------
// This function initializes the SCI2C tool according
// to the input parameters recorded in the SCI2CParameters.
// All info will be stored into FileInfoDatFile.
//
// Input data:
// SCI2CInputPrmFile: name of the .sce file containing input parameters.
//
// Output data:
// FileInfoDatFile: name of the .dat file containing the FileInfo structure.
// SharedInfoDatFile: it is a buffer containing parameters that are exchanged by the
//                    functions of the SCI2C tool.
// Status:
// 13-Apr-2007 -- Nutricato Raffaele: Author.
// -----------------------------------------------------------------

// --- Read Input Parameters. ---
exec(SCI2CInputPrmFile);

FileInfoDatFile   = fullfile(ResultDir,'FileInfo.dat'); 
SharedInfoDatFile = fullfile(ResultDir,'SharedInfo.dat'); 

// ----------------------------
// --- Initialize FileInfo. ---
// ----------------------------
FileInfo.FileInfoDatFile       = FileInfoDatFile;
FileInfo.SharedInfoDatFile     = SharedInfoDatFile;
FileInfo.ResultDir             = ResultDir;
FileInfo.SCI2CLibAnnDirName    = fullfile(FileInfo.ResultDir,'SCI2CLibAnnotations');
FileInfo.USER2CLibAnnDirName   = fullfile(FileInfo.ResultDir,'USER2CLibAnnotations');
FileInfo.SCI2CLibTreeFileName  = fullfile(FileInfo.ResultDir,'SCI2CLibTree.dat');
FileInfo.USER2CLibTreeFileName = fullfile(FileInfo.ResultDir,'USER2CLibTree.dat');
FileInfo.GeneralReport         = fullfile(FileInfo.ResultDir,'SCI2CGeneralReport.txt');
FileInfo.GlobalVarFileName     = fullfile(FileInfo.ResultDir,'GBLVAR.dat');
FileInfo.UserSciFilesPaths     = UserSciFilesPaths;

// ------------------------------
// --- Initialize SharedInfo. ---
// ------------------------------
// File names of the next .sci files to be converted in AST and
// successively into C. 
SharedInfo.Next(1).SCIFileName  = ScilabMainFile; 
[scipath,funname,sciext]        = fileparts(ScilabMainFile);
SharedInfo.Next(1).SCIFunName   = funname; //RN per ora no so cosa metter
SharedInfo.Next(1).CFunName     = funname; //RN per ora no so cosa metter
SharedInfo.Next(1).InArg        = 1; //RN per ora non so che mettere.
SharedInfo.Next(1).OutArg       = 1; //RN per ora non so che mettere.
SharedInfo.NextSCIFunNumber     = 1; 

SharedInfo.Annotations.GBLVAR  = 'global';
SharedInfo.Annotations.VARTYPE = '//_SCI2C_VARTYPE:';
SharedInfo.Annotations.FUNNOUT = '//_SCI2C_NOUT:';
SharedInfo.Annotations.FUNSIZE = '//_SCI2C_FUNSIZE:';
SharedInfo.Annotations.FUNTYPE = '//_SCI2C_FUNTYPE:'; // Type includes also precision.

// Info related to temp variables used in the C code.
SharedInfo.WorkAreaSizeBytes   = WorkAreaSizeBytes;
SharedInfo.WorkAreaUsedBytes   = 0;
SharedInfo.WorkAreaName        = '__WorkAreaPtr';
SharedInfo.TotTempScalarVars   = TotTempScalarVars;
SharedInfo.UsedTempScalarVars  = 0;
SharedInfo.TempScalarVarsName  = '__Scalar';
// Info related to temp variables used in the AST reading phase.
SharedInfo.ASTReader.UsedTempVars = 0;
SharedInfo.ASTReader.TempVarsName = '__temp';
SharedInfo.ASTReader.ReusableTempVars    = [];//RN to be removed
                                               
// ------------------------------
// --- Initialize GlobalVars. ---
// ------------------------------
GlobalVars = [];

// ----------------------------------------------------
// --- Remove previous versions of SCI2C files/dir. ---
// ----------------------------------------------------
//SCI2Cmdelete(FileInfo.FileInfoDatFile);
//SCI2Cmdelete(FileInfo.SharedInfoDatFile);
//SCI2Cmdelete(FileInfo.SCI2CLibTreeFileName);
//SCI2Cmdelete(FileInfo.USER2CLibTreeFileName);
//SCI2Cmdelete(FileInfo.GeneralReport);
//SCI2Cmdelete(FileInfo.GlobalVarFileName);
disp('Removing directory: '+FileInfo.ResultDir);
yesno=input('Are you sure [y/n]?','string');
if (yesno=='y')
  rmdir(FileInfo.ResultDir,'s');
else
  SCI2Cerror('Cannot continue, because you don''t want to delete: '+FileInfo.ResultDir);
end

// ---------------------------
// --- Create Directories. ---
// ---------------------------
SCI2CCreateDir(FileInfo.ResultDir);
SCI2CCreateDir(FileInfo.SCI2CLibAnnDirName);
SCI2CCreateDir(FileInfo.USER2CLibAnnDirName);

// ---------------------------------------------
// --- Generate new versions of SCI2C files. ---
// ---------------------------------------------
save(FileInfo.FileInfoDatFile,FileInfo);
save(FileInfo.SharedInfoDatFile,SharedInfo);
save(FileInfo.GlobalVarFileName,GlobalVars);

endfunction