1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) 2002-2004 - INRIA - Vincent COUVERT
4 // Copyright (C) 2012 - 2016 - Scilab Enterprises
6 // This file is hereby licensed under the terms of the GNU GPL v2.0,
7 // pursuant to article 5.3.4 of the CeCILL v.2.1.
8 // This file was originally licensed under the terms of the CeCILL v2.1,
9 // and continues to be available under such terms.
10 // For more information, see the COPYING file which you should have received
11 // along with this program.
13 function tree=default_trad(tree)
15 // Create a default translation function
17 global("mtlbref_fun") //contains the matlab reference functions which not yet converted
18 global("mtlbtool_fun")//contains the matlab toolboxes functions
19 global("not_mtlb_fun") // contains the not matlab functions
21 if ~exists("mtlbref_fun") then
24 if ~exists("mtlbtool_fun") then
27 if ~exists("not_mtlb_fun") then
34 //true if the name function is the name of scilab function primitive
35 if funptr(tree.name)<>0 then
40 //ismtlbfun is true if the function is in a matlab toolbox, mtlbpath is the path where is the function
41 [mtlbpath,ismtlbtoolfun]=mtlbtoolfun(name)
42 //Matlab reference functions
43 if or(name==not_yet_converted()) then
44 set_infos(msprintf(gettext("Matlab function %s not yet converted, original calling sequence used."),name),2)
45 if ~or(name==mtlbref_fun(:,1)) then
46 mtlbref_fun($+1,1)=name
48 mtlbref_fun($,2)=msprintf(gettext("(Warning name conflict: function name changed from %s to %s)."),name,name1);
53 //Matlab toolboxes functions
54 elseif ismtlbtoolfun then
55 set_infos(msprintf(gettext("Matlab toolbox(es) function %s not converted, original calling sequence used"),name),2)
56 if ~or(name==mtlbtool_fun(:,1)) then
57 mtlbtool_fun($+1,1)=name
59 mtlbtool_fun($,2)=msprintf(gettext("Matlab toolbox(es) function %s not converted, original calling sequence used."),name,name1,mtlbpath)
61 mtlbtool_fun($,2)=msprintf(gettext("(Find this function in matlab/%s)."),mtlbpath)
64 elseif isdefinedvar(Variable(tree.name,Infer())) then
66 operands(1)=Variable(tree.name,Infer())
67 for krhs = 1:size(tree.rhs)
68 operands($+1)=tree.rhs(krhs)
70 tree=Operation("ext",operands,tree.lhs)
71 tree=operation2sci(tree)
75 set_infos(msprintf(gettext("Unknown function %s not converted, original calling sequence used."),name),2)
76 if ~or(name==not_mtlb_fun(:,1)) then
77 not_mtlb_fun($+1,1)=name
79 not_mtlb_fun($,2)=msprintf(gettext("(Warning name conflict: function name changed from %s to %s)."),name,name1);
86 set_infos(msprintf(gettext("(Warning name conflict: function name changed from %s to %s)."),name,name1),0)
88 [tree]=sci_generic(tree)