diff options
Diffstat (limited to 'src')
16 files changed, 758 insertions, 82 deletions
diff --git a/src/Scilab2C/ASTGenerator/%program_p.sci b/src/Scilab2C/ASTGenerator/%program_p.sci new file mode 100644 index 00000000..93e43a7a --- /dev/null +++ b/src/Scilab2C/ASTGenerator/%program_p.sci @@ -0,0 +1,153 @@ +function %program_p(p)
+ //overloading function for "program" type tlist display
+ mprintf("%s\n",string(p))
+endfunction
+
+function txt=%program_string(p)
+//overloading function for "program" type tlist string function
+//main (root) node of the Abstract Formal Tree
+//fields:
+// name : string (the function name)
+// outputs : list of "variable" type tlist (the output arg names)
+// inputs : list of "variable" type tlist (the intput arg names)
+// statements: list of "equal" type tlist and list('EOL') (the
+// instructions list)
+// nblines : number (the number of lines in the scilab function)
+ txt=['Program'
+ 'Name : '+p.name
+ 'Outputs: '+strcat(objectlist2string(p.outputs),' ')
+ 'Inputs : '+strcat(objectlist2string(p.inputs),' ')
+ 'Statements '
+ ' '+objectlist2string(p.statements)
+ 'EndProgram'
+ ]
+endfunction
+
+
+function txt=%equal_string(e)
+//overloading function for "equal" type tlist string function
+//this is a node of the AST
+
+//fields:
+// expression: "expression" type tlist (the right hand side)
+// lhs : list of "variable" type tlist and "operation" type tlist // (the assignment)
+// endsymbol : string (the orginal end-of-instruction symbol (, ; <CR>))
+ txt=['Equal'
+ ' Expression: '
+ ' '+string(e.expression)
+ ' Lhs : '
+ ' '+objectlist2string(e.lhs)
+ 'EndEqual'
+ ]
+endfunction
+
+
+function txt=%for_string(F)
+//overloading function for "for" type tlist string function
+//this is a node of the AST
+//fields:
+// expression : "expression" type tlist (the loop expression)
+// statements : list of "equal" type tlist and list('EOL') (the
+// for instructions list)
+ txt=['For'
+ ' Expression:'
+ ' '+string(F.expression)
+ ' Statements:'
+ ' '+objectlist2string(F.statements)
+ 'EndFor']
+endfunction
+
+function txt=%ifthenel_string(I)
+//overloading function for "ifthenel" type tlist string function
+//this is a node of the AST
+//fields:
+// expression : "expression" type tlist (the if expression)
+// then : list of "equal" type tlist and list('EOL') (the
+// then instructions list)
+// elseifs : a list of tlists
+// else : list of "equal" type tlist and list('EOL') (the
+// else instructions list)
+ txt=['If '
+ ' Expression:'
+ ' '+string(I.expression)
+ ' If Statements'
+ ' '+objectlist2string(I.then)]
+ for e=I.elseifs
+ txt=[txt;
+ " Else If Expression'
+ ' '+string(e.expression)
+ ' Else If Statements'
+ ' '+objectlist2string(e.then)]
+ end
+ txt=[txt;
+ " Else Statements'
+ ' '+objectlist2string(I.else)
+ 'EndIf']
+endfunction
+
+function txt=%operatio_string(O)
+//overloading function for "operation" type tlist string function
+//this is a node of the AST
+//fields:
+// operands: a list
+// operator: a string
+ txt=['Operation'
+ ' Operands:'
+ ' '+objectlist2string(O.operands)
+ ' Operator: '+O.operator
+ 'EndOperation'
+ ]
+endfunction
+
+function txt=%funcall_string(F)
+//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'
+ ]
+endfunction
+
+function txt=%variable_string(v)
+//overloading function for "variable" type tlist string function
+//fields: name
+//this is a leaf of the AST
+ txt=v.name
+endfunction
+
+function txt=%cste_string(c)
+//overloading function for "cste" type tlist string function
+//this is a leaf of the AST
+//fields:
+// value : a number or a string
+ txt=string(c.value)
+endfunction
+
+function txt=%comment_string(e)
+//overloading function for "comment" type tlist string function
+//fields:
+// text: a string
+//this is a leaf of the AST
+ txt=['Comment : '+e.text]
+endfunction
+
+function txt=objectlist2string(L)
+//auxiliary function for conversion of a list of objects
+//into a string vector
+ txt=[];
+ for o=L,
+ if type(o)==15 then //EOL case
+ txt=[txt;'<'+o(1)+'>'],
+ else
+ txt=[txt; string(o)],
+ end
+ end
+ if txt==[] then txt='<empty>',end
+endfunction
diff --git a/src/Scilab2C/ASTGenerator/DescriptionOfmacr2tree.txt b/src/Scilab2C/ASTGenerator/DescriptionOfmacr2tree.txt new file mode 100644 index 00000000..21ec28d7 --- /dev/null +++ b/src/Scilab2C/ASTGenerator/DescriptionOfmacr2tree.txt @@ -0,0 +1,82 @@ +Description from Serge Steer
+Date:
+Fri, 28 Jul 2006 12:14:14 +0200
+To:
+raffaele.nutricato@tiscali.it
+CC:
+Fabio.Bovenga@ba.infn.it, Claude.Gomez@Inria.fr, Didier.Halgand@Inria.fr, Serge.Steer@Inria.fr
+
+>> Let me to ask you one more question: I read in the Scilab2C.doc
+>> document that among the tasks related to the Scilab team/ INRIA
+>> there is the "*_FORTRAN to C code translation"_* task. Is it
+>> possible to have more details about this activity?
+
+
+I am not able to answer this question, please ask it to Claude Gomez
+who wrote this document.
+
+
+
+>> Could you please send us a preliminary version of the output that
+>> will be generated by the Scilab2tree tool starting from the
+>> testscilab.sci code?
+
+
+
+If you have Scilab-4.0 installed you can play with it. The
+preliminary version of Scilab2tree is named macr2tree.
+
+here is very simple example of use
+
+-->function y=foo(x)
+--> y=x+1
+-->endfunction
+
+-->t=macr2tree(foo)
+
+It returns the full abstract syntax tree coded by a hierarchical
+structure of tlists and lists Scilab objects. To get a more readable
+display and also to illustrate how Scilab can deal with such a
+structure, I give you below a file of scilab functions for display
+overloading. If this file is loaded into Scilab
+
+--> exec %program_p.sci;
+
+The display of the t structure above become
+
+-->t
+ t =
+
+Program
+Name : foo
+Outputs: y
+Inputs : x
+Statements
+ <EOL>
+ Equal
+ Expression:
+ Operation
+ Operands:
+ x
+ 1
+ Operator: +
+ EndOperation
+ Lhs :
+ y
+ EndEqual
+ <EOL>
+ Funcall : return
+ #lhs : 0
+ Rhs :
+ <empty>
+ EndFuncall
+ <EOL>
+EndProgram
+
+
+These functions work with your testscilab function too (but select
+case constructs are not yet handled). Just try it and look at the
+comment for the structure explanation
+
+Serge Steer
+Scilab Team
diff --git a/src/Scilab2C/ASTGenerator/GenerateASTfoo.sci b/src/Scilab2C/ASTGenerator/GenerateASTfoo.sci new file mode 100644 index 00000000..70001632 --- /dev/null +++ b/src/Scilab2C/ASTGenerator/GenerateASTfoo.sci @@ -0,0 +1,6 @@ +// Generate the Abstract Syntactic Tree for the foo Scilab function
+
+getf("foo.sci");
+exec %program_p.sci;
+t=macr2tree(foo);
+t
diff --git a/src/Scilab2C/ASTGenerator/foo.sci b/src/Scilab2C/ASTGenerator/foo.sci new file mode 100644 index 00000000..1aad4c34 --- /dev/null +++ b/src/Scilab2C/ASTGenerator/foo.sci @@ -0,0 +1,8 @@ +// example to show how the AST is generated.
+// In the Scilab workspace type the following commands:
+//
+function y=foo(x)
+
+y = sin(cos(x));
+y = sin(convol(x,y));
+endfunction
diff --git a/src/Scilab2C/ASTGenerator/foo1.sci b/src/Scilab2C/ASTGenerator/foo1.sci new file mode 100644 index 00000000..a988bfd8 --- /dev/null +++ b/src/Scilab2C/ASTGenerator/foo1.sci @@ -0,0 +1,8 @@ +// example to show how the AST is generated.
+// In the Scilab workspace type the following commands:
+//
+function y=foo(x)
+
+y=x+1;
+
+endfunction
diff --git a/src/Scilab2C/FunctionTableManagement/AddBranch.sci b/src/Scilab2C/FunctionTableManagement/AddBranch.sci index a03e7193..9b870677 100644 --- a/src/Scilab2C/FunctionTableManagement/AddBranch.sci +++ b/src/Scilab2C/FunctionTableManagement/AddBranch.sci @@ -1,4 +1,4 @@ -function TreeBase = AddBranch(TreeBase, Branch, CINFO )
+function TreeBase = AddBranch(TreeBase, Branch, CINFO)
// To understand how this software works the steps are:
//
diff --git a/src/Scilab2C/FunctionTableManagement/CinfoI1AO1A.sci b/src/Scilab2C/FunctionTableManagement/CinfoI1AO1A.sci new file mode 100644 index 00000000..d5e4342e --- /dev/null +++ b/src/Scilab2C/FunctionTableManagement/CinfoI1AO1A.sci @@ -0,0 +1,55 @@ +function CINFO = CinfoI1AO1A(Pfx,FunctionName,Sfx,ArgType,InStr,OutStr); +// -----------------------------------------------------------------
+// Returns the CINFO structure for elementary functions that work
+// with one input and one output array arguments.
+//
+// Function name prefixes.
+// FunPfx = [...
+// "s",...
+// "d",...
+// "c",...
+// "z"];
+// Function name suffixes.
+// FunSfx = [...
+// "s",...
+// "a",...
+// "m"];
+// Types of the function arguments.
+// FunArgTypes = [...
+// "float ",... +// "double ",... +// "floatComplex ",... +// "doubleComplex ",... +// "float* ",... +// "double* ",... +// "floatComplex* ",... +// "doubleComplex* ",... +// "int "]; +//
+// Status:
+// 19-Mar-2006 -- Intelligente Fabio: Author.
+// 19-Apr-2002 -- Nutricato Raffaele: Changed code into a function.
+// -----------------------------------------------------------------
+
+a = """"; // apex
+b = " "; // blank
+c = ","; // comma
+so = "["; // square open
+sc = "]"; // square close
+
+CINFO.NAME = Pfx + FunctionName + Sfx; +CINFO.ARGLIST = ...
+ so+a+ArgType+a+c+ ...
+ InStr.Name+c+ ...
+ a+c+a+c+ ...
+ a+ArgType+a+c+ ...
+ OutStr.Name+c+ ...
+ a+c+a+c+ ...
+ a+"int "+a+c+ ...
+ "mtlb_num2str(prod(InArg(1).Size))"+sc;
+CINFO.SIZE = Sfx; +CINFO.TYPE = Pfx; +CINFO.DIM = "O1Sz = I1Sz";
+CINFO.NOut = 1; +
+endfunction
diff --git a/src/Scilab2C/FunctionTableManagement/CinfoI1SO1S.sci b/src/Scilab2C/FunctionTableManagement/CinfoI1SO1S.sci new file mode 100644 index 00000000..71d53e99 --- /dev/null +++ b/src/Scilab2C/FunctionTableManagement/CinfoI1SO1S.sci @@ -0,0 +1,49 @@ +function CINFO = CinfoI1SO1S(Pfx,FunctionName,Sfx,ArgType,InStr) +// -----------------------------------------------------------------
+// Returns the CINFO structure for elementary functions that work
+// with one input and one output scalar arguments.
+//
+// Function name prefixes.
+// FunPfx = [...
+// "s",...
+// "d",...
+// "c",...
+// "z"];
+// Function name suffixes.
+// FunSfx = [...
+// "s",...
+// "a",...
+// "m"];
+// Types of the function arguments.
+// FunArgTypes = [...
+// "float ",... +// "double ",... +// "floatComplex ",... +// "doubleComplex ",... +// "float* ",... +// "double* ",... +// "floatComplex* ",... +// "doubleComplex* ",... +// "int "]; +//
+// Status:
+// 19-Mar-2006 -- Intelligente Fabio: Author.
+// 19-Apr-2002 -- Nutricato Raffaele: Changed code into a function.
+// -----------------------------------------------------------------
+
+a = """"; // apex
+b = " "; // blank
+c = ","; // comma
+so = "["; // square open
+sc = "]"; // square close
+
+CINFO.NAME = Pfx + FunctionName + Sfx; +CINFO.ARGLIST = ...
+ so+a+ArgType+a+c+ ...
+ InStr.Name+sc; +CINFO.SIZE = Sfx; +CINFO.TYPE = Pfx; +CINFO.DIM = "O1Sz = I1Sz";
+CINFO.NOut = 1; +
+endfunction diff --git a/src/Scilab2C/FunctionTableManagement/Example.sce b/src/Scilab2C/FunctionTableManagement/Example.sce index 4d69b601..114544aa 100644 --- a/src/Scilab2C/FunctionTableManagement/Example.sce +++ b/src/Scilab2C/FunctionTableManagement/Example.sce @@ -6,10 +6,156 @@ clear;
clc;
-
+mode(0);
getf("InitializeLibraries.sci");
+getf("GetCFunCall.sci");
[SCI2CLib, USER2CLib] = InitializeLibraries();
+save('SCI2CLib.dat',SCI2CLib);
+save('USER2CLib.dat',USER2CLib);
+
+disp("Scalar Version:")
+FunName = "cos";
+InArg.Name="inscalar";
+InArg.Type="z";
+InArg.Size=[1,1];
+OutArg.Name = "outscalar";
+CFunCall = GetCFunCall(FunName,InArg,OutArg);
+disp(CFunCall)
+disp(" ")
+disp(" ")
+
+disp("Array Version:")
+FunName = "sin";
+InArg.Name="inmtx";
+InArg.Type="s";
+InArg.Size=[10,7];
+OutArg.Name = "outmtx";
+CFunCall = GetCFunCall(FunName,InArg,OutArg);
+disp(CFunCall)
+disp(" ")
+disp(" ")
+
+
+
+
+// Let's consider the following example
+
+// **************************************
+// The input function to be traslated is:
+// --------------------------------------
+// function y=foo(x)
+
+// y = sin(cos(x));
+
+// endfunction
+// --------------------------------------
+
+// **************************************
+// The corresponding AST is:
+// --------------------------------------
+// Equal
+// Expression:
+// Funcall : sin
+// #lhs : 1
+// Rhs :
+// Funcall : cos
+// #lhs : 1
+// Rhs :
+// x
+// EndFuncall
+// EndFuncall
+// Lhs :
+// y
+// EndEqual
+
+// **************************************
+// The AST reader generates the following User-readable Intermediate Representation:
+// --------------------------------------
+// __temp1 = cos(x);
+// __temp2 = sin(__temp1);
+// y = __temp2;
+
+// **************************************
+// The AST reader generates also the following internal Intermediate Representation:
+// --------------------------------------
+FunName = "cos";
+InArg.Name="x";
+InArg.Type="s"; // This parameter is retrieved from annotations.
+InArg.Size=[10,7]; // This parameter is retrieved from annotations.
+OutArg.Number = 1;
+OutArg.Name = "__temp1";
+CFunCall = GetCFunCall(FunName,InArg,OutArg);
+disp(CFunCall)
+disp(" ")
+disp(" ")
+
+FunName = "sin";
+InArg.Name="__temp1";
+InArg.Type="s"; // This parameter is retrieved from annotations.
+InArg.Size=[10,7]; // This parameter is retrieved from annotations.
+OutArg.Number = 1;
+OutArg.Name = "__temp2";
+CFunCall = GetCFunCall(FunName,InArg,OutArg);
+disp(CFunCall)
+disp(" ")
+disp(" ")
+
+
+
+
+
+adf
+
+// Test Scalar Function
+clear In1
+clear Out1
+In1.Name = "inscalar";
+disp("Scalar Version:")
+disp([SCI2CLib.cos.S.C.D.CINFO.NAME,"(",eval(SCI2CLib.cos.S.C.D.CINFO.ARGLIST),")"])
+disp(" ")
+disp(" ")
+
+// Test Array Function
+clear In1
+clear Out1
+In1.Name = "inarray";
+In1.Size = [10,7];
+Out1.Name = "outarray";
+disp("Array Version:")
+disp([SCI2CLib.sin.A.C.D.CINFO.NAME,"(",eval(SCI2CLib.sin.A.C.D.CINFO.ARGLIST),")"])
+
+
+
+
+disp(" ")
+disp(" ")
+disp(" ")
+disp(" ")
+
+stoppami
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// ------------------
// --- Example 1. ---
// ------------------
@@ -124,7 +270,7 @@ end //
// I add the same function with two outputs:
// 1. the first output is S.R.D
-// 2. the second output is M.R.D.
+// 2. the second output is A.R.D.
//
// Branch=FunctionStructure;
// TREE="USER2CLib";
diff --git a/src/Scilab2C/FunctionTableManagement/GenerateLeafElementary.sci b/src/Scilab2C/FunctionTableManagement/GenerateLeafElementary.sci index f9c39345..f7365094 100644 --- a/src/Scilab2C/FunctionTableManagement/GenerateLeafElementary.sci +++ b/src/Scilab2C/FunctionTableManagement/GenerateLeafElementary.sci @@ -1,86 +1,108 @@ -function [FuncStruct, CINFO, NumFunc] = GenerateLeafElementary(FunctionName) -// This function generates the leaf for the
-// "FunctionName" elementary function.
+function [FuncStruct, CINFO, NumFunc] = GenerateLeafElementary(FunctionName); +// -----------------------------------------------------------------
+// This function generates the leaf for the "FunctionName" elementary function.
+// Rules used for the function names:
+// s = float
+// d = double
+// c = complex float
+// z = complex double
+// ---
+// s = scalar
+// a = array (element wise functions)
+// m = array (matrix functions)
+//
+// CINFO is an array of structures containing info of the output arguments.
+// The number of elements of the CINFO array is equal to the number
+// of output arguments.
+//
+// Status:
+// 09-Apr-2006 -- Intelligente Fabio: Author.
+// 09-Apr-2006 -- Nutricato Raffaele: Tests + Minor changes.
+// -----------------------------------------------------------------
+
+// ------------
+// --- getf ---
+// ------------
+getf("CinfoI1SO1S.sci");
+getf("CinfoI1AO1A.sci");
+// ----------------
+// --- End getf ---
+// ----------------
+
+// Combinations for the elementary functions:
+// 1: S,R,F +// 2: S,R,D
+// 3: S,C,F
+// 4: S,C,D
+// 5: A,R,F
+// 6: A.R.D
+// 7: A,C,F
+// 8: A,C,D
+// 9: M,R,F NOT IMPLEMENTED YET
+// 10: M.R.D NOT IMPLEMENTED YET
+// 11: M,C,F NOT IMPLEMENTED YET
+// 12: M,C,D NOT IMPLEMENTED YET
+
+// Function name prefixes.
+FunPfx = [...
+ "s",...
+ "d",...
+ "c",...
+ "z"];
+
+// Function name suffixes.
+FunSfx = [...
+ "s",...
+ "a",...
+ "m"];
+
+// Types of the function arguments.
+FunArgTypes = [...
+ "float ",... + "double ",... + "floatComplex ",... + "doubleComplex ",... + "float* ",... + "double* ",... + "floatComplex* ",... + "doubleComplex* ",... + "int "]; +
+InputStruct.Name = "InArg(1).Name";
+OutputStruct.Name = "OutArg(1).Name";
NumFunc = 0;
NumFunc = NumFunc + 1;
-
-FuncStruct(NumFunc) = FunctionName + ".S.R.F.CINFO"; -CINFO(NumFunc).CPROT = "y=SRF" + FunctionName + "SRF(x)"; -CINFO(NumFunc).SIZE = "S"; -CINFO(NumFunc).TYPE = "R"; -CINFO(NumFunc).PREC = "F";
-CINFO(NumFunc).DIM = "O1Sz = I1Sz";
-CINFO(NumFunc).NOut = 1; +FuncStruct(NumFunc) = FunctionName + ".S.R.F.CINFO";
+CINFO = CinfoI1SO1S(FunPfx(1),FunctionName,FunSfx(1),FunArgTypes(1),InputStruct);
NumFunc = NumFunc + 1;
-
FuncStruct(NumFunc) = FunctionName + ".S.R.D.CINFO";
-CINFO(NumFunc).CPROT = "y=SRD" + FunctionName + "SRD(x)"; -CINFO(NumFunc).SIZE = "S"; -CINFO(NumFunc).TYPE = "R"; -CINFO(NumFunc).PREC = "D";
-CINFO(NumFunc).DIM = "O1Sz = I1Sz";
-CINFO(NumFunc).NOut = 1; +CINFO(NumFunc) = CinfoI1SO1S(FunPfx(2),FunctionName,FunSfx(1),FunArgTypes(2),InputStruct);
NumFunc = NumFunc + 1;
-
FuncStruct(NumFunc) = FunctionName + ".S.C.F.CINFO";
-CINFO(NumFunc).CPROT = "y=SCF" + FunctionName + "SCF(x)"; -CINFO(NumFunc).SIZE = "S"; -CINFO(NumFunc).TYPE = "C"; -CINFO(NumFunc).PREC = "F"; -CINFO(NumFunc).DIM = "O1Sz = I1Sz";
-CINFO(NumFunc).NOut = 1;
+CINFO(NumFunc) = CinfoI1SO1S(FunPfx(3),FunctionName,FunSfx(1),FunArgTypes(3),InputStruct);
NumFunc = NumFunc + 1;
-
FuncStruct(NumFunc) = FunctionName + ".S.C.D.CINFO";
-CINFO(NumFunc).CPROT = "y=SCD" + FunctionName + "SCD(x)"; -CINFO(NumFunc).SIZE = "S"; -CINFO(NumFunc).TYPE = "C"; -CINFO(NumFunc).PREC = "D"; -CINFO(NumFunc).DIM = "O1Sz = I1Sz";
-CINFO(NumFunc).NOut = 1;
+CINFO(NumFunc) = CinfoI1SO1S(FunPfx(4),FunctionName,FunSfx(1),FunArgTypes(4),InputStruct);
NumFunc = NumFunc + 1;
-
-FuncStruct(NumFunc) = FunctionName + ".M.R.F.CINFO";
-CINFO(NumFunc).CPROT = "MRF" + FunctionName + "MRF(*X, strideX, *Y, strideY, Nelements)"; -CINFO(NumFunc).SIZE = "M"; -CINFO(NumFunc).TYPE = "R"; -CINFO(NumFunc).PREC = "F";
-CINFO(NumFunc).DIM = "O1Sz = I1Sz";
-CINFO(NumFunc).NOut = 1; +FuncStruct(NumFunc) = FunctionName + ".A.R.F.CINFO";
+CINFO(NumFunc) = CinfoI1AO1A(FunPfx(1),FunctionName,FunSfx(2),FunArgTypes(5),InputStruct,OutputStruct);
NumFunc = NumFunc + 1;
-
-FuncStruct(NumFunc) = FunctionName + ".M.R.D.CINFO";
-CINFO(NumFunc).CPROT = "MRD" + FunctionName + "MRD(*X, strideX, *Y, strideY, Nelements)"; -CINFO(NumFunc).SIZE = "M"; -CINFO(NumFunc).TYPE = "R"; -CINFO(NumFunc).PREC = "D";
-CINFO(NumFunc).DIM = "O1Sz = I1Sz";
-CINFO(NumFunc).NOut = 1; +FuncStruct(NumFunc) = FunctionName + ".A.R.D.CINFO";
+CINFO(NumFunc) = CinfoI1AO1A(FunPfx(2),FunctionName,FunSfx(2),FunArgTypes(6),InputStruct,OutputStruct);
NumFunc = NumFunc + 1;
-
-FuncStruct(NumFunc) = FunctionName + ".M.C.F.CINFO";
-CINFO(NumFunc).CPROT = "MCF" + FunctionName + "MCF(*X, strideX, *Y, strideY, Nelements)"; -CINFO(NumFunc).SIZE = "M"; -CINFO(NumFunc).TYPE = "C"; -CINFO(NumFunc).PREC = "F";
-CINFO(NumFunc).DIM = "O1Sz = I1Sz";
-CINFO(NumFunc).NOut = 1; +FuncStruct(NumFunc) = FunctionName + ".A.C.F.CINFO";
+CINFO(NumFunc) = CinfoI1AO1A(FunPfx(3),FunctionName,FunSfx(2),FunArgTypes(7),InputStruct,OutputStruct);
NumFunc = NumFunc + 1;
+FuncStruct(NumFunc) = FunctionName + ".A.C.D.CINFO";
+CINFO(NumFunc) = CinfoI1AO1A(FunPfx(4),FunctionName,FunSfx(2),FunArgTypes(8),InputStruct,OutputStruct);
-FuncStruct(NumFunc) = FunctionName + ".M.C.D.CINFO";
-CINFO(NumFunc).CPROT = "MCD" + FunctionName + "MCD(*X, strideX, *Y, strideY, Nelements)"; -CINFO(NumFunc).SIZE = "M"; -CINFO(NumFunc).TYPE = "C"; -CINFO(NumFunc).PREC = "D";
-CINFO(NumFunc).DIM = "O1Sz = I1Sz";
-CINFO(NumFunc).NOut = 1;
endfunction diff --git a/src/Scilab2C/FunctionTableManagement/GenerateLeafElementary.sci.bak b/src/Scilab2C/FunctionTableManagement/GenerateLeafElementary.sci.bak new file mode 100644 index 00000000..f9c39345 --- /dev/null +++ b/src/Scilab2C/FunctionTableManagement/GenerateLeafElementary.sci.bak @@ -0,0 +1,86 @@ +function [FuncStruct, CINFO, NumFunc] = GenerateLeafElementary(FunctionName) +// This function generates the leaf for the
+// "FunctionName" elementary function.
+
+NumFunc = 0;
+
+NumFunc = NumFunc + 1;
+
+FuncStruct(NumFunc) = FunctionName + ".S.R.F.CINFO"; +CINFO(NumFunc).CPROT = "y=SRF" + FunctionName + "SRF(x)"; +CINFO(NumFunc).SIZE = "S"; +CINFO(NumFunc).TYPE = "R"; +CINFO(NumFunc).PREC = "F";
+CINFO(NumFunc).DIM = "O1Sz = I1Sz";
+CINFO(NumFunc).NOut = 1; +
+NumFunc = NumFunc + 1;
+
+FuncStruct(NumFunc) = FunctionName + ".S.R.D.CINFO";
+CINFO(NumFunc).CPROT = "y=SRD" + FunctionName + "SRD(x)"; +CINFO(NumFunc).SIZE = "S"; +CINFO(NumFunc).TYPE = "R"; +CINFO(NumFunc).PREC = "D";
+CINFO(NumFunc).DIM = "O1Sz = I1Sz";
+CINFO(NumFunc).NOut = 1; +
+NumFunc = NumFunc + 1;
+
+FuncStruct(NumFunc) = FunctionName + ".S.C.F.CINFO";
+CINFO(NumFunc).CPROT = "y=SCF" + FunctionName + "SCF(x)"; +CINFO(NumFunc).SIZE = "S"; +CINFO(NumFunc).TYPE = "C"; +CINFO(NumFunc).PREC = "F"; +CINFO(NumFunc).DIM = "O1Sz = I1Sz";
+CINFO(NumFunc).NOut = 1;
+
+NumFunc = NumFunc + 1;
+
+FuncStruct(NumFunc) = FunctionName + ".S.C.D.CINFO";
+CINFO(NumFunc).CPROT = "y=SCD" + FunctionName + "SCD(x)"; +CINFO(NumFunc).SIZE = "S"; +CINFO(NumFunc).TYPE = "C"; +CINFO(NumFunc).PREC = "D"; +CINFO(NumFunc).DIM = "O1Sz = I1Sz";
+CINFO(NumFunc).NOut = 1;
+
+NumFunc = NumFunc + 1;
+
+FuncStruct(NumFunc) = FunctionName + ".M.R.F.CINFO";
+CINFO(NumFunc).CPROT = "MRF" + FunctionName + "MRF(*X, strideX, *Y, strideY, Nelements)"; +CINFO(NumFunc).SIZE = "M"; +CINFO(NumFunc).TYPE = "R"; +CINFO(NumFunc).PREC = "F";
+CINFO(NumFunc).DIM = "O1Sz = I1Sz";
+CINFO(NumFunc).NOut = 1; +
+NumFunc = NumFunc + 1;
+
+FuncStruct(NumFunc) = FunctionName + ".M.R.D.CINFO";
+CINFO(NumFunc).CPROT = "MRD" + FunctionName + "MRD(*X, strideX, *Y, strideY, Nelements)"; +CINFO(NumFunc).SIZE = "M"; +CINFO(NumFunc).TYPE = "R"; +CINFO(NumFunc).PREC = "D";
+CINFO(NumFunc).DIM = "O1Sz = I1Sz";
+CINFO(NumFunc).NOut = 1; +
+NumFunc = NumFunc + 1;
+
+FuncStruct(NumFunc) = FunctionName + ".M.C.F.CINFO";
+CINFO(NumFunc).CPROT = "MCF" + FunctionName + "MCF(*X, strideX, *Y, strideY, Nelements)"; +CINFO(NumFunc).SIZE = "M"; +CINFO(NumFunc).TYPE = "C"; +CINFO(NumFunc).PREC = "F";
+CINFO(NumFunc).DIM = "O1Sz = I1Sz";
+CINFO(NumFunc).NOut = 1; +
+NumFunc = NumFunc + 1;
+
+FuncStruct(NumFunc) = FunctionName + ".M.C.D.CINFO";
+CINFO(NumFunc).CPROT = "MCD" + FunctionName + "MCD(*X, strideX, *Y, strideY, Nelements)"; +CINFO(NumFunc).SIZE = "M"; +CINFO(NumFunc).TYPE = "C"; +CINFO(NumFunc).PREC = "D";
+CINFO(NumFunc).DIM = "O1Sz = I1Sz";
+CINFO(NumFunc).NOut = 1;
+endfunction diff --git a/src/Scilab2C/FunctionTableManagement/GetCFunCall.sci b/src/Scilab2C/FunctionTableManagement/GetCFunCall.sci new file mode 100644 index 00000000..2535e4ad --- /dev/null +++ b/src/Scilab2C/FunctionTableManagement/GetCFunCall.sci @@ -0,0 +1,48 @@ +function CFunCall = GetCFunCall(FunTree,FunName,InArg,OutArg); +// -----------------------------------------------------------------
+// Returns the C function call.
+//
+// FunTree is the name of the tree passed as string. Ex.: 'SCI2CLib'.
+// Status:
+// 06-Apr-2006 -- Nutricato Raffaele: Author.
+// -----------------------------------------------------------------
+
+// ------------
+// --- getf ---
+// ------------
+// ----------------
+// --- End getf ---
+// ----------------
+
+NInputs = size(InArg,1);
+NOutputs = size(OutArg,1);
+
+// Generate the string to access the tree.
+TreeAccessString = FunName;
+
+for counterinput = 1:NInputs
+ if prod(InArg(counterinput).Size) == 1
+ TreeAccessString = TreeAccessString+".S";
+ else
+ TreeAccessString = TreeAccessString+".A";
+ end
+
+ if InArg(counterinput).Type == "s"
+ TreeAccessString = TreeAccessString+".R.F";
+ elseif InArg(counterinput).Type == "d"
+ TreeAccessString = TreeAccessString+".R.D";
+ elseif InArg(counterinput).Type == "c"
+ TreeAccessString = TreeAccessString+".C.F";
+ elseif InArg(counterinput).Type == "z"
+ TreeAccessString = TreeAccessString+".C.D";
+ else
+ error("Unknown input argument type");
+ end
+end
+
+CFunName = FunTree+"."+TreeAccessString+".CINFO("+mtlb_num2str(NOutputs)+").NAME";
+CFunArgList = FunTree+"."+TreeAccessString+".CINFO("+mtlb_num2str(NOutputs)+").ARGLIST";
+
+CFunCall = [eval(CFunName),"(",eval(eval(CFunArgList)),")"];
+// CFunCall = [execstr(CFunName),"(",eval(eval(CFunArgList)),")"];
+endfunction diff --git a/src/Scilab2C/FunctionTableManagement/InitializeLibraries.sci b/src/Scilab2C/FunctionTableManagement/InitializeLibraries.sci index a2a71fab..6d62c816 100644 --- a/src/Scilab2C/FunctionTableManagement/InitializeLibraries.sci +++ b/src/Scilab2C/FunctionTableManagement/InitializeLibraries.sci @@ -36,22 +36,22 @@ disp('--> Adding the elementary functions to the SCI2C library tree.'); getf("AddElementaryFunction.sci");
SCI2CLib = AddElementaryFunction("sin",SCI2CLib);
SCI2CLib = AddElementaryFunction("cos",SCI2CLib);
-SCI2CLib = AddElementaryFunction("tan",SCI2CLib);
-SCI2CLib = AddElementaryFunction("cotg",SCI2CLib);
-SCI2CLib = AddElementaryFunction("asin",SCI2CLib);
-SCI2CLib = AddElementaryFunction("acos",SCI2CLib);
-SCI2CLib = AddElementaryFunction("sinh",SCI2CLib);
-SCI2CLib = AddElementaryFunction("cosh",SCI2CLib);
-SCI2CLib = AddElementaryFunction("tanh",SCI2CLib);
-SCI2CLib = AddElementaryFunction("asinh",SCI2CLib);
-SCI2CLib = AddElementaryFunction("acosh",SCI2CLib);
-SCI2CLib = AddElementaryFunction("atanh",SCI2CLib);
-SCI2CLib = AddElementaryFunction("exp",SCI2CLib);
-SCI2CLib = AddElementaryFunction("log",SCI2CLib);
-SCI2CLib = AddElementaryFunction("log10",SCI2CLib);
-SCI2CLib = AddElementaryFunction("abs",SCI2CLib);
-SCI2CLib = AddElementaryFunction("inv",SCI2CLib);
-SCI2CLib = AddElementaryFunction("sqrtR",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("tan",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("cotg",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("asin",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("acos",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("sinh",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("cosh",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("tanh",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("asinh",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("acosh",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("atanh",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("exp",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("log",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("log10",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("abs",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("inv",SCI2CLib);
+// SCI2CLib = AddElementaryFunction("sqrtR",SCI2CLib);
// -------------------------------------------------------------------
// --- End add the elementary functions to the SCI2C library tree. ---
// -------------------------------------------------------------------
diff --git a/src/Scilab2C/FunctionTableManagement/Pass1ASTReader.txt b/src/Scilab2C/FunctionTableManagement/Pass1ASTReader.txt new file mode 100644 index 00000000..c235731b --- /dev/null +++ b/src/Scilab2C/FunctionTableManagement/Pass1ASTReader.txt @@ -0,0 +1,13 @@ +
+
+__temp1 = x * 2;
+__temp1 = 3 + __temp1;
+y = __temp1;
+
+Result = return(<empty>)
+
+zcoss
+zcoss
+zcoss
+zcosa
+zcosa
diff --git a/src/Scilab2C/FunctionTableManagement/SCI2CLib.dat b/src/Scilab2C/FunctionTableManagement/SCI2CLib.dat Binary files differnew file mode 100644 index 00000000..b8785bce --- /dev/null +++ b/src/Scilab2C/FunctionTableManagement/SCI2CLib.dat diff --git a/src/Scilab2C/FunctionTableManagement/USER2CLib.dat b/src/Scilab2C/FunctionTableManagement/USER2CLib.dat Binary files differnew file mode 100644 index 00000000..16818ee7 --- /dev/null +++ b/src/Scilab2C/FunctionTableManagement/USER2CLib.dat |