* Bugs 16567 16586 fixed: mfile2sci() supports block %{..%}. Appended comments improved"
[scilab.git] / scilab / modules / m2sci / macros / kernel / infer2txt.sci
1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) ???? - INRIA - Scilab
3 //
4 // Copyright (C) 2012 - 2016 - Scilab Enterprises
5 //
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.
12
13 function txt=infer2txt(infer)
14     txt=[]
15     dims=[]
16     if typeof(infer)=="infer" then
17         for l=1:size(infer.dims)
18             dims=[dims,string(infer.dims(l))]
19         end
20     else
21         error(gettext("Not yet implemented."))
22     end
23     dims=strcat(dims," ")
24
25     tp=infer.type.vtype
26     if tp==1 then
27         tp="Double"
28     elseif tp==10 then
29         tp="String"
30     elseif or(tp==[4,6]) then
31         tp="Boolean"
32     elseif tp==16 then
33         tp="Struct"
34         for k = 1:size(infer.contents.index)
35             if typeof(infer.contents.index(k))<>"list" then
36                 txt=[txt;expression2code(list(infer.contents.index(k)))+infer2txt(infer.contents.data(k))]
37             else
38                 txt=[txt;expression2code(infer.contents.index(k))+infer2txt(infer.contents.data(k))]
39             end
40         end
41     elseif tp==17 then
42         tp="Cell"
43         for k = 1:size(infer.contents.index)
44             if typeof(infer.contents.index(k))<>"list" then
45                 txt=[txt;expression2code(list(infer.contents.index(k)))+infer2txt(infer.contents.data(k))]
46             else
47                 txt=[txt;expression2code(infer.contents.index(k))+infer2txt(infer.contents.data(k))]
48             end
49         end
50     elseif tp==9 then
51         tp="Handle"
52     else
53         tp="Unknown"
54     end
55     if infer.type.property==Real then
56         prop="Real"
57     elseif infer.type.property==Complex then
58         prop="Complex"
59     else
60         prop="Unknown"
61     end
62     txt=["|"+dims+"|"+tp+"|"+prop;txt]
63 endfunction