File: sci_isa.sci

package info (click to toggle)
scilab 5.2.2-9
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 334,832 kB
  • ctags: 52,586
  • sloc: xml: 526,945; ansic: 223,590; fortran: 163,080; java: 56,934; cpp: 33,840; tcl: 27,936; sh: 20,397; makefile: 9,908; ml: 9,451; perl: 1,323; cs: 614; lisp: 30
file content (75 lines) | stat: -rw-r--r-- 2,604 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
// 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]=sci_isa(tree)
// M2SCI function
// Conversion function for Matlab isa()
// Input: tree = Matlab funcall tree
// Ouput: tree = Scilab equivalent for tree

[OBJ,class] = getrhs(tree)

if typeof(class)=="cste" then
  
  typetree=Funcall("type",1,Rhs_tlist(OBJ),list())
  typeoftree=Funcall("typeof",1,Rhs_tlist(OBJ),list())
  
  select class.value
  case "logical"
    tree=Operation("==",list(typetree,Cste(4)),tree.lhs)
  case "char"
    tree=Operation("==",list(typetree,Cste(10)),tree.lhs)
  case "numeric"
    catop=Operation("rc",list(Cste(1),Cste(5)),list())
    catop=Operation("rc",list(catop,Cste(8)),list())
    eqtree=Operation("==",list(typetree,catop),list())
    tree=Funcall("or",1,list(eqtree),list(tree.lhs(1)))
    tree.lhs(1).dims=list(1,1)
    tree.lhs(1).type=Type(Boolean,Real)
    return
  case "int8"
    tree=Operation("==",list(typeoftree,Cste("int8")),tree.lhs)
  case "uint8"
    tree=Operation("==",list(typeoftree,Cste("uint8")),tree.lhs)
  case "int16"
    tree=Operation("==",list(typeoftree,Cste("int16")),tree.lhs)
  case "uint16"
    tree=Operation("==",list(typeoftree,Cste("uint16")),tree.lhs)
  case "int32"
    tree=Operation("==",list(typeoftree,Cste("int32")),tree.lhs)
  case "uint32"
    tree=Operation("==",list(typeoftree,Cste("uint32")),tree.lhs)
  case "single"
    tree=Operation("==",list(typetree,Cste(1)),tree.lhs)
  case "double"
    tree=Operation("==",list(typetree,Cste(1)),tree.lhs)
  case "cell"
    tree=Operation("==",list(typeoftree,Cste("ce")),tree.lhs)
  case "struct"
    tree=Operation("==",list(typeoftree,Cste("st")),tree.lhs)
  case "function_handle"
    tree=Operation("==",list(typetree,Cste(13)),tree.lhs)
  case "sparse"
    tree=Operation("==",list(typetree,Cste(5)),tree.lhs)
  case "lti"
    tree=Operation("==",list(typeoftree,Cste("state-space")),tree.lhs)
  else
    set_infos(msprintf(gettext("Unhandled class: %s."),class.value),2)
    tree.lhs(1).dims=list(1,1)
    tree.lhs(1).type=Type(Boolean,Real)
    return
  end
  tree.out(1).dims=list(1,1)
  tree.out(1).type=Type(Boolean,Real)
else
  tree.name="mtlb_isa"
  tree.lhs(1).dims=list(1,1)
  tree.lhs(1).type=Type(Boolean,Real)
end
endfunction