File: default_trad.sci

package info (click to toggle)
scilab 5.3.3-10
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 330,656 kB
file content (102 lines) | stat: -rw-r--r-- 3,037 bytes parent folder | download | duplicates (2)
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
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2002-2004 - INRIA - Vincent COUVERT
// 
// 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

function tree=default_trad(tree)
// M2SCI function
// Create a default translation function

global("mtlbref_fun") //contains the matlab reference functions which not yet converted 
global("mtlbtool_fun")//contains the matlab  toolboxes functions  
global("not_mtlb_fun") // contains the not matlab functions

if ~exists('mtlbref_fun') then
  mtlb_fun=[]
end
if ~exists('mtlbtool_fun') then
  mtlbtool_fun=[]
end
if ~exists('not_mtlb_fun') then
  not_mtlb_fun=[]
end

name=tree.name

ispriminame=%f; 
//true if the name function is the name of scilab function primitive
if funptr(tree.name)<>0 then
  name1="%"+tree.name
  tree.name=name1
  ispriminame=%t;   
end  
//ismtlbfun is true if the the function is in a matlab toolboxe, mtlbpath is the path where is the function
[mtlbpath,ismtlbtoolfun]=mtlbtoolfun(name)
//Matlab reference functions
if or(name==not_yet_converted()) then
  set_infos(msprintf(gettext("Matlab function %s not yet converted, original calling sequence used."),name),2)
  if ~or(name==mtlbref_fun(:,1)) then
    mtlbref_fun($+1,1)=name
    if ispriminame then
      mtlbref_fun($,2)=msprintf(gettext("(Warning name conflict: function name changed from %s to %s)."),name,name1);
    else
      mtlbref_fun($,2)=""
    end
  end   
  //Matlab toolboxes functions 
elseif ismtlbtoolfun then
  set_infos(msprintf(gettext("Matlab toolbox(es) function %s not converted, original calling sequence used"),name),2)
  if ~or(name==mtlbtool_fun(:,1)) then
    mtlbtool_fun($+1,1)=name
    if ispriminame then
      mtlbtool_fun($,2)=msprintf(gettext("Matlab toolbox(es) function %s not converted, original calling sequence used."),name,name1,mtlbpath)
    else
      mtlbtool_fun($,2)=msprintf(gettext("(Find this function in matlab/%s)."),mtlbpath)
    end
  end 
elseif isdefinedvar(Variable(tree.name,Infer())) then
  operands=list()
  operands(1)=Variable(tree.name,Infer())
  for krhs=1:lstsize(tree.rhs)
    operands($+1)=tree.rhs(krhs)
  end
  tree=Operation("ext",operands,tree.lhs)
  tree=operation2sci(tree)

  //Not matlbb function
else 
  set_infos(msprintf(gettext("Unknown function %s not converted, original calling sequence used."),name),2)  
  if ~or(name==not_mtlb_fun(:,1)) then
    not_mtlb_fun($+1,1)=name
    if ispriminame then 
      not_mtlb_fun($,2)=msprintf(gettext("(Warning name conflict: function name changed from %s to %s)."),name,name1);
    else
      not_mtlb_fun($,2)=""
    end
  end
end
if ispriminame then
  set_infos(msprintf(gettext("(Warning name conflict: function name changed from %s to %s)."),name,name1),0)
end
[tree]=sci_generic(tree)
endfunction