From 0345245e860375a32c9a437c4a9d9cae807134e9 Mon Sep 17 00:00:00 2001 From: Shashank Date: Mon, 29 May 2017 12:40:26 +0530 Subject: CMSCOPE changed --- .../m2sci/macros/kernel/%contents_i_funcall.bin | Bin 0 -> 752 bytes .../m2sci/macros/kernel/%contents_i_funcall.sci | 17 + .../m2sci/macros/kernel/%contents_i_operatio.bin | Bin 0 -> 752 bytes .../m2sci/macros/kernel/%contents_i_operatio.sci | 17 + .../m2sci/macros/kernel/%contents_i_variable.bin | Bin 0 -> 712 bytes .../m2sci/macros/kernel/%contents_i_variable.sci | 17 + modules/m2sci/macros/kernel/%cste_e.bin | Bin 0 -> 2440 bytes modules/m2sci/macros/kernel/%cste_e.sci | 27 + modules/m2sci/macros/kernel/%funcall_6.bin | Bin 0 -> 2972 bytes modules/m2sci/macros/kernel/%funcall_6.sci | 29 + modules/m2sci/macros/kernel/%funcall_e.bin | Bin 0 -> 2748 bytes modules/m2sci/macros/kernel/%funcall_e.sci | 28 + modules/m2sci/macros/kernel/%infer_i_s.bin | Bin 0 -> 3264 bytes modules/m2sci/macros/kernel/%infer_i_s.sci | 36 + modules/m2sci/macros/kernel/%infer_i_st.bin | Bin 0 -> 360 bytes modules/m2sci/macros/kernel/%infer_i_st.sci | 12 + modules/m2sci/macros/kernel/%l_i_cste.bin | Bin 0 -> 944 bytes modules/m2sci/macros/kernel/%l_i_cste.sci | 19 + modules/m2sci/macros/kernel/%l_i_funcall.bin | Bin 0 -> 964 bytes modules/m2sci/macros/kernel/%l_i_funcall.sci | 18 + modules/m2sci/macros/kernel/%l_i_operatio.bin | Bin 0 -> 964 bytes modules/m2sci/macros/kernel/%l_i_operatio.sci | 18 + modules/m2sci/macros/kernel/%l_i_variable.bin | Bin 0 -> 1204 bytes modules/m2sci/macros/kernel/%l_i_variable.sci | 20 + modules/m2sci/macros/kernel/%m2scivar_e.bin | Bin 0 -> 2496 bytes modules/m2sci/macros/kernel/%m2scivar_e.sci | 28 + modules/m2sci/macros/kernel/%operatio_6.bin | Bin 0 -> 2972 bytes modules/m2sci/macros/kernel/%operatio_6.sci | 29 + modules/m2sci/macros/kernel/%operatio_e.bin | Bin 0 -> 2972 bytes modules/m2sci/macros/kernel/%operatio_e.sci | 29 + modules/m2sci/macros/kernel/%s_i_operatio.bin | Bin 0 -> 960 bytes modules/m2sci/macros/kernel/%s_i_operatio.sci | 18 + modules/m2sci/macros/kernel/%s_i_variable.bin | Bin 0 -> 1284 bytes modules/m2sci/macros/kernel/%s_i_variable.sci | 21 + modules/m2sci/macros/kernel/%type_i_cste.bin | Bin 0 -> 696 bytes modules/m2sci/macros/kernel/%type_i_cste.sci | 17 + modules/m2sci/macros/kernel/%type_i_funcall.bin | Bin 0 -> 708 bytes modules/m2sci/macros/kernel/%type_i_funcall.sci | 17 + modules/m2sci/macros/kernel/%type_i_operatio.bin | Bin 0 -> 708 bytes modules/m2sci/macros/kernel/%type_i_operatio.sci | 17 + modules/m2sci/macros/kernel/%type_i_variable.bin | Bin 0 -> 3248 bytes modules/m2sci/macros/kernel/%type_i_variable.sci | 40 + modules/m2sci/macros/kernel/%variable_6.bin | Bin 0 -> 2720 bytes modules/m2sci/macros/kernel/%variable_6.sci | 29 + modules/m2sci/macros/kernel/%variable_e.bin | Bin 0 -> 2724 bytes modules/m2sci/macros/kernel/%variable_e.sci | 30 + modules/m2sci/macros/kernel/Contents.bin | Bin 0 -> 3080 bytes modules/m2sci/macros/kernel/Contents.sci | 31 + modules/m2sci/macros/kernel/Cste.bin | Bin 0 -> 3664 bytes modules/m2sci/macros/kernel/Cste.sci | 51 + modules/m2sci/macros/kernel/Equal.bin | Bin 0 -> 3696 bytes modules/m2sci/macros/kernel/Equal.sci | 34 + modules/m2sci/macros/kernel/Funcall.bin | Bin 0 -> 4012 bytes modules/m2sci/macros/kernel/Funcall.sci | 30 + modules/m2sci/macros/kernel/Infer.bin | Bin 0 -> 6108 bytes modules/m2sci/macros/kernel/Infer.sci | 42 + modules/m2sci/macros/kernel/M2scivar.bin | Bin 0 -> 3456 bytes modules/m2sci/macros/kernel/M2scivar.sci | 32 + modules/m2sci/macros/kernel/Operation.bin | Bin 0 -> 3196 bytes modules/m2sci/macros/kernel/Operation.sci | 29 + modules/m2sci/macros/kernel/Rhs_tlist.bin | Bin 0 -> 2500 bytes modules/m2sci/macros/kernel/Rhs_tlist.sci | 31 + modules/m2sci/macros/kernel/Type.bin | Bin 0 -> 3364 bytes modules/m2sci/macros/kernel/Type.sci | 30 + modules/m2sci/macros/kernel/Variable.bin | Bin 0 -> 2388 bytes modules/m2sci/macros/kernel/Variable.sci | 27 + modules/m2sci/macros/kernel/allunknown.bin | Bin 0 -> 496 bytes modules/m2sci/macros/kernel/allunknown.sci | 17 + modules/m2sci/macros/kernel/buildmacros.sce | 16 + modules/m2sci/macros/kernel/changevarname.bin | Bin 0 -> 8792 bytes modules/m2sci/macros/kernel/changevarname.sci | 63 + modules/m2sci/macros/kernel/clause2sci.bin | Bin 0 -> 60052 bytes modules/m2sci/macros/kernel/clause2sci.sci | 385 +++ modules/m2sci/macros/kernel/convert2double.bin | Bin 0 -> 4804 bytes modules/m2sci/macros/kernel/convert2double.sci | 40 + modules/m2sci/macros/kernel/default_trad.bin | Bin 0 -> 12140 bytes modules/m2sci/macros/kernel/default_trad.sci | 102 + modules/m2sci/macros/kernel/equal2sci.bin | Bin 0 -> 23972 bytes modules/m2sci/macros/kernel/equal2sci.sci | 158 + modules/m2sci/macros/kernel/expression2sci.bin | Bin 0 -> 17320 bytes modules/m2sci/macros/kernel/expression2sci.sci | 132 + .../m2sci/macros/kernel/first_non_singleton.bin | Bin 0 -> 1476 bytes .../m2sci/macros/kernel/first_non_singleton.sci | 26 + modules/m2sci/macros/kernel/funcall2sci.bin | Bin 0 -> 11480 bytes modules/m2sci/macros/kernel/funcall2sci.sci | 98 + modules/m2sci/macros/kernel/funcallsearch.bin | Bin 0 -> 18152 bytes modules/m2sci/macros/kernel/funcallsearch.sci | 104 + modules/m2sci/macros/kernel/get_unknown.bin | Bin 0 -> 3708 bytes modules/m2sci/macros/kernel/get_unknown.sci | 31 + modules/m2sci/macros/kernel/getoperands.bin | Bin 0 -> 1292 bytes modules/m2sci/macros/kernel/getoperands.sci | 24 + modules/m2sci/macros/kernel/getrhs.bin | Bin 0 -> 1352 bytes modules/m2sci/macros/kernel/getrhs.sci | 24 + modules/m2sci/macros/kernel/gettempvar.bin | Bin 0 -> 3784 bytes modules/m2sci/macros/kernel/gettempvar.sci | 35 + modules/m2sci/macros/kernel/getvar2sci.bin | Bin 0 -> 7828 bytes modules/m2sci/macros/kernel/getvar2sci.sci | 63 + modules/m2sci/macros/kernel/i_notation.bin | Bin 0 -> 11776 bytes modules/m2sci/macros/kernel/i_notation.sci | 94 + modules/m2sci/macros/kernel/infer2txt.bin | Bin 0 -> 7084 bytes modules/m2sci/macros/kernel/infer2txt.sci | 60 + modules/m2sci/macros/kernel/insert.bin | Bin 0 -> 1480 bytes modules/m2sci/macros/kernel/insert.sci | 26 + modules/m2sci/macros/kernel/instruction2sci.bin | Bin 0 -> 2804 bytes modules/m2sci/macros/kernel/instruction2sci.sci | 32 + modules/m2sci/macros/kernel/is_a_scalar.bin | Bin 0 -> 1348 bytes modules/m2sci/macros/kernel/is_a_scalar.sci | 24 + modules/m2sci/macros/kernel/is_a_vector.bin | Bin 0 -> 1820 bytes modules/m2sci/macros/kernel/is_a_vector.sci | 27 + modules/m2sci/macros/kernel/is_complex.bin | Bin 0 -> 784 bytes modules/m2sci/macros/kernel/is_complex.sci | 18 + modules/m2sci/macros/kernel/is_empty.bin | Bin 0 -> 1492 bytes modules/m2sci/macros/kernel/is_empty.sci | 25 + modules/m2sci/macros/kernel/is_real.bin | Bin 0 -> 788 bytes modules/m2sci/macros/kernel/is_real.sci | 18 + modules/m2sci/macros/kernel/isacomment.bin | Bin 0 -> 4376 bytes modules/m2sci/macros/kernel/isacomment.sci | 45 + modules/m2sci/macros/kernel/isanmfile.bin | Bin 0 -> 3804 bytes modules/m2sci/macros/kernel/isanmfile.sci | 46 + modules/m2sci/macros/kernel/isdefinedvar.bin | Bin 0 -> 6692 bytes modules/m2sci/macros/kernel/isdefinedvar.sci | 65 + modules/m2sci/macros/kernel/isinstring.bin | Bin 0 -> 8360 bytes modules/m2sci/macros/kernel/isinstring.sci | 78 + modules/m2sci/macros/kernel/lib | Bin 0 -> 2372 bytes modules/m2sci/macros/kernel/lst_funcall.bin | Bin 0 -> 37000 bytes modules/m2sci/macros/kernel/lst_funcall.sci | 234 ++ modules/m2sci/macros/kernel/m2sci.bin | Bin 0 -> 47728 bytes modules/m2sci/macros/kernel/m2sci.sci | 299 ++ modules/m2sci/macros/kernel/m2sci_info.bin | Bin 0 -> 6328 bytes modules/m2sci/macros/kernel/m2sci_info.sci | 45 + modules/m2sci/macros/kernel/m2sci_syntax.bin | Bin 0 -> 71736 bytes modules/m2sci/macros/kernel/m2sci_syntax.sci | 455 +++ modules/m2sci/macros/kernel/mfile_path.bin | Bin 0 -> 1384 bytes modules/m2sci/macros/kernel/mfile_path.sci | 21 + modules/m2sci/macros/kernel/mtlbtoolfun.bin | Bin 0 -> 684048 bytes modules/m2sci/macros/kernel/mtlbtoolfun.sci | 3653 ++++++++++++++++++++ modules/m2sci/macros/kernel/mtlbtree2sci.bin | Bin 0 -> 16272 bytes modules/m2sci/macros/kernel/mtlbtree2sci.sci | 125 + modules/m2sci/macros/kernel/multi_fun_file.bin | Bin 0 -> 23064 bytes modules/m2sci/macros/kernel/multi_fun_file.sci | 174 + modules/m2sci/macros/kernel/names | 87 + modules/m2sci/macros/kernel/no_equiv.bin | Bin 0 -> 468 bytes modules/m2sci/macros/kernel/no_equiv.sci | 14 + modules/m2sci/macros/kernel/not_a_scalar.bin | Bin 0 -> 1700 bytes modules/m2sci/macros/kernel/not_a_scalar.sci | 24 + modules/m2sci/macros/kernel/not_a_vector.bin | Bin 0 -> 1788 bytes modules/m2sci/macros/kernel/not_a_vector.sci | 25 + modules/m2sci/macros/kernel/not_empty.bin | Bin 0 -> 1932 bytes modules/m2sci/macros/kernel/not_empty.sci | 25 + modules/m2sci/macros/kernel/not_yet_converted.bin | Bin 0 -> 78112 bytes modules/m2sci/macros/kernel/not_yet_converted.sci | 1337 +++++++ modules/m2sci/macros/kernel/old2newinstr.bin | Bin 0 -> 15780 bytes modules/m2sci/macros/kernel/old2newinstr.sci | 94 + modules/m2sci/macros/kernel/operation2sci.bin | Bin 0 -> 7508 bytes modules/m2sci/macros/kernel/operation2sci.sci | 72 + modules/m2sci/macros/kernel/repl_poss.bin | Bin 0 -> 3988 bytes modules/m2sci/macros/kernel/repl_poss.sci | 40 + modules/m2sci/macros/kernel/replace_brackets.bin | Bin 0 -> 6636 bytes modules/m2sci/macros/kernel/replace_brackets.sci | 52 + modules/m2sci/macros/kernel/sci_generic.bin | Bin 0 -> 2196 bytes modules/m2sci/macros/kernel/sci_generic.sci | 25 + modules/m2sci/macros/kernel/sci_m2scideclare.bin | Bin 0 -> 58424 bytes modules/m2sci/macros/kernel/sci_m2scideclare.sci | 342 ++ modules/m2sci/macros/kernel/sciparam.bin | Bin 0 -> 4176 bytes modules/m2sci/macros/kernel/sciparam.sci | 56 + modules/m2sci/macros/kernel/set_infos.bin | Bin 0 -> 1808 bytes modules/m2sci/macros/kernel/set_infos.sci | 27 + modules/m2sci/macros/kernel/transformtree.bin | Bin 0 -> 12008 bytes modules/m2sci/macros/kernel/transformtree.sci | 84 + modules/m2sci/macros/kernel/translateorder.bin | Bin 0 -> 6368 bytes modules/m2sci/macros/kernel/translateorder.sci | 49 + modules/m2sci/macros/kernel/update_instr_list.bin | Bin 0 -> 3996 bytes modules/m2sci/macros/kernel/update_instr_list.sci | 45 + modules/m2sci/macros/kernel/updatevarslist.bin | Bin 0 -> 32828 bytes modules/m2sci/macros/kernel/updatevarslist.sci | 233 ++ modules/m2sci/macros/kernel/variablesearch.bin | Bin 0 -> 9756 bytes modules/m2sci/macros/kernel/variablesearch.sci | 71 + 177 files changed, 10454 insertions(+) create mode 100755 modules/m2sci/macros/kernel/%contents_i_funcall.bin create mode 100755 modules/m2sci/macros/kernel/%contents_i_funcall.sci create mode 100755 modules/m2sci/macros/kernel/%contents_i_operatio.bin create mode 100755 modules/m2sci/macros/kernel/%contents_i_operatio.sci create mode 100755 modules/m2sci/macros/kernel/%contents_i_variable.bin create mode 100755 modules/m2sci/macros/kernel/%contents_i_variable.sci create mode 100755 modules/m2sci/macros/kernel/%cste_e.bin create mode 100755 modules/m2sci/macros/kernel/%cste_e.sci create mode 100755 modules/m2sci/macros/kernel/%funcall_6.bin create mode 100755 modules/m2sci/macros/kernel/%funcall_6.sci create mode 100755 modules/m2sci/macros/kernel/%funcall_e.bin create mode 100755 modules/m2sci/macros/kernel/%funcall_e.sci create mode 100755 modules/m2sci/macros/kernel/%infer_i_s.bin create mode 100755 modules/m2sci/macros/kernel/%infer_i_s.sci create mode 100755 modules/m2sci/macros/kernel/%infer_i_st.bin create mode 100755 modules/m2sci/macros/kernel/%infer_i_st.sci create mode 100755 modules/m2sci/macros/kernel/%l_i_cste.bin create mode 100755 modules/m2sci/macros/kernel/%l_i_cste.sci create mode 100755 modules/m2sci/macros/kernel/%l_i_funcall.bin create mode 100755 modules/m2sci/macros/kernel/%l_i_funcall.sci create mode 100755 modules/m2sci/macros/kernel/%l_i_operatio.bin create mode 100755 modules/m2sci/macros/kernel/%l_i_operatio.sci create mode 100755 modules/m2sci/macros/kernel/%l_i_variable.bin create mode 100755 modules/m2sci/macros/kernel/%l_i_variable.sci create mode 100755 modules/m2sci/macros/kernel/%m2scivar_e.bin create mode 100755 modules/m2sci/macros/kernel/%m2scivar_e.sci create mode 100755 modules/m2sci/macros/kernel/%operatio_6.bin create mode 100755 modules/m2sci/macros/kernel/%operatio_6.sci create mode 100755 modules/m2sci/macros/kernel/%operatio_e.bin create mode 100755 modules/m2sci/macros/kernel/%operatio_e.sci create mode 100755 modules/m2sci/macros/kernel/%s_i_operatio.bin create mode 100755 modules/m2sci/macros/kernel/%s_i_operatio.sci create mode 100755 modules/m2sci/macros/kernel/%s_i_variable.bin create mode 100755 modules/m2sci/macros/kernel/%s_i_variable.sci create mode 100755 modules/m2sci/macros/kernel/%type_i_cste.bin create mode 100755 modules/m2sci/macros/kernel/%type_i_cste.sci create mode 100755 modules/m2sci/macros/kernel/%type_i_funcall.bin create mode 100755 modules/m2sci/macros/kernel/%type_i_funcall.sci create mode 100755 modules/m2sci/macros/kernel/%type_i_operatio.bin create mode 100755 modules/m2sci/macros/kernel/%type_i_operatio.sci create mode 100755 modules/m2sci/macros/kernel/%type_i_variable.bin create mode 100755 modules/m2sci/macros/kernel/%type_i_variable.sci create mode 100755 modules/m2sci/macros/kernel/%variable_6.bin create mode 100755 modules/m2sci/macros/kernel/%variable_6.sci create mode 100755 modules/m2sci/macros/kernel/%variable_e.bin create mode 100755 modules/m2sci/macros/kernel/%variable_e.sci create mode 100755 modules/m2sci/macros/kernel/Contents.bin create mode 100755 modules/m2sci/macros/kernel/Contents.sci create mode 100755 modules/m2sci/macros/kernel/Cste.bin create mode 100755 modules/m2sci/macros/kernel/Cste.sci create mode 100755 modules/m2sci/macros/kernel/Equal.bin create mode 100755 modules/m2sci/macros/kernel/Equal.sci create mode 100755 modules/m2sci/macros/kernel/Funcall.bin create mode 100755 modules/m2sci/macros/kernel/Funcall.sci create mode 100755 modules/m2sci/macros/kernel/Infer.bin create mode 100755 modules/m2sci/macros/kernel/Infer.sci create mode 100755 modules/m2sci/macros/kernel/M2scivar.bin create mode 100755 modules/m2sci/macros/kernel/M2scivar.sci create mode 100755 modules/m2sci/macros/kernel/Operation.bin create mode 100755 modules/m2sci/macros/kernel/Operation.sci create mode 100755 modules/m2sci/macros/kernel/Rhs_tlist.bin create mode 100755 modules/m2sci/macros/kernel/Rhs_tlist.sci create mode 100755 modules/m2sci/macros/kernel/Type.bin create mode 100755 modules/m2sci/macros/kernel/Type.sci create mode 100755 modules/m2sci/macros/kernel/Variable.bin create mode 100755 modules/m2sci/macros/kernel/Variable.sci create mode 100755 modules/m2sci/macros/kernel/allunknown.bin create mode 100755 modules/m2sci/macros/kernel/allunknown.sci create mode 100755 modules/m2sci/macros/kernel/buildmacros.sce create mode 100755 modules/m2sci/macros/kernel/changevarname.bin create mode 100755 modules/m2sci/macros/kernel/changevarname.sci create mode 100755 modules/m2sci/macros/kernel/clause2sci.bin create mode 100755 modules/m2sci/macros/kernel/clause2sci.sci create mode 100755 modules/m2sci/macros/kernel/convert2double.bin create mode 100755 modules/m2sci/macros/kernel/convert2double.sci create mode 100755 modules/m2sci/macros/kernel/default_trad.bin create mode 100755 modules/m2sci/macros/kernel/default_trad.sci create mode 100755 modules/m2sci/macros/kernel/equal2sci.bin create mode 100755 modules/m2sci/macros/kernel/equal2sci.sci create mode 100755 modules/m2sci/macros/kernel/expression2sci.bin create mode 100755 modules/m2sci/macros/kernel/expression2sci.sci create mode 100755 modules/m2sci/macros/kernel/first_non_singleton.bin create mode 100755 modules/m2sci/macros/kernel/first_non_singleton.sci create mode 100755 modules/m2sci/macros/kernel/funcall2sci.bin create mode 100755 modules/m2sci/macros/kernel/funcall2sci.sci create mode 100755 modules/m2sci/macros/kernel/funcallsearch.bin create mode 100755 modules/m2sci/macros/kernel/funcallsearch.sci create mode 100755 modules/m2sci/macros/kernel/get_unknown.bin create mode 100755 modules/m2sci/macros/kernel/get_unknown.sci create mode 100755 modules/m2sci/macros/kernel/getoperands.bin create mode 100755 modules/m2sci/macros/kernel/getoperands.sci create mode 100755 modules/m2sci/macros/kernel/getrhs.bin create mode 100755 modules/m2sci/macros/kernel/getrhs.sci create mode 100755 modules/m2sci/macros/kernel/gettempvar.bin create mode 100755 modules/m2sci/macros/kernel/gettempvar.sci create mode 100755 modules/m2sci/macros/kernel/getvar2sci.bin create mode 100755 modules/m2sci/macros/kernel/getvar2sci.sci create mode 100755 modules/m2sci/macros/kernel/i_notation.bin create mode 100755 modules/m2sci/macros/kernel/i_notation.sci create mode 100755 modules/m2sci/macros/kernel/infer2txt.bin create mode 100755 modules/m2sci/macros/kernel/infer2txt.sci create mode 100755 modules/m2sci/macros/kernel/insert.bin create mode 100755 modules/m2sci/macros/kernel/insert.sci create mode 100755 modules/m2sci/macros/kernel/instruction2sci.bin create mode 100755 modules/m2sci/macros/kernel/instruction2sci.sci create mode 100755 modules/m2sci/macros/kernel/is_a_scalar.bin create mode 100755 modules/m2sci/macros/kernel/is_a_scalar.sci create mode 100755 modules/m2sci/macros/kernel/is_a_vector.bin create mode 100755 modules/m2sci/macros/kernel/is_a_vector.sci create mode 100755 modules/m2sci/macros/kernel/is_complex.bin create mode 100755 modules/m2sci/macros/kernel/is_complex.sci create mode 100755 modules/m2sci/macros/kernel/is_empty.bin create mode 100755 modules/m2sci/macros/kernel/is_empty.sci create mode 100755 modules/m2sci/macros/kernel/is_real.bin create mode 100755 modules/m2sci/macros/kernel/is_real.sci create mode 100755 modules/m2sci/macros/kernel/isacomment.bin create mode 100755 modules/m2sci/macros/kernel/isacomment.sci create mode 100755 modules/m2sci/macros/kernel/isanmfile.bin create mode 100755 modules/m2sci/macros/kernel/isanmfile.sci create mode 100755 modules/m2sci/macros/kernel/isdefinedvar.bin create mode 100755 modules/m2sci/macros/kernel/isdefinedvar.sci create mode 100755 modules/m2sci/macros/kernel/isinstring.bin create mode 100755 modules/m2sci/macros/kernel/isinstring.sci create mode 100755 modules/m2sci/macros/kernel/lib create mode 100755 modules/m2sci/macros/kernel/lst_funcall.bin create mode 100755 modules/m2sci/macros/kernel/lst_funcall.sci create mode 100755 modules/m2sci/macros/kernel/m2sci.bin create mode 100755 modules/m2sci/macros/kernel/m2sci.sci create mode 100755 modules/m2sci/macros/kernel/m2sci_info.bin create mode 100755 modules/m2sci/macros/kernel/m2sci_info.sci create mode 100755 modules/m2sci/macros/kernel/m2sci_syntax.bin create mode 100755 modules/m2sci/macros/kernel/m2sci_syntax.sci create mode 100755 modules/m2sci/macros/kernel/mfile_path.bin create mode 100755 modules/m2sci/macros/kernel/mfile_path.sci create mode 100755 modules/m2sci/macros/kernel/mtlbtoolfun.bin create mode 100755 modules/m2sci/macros/kernel/mtlbtoolfun.sci create mode 100755 modules/m2sci/macros/kernel/mtlbtree2sci.bin create mode 100755 modules/m2sci/macros/kernel/mtlbtree2sci.sci create mode 100755 modules/m2sci/macros/kernel/multi_fun_file.bin create mode 100755 modules/m2sci/macros/kernel/multi_fun_file.sci create mode 100755 modules/m2sci/macros/kernel/names create mode 100755 modules/m2sci/macros/kernel/no_equiv.bin create mode 100755 modules/m2sci/macros/kernel/no_equiv.sci create mode 100755 modules/m2sci/macros/kernel/not_a_scalar.bin create mode 100755 modules/m2sci/macros/kernel/not_a_scalar.sci create mode 100755 modules/m2sci/macros/kernel/not_a_vector.bin create mode 100755 modules/m2sci/macros/kernel/not_a_vector.sci create mode 100755 modules/m2sci/macros/kernel/not_empty.bin create mode 100755 modules/m2sci/macros/kernel/not_empty.sci create mode 100755 modules/m2sci/macros/kernel/not_yet_converted.bin create mode 100755 modules/m2sci/macros/kernel/not_yet_converted.sci create mode 100755 modules/m2sci/macros/kernel/old2newinstr.bin create mode 100755 modules/m2sci/macros/kernel/old2newinstr.sci create mode 100755 modules/m2sci/macros/kernel/operation2sci.bin create mode 100755 modules/m2sci/macros/kernel/operation2sci.sci create mode 100755 modules/m2sci/macros/kernel/repl_poss.bin create mode 100755 modules/m2sci/macros/kernel/repl_poss.sci create mode 100755 modules/m2sci/macros/kernel/replace_brackets.bin create mode 100755 modules/m2sci/macros/kernel/replace_brackets.sci create mode 100755 modules/m2sci/macros/kernel/sci_generic.bin create mode 100755 modules/m2sci/macros/kernel/sci_generic.sci create mode 100755 modules/m2sci/macros/kernel/sci_m2scideclare.bin create mode 100755 modules/m2sci/macros/kernel/sci_m2scideclare.sci create mode 100755 modules/m2sci/macros/kernel/sciparam.bin create mode 100755 modules/m2sci/macros/kernel/sciparam.sci create mode 100755 modules/m2sci/macros/kernel/set_infos.bin create mode 100755 modules/m2sci/macros/kernel/set_infos.sci create mode 100755 modules/m2sci/macros/kernel/transformtree.bin create mode 100755 modules/m2sci/macros/kernel/transformtree.sci create mode 100755 modules/m2sci/macros/kernel/translateorder.bin create mode 100755 modules/m2sci/macros/kernel/translateorder.sci create mode 100755 modules/m2sci/macros/kernel/update_instr_list.bin create mode 100755 modules/m2sci/macros/kernel/update_instr_list.sci create mode 100755 modules/m2sci/macros/kernel/updatevarslist.bin create mode 100755 modules/m2sci/macros/kernel/updatevarslist.sci create mode 100755 modules/m2sci/macros/kernel/variablesearch.bin create mode 100755 modules/m2sci/macros/kernel/variablesearch.sci (limited to 'modules/m2sci/macros/kernel') diff --git a/modules/m2sci/macros/kernel/%contents_i_funcall.bin b/modules/m2sci/macros/kernel/%contents_i_funcall.bin new file mode 100755 index 000000000..ea3f8cd8c Binary files /dev/null and b/modules/m2sci/macros/kernel/%contents_i_funcall.bin differ diff --git a/modules/m2sci/macros/kernel/%contents_i_funcall.sci b/modules/m2sci/macros/kernel/%contents_i_funcall.sci new file mode 100755 index 000000000..63f3c1ef4 --- /dev/null +++ b/modules/m2sci/macros/kernel/%contents_i_funcall.sci @@ -0,0 +1,17 @@ +// 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.1-en.txt + +function funcall=%contents_i_funcall(field,contlist,funcall) + + if field=="contents" then + funcall.lhs(1).infer.contents=contlist + else + error(gettext("Not yet implemented.")) + end +endfunction diff --git a/modules/m2sci/macros/kernel/%contents_i_operatio.bin b/modules/m2sci/macros/kernel/%contents_i_operatio.bin new file mode 100755 index 000000000..6984de3c2 Binary files /dev/null and b/modules/m2sci/macros/kernel/%contents_i_operatio.bin differ diff --git a/modules/m2sci/macros/kernel/%contents_i_operatio.sci b/modules/m2sci/macros/kernel/%contents_i_operatio.sci new file mode 100755 index 000000000..d209095b1 --- /dev/null +++ b/modules/m2sci/macros/kernel/%contents_i_operatio.sci @@ -0,0 +1,17 @@ +// 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.1-en.txt + +function operation=%contents_i_operatio(field,contlist,operation) + + if field=="contents" then + operation.out(1).infer.contents=contlist + else + error(gettext("Not yet implemented.")) + end +endfunction diff --git a/modules/m2sci/macros/kernel/%contents_i_variable.bin b/modules/m2sci/macros/kernel/%contents_i_variable.bin new file mode 100755 index 000000000..cdbcc3b38 Binary files /dev/null and b/modules/m2sci/macros/kernel/%contents_i_variable.bin differ diff --git a/modules/m2sci/macros/kernel/%contents_i_variable.sci b/modules/m2sci/macros/kernel/%contents_i_variable.sci new file mode 100755 index 000000000..e10362c97 --- /dev/null +++ b/modules/m2sci/macros/kernel/%contents_i_variable.sci @@ -0,0 +1,17 @@ +// 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.1-en.txt + +function variable=%contents_i_variable(field,contlist,variable) + + if field=="contents" then + variable.infer.contents=contlist + else + error(gettext("Not yet implemented.")) + end +endfunction diff --git a/modules/m2sci/macros/kernel/%cste_e.bin b/modules/m2sci/macros/kernel/%cste_e.bin new file mode 100755 index 000000000..64ca00ff9 Binary files /dev/null and b/modules/m2sci/macros/kernel/%cste_e.bin differ diff --git a/modules/m2sci/macros/kernel/%cste_e.sci b/modules/m2sci/macros/kernel/%cste_e.sci new file mode 100755 index 000000000..3c4dd8182 --- /dev/null +++ b/modules/m2sci/macros/kernel/%cste_e.sci @@ -0,0 +1,27 @@ +// 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.1-en.txt + +function val=%cste_e(field,m2scitlist) + // File generated from %PROTO_e.g: PLEASE DO NOT EDIT ! + + val=[] + if field=="infer" then + val=m2scitlist.infer + elseif field=="dims" then + val=m2scitlist.infer.dims + elseif field=="type" then + val=m2scitlist.infer.type + elseif field=="vtype" then + val=m2scitlist.infer.type.vtype + elseif field=="property" then + val=m2scitlist.infer.type.property + else + error(msprintf(gettext("Extraction of %s from ''%s'' tlist is not yet implemented."),string(field),typeof(m2scitlist))) + end +endfunction diff --git a/modules/m2sci/macros/kernel/%funcall_6.bin b/modules/m2sci/macros/kernel/%funcall_6.bin new file mode 100755 index 000000000..65db8eed5 Binary files /dev/null and b/modules/m2sci/macros/kernel/%funcall_6.bin differ diff --git a/modules/m2sci/macros/kernel/%funcall_6.sci b/modules/m2sci/macros/kernel/%funcall_6.sci new file mode 100755 index 000000000..274f88ec4 --- /dev/null +++ b/modules/m2sci/macros/kernel/%funcall_6.sci @@ -0,0 +1,29 @@ +// 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.1-en.txt + +function val=%funcall_6(field,m2scitlist) + // File generated from %PROTO_6.g: PLEASE DO NOT EDIT ! + + val=[] + if field=="infer" then + val=m2scitlist.lhs(1).infer + elseif field=="dims" then + val=m2scitlist.lhs(1).infer.dims + elseif field=="type" then + val=m2scitlist.lhs(1).infer.type + elseif field=="vtype" then + val=m2scitlist.lhs(1).infer.type.vtype + elseif field=="property" then + val=m2scitlist.lhs(1).infer.type.property + elseif field=="contents" then + val=m2scitlist.lhs(1).infer.contents + else + error(msprintf(gettext("Extraction of %s from ''%s'' tlist is not yet implemented."),string(field),typeof(m2scitlist))) + end +endfunction diff --git a/modules/m2sci/macros/kernel/%funcall_e.bin b/modules/m2sci/macros/kernel/%funcall_e.bin new file mode 100755 index 000000000..56f98f63a Binary files /dev/null and b/modules/m2sci/macros/kernel/%funcall_e.bin differ diff --git a/modules/m2sci/macros/kernel/%funcall_e.sci b/modules/m2sci/macros/kernel/%funcall_e.sci new file mode 100755 index 000000000..aa227e52f --- /dev/null +++ b/modules/m2sci/macros/kernel/%funcall_e.sci @@ -0,0 +1,28 @@ +// 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.1-en.txt + +function val=%funcall_e(field,m2scitlist) + + val=[] + if field=="infer" then + val=m2scitlist.lhs(1).infer + elseif field=="dims" then + val=m2scitlist.lhs(1).infer.dims + elseif field=="type" then + val=m2scitlist.lhs(1).infer.type + elseif field=="vtype" then + val=m2scitlist.lhs(1).infer.type.vtype + elseif field=="property" then + val=m2scitlist.lhs(1).infer.type.property + elseif field=="contents" then + val=m2scitlist.lhs(1).infer.contents + else + error(msprintf(gettext("Extraction of %s from ''%s'' tlist is not yet implemented."),string(field),typeof(m2scitlist))) + end +endfunction diff --git a/modules/m2sci/macros/kernel/%infer_i_s.bin b/modules/m2sci/macros/kernel/%infer_i_s.bin new file mode 100755 index 000000000..ac533086b Binary files /dev/null and b/modules/m2sci/macros/kernel/%infer_i_s.bin differ diff --git a/modules/m2sci/macros/kernel/%infer_i_s.sci b/modules/m2sci/macros/kernel/%infer_i_s.sci new file mode 100755 index 000000000..528cc0f90 --- /dev/null +++ b/modules/m2sci/macros/kernel/%infer_i_s.sci @@ -0,0 +1,36 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function M=%infer_i_s(varargin) + + [lhs,rhs]=argn(0) + M=varargin(rhs) + N=varargin(rhs-1)//inserted matrix + index=varargin(1) // + + if rhs==3&(type(index)==10|type(index)==15) then + if type(index)<>15 then + M=struct() + M(index)=N + if index=="entries" then + // change struct to cell + f=getfield(1,M);f(1)="ce" + setfield(1,f,M) + end + else + M=createstruct(index,N) + if type(index(1))<>10 & index(2)=="entries" then + // change struct to cell + f=getfield(1,M);f(1)="ce" + setfield(1,f,M) + end + end + return + end +endfunction diff --git a/modules/m2sci/macros/kernel/%infer_i_st.bin b/modules/m2sci/macros/kernel/%infer_i_st.bin new file mode 100755 index 000000000..e452c1545 Binary files /dev/null and b/modules/m2sci/macros/kernel/%infer_i_st.bin differ diff --git a/modules/m2sci/macros/kernel/%infer_i_st.sci b/modules/m2sci/macros/kernel/%infer_i_st.sci new file mode 100755 index 000000000..a87ce6c00 --- /dev/null +++ b/modules/m2sci/macros/kernel/%infer_i_st.sci @@ -0,0 +1,12 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function st=%infer_i_st(field,infer,st) + st=generic_i_st(field,infer,st) +endfunction diff --git a/modules/m2sci/macros/kernel/%l_i_cste.bin b/modules/m2sci/macros/kernel/%l_i_cste.bin new file mode 100755 index 000000000..88c18f3b9 Binary files /dev/null and b/modules/m2sci/macros/kernel/%l_i_cste.bin differ diff --git a/modules/m2sci/macros/kernel/%l_i_cste.sci b/modules/m2sci/macros/kernel/%l_i_cste.sci new file mode 100755 index 000000000..2f3503f28 --- /dev/null +++ b/modules/m2sci/macros/kernel/%l_i_cste.sci @@ -0,0 +1,19 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function cste=%l_i_cste(field,inslist,cste) + + if field=="dims" then + cste.infer.dims=inslist + elseif field=="type" then + cste.infer.type=inslist + else + error(gettext("Not yet implemented.")) + end +endfunction diff --git a/modules/m2sci/macros/kernel/%l_i_funcall.bin b/modules/m2sci/macros/kernel/%l_i_funcall.bin new file mode 100755 index 000000000..bf28cf848 Binary files /dev/null and b/modules/m2sci/macros/kernel/%l_i_funcall.bin differ diff --git a/modules/m2sci/macros/kernel/%l_i_funcall.sci b/modules/m2sci/macros/kernel/%l_i_funcall.sci new file mode 100755 index 000000000..8d6c66e5f --- /dev/null +++ b/modules/m2sci/macros/kernel/%l_i_funcall.sci @@ -0,0 +1,18 @@ +// 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.1-en.txt + +function funcall=%l_i_funcall(field,inslist,funcall) + if field=="dims" then + funcall.lhs(1).dims=inslist + elseif field=="type" then + funcall.lhs(1).type=inslist + else + error(gettext("Not yet implemented.")) + end +endfunction diff --git a/modules/m2sci/macros/kernel/%l_i_operatio.bin b/modules/m2sci/macros/kernel/%l_i_operatio.bin new file mode 100755 index 000000000..655a4a679 Binary files /dev/null and b/modules/m2sci/macros/kernel/%l_i_operatio.bin differ diff --git a/modules/m2sci/macros/kernel/%l_i_operatio.sci b/modules/m2sci/macros/kernel/%l_i_operatio.sci new file mode 100755 index 000000000..ad4fe2162 --- /dev/null +++ b/modules/m2sci/macros/kernel/%l_i_operatio.sci @@ -0,0 +1,18 @@ +// 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.1-en.txt + +function operation=%l_i_operatio(field,inslist,operation) + if field=="dims" then + operation.out(1).dims=inslist + elseif field=="type" then + operation.out(1).type=inslist + else + error(gettext("Not yet implemented.")) + end +endfunction diff --git a/modules/m2sci/macros/kernel/%l_i_variable.bin b/modules/m2sci/macros/kernel/%l_i_variable.bin new file mode 100755 index 000000000..892071fe0 Binary files /dev/null and b/modules/m2sci/macros/kernel/%l_i_variable.bin differ diff --git a/modules/m2sci/macros/kernel/%l_i_variable.sci b/modules/m2sci/macros/kernel/%l_i_variable.sci new file mode 100755 index 000000000..68c109e99 --- /dev/null +++ b/modules/m2sci/macros/kernel/%l_i_variable.sci @@ -0,0 +1,20 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function var=%l_i_variable(field,inslist,var) + if field=="dims" then + var.infer.dims=inslist + elseif field=="type" then + var.infer.type=inslist + elseif field=="contents" then + var.infer.contents=inslist + else + error(gettext("Not yet implemented.")) + end +endfunction diff --git a/modules/m2sci/macros/kernel/%m2scivar_e.bin b/modules/m2sci/macros/kernel/%m2scivar_e.bin new file mode 100755 index 000000000..af7c773c4 Binary files /dev/null and b/modules/m2sci/macros/kernel/%m2scivar_e.bin differ diff --git a/modules/m2sci/macros/kernel/%m2scivar_e.sci b/modules/m2sci/macros/kernel/%m2scivar_e.sci new file mode 100755 index 000000000..47da81db4 --- /dev/null +++ b/modules/m2sci/macros/kernel/%m2scivar_e.sci @@ -0,0 +1,28 @@ +// 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.1-en.txt + +function val=%m2scivar_e(field,m2scitlist) + + val=[] + if field=="infer" then + val=m2scitlist.infer + elseif field=="dims" then + val=m2scitlist.infer.dims + elseif field=="type" then + val=m2scitlist.infer.type + elseif field=="vtype" then + val=m2scitlist.infer.type.vtype + elseif field=="property" then + val=m2scitlist.infer.type.property + elseif field=="contents" then + val=m2scitlist.infer.contents + else + error(msprintf(gettext("Extraction of %s from ''%s'' tlist is not yet implemented."),string(field),typeof(m2scitlist))) + end +endfunction diff --git a/modules/m2sci/macros/kernel/%operatio_6.bin b/modules/m2sci/macros/kernel/%operatio_6.bin new file mode 100755 index 000000000..241c7e464 Binary files /dev/null and b/modules/m2sci/macros/kernel/%operatio_6.bin differ diff --git a/modules/m2sci/macros/kernel/%operatio_6.sci b/modules/m2sci/macros/kernel/%operatio_6.sci new file mode 100755 index 000000000..d5cc4661e --- /dev/null +++ b/modules/m2sci/macros/kernel/%operatio_6.sci @@ -0,0 +1,29 @@ +// 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.1-en.txt + +function val=%operatio_6(field,m2scitlist) + // File generated from %PROTO_6.g: PLEASE DO NOT EDIT ! + + val=[] + if field=="infer" then + val=m2scitlist.out(1).infer + elseif field=="dims" then + val=m2scitlist.out(1).infer.dims + elseif field=="type" then + val=m2scitlist.out(1).infer.type + elseif field=="vtype" then + val=m2scitlist.out(1).infer.type.vtype + elseif field=="property" then + val=m2scitlist.out(1).infer.type.property + elseif field=="contents" then + val=m2scitlist.out(1).infer.contents + else + error(msprintf(gettext("Extraction of %s from ''%s'' tlist is not yet implemented."),string(field),typeof(m2scitlist))) + end +endfunction diff --git a/modules/m2sci/macros/kernel/%operatio_e.bin b/modules/m2sci/macros/kernel/%operatio_e.bin new file mode 100755 index 000000000..08fdf78db Binary files /dev/null and b/modules/m2sci/macros/kernel/%operatio_e.bin differ diff --git a/modules/m2sci/macros/kernel/%operatio_e.sci b/modules/m2sci/macros/kernel/%operatio_e.sci new file mode 100755 index 000000000..66907542c --- /dev/null +++ b/modules/m2sci/macros/kernel/%operatio_e.sci @@ -0,0 +1,29 @@ +// 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.1-en.txt + +function val=%operatio_e(field,m2scitlist) + // File generated from %PROTO_e.g: PLEASE DO NOT EDIT ! + + val=[] + if field=="infer" then + val=m2scitlist.out(1).infer + elseif field=="dims" then + val=m2scitlist.out(1).infer.dims + elseif field=="type" then + val=m2scitlist.out(1).infer.type + elseif field=="vtype" then + val=m2scitlist.out(1).infer.type.vtype + elseif field=="property" then + val=m2scitlist.out(1).infer.type.property + elseif field=="contents" then + val=m2scitlist.out(1).infer.contents + else + error(msprintf(gettext("Extraction of %s from ''%s'' tlist is not yet implemented."),string(field),typeof(m2scitlist))) + end +endfunction diff --git a/modules/m2sci/macros/kernel/%s_i_operatio.bin b/modules/m2sci/macros/kernel/%s_i_operatio.bin new file mode 100755 index 000000000..357dc8c5e Binary files /dev/null and b/modules/m2sci/macros/kernel/%s_i_operatio.bin differ diff --git a/modules/m2sci/macros/kernel/%s_i_operatio.sci b/modules/m2sci/macros/kernel/%s_i_operatio.sci new file mode 100755 index 000000000..4ac65ba1b --- /dev/null +++ b/modules/m2sci/macros/kernel/%s_i_operatio.sci @@ -0,0 +1,18 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function op=%s_i_operatio(field,cste,op) + if field=="vtype" then + op.type.vtype=cste + elseif field=="property" then + op.type.property=cste + else + error(gettext("Not yet implemented.")) + end +endfunction diff --git a/modules/m2sci/macros/kernel/%s_i_variable.bin b/modules/m2sci/macros/kernel/%s_i_variable.bin new file mode 100755 index 000000000..19778f4f7 Binary files /dev/null and b/modules/m2sci/macros/kernel/%s_i_variable.bin differ diff --git a/modules/m2sci/macros/kernel/%s_i_variable.sci b/modules/m2sci/macros/kernel/%s_i_variable.sci new file mode 100755 index 000000000..1998542a6 --- /dev/null +++ b/modules/m2sci/macros/kernel/%s_i_variable.sci @@ -0,0 +1,21 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function var=%s_i_variable(field,cste,var) + + if field=="vtype" then + var.infer.type.vtype=cste + elseif field=="property" then + var.infer.type.property=cste + elseif field=="contents" then + var.infer.contents=cste + else + error(gettext("Not yet implemented.")) + end +endfunction diff --git a/modules/m2sci/macros/kernel/%type_i_cste.bin b/modules/m2sci/macros/kernel/%type_i_cste.bin new file mode 100755 index 000000000..1f082b41f Binary files /dev/null and b/modules/m2sci/macros/kernel/%type_i_cste.bin differ diff --git a/modules/m2sci/macros/kernel/%type_i_cste.sci b/modules/m2sci/macros/kernel/%type_i_cste.sci new file mode 100755 index 000000000..a85e4c240 --- /dev/null +++ b/modules/m2sci/macros/kernel/%type_i_cste.sci @@ -0,0 +1,17 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function cste=%type_i_cste(field,inslist,cste) + + if field=="type" then + cste.infer.type=inslist + else + error(gettext("Not yet implemented.")) + end +endfunction diff --git a/modules/m2sci/macros/kernel/%type_i_funcall.bin b/modules/m2sci/macros/kernel/%type_i_funcall.bin new file mode 100755 index 000000000..fe57ef823 Binary files /dev/null and b/modules/m2sci/macros/kernel/%type_i_funcall.bin differ diff --git a/modules/m2sci/macros/kernel/%type_i_funcall.sci b/modules/m2sci/macros/kernel/%type_i_funcall.sci new file mode 100755 index 000000000..996a354bd --- /dev/null +++ b/modules/m2sci/macros/kernel/%type_i_funcall.sci @@ -0,0 +1,17 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function funcall=%type_i_funcall(field,inslist,funcall) + + if field=="type" then + funcall.lhs(1).type=inslist + else + error(gettext("Not yet implemented.")) + end +endfunction diff --git a/modules/m2sci/macros/kernel/%type_i_operatio.bin b/modules/m2sci/macros/kernel/%type_i_operatio.bin new file mode 100755 index 000000000..a70ae1a1b Binary files /dev/null and b/modules/m2sci/macros/kernel/%type_i_operatio.bin differ diff --git a/modules/m2sci/macros/kernel/%type_i_operatio.sci b/modules/m2sci/macros/kernel/%type_i_operatio.sci new file mode 100755 index 000000000..137be6fc9 --- /dev/null +++ b/modules/m2sci/macros/kernel/%type_i_operatio.sci @@ -0,0 +1,17 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function operation=%type_i_operatio(field,inslist,operation) + + if field=="type" then + operation.out(1).type=inslist + else + error(gettext("Not yet implemented.")) + end +endfunction diff --git a/modules/m2sci/macros/kernel/%type_i_variable.bin b/modules/m2sci/macros/kernel/%type_i_variable.bin new file mode 100755 index 000000000..e781b7364 Binary files /dev/null and b/modules/m2sci/macros/kernel/%type_i_variable.bin differ diff --git a/modules/m2sci/macros/kernel/%type_i_variable.sci b/modules/m2sci/macros/kernel/%type_i_variable.sci new file mode 100755 index 000000000..d0ab15387 --- /dev/null +++ b/modules/m2sci/macros/kernel/%type_i_variable.sci @@ -0,0 +1,40 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function var=%type_i_variable(field,inslist,var) + + if typeof(inslist)=="ce" then + if field=="type" then + var.infer=inslist + else + error(gettext("Not yet implemented.")) + end + elseif typeof(inslist)=="st" then + pause + else + if or(typeof(var.infer)==["ce","st"]) then + if field=="type" then + dims=list() + for kd=1:size(var.infer.dims,"*") + dims(kd)=var.infer.dims(kd) + end + var.infer=Infer(dims,Type()) + var.infer.type=inslist + else + error(gettext("Not yet implemented.")) + end + else + if field=="type" then + var.infer.type=inslist + else + error(gettext("Not yet implemented.")) + end + end + end +endfunction diff --git a/modules/m2sci/macros/kernel/%variable_6.bin b/modules/m2sci/macros/kernel/%variable_6.bin new file mode 100755 index 000000000..512ab3a8d Binary files /dev/null and b/modules/m2sci/macros/kernel/%variable_6.bin differ diff --git a/modules/m2sci/macros/kernel/%variable_6.sci b/modules/m2sci/macros/kernel/%variable_6.sci new file mode 100755 index 000000000..6a735f665 --- /dev/null +++ b/modules/m2sci/macros/kernel/%variable_6.sci @@ -0,0 +1,29 @@ +// 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.1-en.txt + +function val=%variable_6(field,m2scitlist) + // File generated from %PROTO_6.g: PLEASE DO NOT EDIT ! + + val=[] + if field=="infer" then + val=m2scitlist.infer + elseif field=="dims" then + val=m2scitlist.infer.dims + elseif field=="type" then + val=m2scitlist.infer.type + elseif field=="vtype" then + val=m2scitlist.infer.type.vtype + elseif field=="property" then + val=m2scitlist.infer.type.property + elseif field=="contents" then + val=m2scitlist.infer.contents + else + error(msprintf(gettext("Extraction of %s from ''%s'' tlist is not yet implemented."),string(field),typeof(m2scitlist))) + end +endfunction diff --git a/modules/m2sci/macros/kernel/%variable_e.bin b/modules/m2sci/macros/kernel/%variable_e.bin new file mode 100755 index 000000000..6fe7b191a Binary files /dev/null and b/modules/m2sci/macros/kernel/%variable_e.bin differ diff --git a/modules/m2sci/macros/kernel/%variable_e.sci b/modules/m2sci/macros/kernel/%variable_e.sci new file mode 100755 index 000000000..6a7fab8e8 --- /dev/null +++ b/modules/m2sci/macros/kernel/%variable_e.sci @@ -0,0 +1,30 @@ +// 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.1-en.txt + +function val=%variable_e(field,m2scitlist) + // File generated from %PROTO_e.g: PLEASE DO NOT EDIT ! + + val=[] + + if field=="infer" then + val=m2scitlist.infer + elseif field=="dims" then + val=m2scitlist.infer.dims + elseif field=="type" then + val=m2scitlist.infer.type + elseif field=="vtype" then + val=m2scitlist.infer.type.vtype + elseif field=="property" then + val=m2scitlist.infer.type.property + elseif field=="contents" then + val=m2scitlist.infer.contents + else + error(msprintf(gettext("Extraction of %s from ''%s'' tlist is not yet implemented."),string(field),typeof(m2scitlist))) + end +endfunction diff --git a/modules/m2sci/macros/kernel/Contents.bin b/modules/m2sci/macros/kernel/Contents.bin new file mode 100755 index 000000000..b87f044a2 Binary files /dev/null and b/modules/m2sci/macros/kernel/Contents.bin differ diff --git a/modules/m2sci/macros/kernel/Contents.sci b/modules/m2sci/macros/kernel/Contents.sci new file mode 100755 index 000000000..f4f91811a --- /dev/null +++ b/modules/m2sci/macros/kernel/Contents.sci @@ -0,0 +1,31 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function cont=Contents(varargin) + // Create a new inference tlist + + fields=["contents","index","data"] + + nargs=size(varargin) + + // Contents: all unknown + if nargs==0 then + cont=tlist(fields,list(),list()) + elseif nargs==2 then + if typeof(varargin(1))<>"list" then + error(msprintf(gettext("index must be a list instead of a: %s."),typeof(varargin(1)))) + end + if typeof(varargin(2))<>"list" then + error(msprintf(gettext("index must be a list instead of a: %s."),typeof(varargin(2)))) + end + cont=tlist(fields,varargin(1),varargin(2)) + else + error(gettext("Wrong number of inputs.")); + end +endfunction diff --git a/modules/m2sci/macros/kernel/Cste.bin b/modules/m2sci/macros/kernel/Cste.bin new file mode 100755 index 000000000..7936c7337 Binary files /dev/null and b/modules/m2sci/macros/kernel/Cste.bin differ diff --git a/modules/m2sci/macros/kernel/Cste.sci b/modules/m2sci/macros/kernel/Cste.sci new file mode 100755 index 000000000..8dd54986a --- /dev/null +++ b/modules/m2sci/macros/kernel/Cste.sci @@ -0,0 +1,51 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function const=Cste(value) + // Create a new constant tlist + + rhs=argn(2) + + if rhs~=1 then + error(gettext("Wrong number of inputs.")); + end + + dims=list() + + if value=="" then + dims=list(0,0) + else + sz=size(value) + for k=1:size(sz,"*") + dims($+1)=sz(k) + if type(value)==String then + if k==2 then + dims($)=sum(length(value)) + end + end + end + end + + if type(value)==String then + prop=Real + value=value + else + if type(value)==1 then + if isreal(value) then + prop=Real + else + prop=Complex + end + else + prop=Real + end + end + + const=tlist(["cste","value","infer"],value,Infer(dims,Type(type(value),prop))) +endfunction diff --git a/modules/m2sci/macros/kernel/Equal.bin b/modules/m2sci/macros/kernel/Equal.bin new file mode 100755 index 000000000..504a4c80d Binary files /dev/null and b/modules/m2sci/macros/kernel/Equal.bin differ diff --git a/modules/m2sci/macros/kernel/Equal.sci b/modules/m2sci/macros/kernel/Equal.sci new file mode 100755 index 000000000..d742b690a --- /dev/null +++ b/modules/m2sci/macros/kernel/Equal.sci @@ -0,0 +1,34 @@ +// 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.1-en.txt + +function eq=Equal(lhslist,expression,endsymbol) + // Create a new 'equal' tlist + + rhs=argn(2) + + if rhs<2 then + error(gettext("Wrong number of inputs.")) + end + if rhs<3 then + endsymbol=";" + end + if typeof(lhslist)<>"list" then + error(msprintf(gettext("lhslist should be a list and not a: %s."),typeof(lhslist))); + end + if and(typeof(expression)<>["funcall","cste","operation","variable"]) then + disp(expression) + error(msprintf(gettext("expression can not be a: %s."),typeof(expression))) + end + if type(endsymbol)<>10 then + error(msprintf(gettext("endsymbol should be a character string and not a: %s."),typeof(lhslist))); + end + + eq=tlist(["equal","lhs","expression","endsymbol"],lhslist,expression,endsymbol) + +endfunction diff --git a/modules/m2sci/macros/kernel/Funcall.bin b/modules/m2sci/macros/kernel/Funcall.bin new file mode 100755 index 000000000..9d1fa324f Binary files /dev/null and b/modules/m2sci/macros/kernel/Funcall.bin differ diff --git a/modules/m2sci/macros/kernel/Funcall.sci b/modules/m2sci/macros/kernel/Funcall.sci new file mode 100755 index 000000000..feca5cf5a --- /dev/null +++ b/modules/m2sci/macros/kernel/Funcall.sci @@ -0,0 +1,30 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function funcall_tlist=Funcall(name,lhsnb,rhslist,lhslist) + // Copyright INRIA + // Create a new function tlist + + rhs=argn(2) + + // Verify input value + if rhs~=4 then + error(gettext("Wrong number of inputs.")); + elseif typeof(name)~="string" then + error(msprintf(gettext("name must be a string instead of a: %s."),typeof(name))); + elseif typeof(lhsnb)~="constant" then + error(msprintf(gettext("lhsnb must be a constant instead of a: %s."),typeof(lhsnb))); + elseif typeof(rhslist)~="list" & rhslist<>[] then + error(msprintf(gettext("rhslist must be a list instead of a: %s."),typeof(rhslist))); + elseif typeof(lhslist)~="list" then + error(msprintf(gettext("lhslist must be a list instead of a: %s."),typeof(lhslist))); + end + + funcall_tlist=tlist(["funcall","name","lhsnb","rhs","lhs"],name,lhsnb,rhslist,lhslist) +endfunction diff --git a/modules/m2sci/macros/kernel/Infer.bin b/modules/m2sci/macros/kernel/Infer.bin new file mode 100755 index 000000000..661284cb1 Binary files /dev/null and b/modules/m2sci/macros/kernel/Infer.bin differ diff --git a/modules/m2sci/macros/kernel/Infer.sci b/modules/m2sci/macros/kernel/Infer.sci new file mode 100755 index 000000000..26e3100cc --- /dev/null +++ b/modules/m2sci/macros/kernel/Infer.sci @@ -0,0 +1,42 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function infer=Infer(varargin) + // Create a new inference tlist + + fields=["infer","dims","type","contents"] + + rhs=argn(2) + + nargs=size(varargin) + + // Infer(): all unknown + if nargs==0 then + infer=tlist(fields,list(Unknown,Unknown),Type(Unknown,Unknown),Contents()) + elseif nargs==2 then + if typeof(varargin(1))<>"list" then + error(msprintf(gettext("dims must be a list instead of a: %s."),typeof(varargin(1)))); + end + if typeof(varargin(2))<>"type" then + error(msprintf(gettext("type must be a ''type'' tlist instead of a: %s."),typeof(varargin(2)))); + end + infer=tlist(fields,varargin(1),varargin(2),Contents()) + elseif nargs==3 then // Should only be used for cells and structs + if typeof(varargin(1))<>"list" then + error(msprintf(gettext("dims must be a list instead of a: %s."),typeof(varargin(1)))); + end + if typeof(varargin(2))<>"type" then + error(msprintf(gettext("type must be a ''type'' tlist instead of a: %s."),typeof(varargin(2)))); + end + if typeof(varargin(3))<>"contents" then + error(msprintf(gettext("contents must be a ''contents'' tlist instead of a: %s."),typeof(varargin(3)))); + end + infer=tlist(fields,varargin(1),varargin(2),varargin(3)) + end +endfunction diff --git a/modules/m2sci/macros/kernel/M2scivar.bin b/modules/m2sci/macros/kernel/M2scivar.bin new file mode 100755 index 000000000..6521eeddd Binary files /dev/null and b/modules/m2sci/macros/kernel/M2scivar.bin differ diff --git a/modules/m2sci/macros/kernel/M2scivar.sci b/modules/m2sci/macros/kernel/M2scivar.sci new file mode 100755 index 000000000..c755548c3 --- /dev/null +++ b/modules/m2sci/macros/kernel/M2scivar.sci @@ -0,0 +1,32 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function var=M2scivar(sciname,matname,infer,call_level) + // Create a new 'm2scivar' tlist + + rhs=argn(2) + + if rhs<3 then + error(gettext("Wrong number of inputs.")) + end + if rhs==3 then + call_level=0 + end + + if typeof(sciname)~="string" then + error(msprintf(gettext("sciname must be a string instead of a: %s."),typeof(sciname))); + elseif typeof(matname)~="string" then + error(msprintf(gettext("matname must be a string instead of a: %s."),typeof(matname))); + elseif typeof(infer)~="infer" then + error(msprintf(gettext("infer must be an ''infer'' tlist instead of a: %s."),typeof(infer))); + end + + var=tlist(["m2scivar","sciname","matname","infer","level"],sciname,matname,infer,call_level) + +endfunction diff --git a/modules/m2sci/macros/kernel/Operation.bin b/modules/m2sci/macros/kernel/Operation.bin new file mode 100755 index 000000000..eec4f0bb0 Binary files /dev/null and b/modules/m2sci/macros/kernel/Operation.bin differ diff --git a/modules/m2sci/macros/kernel/Operation.sci b/modules/m2sci/macros/kernel/Operation.sci new file mode 100755 index 000000000..0c2ed5eac --- /dev/null +++ b/modules/m2sci/macros/kernel/Operation.sci @@ -0,0 +1,29 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function operation_tlist=Operation(operator,operands,out) + // Create a new operation tlist + + rhs=argn(2) + + // Verify input value + if rhs~=3 then + error(gettext("Wrong number of inputs.")) + end + + if typeof(operator)~="string" then + error(msprintf(gettext("operator must be a string instead of a: %s."),typeof(operator)));; + elseif typeof(operands)~="list" then + error(msprintf(gettext("operands must be a list instead of a: %s."),typeof(operands))); + elseif typeof(out)~="list" then + error(msprintf(gettext("out must be a list instead of a: %s."),typeof(out))); + end + + operation_tlist=tlist(["operation","operator","operands","out"],operator,operands,out) +endfunction diff --git a/modules/m2sci/macros/kernel/Rhs_tlist.bin b/modules/m2sci/macros/kernel/Rhs_tlist.bin new file mode 100755 index 000000000..6df3132ed Binary files /dev/null and b/modules/m2sci/macros/kernel/Rhs_tlist.bin differ diff --git a/modules/m2sci/macros/kernel/Rhs_tlist.sci b/modules/m2sci/macros/kernel/Rhs_tlist.sci new file mode 100755 index 000000000..437971d81 --- /dev/null +++ b/modules/m2sci/macros/kernel/Rhs_tlist.sci @@ -0,0 +1,31 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function rhs_tlist=Rhs_tlist(varargin) + // Create a new rhs tlist + + expressions=list() + if size(varargin)==1 then + if or(typeof(varargin(1))==["string","constant"]) then + expressions(1)=Cste(varargin(1)) + else + expressions(1)=varargin(1) + end + else + for k=1:size(varargin) + if or(typeof(varargin(k))==["string","constant"]) then + expressions(k)=Cste(varargin(k)) + elseif varargin(k)<>list() then //list() is used for rand()... + expressions(k)=varargin(k) + end + end + end + rhs_tlist=expressions + +endfunction diff --git a/modules/m2sci/macros/kernel/Type.bin b/modules/m2sci/macros/kernel/Type.bin new file mode 100755 index 000000000..35edeaf53 Binary files /dev/null and b/modules/m2sci/macros/kernel/Type.bin differ diff --git a/modules/m2sci/macros/kernel/Type.sci b/modules/m2sci/macros/kernel/Type.sci new file mode 100755 index 000000000..ec587b11a --- /dev/null +++ b/modules/m2sci/macros/kernel/Type.sci @@ -0,0 +1,30 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function Type_tlist=Type(vtype,property) + // Create a new 'type' tlist for inference + + rhs=argn(2) + if rhs<2 then + Type_tlist=tlist(["type","vtype","property"],Unknown,Unknown) + return + end + + if and(vtype~=[Double,Boolean,String,Unknown,Sparse,Cell,Struct,Int,Handle]) then + error(msprintf(gettext("%s is not yet implemented."),string(vtype))) + end + + if typeof(property)=="list" then + error(gettext("list of properties is not yet implemented.")) + elseif and(property~=[Real,Complex,Unknown]) then + error(msprintf(gettext("wrong property %s."),string(property))) + end + + Type_tlist=tlist(["type","vtype","property"],vtype,property) +endfunction diff --git a/modules/m2sci/macros/kernel/Variable.bin b/modules/m2sci/macros/kernel/Variable.bin new file mode 100755 index 000000000..7132c5a53 Binary files /dev/null and b/modules/m2sci/macros/kernel/Variable.bin differ diff --git a/modules/m2sci/macros/kernel/Variable.sci b/modules/m2sci/macros/kernel/Variable.sci new file mode 100755 index 000000000..7b55ff9e1 --- /dev/null +++ b/modules/m2sci/macros/kernel/Variable.sci @@ -0,0 +1,27 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function var=Variable(name,infer) + // Create a new variable tlist + + rhs=argn(2) + + if rhs<>2 then + error(gettext("Wrong number of inputs.")) + end + + if typeof(name)~="string" then + error(msprintf(gettext("name must be a string instead of a: %s."),typeof(name))) + elseif typeof(infer)~="infer" then + error(msprintf(gettext("infer must be an ''infer'' tlist instead of a: %s."),typeof(infer))) + end + + var=tlist(["variable","name","infer"],name,infer) + +endfunction diff --git a/modules/m2sci/macros/kernel/allunknown.bin b/modules/m2sci/macros/kernel/allunknown.bin new file mode 100755 index 000000000..f58cc3854 Binary files /dev/null and b/modules/m2sci/macros/kernel/allunknown.bin differ diff --git a/modules/m2sci/macros/kernel/allunknown.sci b/modules/m2sci/macros/kernel/allunknown.sci new file mode 100755 index 000000000..8e469a182 --- /dev/null +++ b/modules/m2sci/macros/kernel/allunknown.sci @@ -0,0 +1,17 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function dims=allunknown(in) + + dims=list() + for k=1:size(in) + dims(k)=-1 + end + +endfunction diff --git a/modules/m2sci/macros/kernel/buildmacros.sce b/modules/m2sci/macros/kernel/buildmacros.sce new file mode 100755 index 000000000..1adb52e12 --- /dev/null +++ b/modules/m2sci/macros/kernel/buildmacros.sce @@ -0,0 +1,16 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2005 - INRIA - Allan CORNET +// +// 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.1-en.txt + +//------------------------------------ +if (isdef("genlib") == %f) then + exec(SCI+"/modules/functions/scripts/buildmacros/loadgenlib.sce"); +end +//------------------------------------ +genlib("m2scikernellib","SCI/modules/m2sci/macros/kernel",%f,%t); +//------------------------------------ diff --git a/modules/m2sci/macros/kernel/changevarname.bin b/modules/m2sci/macros/kernel/changevarname.bin new file mode 100755 index 000000000..44c51a08a Binary files /dev/null and b/modules/m2sci/macros/kernel/changevarname.bin differ diff --git a/modules/m2sci/macros/kernel/changevarname.sci b/modules/m2sci/macros/kernel/changevarname.sci new file mode 100755 index 000000000..00e3837ff --- /dev/null +++ b/modules/m2sci/macros/kernel/changevarname.sci @@ -0,0 +1,63 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2004-2006 - INRIA - Farid BELAHCENE +// +// 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.1-en.txt + +function changevarname(fun,oldname,newname) + // This function replaces the variable (named oldname) of a file by a new name (which is newname). It uses the old2newinstr function + // INPUTS: + // -fun: a string, the name (with the whole path) of the modifed file + // -oldname: a string, the old name of the variable + // -newname: a string, the new name of the variable after modification + + sep=filesep(); + + sep_ind=strindex(fun,sep); + dot_ind=strindex(fun,"."); + + // funname is the function name (without the path and the extension) + funname=part(fun,sep_ind($)+1:dot_ind($)-1); + + if sep_ind<>[] + funsave=part(fun,1:sep_ind($))+"save_"+part(fun,sep_ind($)+1:dot_ind($)-1)+".sci"; + else + funsave="save_"+part(fun,sep_ind($)+1:dot_ind($)-1)+".sci"; + end + + // Compilation + exec(fun); + var=who("get"); + indvar=find(var==funname); + funvect=var(indvar(1):-1:1); + txt=mgetl(fun); + mputl(txt,funsave); + + txt=[] + for j=1:size(funvect,1) + //Get the tree of the function + execstr("tree=macr2tree("+funvect(j)+")"); + // Change oldname into newname in the tree + if tree.name==oldname then + tree.name=newname; + end + for i=1:size(tree.inputs) + tree.inputs(i)=old2newinstr(tree.inputs(i),oldname,newname); + end + for i=1:size(tree.outputs) + tree.outputs(i)=old2newinstr(tree.outputs(i),oldname,newname); + end + for i=1:size(tree.statements) + tree.statements(i)=old2newinstr(tree.statements(i),oldname,newname); + end + + // Get the matching code of the tree after modification + txt=[txt; tree2code(tree,%T)]; + end + + // Replace the old code by the new code (which is txt) in the file fun + mputl(txt,fun); +endfunction \ No newline at end of file diff --git a/modules/m2sci/macros/kernel/clause2sci.bin b/modules/m2sci/macros/kernel/clause2sci.bin new file mode 100755 index 000000000..2690bd04d Binary files /dev/null and b/modules/m2sci/macros/kernel/clause2sci.bin differ diff --git a/modules/m2sci/macros/kernel/clause2sci.sci b/modules/m2sci/macros/kernel/clause2sci.sci new file mode 100755 index 000000000..a50a74bef --- /dev/null +++ b/modules/m2sci/macros/kernel/clause2sci.sci @@ -0,0 +1,385 @@ +// 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.1-en.txt + +function [sci_clause,nblines]=clause2sci(mtlb_clause,nblines,leveltemp) + // M2SCI function + + // Global variables for M2SCI + global("m2sci_to_insert_b") + global("varslist") + + // Increment level of clause indentation + level + + // Temp variable used to store instructions to insert before clause + to_insert=list() + select typeof(mtlb_clause) + // --- TRYCATCH --- + case "trycatch" + level=[level;0] + + // Get instructions to insert if there are + if m2sci_to_insert_b<>list() then + to_insert=m2sci_to_insert_b + m2sci_to_insert_b=list() + end + + // Convert try + sci_try=list() + level($)=level($)+1 + for k=1:size(mtlb_clause.trystat) + if typeof(mtlb_clause.trystat(k))=="sup_equal" then + sci_try_temp=list() + for i=1:size(mtlb_clause.trystat(k).sup_instr) + [instr,nblines]=instruction2sci(mtlb_clause.trystat(k).sup_instr(i),nblines) + sci_try_temp=update_instr_list(sci_try_temp,instr) + end + sci_try($+1)=tlist(["sup_equal","sup_instr","nb_opr"],sci_try_temp,mtlb_clause.trystat(k).nb_opr) + else + [instr,nblines]=instruction2sci(mtlb_clause.trystat(k),nblines) + sci_try=update_instr_list(sci_try,instr) + end + end + + // Convert catch + sci_catch=list() + level($)=level($)+1 + for k=1:size(mtlb_clause.catchstat) + if typeof(mtlb_clause.catchstat(k))=="sup_equal" then + sci_catch_temp=list() + for i=1:size(mtlb_clause.catchstat(k).sup_instr) + [instr,nblines]=instruction2sci(mtlb_clause.catchstat(k).sup_instr(i),nblines) + sci_catch_temp=update_instr_list(sci_catch_temp,instr) + end + sci_catch($+1)=tlist(["sup_equal","sup_instr","nb_opr"],sci_catch_temp,mtlb_clause.catchstat(k).nb_opr) + else + [instr,nblines]=instruction2sci(mtlb_clause.catchstat(k),nblines) + sci_catch=update_instr_list(sci_catch,instr) + end + end + + // Create Scilab trycatch + sci_clause=tlist(["trycatch","trystat","catchstat"],sci_try,sci_catch) + level($)=level($)+1 + updatevarslist("END OF CLAUSE") + + // --- IF --- + case "ifthenelse" + level=[level;0] + + // Convert expression + [sci_expr]=expression2sci(mtlb_clause.expression) + + // Get instructions to insert if there are + if m2sci_to_insert_b<>list() then + to_insert=m2sci_to_insert_b + m2sci_to_insert_b=list() + end + + // Convert then statements + sci_then=list() + level($)=level($)+1 + for k=1:size(mtlb_clause.then) + if typeof(mtlb_clause.then(k))=="sup_equal" then + sci_then_temp=list() + for i=1:size(mtlb_clause.then(k).sup_instr) + [instr,nblines]=instruction2sci(mtlb_clause.then(k).sup_instr(i),nblines) + sci_then_temp=update_instr_list(sci_then_temp,instr) + end + sci_then($+1)=tlist(["sup_equal","sup_instr","nb_opr"],sci_then_temp,mtlb_clause.then(k).nb_opr) + else + [instr,nblines]=instruction2sci(mtlb_clause.then(k),nblines) + sci_then=update_instr_list(sci_then,instr) + end + end + + // Convert elseifs + sci_elseifs=list() + for k=1:size(mtlb_clause.elseifs) + level($)=level($)+1 + + // Convert expression + [sci_exprn]=expression2sci(mtlb_clause.elseifs(k).expression) + + // Get instructions to insert if there are + if m2sci_to_insert_b<>list() then + to_insert=m2sci_to_insert_b + m2sci_to_insert_b=list() + end + + // Convert statements + sci_stat=list() + for l=1:size(mtlb_clause.elseifs(k).then) + if typeof(mtlb_clause.elseifs(k).then(l))=="sup_equal" then + sci_stat_temp=list() + for i=1:size(mtlb_clause.elseifs(k).then(l).sup_instr) + [instr,nblines]=instruction2sci(mtlb_clause.elseifs(k).then(l).sup_instr(i),nblines) + sci_stat_temp=update_instr_list(sci_stat_temp,instr) + end + sci_stat($+1)=tlist(["sup_equal","sup_instr","nb_opr"],sci_stat_temp,mtlb_clause.elseifs(k).then(l).nb_opr) + else + [instr,nblines]=instruction2sci(mtlb_clause.elseifs(k).then(l),nblines) + sci_stat=update_instr_list(sci_stat,instr) + end + end + sci_elseifs($+1)=tlist(["elseif","expression","then"],sci_exprn,sci_stat) + end + + // Convert else + sci_else=list() + if size(mtlb_clause.else)<>0 then + level($)=level($)+1 + end + for k=1:size(mtlb_clause.else) + if typeof(mtlb_clause.else(k))=="sup_equal" then + sci_else_temp=list() + for i=1:size(mtlb_clause.else(k).sup_instr) + [instr,nblines]=instruction2sci(mtlb_clause.else(k).sup_instr(i),nblines) + sci_else_temp=update_instr_list(sci_else_temp,instr) + end + sci_else($+1)=tlist(["sup_equal","sup_instr","nb_opr"],sci_else_temp,mtlb_clause.else(k).nb_opr) + else + [instr,nblines]=instruction2sci(mtlb_clause.else(k),nblines) + sci_else=update_instr_list(sci_else,instr) + end + end + + // Create Scilab ifthenelse + sci_clause=tlist(["ifthenelse","expression","then","elseifs","else"],sci_expr,sci_then,sci_elseifs,sci_else) + level($)=level($)+1 + updatevarslist("END OF CLAUSE") + + // --- SELECT --- + case "selectcase" + level=[level;0] + // Convert expression + sci_expr=list() + [sci_expr(1)]=expression2sci(mtlb_clause.expression(1)) + for i=2:size(mtlb_clause.expression) + sci_expr(i)=mtlb_clause.expression(i) // EOL or comment + end + + // Get instructions to insert if there are + if m2sci_to_insert_b<>list() then + to_insert=m2sci_to_insert_b + m2sci_to_insert_b=list() + end + + // Convert cases + sci_cases=list() + k=0 + while klist() then + to_insert=m2sci_to_insert_b + m2sci_to_insert_b=list() + end + + // Convert statements + sci_stat=list() + for l=1:size(mtlb_clause.cases(k).then) + if typeof(mtlb_clause.cases(k).then(l))=="sup_equal" then + sci_stat_temp=list() + for i=1:size(mtlb_clause.cases(k).then(l).sup_instr) + [instr,nblines]=instruction2sci(mtlb_clause.cases(k).then(l).sup_instr(i),nblines) + sci_stat_temp=update_instr_list(sci_stat_temp,instr) + end + sci_stat($+1)=tlist(["sup_equal","sup_instr","nb_opr"],sci_stat_temp,mtlb_clause.cases(k).then(l).nb_opr) + else + [instr,nblines]=instruction2sci(mtlb_clause.cases(k).then(l),nblines) + sci_stat=update_instr_list(sci_stat,instr) + end + end + sci_cases($+1)=tlist(["case","expression","then"],sci_exprn,sci_stat) + end + + // Convert else + sci_else=list() + if size(mtlb_clause.else)<>0 then + level($)=level($)+1 + end + for k=1:size(mtlb_clause.else) + if typeof(mtlb_clause.else(k))=="sup_equal" then + sci_else_temp=list(); + for i=1:size(mtlb_clause.else(k).sup_instr) + [instr,nblines]=instruction2sci(mtlb_clause.else(k).sup_instr(i),nblines) + sci_else_temp=update_instr_list(sci_else_temp,instr) + end + sci_else($+1)=tlist(["sup_equal","sup_instr","nb_opr"],sci_else_temp,mtlb_clause.else(k).nb_opr) + else + [instr,nblines]=instruction2sci(mtlb_clause.else(k),nblines) + sci_else=update_instr_list(sci_else,instr) + end + end + // Create Scilab selectcase + sci_clause=tlist(["selectcase","expression","cases","else"],sci_expr,sci_cases,sci_else) + level($)=level($)+1 + updatevarslist("END OF CLAUSE") + + // --- WHILE --- + case "while" + level=[level;0] + sci_do=list() + // Convert expression + [sci_expr]=expression2sci(mtlb_clause.expression) + // If there are instructions to insert, while is modified so that inserted instruction is evaluated in each loop + if m2sci_to_insert_b<>list() then + newif=tlist(["ifthenelse","expression","then","elseifs","else"],sci_expr,list(Funcall("break",1,list(),list())),list(),list()) + m2sci_to_insert_b($+1)=newif + sci_expr=Cste(%T) + sci_do=m2sci_to_insert_b + m2sci_to_insert_b=list() + end + + // Convert all do instructions + level($)=level($)+1 + for k=1:size(mtlb_clause.statements) + if typeof(mtlb_clause.statements(k))=="sup_equal" then + sci_do_temp=list() + for i=1:size(mtlb_clause.statements(k).sup_instr) + [instr,nblines]=instruction2sci(mtlb_clause.statements(k).sup_instr(i),nblines) + // If inserted instruction is an initialisation, it has to be done just one time and before loop + l=1; + while l<=lstsize(m2sci_to_insert_b) + if typeof(m2sci_to_insert_b(l))=="equal" & .. + (and(m2sci_to_insert_b(l).expression==Cste([])) | .. + and(m2sci_to_insert_b(l).expression==Funcall("struct",1,list(),list())) | .. + and(m2sci_to_insert_b(l).expression==Funcall("cell",1,list(),list())) ) then + to_insert($+1)=m2sci_to_insert_b(l) + m2sci_to_insert_b(l)=null() + if lstsize(m2sci_to_insert_b)>=l & m2sci_to_insert_b(l)==list("EOL") then + to_insert($+1)=m2sci_to_insert_b(l) + m2sci_to_insert_b(l)=null() + end + else + l=l+1; + end + end + sci_do_temp=update_instr_list(sci_do_temp,instr) + end + sci_do($+1)=tlist(["sup_equal","sup_instr","nb_opr"],sci_do_temp,mtlb_clause.statements(k).nb_opr) + else + [instr,nblines]=instruction2sci(mtlb_clause.statements(k),nblines) + // If inserted instruction is an initialisation, it has to be done just one time and before loop + l=1; + while l<=lstsize(m2sci_to_insert_b) + if typeof(m2sci_to_insert_b(l))=="equal" & .. + (and(m2sci_to_insert_b(l).expression==Cste([])) | .. + and(m2sci_to_insert_b(l).expression==Funcall("struct",1,list(),list())) | .. + and(m2sci_to_insert_b(l).expression==Funcall("cell",1,list(),list())) ) then + to_insert($+1)=m2sci_to_insert_b(l) + m2sci_to_insert_b(l)=null() + if lstsize(m2sci_to_insert_b)>=l & m2sci_to_insert_b(l)==list("EOL") then + to_insert($+1)=m2sci_to_insert_b(l) + m2sci_to_insert_b(l)=null() + end + else + l=l+1; + end + end + sci_do=update_instr_list(sci_do,instr) + end + end + + // Create Scilab while + sci_clause=tlist(["while","expression","statements"],sci_expr,sci_do) + level($)=level($)+1 + updatevarslist("END OF CLAUSE") + + // --- FOR --- + case "for" + //level=[level;1] + // Convert expression + [sci_expr,nblines]=instruction2sci(mtlb_clause.expression,nblines) + if typeof(sci_expr)=="equal" then + [bval,pos]=isdefinedvar(sci_expr.lhs(1)) + if bval then + varslist(pos).infer.dims=list(varslist(pos).infer.dims(1),1) + end + end + // Get instructions to insert if there are + if m2sci_to_insert_b<>list() then + to_insert=m2sci_to_insert_b + m2sci_to_insert_b=list() + end + sci_instr=list() + // Convert all do instructions + for k=1:size(mtlb_clause.statements) + if typeof(mtlb_clause.statements(k))=="sup_equal" then + sci_instr_temp=list() + for i=1:size(mtlb_clause.statements(k).sup_instr) + [instr,nblines]=instruction2sci(mtlb_clause.statements(k).sup_instr(i),nblines) + // If inserted instruction is an initialisation, it has to be done just one time and before loop + l=1; + while l<=lstsize(m2sci_to_insert_b) + if typeof(m2sci_to_insert_b(l))=="equal" & .. + (and(m2sci_to_insert_b(l).expression==Cste([])) | .. + and(m2sci_to_insert_b(l).expression==Funcall("struct",1,list(),list())) | .. + and(m2sci_to_insert_b(l).expression==Funcall("cell",1,list(),list())) ) then + to_insert($+1)=m2sci_to_insert_b(l) + m2sci_to_insert_b(l)=null() + if lstsize(m2sci_to_insert_b)>=l & m2sci_to_insert_b(l)==list("EOL") then + to_insert($+1)=m2sci_to_insert_b(l) + m2sci_to_insert_b(l)=null() + end + else + l=l+1; + end + end + sci_instr_temp=update_instr_list(sci_instr_temp,instr) + end + sci_instr($+1)=tlist(["sup_equal","sup_instr","nb_opr"],sci_instr_temp,mtlb_clause.statements(k).nb_opr) + else + [instr,nblines]=instruction2sci(mtlb_clause.statements(k),nblines) + // If inserted instruction is an initialisation, it has to be done just one time and before loop + l=1; + while l<=lstsize(m2sci_to_insert_b) + if typeof(m2sci_to_insert_b(l))=="equal" & .. + (and(m2sci_to_insert_b(l).expression==Cste([])) | .. + and(m2sci_to_insert_b(l).expression==Funcall("struct",1,list(),list())) | .. + and(m2sci_to_insert_b(l).expression==Funcall("cell",1,list(),list())) ) then + to_insert($+1)=m2sci_to_insert_b(l) + m2sci_to_insert_b(l)=null() + if lstsize(m2sci_to_insert_b)>=l & m2sci_to_insert_b(l)==list("EOL") then + to_insert($+1)=m2sci_to_insert_b(l) + m2sci_to_insert_b(l)=null() + end + else + l=l+1; + end + end + sci_instr=update_instr_list(sci_instr,instr) + end + end + // Create Scilab while + sci_clause=tlist(["for","expression","statements"],sci_expr,sci_instr) + else + error(msprintf(gettext("unknown clause type: %s."),typeof(mtlb_clause))) + end + m2sci_to_insert_b=to_insert + if m2sci_to_insert_b<>list() then + m2sci_to_insert_b($+1)=list("EOL"); + end +endfunction diff --git a/modules/m2sci/macros/kernel/convert2double.bin b/modules/m2sci/macros/kernel/convert2double.bin new file mode 100755 index 000000000..2161e1b88 Binary files /dev/null and b/modules/m2sci/macros/kernel/convert2double.bin differ diff --git a/modules/m2sci/macros/kernel/convert2double.sci b/modules/m2sci/macros/kernel/convert2double.sci new file mode 100755 index 000000000..1933dac57 --- /dev/null +++ b/modules/m2sci/macros/kernel/convert2double.sci @@ -0,0 +1,40 @@ +// 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.1-en.txt + +function [dble]=convert2double(A) + // This function converts input parameters to double to avoid to write overloading functions in Scilab + + lhs=argn(1) + + if A.vtype==Double then + dble=A + return + end + + if only_double then + dble=A + dble.type=Type(Double,Unknown) + else + if A.vtype==String then + lhslist=list(); + lhslist($+1)=Variable("ans",Infer(A.dims,Type(Double,Real))) + dble=Funcall("asciimat",1,Rhs_tlist(A),lhslist) + elseif A.vtype==Boolean then + lhslist=list(); + lhslist($+1)=Variable("ans",Infer(A.dims,Type(Double,Real))) + dble=Funcall("bool2s",1,Rhs_tlist(A),lhslist) + elseif A.vtype==Unknown then + lhslist=list(); + lhslist($+1)=Variable("ans",Infer(A.dims,Type(Double,Unknown))) + dble=Funcall("mtlb_double",1,Rhs_tlist(A),lhslist) + else + error(msprintf(gettext("%s is not yet implemented."),string(A.vtype))) + end + end +endfunction diff --git a/modules/m2sci/macros/kernel/default_trad.bin b/modules/m2sci/macros/kernel/default_trad.bin new file mode 100755 index 000000000..a0312b06d Binary files /dev/null and b/modules/m2sci/macros/kernel/default_trad.bin differ diff --git a/modules/m2sci/macros/kernel/default_trad.sci b/modules/m2sci/macros/kernel/default_trad.sci new file mode 100755 index 000000000..4d9868308 --- /dev/null +++ b/modules/m2sci/macros/kernel/default_trad.sci @@ -0,0 +1,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.1-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 function is in a matlab toolbox, 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 + + + + + + + + + + + + + + + + diff --git a/modules/m2sci/macros/kernel/equal2sci.bin b/modules/m2sci/macros/kernel/equal2sci.bin new file mode 100755 index 000000000..6cbf3980c Binary files /dev/null and b/modules/m2sci/macros/kernel/equal2sci.bin differ diff --git a/modules/m2sci/macros/kernel/equal2sci.sci b/modules/m2sci/macros/kernel/equal2sci.sci new file mode 100755 index 000000000..9b2bebc0e --- /dev/null +++ b/modules/m2sci/macros/kernel/equal2sci.sci @@ -0,0 +1,158 @@ +// 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.1-en.txt + +function [sci_instr]=equal2sci(mtlb_instr) + // Convertion of a Matlab instruction or expression to Scilab + // Input: + // - mtlb_instr: Matlab instr or expression to convert + // Output: + // - sci_instr: Scilab equivalent for mtlb_instr + + // Trees to insert in converted function tree + global("m2sci_to_insert_b") + m2sci_to_insert_b=list() + global("m2sci_to_insert_a") + m2sci_to_insert_a=list() + global("varslist") + + sci_instr=mtlb_instr + + // Add inference data to lhs + lhslist=list() + + // Inference field added to each lhs argument + // Get infos in varslist to init + for k=1:size(mtlb_instr.lhs) + if typeof(mtlb_instr.lhs(k))=="variable" then + [bval,index]=isdefinedvar(mtlb_instr.lhs(k)) + if bval then + INFER=varslist(index).infer + else + INFER=Infer() + end + lhslist($+1)=Variable(mtlb_instr.lhs(k).name,INFER) + elseif typeof(mtlb_instr.lhs(k))=="operation" then + if mtlb_instr.lhs(k).operator<>"ins" then + error(msprintf(gettext("lhs cannot be a %s operation."),mtlb_instr.lhs(k).operator)) + end + + [bval,index]=isdefinedvar(mtlb_instr.lhs(k).operands(1)) + if bval then + INFER=varslist(index).infer + else + INFER=Infer() + end + + lhslist($+1)=Operation(mtlb_instr.lhs(k).operator,.. + mtlb_instr.lhs(k).operands,.. + list(Variable(mtlb_instr.lhs(k).operands(1).name,INFER))) + else + error(msprintf(gettext("lhs cannot be a %s."),typeof(mtlb_instr.lhs(k)))) + end + end + + // Convert expression + + [sci_expr]=expression2sci(mtlb_instr.expression,lhslist); + + if sci_expr==list() then // Conversion made by inserted instructions or 'm2scideclare' + sci_instr=list() + else + + sci_instr.expression=sci_expr; + + // Update lhs of instruction + select typeof(sci_instr.expression) + case "operation" then + sci_instr.lhs=sci_expr.out; + case "funcall" then + sci_instr.lhs=sci_instr.expression.lhs + if typeof(mtlb_instr.expression)=="funcall" then + sci_instr.lhs=sci_expr.lhs; + end + case "cste" then + sci_instr.lhs=lhslist; + sci_instr.lhs(1).dims=sci_expr.dims; + sci_instr.lhs(1).type=sci_expr.type; + case "variable" then + sci_instr.lhs=lhslist; + sci_instr.lhs(1).dims=sci_expr.dims; + sci_instr.lhs(1).type=sci_expr.type; + else + error(msprintf(gettext("%s is not yet implemented."),typeof(sci_instr.expression))); + end + + // If lhs are insertion operation, they also have to be converted + for k=1:size(sci_instr.lhs) + if typeof(sci_instr.lhs(k))=="operation" then + sci_instr.lhs(k).operands($+1)=sci_instr.expression + // Keep just one inference field in sci_instr.expression (if is a funcall) so that inference can be made in operation2sci() + if typeof(sci_instr.lhs(k).operands($))=="funcall" then + for l=1:size(sci_instr.lhs(k).operands($).lhs) + if l<>k then + sci_instr.lhs(k).operands($).lhs(l)=list() + end + end + l=1 + while l<=size(sci_instr.lhs(k).operands($).lhs) + if sci_instr.lhs(k).operands($).lhs(l)==list() then + sci_instr.lhs(k).operands($).lhs(l)=null() + else + l=l+1 + end + end + // Verify that there is just one lhs kept + if size(sci_instr.lhs(k).operands($).lhs)<>1 then pause;end + end + // If insertion made in an unknown variable, I add it to varslist + inservar=sci_instr.lhs(k).operands(1) + [bval,index]=isdefinedvar(inservar) + if ~bval then + // Variable added to varslist before insertion + if funptr(inservar.name)<>0 then + matname="%"+inservar.name + else + matname=inservar.name + end + if sci_instr.expression.vtype==Struct then + // Variable is initialized to struct() in converted script is does not already exist + varslist($+1)=M2scivar(matname,inservar.name,Infer(list(0,0),Type(Struct,Unknown))) + //m2sci_to_insert_b($+1)=Equal(list(inservar),Funcall("struct",1,list(),list())) + elseif sci_instr.expression.vtype==Cell then + // Variable is initialized to cell() in converted script is does not already exist + varslist($+1)=M2scivar(matname,inservar.name,Infer(list(0,0),Type(Cell,Unknown))) + //m2sci_to_insert_b($+1)=Equal(list(inservar),Funcall("cell",1,list(),list())) + else + // Variable is initialized to [] in converted script is does not already exist + varslist($+1)=M2scivar(matname,inservar.name,Infer(list(0,0),Type(Double,Real))) + //m2sci_to_insert_b($+1)=Equal(list(inservar),Cste([])) + end + sci_instr.lhs(k).out(1).infer=varslist($).infer + else + sci_instr.lhs(k).out(1).infer=varslist(index).infer + end + [sci_instr.lhs(k)]=operation2sci(sci_instr.lhs(k)) + if typeof(sci_instr.lhs(k))=="operation" then + if or(sci_instr.lhs(k).operands($)<>sci_instr.expression) then // Update expression if has been modified while converting lhs + sci_instr.expression=sci_instr.lhs(k).operands($) + end + + sci_instr.lhs(k).operands($)=null() + updatevarslist(sci_instr.lhs(k).out) + else + // Insertion done by inserted instruction + sci_instr=list() + return + end + end + end + // Update varslist + updatevarslist(sci_instr.lhs); + end +endfunction diff --git a/modules/m2sci/macros/kernel/expression2sci.bin b/modules/m2sci/macros/kernel/expression2sci.bin new file mode 100755 index 000000000..aa20981dd Binary files /dev/null and b/modules/m2sci/macros/kernel/expression2sci.bin differ diff --git a/modules/m2sci/macros/kernel/expression2sci.sci b/modules/m2sci/macros/kernel/expression2sci.sci new file mode 100755 index 000000000..ded4e6b1f --- /dev/null +++ b/modules/m2sci/macros/kernel/expression2sci.sci @@ -0,0 +1,132 @@ +// 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.1-en.txt + +function [sci_expr]=expression2sci(mtlb_expr,lhslist) + // M2SCI function + + // Global variable for M2SCI + global("varslist") + + // When lhslist is given, then expression2sci is called from equal2sci + // else it is called from an other function (clause2sci for example) + rhs=argn(2); + // If not given, lhslist is initialized with no name lhs + if rhs==1 then + if typeof(mtlb_expr)=="funcall" then + lhsnb=mtlb_expr.lhsnb; + else + lhsnb=1; + end + lhslist=list(); + for k=1:lhsnb + lhslist($+1)=Variable("ans",Infer()); + end + end + + select typeof(mtlb_expr) + // --- Expression is an 'operation' tlist --- + case "operation" + // Add inference fields to operation + mtlb_expr=Operation(mtlb_expr.operator,mtlb_expr.operands,lhslist) + + // Translation + [sci_expr]=operation2sci(mtlb_expr) + + // --- Expression is a 'funcall' tlist --- + case "funcall" + + // Particular case if expression is a call to 'm2scideclare' + if mtlb_expr.name=="m2scideclare" then + sci_expr=list() + // varslist is updated with user defined data + sci_m2scideclare(mtlb_expr) + + // Particular case if expression is a call to 'comment' + elseif mtlb_expr.name=="%comment" then + // Add inference fields to funcall + sci_expr=Funcall(mtlb_expr.name,mtlb_expr.lhsnb,mtlb_expr.rhs,lhslist) + // All other 'funcall' expressions + else + // Add inference fields to funcall + mtlb_expr=Funcall(mtlb_expr.name,mtlb_expr.lhsnb,mtlb_expr.rhs,lhslist) + + // Translation + [sci_expr]=funcall2sci(mtlb_expr) + end + + // --- Expression is a 'cste' tlist --- + case "cste" + // Convert expression + sci_expr=Cste(mtlb_expr.value) + + // --- Expression is a 'variable' tlist --- + case "variable" + [bval,index]=isdefinedvar(mtlb_expr) + + // Variable already exists + if bval then + sci_expr=Variable(varslist(index).sciname,varslist(index).infer) + // Variable is unknown + else + // Try to find what is this variable + [sci_expr]=getvar2sci(mtlb_expr,lhslist) + if typeof(sci_expr)=="funcall" then + if typeof(lhslist(1))=="variable" & sci_expr.name==lhslist(1).name then // Used for commands such as keyboard, cputime... + // keyboard in an M-file is represented in tree by an equal with lhs=keyboard and expression=keyboard + sci_expr.lhs(1).name="ans" + elseif typeof(lhslist(1))=="variable" & mtlb_expr.name==lhslist(1).name then // When command converted by mtlb(cmd_name) + sci_expr.lhs(1).name="ans" + end + if sci_expr.name<>"mtlb" then + [sci_expr]=funcall2sci(sci_expr) + end + end + end + // --- operand is a list (only for operations) --- + case "list" + if lstsize(mtlb_expr)==1 & mtlb_expr==list("EOL") then + sci_expr=mtlb_expr + return + end + for k=1:size(mtlb_expr) + if typeof(mtlb_expr(k))=="cste" then + mtlb_expr(k)=Cste(mtlb_expr(k).value) + elseif typeof(mtlb_expr(k))=="variable" then + [isvar,index]=isdefinedvar(mtlb_expr(k)) + if isvar then + mtlb_expr(k)=Variable(mtlb_expr(k).name,varslist(index).infer) + else + mtlb_expr(k)=Variable(mtlb_expr(k).name,Infer()) + end + elseif typeof(mtlb_expr(k))=="list" then + [mtlb_expr(k)]=expression2sci(mtlb_expr(k),lhslist) + elseif typeof(mtlb_expr(k))=="operation" then + [mtlb_expr(k)]=expression2sci(mtlb_expr(k),lhslist) + elseif typeof(mtlb_expr(k))=="funcall" then + [mtlb_expr(k)]=expression2sci(mtlb_expr(k),lhslist) + else + error(msprintf(gettext("recursive extraction with one index of type %s is not yet implemented."),typeof(mtlb_expr(k)))) + end + end + sci_expr=mtlb_expr + // --- operand is a comment --- + case "comment" + sci_expr=mtlb_expr + // --- Expression is a not tolerated tlist --- + else + error(msprintf(gettext("%s is not yet implemented."),typeof(mtlb_expr))) + end + + // Verify if flag for translation improvements has to be set + if typeof(sci_expr)=="funcall" then + if part(sci_expr.name,1:4)=="mtlb" then + m2sci_infos(1)=%t // level 1 = improvements + end + end +endfunction diff --git a/modules/m2sci/macros/kernel/first_non_singleton.bin b/modules/m2sci/macros/kernel/first_non_singleton.bin new file mode 100755 index 000000000..168324531 Binary files /dev/null and b/modules/m2sci/macros/kernel/first_non_singleton.bin differ diff --git a/modules/m2sci/macros/kernel/first_non_singleton.sci b/modules/m2sci/macros/kernel/first_non_singleton.sci new file mode 100755 index 000000000..4d5d80747 --- /dev/null +++ b/modules/m2sci/macros/kernel/first_non_singleton.sci @@ -0,0 +1,26 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function dim=first_non_singleton(m2scitlist) + dim=-1 + if is_a_scalar(m2scitlist) | is_a_vector(m2scitlist) then + dim=0; + return + end + for k=1:size(m2scitlist.dims) + if m2scitlist.dims(k)==0 then + dim=0 + break + elseif m2scitlist.dims(k)>0 & m2scitlist.dims(k)<>1 then + dim=k + break + end + end + +endfunction diff --git a/modules/m2sci/macros/kernel/funcall2sci.bin b/modules/m2sci/macros/kernel/funcall2sci.bin new file mode 100755 index 000000000..1b06ecd50 Binary files /dev/null and b/modules/m2sci/macros/kernel/funcall2sci.bin differ diff --git a/modules/m2sci/macros/kernel/funcall2sci.sci b/modules/m2sci/macros/kernel/funcall2sci.sci new file mode 100755 index 000000000..56a2af907 --- /dev/null +++ b/modules/m2sci/macros/kernel/funcall2sci.sci @@ -0,0 +1,98 @@ +// 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.1-en.txt + +function [sci_equiv]=funcall2sci(mtlb_expr) + // M2SCI function + // Convert a function call in an instruction or in an expression from Matlab to Scilab + // Input: + // - mtlb_instr: Matlab instr or expression to convert + // Output: + // - sci_instr: Scilab equivalent for mtlb_instr + + rhslist=mtlb_expr.rhs + if rhslist==[] then // Function called as a command + rhsnb=-1 + rhslist=list() + mtlb_expr.rhs=list() + else + rhsnb=size(rhslist) + end + // Init returned value + sci_expr=mtlb_expr + + rhsind=1 + while rhsind<=rhsnb + [sci_equiv]=expression2sci(rhslist(rhsind)); + mtlb_expr.rhs(rhsind)=sci_equiv; + rhsind=rhsind+1; + end + + // Performs the conversion of function call + lhs=mtlb_expr.lhsnb + if rhsnb==-1 then + rhs=-1 + else + rhs=size(mtlb_expr.rhs) + end + funname=mtlb_expr.name + + // If a translation function exists + if exists("sci_"+funname)==1 then + execstr("[sci_equiv]=sci_"+funname+"(mtlb_expr)"); + // If I don't know where I can search other M-files + elseif res_path==[] then + sci_equiv=default_trad(mtlb_expr) + else + sci_tmpfile =pathconvert(TMPDIR)+pathconvert(fnam)+"sci_"+funname+".sci" + tmpierr=execstr("exec(sci_tmpfile,-1)","errcatch");errclear(); + sci_file=res_path+"sci_"+funname+".sci" + ierr=execstr("exec(sci_file,-1)","errcatch");errclear(); + if tmpierr==0 then + execstr("[sci_equiv]=sci_"+mtlb_expr.name+"(mtlb_expr)"); + // If a translation function exists + elseif ierr==0 then + execstr("[sci_equiv]=sci_"+mtlb_expr.name+"(mtlb_expr)"); + // If no translation indication given + elseif Recmode then + // Check if the M-file exists in the given paths + path=mfile_path(funname) + if path==[] then + sci_equiv=default_trad(mtlb_expr) + elseif or(funname==nametbl) + sci_equiv=sci_generic(mtlb_expr) + else + fnam=funname + scipath=res_path+fnam+".sci" + scepath=res_path+fnam+".sce" + catpath=res_path+fnam+".cat" + res=0 + if newest(path,scipath,scepath)==1 then + res=mfile2sci(path,res_path,%F,%T) + end + if res==1 then + exec(sci_file, -1) + ierr=execstr("[sci_equiv]=sci_"+mtlb_expr.name+"(mtlb_expr)","errcatch"); + if ierr<>0 then + error(msprintf(gettext("Error while executing : [sci_equiv]=sci_%s(mtlb_expr)."),mtlb_expr.name)); + end + else + sci_equiv=default_trad(mtlb_expr) + end + end + else // Default translation + sci_equiv=default_trad(mtlb_expr) + end + end + + // If equivalent is a funcall, number of lhs can have changed + if typeof(sci_equiv)=="funcall" then + sci_equiv.lhsnb=size(sci_equiv.lhs) + end + +endfunction diff --git a/modules/m2sci/macros/kernel/funcallsearch.bin b/modules/m2sci/macros/kernel/funcallsearch.bin new file mode 100755 index 000000000..857a7dd71 Binary files /dev/null and b/modules/m2sci/macros/kernel/funcallsearch.bin differ diff --git a/modules/m2sci/macros/kernel/funcallsearch.sci b/modules/m2sci/macros/kernel/funcallsearch.sci new file mode 100755 index 000000000..3b96282e2 --- /dev/null +++ b/modules/m2sci/macros/kernel/funcallsearch.sci @@ -0,0 +1,104 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function [funcallname,variablename]=funcallsearch(instr,funcallname,fnamvect,variablename) + // + // FUNCALLSEARCH recursive function (used by "translatepaths" function) + // Searches the functions names in each instruction of mtlbtree + // Input-Output + // -funcallname : a vector which contains the names of called functions if it exists a M-file having the same name in the Paths + // -variablename : a vector which contains the names of declared variables + // Input + // -instr : mtlbtree instruction + // -fnamvect : vector which contains all M-files names found in the Paths + + // case : ifthenelse instruction + if typeof(instr) == "ifthenelse" then + [funcallname,variablename]=funcallsearch(instr.expression,funcallname,fnamvect,variablename) + for i=1:size(instr.then) + [funcallname,variablename]=funcallsearch((instr.then(i)),funcallname,fnamvect,variablename) + end + for i=1:size(instr.elseifs) + for k=1:size(instr.elseifs(i).then) + [funcallname,variablename]=funcallsearch((instr.elseifs(i).then(k)),funcallname,fnamvect,variablename) + end + end + for i=1:size(instr.else) + [funcallname,variablename]=funcallsearch((instr.else(i)),funcallname,fnamvect,variablename) + end + // case : selectcase instruction + elseif typeof(instr) == "selectcase" then + [funcallname,variablename]=funcallsearch(instr.expression,funcallname,fnamvect,variablename) + + for i=1:size(instr.cases) + [funcallname,variablename]=funcallsearch((instr.cases(i).expression),funcallname,fnamvect,variablename) + for j=1:size(instr.cases(i).then) + [funcallname,variablename]=funcallsearch((instr.cases(i).then(j)),funcallname,fnamvect,variablename) + end + end + for i=1:size(instr.else) + [funcallname,variablename]=funcallsearch(instr.else(i),funcallname,fnamvect,variablename) + end + // case : while instruction + elseif typeof(instr) == "while" then + [funcallname,variablename]=funcallsearch(instr.expression,funcallname,fnamvect,variablename) + for i=1:size(instr.statements) + [funcallname,variablename]=funcallsearch(instr.statements(i),funcallname,fnamvect,variablename) + end + // case : for instruction + elseif typeof(instr) == "for" then + [funcallname,variablename]=funcallsearch(instr.expression,funcallname,fnamvect,variablename) + for i=1:size(instr.statements) + [funcallname,variablename]=funcallsearch(instr.statements(i),funcallname,fnamvect,variablename) + end + // case : cste instruction + elseif typeof(instr)== "cste" then + return + // case : variable instruction + elseif typeof(instr)=="variable" + if find(instr.name==variablename)==[] & find(instr.name==stripblanks(part(fnamvect,1:24)))<>[] & find(instr.name==funcallname)==[] then + funcallname=[funcallname;fnamvect(find(instr.name==stripblanks(part(fnamvect,1:24))))] + else + return + end + // case : equal instruction + elseif typeof(instr) == "equal" then + [funcallname,variablename]=funcallsearch(instr.expression,funcallname,fnamvect,variablename) + // case : expression is a funcall + elseif typeof(instr) == "funcall" then + if find(funcallname==instr.name) == [] & find(instr.name==stripblanks(part(fnamvect,1:24)))<>[] then + if size(find(instr.name==stripblanks(part(fnamvect,1:24))),2)==1 then + funcallname=[funcallname;fnamvect(find(instr.name==stripblanks(part(fnamvect,1:24))))] + else + findvect=find(instr.name==stripblanks(part(fnamvect,1:24))) + funcallname=[funcallname;fnamvect(findvect(2))] + st = " " + mtlbtree.name + ": " + fnamvect(findvect(1)) + for i=2:size(findvect,2) + st = st+ " <-> " + fnamvect(findvect(i)) + end + st = st + gettext(": The 24 first characters of the files names are equal: "); + warning(st) + end + end + // case : expression is cste + if typeof(instr.rhs)== "constant" then + return + else + for ind=1:size(instr.rhs) + [funcallname,variablename]=funcallsearch(instr.rhs(ind),funcallname,fnamvect,variablename) + end + end + // case : operation instruction + elseif typeof(instr) == "operation" then + for ind=1:size(instr.operands) + [funcallname,variablename]=funcallsearch(instr.operands(ind),funcallname,fnamvect,variablename) + end + end + +endfunction \ No newline at end of file diff --git a/modules/m2sci/macros/kernel/get_unknown.bin b/modules/m2sci/macros/kernel/get_unknown.bin new file mode 100755 index 000000000..aff5c164c Binary files /dev/null and b/modules/m2sci/macros/kernel/get_unknown.bin differ diff --git a/modules/m2sci/macros/kernel/get_unknown.sci b/modules/m2sci/macros/kernel/get_unknown.sci new file mode 100755 index 000000000..02f1181ee --- /dev/null +++ b/modules/m2sci/macros/kernel/get_unknown.sci @@ -0,0 +1,31 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function [sci_equiv]=get_unknown(varname,lhslist) + // Handle cases where varname appear in an expression while it is not known. + + // nam may be: + // - a variable created in an other clause part + // - a M-file called without args + // - a variable created by an eval + + // Check clause !!! + + // Check if it is a Matlab function not converted yet + if or(varname==not_yet_converted()) then + set_infos(msprintf(gettext("Matlab function %s not yet converted."),varname),2) + tmpvar=Variable(varname,Infer()) + sci_equiv=Funcall("mtlb",1,Rhs_tlist(tmpvar),lhslist) + else + // Other cases: I am not able to determine what is nam + set_infos(msprintf(gettext("mtlb(%s) can be replaced by %s() or %s whether %s is an M-file or not."),varname,varname,varname,varname),1) + tmpvar=Variable(varname,Infer()) + sci_equiv=Funcall("mtlb",1,Rhs_tlist(tmpvar),lhslist) + end +endfunction diff --git a/modules/m2sci/macros/kernel/getoperands.bin b/modules/m2sci/macros/kernel/getoperands.bin new file mode 100755 index 000000000..ed31252d0 Binary files /dev/null and b/modules/m2sci/macros/kernel/getoperands.bin differ diff --git a/modules/m2sci/macros/kernel/getoperands.sci b/modules/m2sci/macros/kernel/getoperands.sci new file mode 100755 index 000000000..b9f77eabf --- /dev/null +++ b/modules/m2sci/macros/kernel/getoperands.sci @@ -0,0 +1,24 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function [varargout] = getoperands(op_tree) + + varargout=list() + + if typeof(op_tree)<>"operation" then + error(gettext("input argument must be an ''operation'' tlist.")) + end + + opnb=size(op_tree.operands) + + for k=1:opnb + varargout(k)=op_tree.operands(k) + end + +endfunction diff --git a/modules/m2sci/macros/kernel/getrhs.bin b/modules/m2sci/macros/kernel/getrhs.bin new file mode 100755 index 000000000..9d2d21eec Binary files /dev/null and b/modules/m2sci/macros/kernel/getrhs.bin differ diff --git a/modules/m2sci/macros/kernel/getrhs.sci b/modules/m2sci/macros/kernel/getrhs.sci new file mode 100755 index 000000000..3401a22ce --- /dev/null +++ b/modules/m2sci/macros/kernel/getrhs.sci @@ -0,0 +1,24 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function [varargout] = getrhs(instr_tree) + + varargout=list() + + if typeof(instr_tree)<>"funcall" then + error(gettext("Wrong input argument in getrhs() (Must be a ''funcall'' tlist).")) + end + + rhsnb=size(instr_tree.rhs) + + for k=1:rhsnb + varargout(k)=instr_tree.rhs(k) + end + +endfunction diff --git a/modules/m2sci/macros/kernel/gettempvar.bin b/modules/m2sci/macros/kernel/gettempvar.bin new file mode 100755 index 000000000..43479e444 Binary files /dev/null and b/modules/m2sci/macros/kernel/gettempvar.bin differ diff --git a/modules/m2sci/macros/kernel/gettempvar.sci b/modules/m2sci/macros/kernel/gettempvar.sci new file mode 100755 index 000000000..699739779 --- /dev/null +++ b/modules/m2sci/macros/kernel/gettempvar.sci @@ -0,0 +1,35 @@ +// 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.1-en.txt + +function var=gettempvar(n) + // M2SCI function + // Create a temporary variable with name depending on clause level... + + global("tmpvarnb") + [lhs,rhs]=argn(0) + + varname="%v"+string(tmpvarnb) + tmpvarnb=tmpvarnb+1 + + // If in the expression of a clause then variable name is modified by adding level + if size(level,1)>1 then + if level(size(level,1))==0 then + varname=varname+string(size(level,1)) + elseif level(size(level,1))>0 then // If in statements of a clause then variable name is modified by adding _level + varname=varname+"_"+string(level(size(level,1))) + end + end + + // User is allowed to precise a variable number + if rhs==1 then + varname=varname+"$"+string(n) + end + + var=Variable(varname,Infer(list(0,0),Type())) +endfunction diff --git a/modules/m2sci/macros/kernel/getvar2sci.bin b/modules/m2sci/macros/kernel/getvar2sci.bin new file mode 100755 index 000000000..6796fa65e Binary files /dev/null and b/modules/m2sci/macros/kernel/getvar2sci.bin differ diff --git a/modules/m2sci/macros/kernel/getvar2sci.sci b/modules/m2sci/macros/kernel/getvar2sci.sci new file mode 100755 index 000000000..caf989093 --- /dev/null +++ b/modules/m2sci/macros/kernel/getvar2sci.sci @@ -0,0 +1,63 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function [sci_equiv]=getvar2sci(var,lhslist) + // Translate the named variable acquisition + + // Global variable for M2SCI + global("varslist") + + rhs=argn(2) + if rhs<>2 then + error(gettext("Wrong number of inputs.")) + end + + // Search variable name in variable name table + [boolval,index]=isdefinedvar(var) + varname=var.name + + // Variable is not defined yet + if ~boolval then + scinam=varname + + // If Matlab variable name is a function name in Scilab + if funptr(varname)<>0 then + scinam="%"+varname + end + + // Undefined variable may be a M-file or a global variable + // Check if a corresponding M-file exists here + if isanmfile(varname) then + // A M-file without parameter + if verbose_mode<0 then + m2sci_info(msprintf(gettext("L.%d: Unknown variable %s is a M-file."),nblines,varname),-1); + end + sci_equiv=Funcall(varname,size(lhslist),list(),lhslist) + elseif exists("sci_"+varname)==1 then + // A translated function without parameter + if verbose_mode<0 then + m2sci_info(msprintf(gettext("L.%d: Unknown variable %s is a M-file (sci_%s exists)."),nblines,varname,varname),-1); + end + sci_equiv=Funcall(varname,size(lhslist),list(),lhslist) + elseif or(varname==["i","j"]) then + if verbose_mode<0 then + m2sci_info(msprintf(gettext("Variable %s supposed to be the Imaginary unit."),varname),-1); + end + sci_equiv=Variable("%i",Infer(list(1,1),Type(Double,Complex))) + else + // Try to find what is 'varname' + sci_equiv=get_unknown(varname,lhslist) + if verbose_mode<0 then + m2sci_info(msprintf(gettext("L.%d: Unknown variable %s."),nblines,varname),-1); + end + end + else + sci_equiv=Variable(varname,Infer(varslist(index).dims,varslist(index).type)) + end +endfunction diff --git a/modules/m2sci/macros/kernel/i_notation.bin b/modules/m2sci/macros/kernel/i_notation.bin new file mode 100755 index 000000000..0bbd59db5 Binary files /dev/null and b/modules/m2sci/macros/kernel/i_notation.bin differ diff --git a/modules/m2sci/macros/kernel/i_notation.sci b/modules/m2sci/macros/kernel/i_notation.sci new file mode 100755 index 000000000..c7ae4c9b0 --- /dev/null +++ b/modules/m2sci/macros/kernel/i_notation.sci @@ -0,0 +1,94 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function txt=i_notation(txt) + // This function changes 1i ,... by 1*i,... + + // M2SCI kernel functions called : + // - isinstring + + + // To succeed in this work, we successively suppress occurences which can be proved not to be complex notation + // Until we are 'sure' to have a complex notation + + n=size(txt,"r") + + I="i";J="j" + matches=[string(0:9)+I(ones(1,10)),".i",string(0:9)+J(ones(1,10)),".j"] + symbs=["+","-","*","/","\","(","["," ","^"," ",",",";","=","{"] + s1=["+","-","*","/","\",",",";"," ","^",".","&","|","''","]",")","}"] + s2=[string(0:9),"d","e","D","E","."] + + for k=1:n + st=strindex(txt(k),[";//","//"]) + if st<> [] then + for stk=1:size(st,"*") + if ~isinstring(txt(k),stk) then + break + end + end + continue + end + tk=txt(k)+" " + + // Find possible occurence of complex notation + kc=strindex(tk,matches) + + // Kill indexes which point to non complex values (e.g. : a1item...) + for kk=size(kc,"*"):-1:1 + km=kc(kk)+2 + if find(part(tk,km)==s1)==[] then kc(kk)=[],end + end + + kc=[0 kc] + + for kk=size(kc,"*"):-1:2 + km=kc(kk) + num=%T + // Reads numeric value leading complex variable + while or(part(tk,km)==s2) + km=km-1 + if km<=kc(kk-1)+1 then + km=kc(kk-1); + num=%F; + break + end + end + + tokill=%F + num=part(tk,km+1:kc(kk)-1) + ke=strindex(convstr(num),["e","d"]) + kd=strindex(convstr(num),".") + + // Searching for invalid numeric values (more than one dot...) + if size(ke,2)>1|size(kd,2)>1 then + tokill=%T + elseif size(ke,2)==1&size(kd,2)==1 then + if kekc(kk-1) then + if and(part(tk,km)<>symbs) then tokill=%T,end + end + end + + if ~tokill then + km=kc(kk) + // If supposed complex notation is not in a string + if ~isinstring(tk,km) then + tk=part(tk,1:km)+"*%"+part(tk,km+1:length(tk)) + end + end + end + txt(k)=tk + end +endfunction diff --git a/modules/m2sci/macros/kernel/infer2txt.bin b/modules/m2sci/macros/kernel/infer2txt.bin new file mode 100755 index 000000000..2b05e16fa Binary files /dev/null and b/modules/m2sci/macros/kernel/infer2txt.bin differ diff --git a/modules/m2sci/macros/kernel/infer2txt.sci b/modules/m2sci/macros/kernel/infer2txt.sci new file mode 100755 index 000000000..bef0b616f --- /dev/null +++ b/modules/m2sci/macros/kernel/infer2txt.sci @@ -0,0 +1,60 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function txt=infer2txt(infer) + txt=[] + dims=[] + if typeof(infer)=="infer" then + for l=1:size(infer.dims) + dims=[dims,string(infer.dims(l))] + end + else + error(gettext("Not yet implemented.")) + end + dims=strcat(dims," ") + + tp=infer.type.vtype + if tp==1 then + tp="Double" + elseif tp==10 then + tp="String" + elseif or(tp==[4,6]) then + tp="Boolean" + elseif tp==16 then + tp="Struct" + for k=1:lstsize(infer.contents.index) + if typeof(infer.contents.index(k))<>"list" then + txt=[txt;expression2code(list(infer.contents.index(k)))+infer2txt(infer.contents.data(k))] + else + txt=[txt;expression2code(infer.contents.index(k))+infer2txt(infer.contents.data(k))] + end + end + elseif tp==17 then + tp="Cell" + for k=1:lstsize(infer.contents.index) + if typeof(infer.contents.index(k))<>"list" then + txt=[txt;expression2code(list(infer.contents.index(k)))+infer2txt(infer.contents.data(k))] + else + txt=[txt;expression2code(infer.contents.index(k))+infer2txt(infer.contents.data(k))] + end + end + elseif tp==9 then + tp="Handle" + else + tp="Unknown" + end + if infer.type.property==Real then + prop="Real" + elseif infer.type.property==Complex then + prop="Complex" + else + prop="Unknown" + end + txt=["|"+dims+"|"+tp+"|"+prop;txt] +endfunction diff --git a/modules/m2sci/macros/kernel/insert.bin b/modules/m2sci/macros/kernel/insert.bin new file mode 100755 index 000000000..bc4e95a9e Binary files /dev/null and b/modules/m2sci/macros/kernel/insert.bin differ diff --git a/modules/m2sci/macros/kernel/insert.sci b/modules/m2sci/macros/kernel/insert.sci new file mode 100755 index 000000000..d72cfcdf4 --- /dev/null +++ b/modules/m2sci/macros/kernel/insert.sci @@ -0,0 +1,26 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function []=insert(instr,opt) + + // Global variables for M2SCI + global("m2sci_to_insert_b") + global("m2sci_to_insert_a") + + [lhs,rhs]=argn() + + if rhs==1 then + opt=0 // Insertion before current instruction + end + if opt<>1 then + m2sci_to_insert_b($+1)=instr + else + m2sci_to_insert_a($+1)=instr + end +endfunction diff --git a/modules/m2sci/macros/kernel/instruction2sci.bin b/modules/m2sci/macros/kernel/instruction2sci.bin new file mode 100755 index 000000000..af311919f Binary files /dev/null and b/modules/m2sci/macros/kernel/instruction2sci.bin differ diff --git a/modules/m2sci/macros/kernel/instruction2sci.sci b/modules/m2sci/macros/kernel/instruction2sci.sci new file mode 100755 index 000000000..903f993fc --- /dev/null +++ b/modules/m2sci/macros/kernel/instruction2sci.sci @@ -0,0 +1,32 @@ +// 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.1-en.txt + +function [converted_instr,nblines]=instruction2sci(mtlb_instr,nblines) + + // Convertion of empty lines + if mtlb_instr==list("EOL") then + converted_instr=list("EOL") + nblines = nblines + 1; + return + end + + if typeof(mtlb_instr)=="equal" then + [converted_instr]=equal2sci(mtlb_instr) + elseif or(typeof(mtlb_instr)==["ifthenelse","selectcase","for","while","trycatch"]) then + [converted_instr,nblines]=clause2sci(mtlb_instr,nblines) + elseif or(typeof(mtlb_instr)==["funcall","cste","operation","variable"]) then + [converted_instr]=expression2sci(mtlb_instr) + elseif typeof(mtlb_instr)=="comment" then + [converted_instr]=mtlb_instr + + else + error(gettext("unknown instruction type %s."),typeof(mtlb_instr)) + end + +endfunction diff --git a/modules/m2sci/macros/kernel/is_a_scalar.bin b/modules/m2sci/macros/kernel/is_a_scalar.bin new file mode 100755 index 000000000..d18b829bd Binary files /dev/null and b/modules/m2sci/macros/kernel/is_a_scalar.bin differ diff --git a/modules/m2sci/macros/kernel/is_a_scalar.sci b/modules/m2sci/macros/kernel/is_a_scalar.sci new file mode 100755 index 000000000..5ad16a005 --- /dev/null +++ b/modules/m2sci/macros/kernel/is_a_scalar.sci @@ -0,0 +1,24 @@ +// 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.1-en.txt + +function r=is_a_scalar(A) + // M2SCI function + // Checks if all dimensions of A are 1 + // Input: A = a M2SCI tlist + // Output: r = boolean value (true if A is a scalar) + + n=size(A.dims) + r=%T + for k=1:n + if A.dims(k)<>1 then + r=%F + return + end + end +endfunction diff --git a/modules/m2sci/macros/kernel/is_a_vector.bin b/modules/m2sci/macros/kernel/is_a_vector.bin new file mode 100755 index 000000000..dcae3cbce Binary files /dev/null and b/modules/m2sci/macros/kernel/is_a_vector.bin differ diff --git a/modules/m2sci/macros/kernel/is_a_vector.sci b/modules/m2sci/macros/kernel/is_a_vector.sci new file mode 100755 index 000000000..3c4b01af6 --- /dev/null +++ b/modules/m2sci/macros/kernel/is_a_vector.sci @@ -0,0 +1,27 @@ +// 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.1-en.txt + +function r=is_a_vector(A) + // M2SCI function + // Checks if all dimensions of A but one are 1 + // Input: A = a M2SCI tlist + // Output: r = boolean value (true if A is a vector) + + nbones=0 + n=size(A.dims) + r=%F + for k=1:n + if A.dims(k)==1 then + nbones=nbones+1 + elseif A.dims(k)==-1 then + return + end + end + r=nbones==n-1 +endfunction diff --git a/modules/m2sci/macros/kernel/is_complex.bin b/modules/m2sci/macros/kernel/is_complex.bin new file mode 100755 index 000000000..81263e6cb Binary files /dev/null and b/modules/m2sci/macros/kernel/is_complex.bin differ diff --git a/modules/m2sci/macros/kernel/is_complex.sci b/modules/m2sci/macros/kernel/is_complex.sci new file mode 100755 index 000000000..5c804ed89 --- /dev/null +++ b/modules/m2sci/macros/kernel/is_complex.sci @@ -0,0 +1,18 @@ +// 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.1-en.txt + +function r=is_complex(A) + // M2SCI function + // Checks if A is complex + // Input: A = a M2SCI tlist + // Output: r = boolean value (true if A is complex) + + r=A.property==Complex +endfunction + diff --git a/modules/m2sci/macros/kernel/is_empty.bin b/modules/m2sci/macros/kernel/is_empty.bin new file mode 100755 index 000000000..d19743406 Binary files /dev/null and b/modules/m2sci/macros/kernel/is_empty.bin differ diff --git a/modules/m2sci/macros/kernel/is_empty.sci b/modules/m2sci/macros/kernel/is_empty.sci new file mode 100755 index 000000000..5f605e37f --- /dev/null +++ b/modules/m2sci/macros/kernel/is_empty.sci @@ -0,0 +1,25 @@ +// 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.1-en.txt + +function r=is_empty(A) + // M2SCI function + // Checks if all A dimension are 0 + // Input: A = a M2SCI tlist + // Output: r = boolean value (true if A is an empty matrix) + + n=size(A.dims) + nb=0 + for k=1:n + if A.dims(k)==0 then + nb=nb+1 + end + end + + r=nb==n +endfunction diff --git a/modules/m2sci/macros/kernel/is_real.bin b/modules/m2sci/macros/kernel/is_real.bin new file mode 100755 index 000000000..809de4d86 Binary files /dev/null and b/modules/m2sci/macros/kernel/is_real.bin differ diff --git a/modules/m2sci/macros/kernel/is_real.sci b/modules/m2sci/macros/kernel/is_real.sci new file mode 100755 index 000000000..8edb3c84f --- /dev/null +++ b/modules/m2sci/macros/kernel/is_real.sci @@ -0,0 +1,18 @@ +// 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.1-en.txt + +function r=is_real(A) + // M2SCI function + // Checks if A real + // Input: A = a M2SCI tlist + // Output: r = boolean value (true if A is real) + + r=A.type.property==Real +endfunction + diff --git a/modules/m2sci/macros/kernel/isacomment.bin b/modules/m2sci/macros/kernel/isacomment.bin new file mode 100755 index 000000000..d44b0aeb4 Binary files /dev/null and b/modules/m2sci/macros/kernel/isacomment.bin differ diff --git a/modules/m2sci/macros/kernel/isacomment.sci b/modules/m2sci/macros/kernel/isacomment.sci new file mode 100755 index 000000000..f70d1ea81 --- /dev/null +++ b/modules/m2sci/macros/kernel/isacomment.sci @@ -0,0 +1,45 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function k=isacomment(txt) + // Find if txt contains a Matlab comment + // If no return 0 + // If yes return the position of the beginning of the comment + + kc=strindex(txt,"%") + k=0 + if kc<>[] then + kq=strindex(txt,quote) + while %t then + qc=size(find(kq2 then + if (kq(qc-1)==kq(qc)-1) then // Found a '' sequence + qc=qc-2 + else + break + end + end + kk=kq(qc) + if execstr("prev = part(txt,kk-1)","errcatch")<>0 then pause,end;errclear(); + if or(prev==[" ",",",";","=","[","("]) then // qc points on a string beginning + kc(1)=[] + if kc==[] then break,end + else + k=kc(1) + break + end + end + end + end +endfunction diff --git a/modules/m2sci/macros/kernel/isanmfile.bin b/modules/m2sci/macros/kernel/isanmfile.bin new file mode 100755 index 000000000..4aa97fe3c Binary files /dev/null and b/modules/m2sci/macros/kernel/isanmfile.bin differ diff --git a/modules/m2sci/macros/kernel/isanmfile.sci b/modules/m2sci/macros/kernel/isanmfile.sci new file mode 100755 index 000000000..baa6b5bcf --- /dev/null +++ b/modules/m2sci/macros/kernel/isanmfile.sci @@ -0,0 +1,46 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function r=isanmfile(nam) + + // Try to find if nam is the name of a M-file + r=%F + + // If a translation function exists + if exists("sci_"+nam)==1 then + r=%T + return + end + + // If this function is part of known untranslated functions + // Special case of untranslated function without arguments + if find(nam==["grid","hold","gca"])<>[] then + r=%T + return + end + + // If recursive mode, try to find M-file in user defined paths + if Recmode then + for k=1:size(Paths,"*") + [u,ierr]=file("open",Paths(k)+nam+".m","old") + if ierr==0 then + file("close",u) + r=%T + break + end + end + else + // Try to find file in working directory + [u,ierr]=file("open",file_path+nam+".m","old") + if ierr==0 then + file("close",u) + end + r=(ierr==0) + end +endfunction diff --git a/modules/m2sci/macros/kernel/isdefinedvar.bin b/modules/m2sci/macros/kernel/isdefinedvar.bin new file mode 100755 index 000000000..010ac9b22 Binary files /dev/null and b/modules/m2sci/macros/kernel/isdefinedvar.bin differ diff --git a/modules/m2sci/macros/kernel/isdefinedvar.sci b/modules/m2sci/macros/kernel/isdefinedvar.sci new file mode 100755 index 000000000..e0bdca09c --- /dev/null +++ b/modules/m2sci/macros/kernel/isdefinedvar.sci @@ -0,0 +1,65 @@ +// 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.1-en.txt + +function [boolval,index]=isdefinedvar(var) + // Verify if variable is defined in varslist + // Input: + // - var: a M2SCI tlist (funcall, operation...) or a character string (name) for special variables + // Special variables i, j, pi, eps, nargin, nargout + // Output: + // - boolval: + // %T if input tlist is a defined 'variable' (already found while converting M-file) + // %F if input is not a 'variable' or an uknown 'variable' + + // Global variable for M2SCI + global("varslist") + + // level is declared in m2sci.sci and modified in clause2sci.sci + level; + + boolval=%F + index=[] + + // If input is a string + if type(var)==10 then + if and(var<>["i","j","pi","eps","%nargin","%nargout"]) then + warning(msprintf(gettext("Bad use of isdefinedvar() with input: %s."),var)) + return + end + varname=var + else + // If input is not a 'variable', it can be a defined variable... + if typeof(var)=="variable" then + varname=var.name + elseif typeof(var)=="m2scivar" then + varname=var.matname + else + return + end + end + + // Compare with all existing variables varslist + levelsize=size(level,1) + i=0 + while i=pos then + r=strcnt<>0; + return + end + ksym=ksym+1; + psym=sym; // psym = previous symbol + sym=part(str,ksym); + if sym<>" " then break,end + end + + if strcnt<>0 then // If in a string + if sym==quote then + qcount=1 + while part(str,ksym+1)<>quote&ksym+1qcount then + strcnt=0 + sym=part(str,ksym) + end + end + elseif sym==quote then + // Check if transpose or beginning of a string + if abs(_str2code(psym))>=36&psym<>")"&psym<>"]"&psym<>"."&psym<>quote then // Not a transpose + strcnt=1 + elseif bcount<>0 then // Inside a matrix definition + if part(str,ksym-1)==" " then strcnt=1,end + end + elseif sym=="[" then + bcount=bcount+1 + elseif sym=="]" then + bcount=bcount-1 + end + end +endfunction diff --git a/modules/m2sci/macros/kernel/lib b/modules/m2sci/macros/kernel/lib new file mode 100755 index 000000000..625e3229d Binary files /dev/null and b/modules/m2sci/macros/kernel/lib differ diff --git a/modules/m2sci/macros/kernel/lst_funcall.bin b/modules/m2sci/macros/kernel/lst_funcall.bin new file mode 100755 index 000000000..4e515f19e Binary files /dev/null and b/modules/m2sci/macros/kernel/lst_funcall.bin differ diff --git a/modules/m2sci/macros/kernel/lst_funcall.sci b/modules/m2sci/macros/kernel/lst_funcall.sci new file mode 100755 index 000000000..c02374d3a --- /dev/null +++ b/modules/m2sci/macros/kernel/lst_funcall.sci @@ -0,0 +1,234 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function funcallname=lst_funcall(fil,fnamvect) + // LST_FUNCALL function (used by "translatepaths" function) Creates a list of vectors. The first component of each vector is the name of a M-file (found in the Paths to translate), followed by the called functions by this file + // Output + // -funcallname : a list of vectors + // Input + // -fil : vector which contains all M-files names (path+name) found in the Paths + // -fnamvect : vector which contains all M-files names (just the name) found in the Paths + + quote="''"; + dquote=""""; + + k=strindex(fil,".") + ke=k($)-1 + // Function name + ksep=strindex(fil,sep) + fnam=part(fil,ksep($)+1:ke) // File name without extension + txt=mgetl(fil); + + kf=grep(txt,["function[","function "]) + + if isempty(kf) then + // Batch file + bval=%f + elseif size(kf,"*")==1 then + // Only one function defined + bval=%f + else + funcdecl=[] + for kk=kf + ind=strindex(txt(kk),["function[";"function "]) + if (ind + // - txt: Scilab equivalent function code (function declaration and varaibles initialisation) + // - crp: Scilab equivalent function code (function body) + + [lhs,rhs]=argn(0) + if rhs==1 then + error(gettext("Wrong number of inputs.")) + end + if rhs==2 then Recmode=%f,end + + lcount=1; + + // Level of clause indentation (used for getting temporary variables and for updating varslist) + // if there is not a clause then size of level = 1 and the value is 0 (level=0) + // add one size at level each time a new clause is found + // if just one clause then size of level = 2, the value of level(2) : the index of clause part for the first clause (1 for 'if' statements, 2 for first 'elseif' statements, 3 for first 'elseif' statements,...) + // if there are 2 clauses, then size of level = 3, the value of level(3) : the index of clause part for the second clause (1 for if statements, 2 for first elseif statements, 3 for second elseif statements,...) + // for example : level = [0,4,1] : in this case there are 2 clauses the index for the first clause (i.e level(2)) is 4 (4 for second 'elseif' statements), the index for the second clause (i.e level(3)) is 1 (1 for 'if' statements) + // the first components of level (i.e level(1)) is always 0 (because in the zero level there is no clause, so there is no 'if' no 'elseif' no 'else') + level=0 + + // Parameters declaration + sciparam() + + // Scilab variable types + Double=1; + Boolean=4; // Boolean type can also be 6 + Sparse=5; + Int=8; + Handle=9; + String=10; + Cell=17; + Struct=16; + Void=0; + Unknown=-1; // Unknown type or dimension + SupToOne=-2; // Dimension >1 + NotNull=-3; // Dimension >0 + Complex=1 //"Complex" + Real=0 //"Real" + Units=["pixels","centimeters","points","inches","normalized"] + + global %graphics + %graphics=struct() + %graphics.type=Double + %graphics.units="pixels" + + // Translated function input arguments + macrhs=size(mtlbtree.inputs) + global("varslist") + varslist=list() + for k=1:macrhs + if funptr(mtlbtree.inputs(k).name)<>0 then // Matlab variable name corresponding to a Scilab function name + varslist($+1)=M2scivar("%"+mtlbtree.inputs(k).name,mtlbtree.inputs(k).name,Infer()) + mtlbtree.inputs(k).name="%"+mtlbtree.inputs(k).name, + elseif mtlbtree.inputs(k).name=="varargin" then + varslist($+1)=M2scivar("varargin","varargin",Infer(list(Unknown,Unknown),Type(Cell,Unknown))) + else + varslist($+1)=M2scivar(mtlbtree.inputs(k).name,mtlbtree.inputs(k).name,Infer()) + end + end + // Add predefined variables in the defined variables + varslist($+1)=M2scivar("%i","%i",Infer(list(1,1),Type(Double,Complex))) + varslist($+1)=M2scivar("%i","%j",Infer(list(1,1),Type(Double,Complex))) + varslist($+1)=M2scivar("%nan","NaN",Infer(list(1,1),Type(Double,Real))) + varslist($+1)=M2scivar("%nan","nan",Infer(list(1,1),Type(Double,Real))) + varslist($+1)=M2scivar("%inf","Inf",Infer(list(1,1),Type(Double,Real))) + varslist($+1)=M2scivar("%inf","inf",Infer(list(1,1),Type(Double,Real))) + varslist($+1)=M2scivar("$","end",Infer(list(1,1),Type(Double,Real))) + varslist($+1)=M2scivar("%pi","pi",Infer(list(1,1),Type(Double,Real))) + varslist($+1)=M2scivar("%eps","eps",Infer(list(1,1),Type(Double,Real))) + varslist($+1)=M2scivar("varargout","%varargout",Infer(list(Unknown,Unknown),Type(Cell,Unknown))) + varslist($+1)=M2scivar("%shortcircuit","%shortcircuit",Infer(list(1,1),Type(Double,Real))) // Used for short circuiting operators + + // Translated function output arguments + maclhs=size(mtlbtree.outputs) + for k=1:maclhs + if funptr(mtlbtree.outputs(k).name)<>0 then + varslist($+1)=M2scivar("%"+mtlbtree.outputs(k).name,mtlbtree.outputs(k).name,Infer(list(0,0),Type(Double,Real))) + mtlbtree.outputs(k).name="%"+mtlbtree.outputs(k).name + else + varslist($+1)=M2scivar(mtlbtree.outputs(k).name,mtlbtree.outputs(k).name,Infer(list(0,0),Type(Double,Real))) + end + end + + // Translation + [scitree,crp]=mtlbtree2sci(mtlbtree,prettyprintoutput) + + dcl=[] + // Add special code + // If nargin or nargout function is used + if isdefinedvar("%nargin") | isdefinedvar("%nargout") then + dcl=["";gettext("// Number of arguments in function call");"[%nargout,%nargin] = argn(0)"] + end + + // Set display mode equivalent to Matlab echo off + dcl=[dcl;"";gettext("// Display mode");"mode(0);"] + // Set flotting point exception mode + dcl=[dcl;"";gettext("// Display warning for floating point exception");"ieee(1);"] + + // Initial value of lhs arguments + // If they are not initialized by input value, they are initialized with [] + ini=[] + for k=1:size(mtlbtree.outputs) + found=%F + for l=1:size(mtlbtree.inputs) + if mtlbtree.inputs(l).name==mtlbtree.outputs(k).name then + found=%T + end + end + if ~found then + if mtlbtree.outputs(k).name<>"varargout" then + ini=[ini;mtlbtree.outputs(k).name+"=[];"] + else + ini=[ini;mtlbtree.outputs(k).name+"=list();"] + end + end + end + + // Graphics init + //graph_ini=[gettext("// Graphics initialisation");"global %graphics";"%graphics.type=1";"%graphics.units=""pixels"""]; + graph_ini=[] + if ini<>[] then + ini=["";gettext("// Output variables initialisation (not found in input variables)");ini] + end + //ini=[ini;" ";graph_ini] + + // Info on macros variables + if verbose_mode<0 then + write(%io(2),gettext("TESTING M2SCI: creating varslist file...")) + n=size(varslist) + info=[] + + for k=1:n + info=[info;"//"+varslist(k).sciname+infer2txt(varslist(k).infer)]; + end + infofilename=res_path+nam+"_varslist.dia.ref"; + if verbose_mode==-2 then + write(%io(2),info) + end + infofile=mopen(infofilename,"w"); + mputl(info,infofile); + mclose(infofile); + end + + // Add function header + if ~batch then + rhsexpr="(" + for k=1:macrhs + rhsexpr=rhsexpr+varslist(k).sciname + if ksize(mtlbtree.outputs) then + hdr=hdr+"," + end + end + hdr=hdr+"] = "+nam+rhsexpr; + txt=[hdr;ini;dcl] + else + txt=[ini;dcl] + end + + // Generate associated translation function + if batch then + trad=[ + "function [tree] = sci_"+fnam+"(tree)" + msprintf(gettext("// Generated by M2SCI\n// Conversion function for Matlab %s\n// Input: tree = Matlab funcall tree\n// Output: tree = Scilab equivalent for tree"),fnam) + "" + "tree=Funcall(""exec"",1,Rhs_tlist(tree.name),tree.lhs)" + ] + else + trad=[ + "function [tree] = sci_"+nam+"(tree)" + msprintf(gettext("// Copyright INRIA (Generated by M2SCI)\n// Conversion function for Matlab %s()\n// Input: tree = Matlab funcall tree\n// Output: tree = Scilab equivalent for tree"),nam) + ] + + if maclhs==0 then // Function with no outputs + // Do nothing + elseif maclhs==1 then // Function with one output + [boolval,index]=isdefinedvar(M2scivar(mtlbtree.outputs(1).name,strsubst(mtlbtree.outputs(1).name,"%",""),Infer())) + if boolval then + dims=sci2exp(varslist(index).dims) + vtype=varslist(index).vtype + prop=varslist(index).property + else + dims="list(Unknown,Unknown)" + vtype=Unknown + prop=Unknown + end + + select vtype + case Double then vtype="Double" + case Boolean then vtype="Boolean" + case String then vtype="String" + case Struct then vtype="Struct" + case Cell then vtype="Cell" + case Unknown then vtype="Unknown" + case Sparse then vtype="Sparse" + end + + select prop + case -1 then prop="Unknown" + case 0 then prop="Real" + case 1 then prop="Complex" + end + + typ="Type("+vtype+","+prop+")" + + if mtlbtree.outputs($).name<>"varargout" then + trad=[trad;"tree.lhs(1).dims="+dims;"tree.lhs(1).type="+typ] + else + trad=[trad; + "for k=1:lhs" + " tree.lhs(k).dims=list(Unknown,Unknown)" + " tree.lhs(k).vtype=Unknown" + " tree.lhs(k).property=Unknown" + "end" + ] + end + else // Function with more than 1 output + dims=list(); + vtype=[]; + prop=[] + for k=1:maclhs + [boolval,index]=isdefinedvar(M2scivar(mtlbtree.outputs(k).name,strsubst(mtlbtree.outputs(k).name,"%",""),Infer())) + if boolval then + dims(k)=varslist(index).dims + vtype=[vtype;varslist(index).vtype] + prop=[prop;varslist(index).property] + else + dims(k)=list(Unknown,Unknown) + vtype=[vtype;Unknown] + prop=[prop;Unknown] + end + end + + dimstemp=sci2exp(dims) + dims=["dims="+dimstemp(1);dimstemp(2:$)] + vtype="vtype="+sci2exp(vtype) + prop="prop="+sci2exp(prop) + trad=[trad; + gettext("// dims(i,:) is the ith output argument dimensions vector") + dims + gettext("// dims(i,:) is the ith output argument dimensions vector") + vtype + gettext("// prop(i) is the ith output argument property") + prop] + if mtlbtree.outputs($).name<>"varargout" then + trad=[trad; + "for k=1:lhs" + " tree.lhs(k).dims=dims(k)" + " tree.lhs(k).vtype=vtype(k)" + " tree.lhs(k).property=prop(k)" + "end" + ] + else + trad=[trad; + "for k=1:min(lstsize(dims),lhs)" + " tree.lhs(k).dims=dims(k)" + " tree.lhs(k).vtype=vtype(k)" + " tree.lhs(k).property=prop(k)" + "end" + gettext("// Inference for varargout") + "for k=min(lstsize(dims),lhs)+1:lhs" + " tree.lhs(k).dims=list(Unknown,Unknown)" + " tree.lhs(k).vtype=Unknown" + " tree.lhs(k).property=Unknown" + "end" + ] + end + end + end + trad=[trad;"endfunction"] + clearglobal varslist + clearglobal %graphics +endfunction diff --git a/modules/m2sci/macros/kernel/m2sci_info.bin b/modules/m2sci/macros/kernel/m2sci_info.bin new file mode 100755 index 000000000..3c8c33632 Binary files /dev/null and b/modules/m2sci/macros/kernel/m2sci_info.bin differ diff --git a/modules/m2sci/macros/kernel/m2sci_info.sci b/modules/m2sci/macros/kernel/m2sci_info.sci new file mode 100755 index 000000000..e27fadc56 --- /dev/null +++ b/modules/m2sci/macros/kernel/m2sci_info.sci @@ -0,0 +1,45 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function m2sci_info(txt,verb_mode) + // verb_mode=0: no information displayed + // verb_mode=1: information written as comment is resulting SCI-file + // verb_mode=2: information written as comment is resulting SCI-file and in logfile + // verb_mode=3: information written as comment is resulting SCI-file, in logfile and displayed in Scilab window + // verb_mode=-1: information written in logfile and displayed in Scilab window (should not be used by user) (TEST MODE) + // verb_mode=-2: information written in logfile and displayed in Scilab window (should not be used by user) and varslist displayed in Scilab command window (DEBUG MODE) + + + + if verb_mode==0 then + return + end + + if verb_mode>0 then + if exists("m2sci_to_insert_b")==0 then + write(%io(2),gettext("loginfos: verb_mode 0 should not be used in this context, information ignored.")); + return + end + global("m2sci_to_insert_b") + for k=1:size(txt,"*") + m2sci_to_insert_b($+1)=Equal(.. + list(Variable("ans",Infer())),.. + Funcall("%comment",1,list(Cste(" "+txt(k))),list(Variable("",Infer())))) + m2sci_to_insert_b($+1)=list("EOL"); + end + end + + if verb_mode>1 | verb_mode==-1 then + write(logfile,margin+txt); // margin is defined in mfile2sci() + end + + if verb_mode>2 | verb_mode==-1 then + mprintf("%s\n",strsubst(strsubst(margin+txt, "%i", "%%i"),"%n","%%n")); // margin is defined in mfile2sci() + end +endfunction diff --git a/modules/m2sci/macros/kernel/m2sci_syntax.bin b/modules/m2sci/macros/kernel/m2sci_syntax.bin new file mode 100755 index 000000000..e517dd610 Binary files /dev/null and b/modules/m2sci/macros/kernel/m2sci_syntax.bin differ diff --git a/modules/m2sci/macros/kernel/m2sci_syntax.sci b/modules/m2sci/macros/kernel/m2sci_syntax.sci new file mode 100755 index 000000000..d9f5aca6f --- /dev/null +++ b/modules/m2sci/macros/kernel/m2sci_syntax.sci @@ -0,0 +1,455 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - 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.1-en.txt + +function [helppart,txt,batch]=m2sci_syntax(txt) + // Make minor changes on M-file data syntax to have it readable by Scilab + // Input arguments: + // - txt: the contents of an M-file + // Output: + // - helppart: Matlab help contained in M-file + // - txt: input txt modified (If M-file contains only comments returned txt is[]) + // - batch: boolean flag indicates if it is a batch file + + // m2sci kernel functions called : + // - isacomment + // - isinstring + // - replace_brackets + + sciparam(); + quote="''" + dquote="""" + ctm="."+"."+"." // Continuation mark + batch=%t + + k=0 + first_ncl=[] + while k[] then + kc=isacomment(tk) + if kc<>0 then // Current line has or is a comment + // If function prototype immediately followed by a comment on same line + if stripblanks(part(tk,eolind(1):kc))<>"" then + txt=[txt(1:k-1);part(tk,1:eolind(1)-1);part(tk,eolind(1)+1:length(tk));txt(k+1:size(txt,"*"))] + tk=part(tk,1:eolind(1)-1) + end + elseif stripblanks(part(tk,eolind(1)+1:length(tk)))<>"" then + txt=[txt(1:k-1);part(tk,1:eolind(1)-1);part(tk,eolind(1)+1:length(tk));txt(k+1:size(txt,"*"))] + tk=part(tk,1:eolind(1)-1) + end + end + end + end + + // Number of lines in txt (i.e. in M-file) + n=size(txt,"r") + eoltoinsert=0 + firstctm=[] + k=0 + while k0 then // Line has a comment + if kc10 then + if part(stripblanks(txt(k)),1)=="}" then + txt(k-1)=txt(k-1)+txt(k); + txt(k)=""; + end + end + end + + // Change comments and get help part in input txt + n=size(txt,"r") + first=%t + helppart=[],endofhelp=%f + + for k=1:n + tk=txt(k) + + // ifthenelse expression like if (x==1)t=2 becomes if (x==1) t=2 + // Add a blank between parenthesize expression and the first instruction + kif=strindex(tk,"if") + if kif<>[] then + kcom=isacomment(tk) + for i=1:size(kif,"*") + if kif(i)>kcom & kcom<>0 then + break + else + if (kif(i)>1 & or(stripblanks(part(tk,kif(i)-1:kif(i)+2))==["if(","if"])) | (kif(i)==1 & or(stripblanks(part(tk,kif(i):kif(i)+2))==["if(","if"])) + m=min(strindex(tk,"(")) + if m<>[] then + for l=1:size(m,"*") + if m(l)>=kif(i)+2 + if stripblanks(part(tk,kif(i)+2:m(l)))=="(" then + openpar=1 + mtemp=m(l)+1 + while openpar<>0 + if or(part(tk,mtemp)=="(") then + openpar=openpar+1 + elseif or(part(tk,mtemp)==")") then + openpar=openpar-1 + end + mtemp=mtemp+1 + end + tk=part(tk,1:mtemp-1)+" "+part(tk,mtemp:length(tk)) + break + end + end + end + end + end + end + end + end + + // Insert a blank when a digit is followed by a dotted operator + // So that point is associated to operator and not to digit + // Because if it is associated to digit, dot is suppressed by comp() + kdot=strindex(tk,[".*","./",".\",".^",".''"]) + if kdot<>[] then + kdgt=kdot(find(abs(_str2code(part(tk,kdot-1)))<9)) + for kk=size(kdgt,"*"):-1:1 + tk=part(tk,1:kdgt(kk)-1)+" "+part(tk,kdgt(kk):length(tk)); + end + end + + // Modify struct like x.(fieldname) which become x(fieldname) + tk=strsubst(tk,".(","(") + + // Parenthesize calls to pause when pause on or pause off + kpause=strindex(tk,"pause") + kpsav=length(tk) // kpsave is kp value for l-1 index + for l=size(kpause,"*"):-1:1 + kp=kpause(l) + kon=strindex(tk,"on") + kon=kon(find((kon>kp)&(kon[] then + for l=kp+5:kon-1 + if part(tk,l)<>" " then + break + end + end + tk=part(tk,1:kp+4)+"(''on'')"+part(tk,kon+2:length(tk)) + end + koff=strindex(tk,"off") + koff=koff(find((koff>kp)&(koff[] then + for l=kp+5:koff-1 + if part(tk,l)<>" " then + break + end + end + tk=part(tk,1:kp+4)+"(''off'')"+part(tk,koff+3:length(tk)) + end + kpsav=kp + end + + // Convert @fhandle to 'fhandle' (cf feval) + symbs=[" ",",",";","=",")","]"] + kpunct=strindex(tk,"@") + kcom=isacomment(tk) + if kcom<>0 then + kpunct=kpunct(kpunct[] then + for l=size(kpunct,"*"):-1:1 + if ~isinstring(tk,kpunct(l)) then + kk=gsort(strindex(tk,symbs),"r","i") + kk=kk(find(kk>kpunct(l))) + if kk==[] then + kk=length(tk) + tk=part(tk,1:kpunct(l)-1)+quote+part(tk,kpunct(l)+1:kk)+quote + else + kk=kk(1) + tk=part(tk,1:kpunct(l)-1)+quote+part(tk,kpunct(l)+1:kk-1)+quote+part(tk,kk:length(tk)) + end + end + end + end + + // Looking for comments + kc=isacomment(tk) + if kc<>0 then // Current line has or is a comment + // If function prototype immediately followed by a comment on same line + if part(stripblanks(tk),1:9) == "function " | part(stripblanks(tk),1:9) == "function[" then + first_ncl=k + end + com=part(tk,kc+1:length(tk)) + if stripblanks(part(tk,1:kc-1))<>"" & ~(stripblanks(part(tk,1:9))=="function " | stripblanks(part(tk,1:9))=="function[") then endofhelp=%t;end + if ~endofhelp & part(tk,1:9) ~= "function " then helppart=[helppart;com];end // Get help part placed at the beginning of the file + if length(com)==0 then com=" ",end + com=strsubst(com,quote,quote+quote) + com=strsubst(com,dquote,dquote+dquote) + if part(com,1:12)=="m2sciassume " | part(com,1:13)=="m2scideclare " then // User has given a clue to help translation + if part(com,1:12)=="m2sciassume " then + warning(gettext("m2sciassume is obsolete, used m2scideclare instead.")); + end + com=";m2scideclare("+quote+part(com,13:length(com))+quote+")" + else + com=";//"+com + end + tkbeg=part(tk,1:kc-1) + + // Short circuiting operators + if ~isempty(strindex(tkbeg,"||")) then + orexpr=tokens(tkbeg,"|") + boolendsymbol=%f + orexprtemp=orexpr($) + indendsymbol=strindex(orexpr($),[";",","]) + if indendsymbol<>[] then + if stripblanks(part(orexpr($),indendsymbol($)+1:length(orexpr($))))=="" then + boolendsymbol=%t + endsymbol=part(orexprtemp,indendsymbol($)) + indendsymbol=indendsymbol($) + orexpr($)=part(orexpr($),1:indendsymbol($)-1) + end + end + for i=2:size(orexpr,"*") + notsymbol=strindex(stripblanks(orexpr(i)),"~") + if notsymbol<>[] + if notsymbol(1)==1 then + orexpr(i)="("+ stripblanks(orexpr(i)) + ")" + end + end + end + for kk=2:2:size(orexpr,"*") + orexpr=[orexpr(1:kk);"%shortcircuit";orexpr(kk+1:size(orexpr,"*"))] + end + tkbeg=strcat(orexpr,"|") + if boolendsymbol then + tkbeg=tkbeg+endsymbol + end + end + if ~isempty(strindex(tkbeg,"&&")) then + andexpr=tokens(tkbeg,"&") + boolendsymbol=%f + andexprtemp=andexpr($) + indendsymbol=strindex(andexpr($),[";",","]) + if indendsymbol<>[] then + if stripblanks(part(andexpr($),indendsymbol($)+1:length(andexpr($))))=="" then + boolendsymbol=%t + endsymbol=part(andexprtemp,indendsymbol($)) + indendsymbol=indendsymbol($) + andexpr($)=part(andexpr($),1:indendsymbol($)-1) + end + end + for i=2:size(andexpr,"*") + notsymbol=strindex(stripblanks(andexpr(i)),"~") + if notsymbol<>[] + if notsymbol(1)==1 then + andexpr(i)="("+ stripblanks(andexpr(i)) + ")" + end + end + end + for kk=2:2:size(andexpr,"*") + andexpr=[andexpr(1:kk);"%shortcircuit";andexpr(kk+1:size(andexpr,"*"))] + end + tkbeg=strcat(andexpr,"&") + if boolendsymbol then + tkbeg=tkbeg+endsymbol + end + end + + // varargout replaced by %varargout so that code can be compiled with varargout considered as a Cell + if isempty(strindex(tkbeg,"function")) then + tkbeg=strsubst(tkbeg,"varargout","%varargout") + end + + txt(k)=tkbeg+com + else // Current line has not and is not a comment line + if first then // Function keyword not yet found + tk=stripblanks(tk) + if tk<>"" then // Current line is not a blank line + if ~(part(tk,1:9) == "function "| part(tk,1:9) == "function[") then + endofhelp=%t; + txt(k)=tk; // VC 01/04/2003 + else + first_ncl=k + first=%f + end + else + if ~endofhelp then helppart=[helppart;" "],end + txt(k)="// " + end + else // Current line is a line after function keyword + endofhelp=%t + txt(k)=tk + end + + // Short circuiting operators + if ~isempty(strindex(tk,"||")) then + orexpr=tokens(tk,"|") + indendsymbol=strindex(orexpr($),[";",","]) + boolendsymbol=%f + if indendsymbol<>[] then + if stripblanks(part(orexpr($),indendsymbol($)+1:length(orexpr($))))=="" then + boolendsymbol=%t + indendsymbol=indendsymbol($) + endsymbol=part(orexpr($),indendsymbol($)) + orexpr($)=part(orexpr($),1:indendsymbol($)-1) + end + end + for i=2:size(orexpr,"*") + notsymbol=strindex(stripblanks(orexpr(i)),"~") + if notsymbol<>[] + if notsymbol(1)==1 then + orexpr(i)="("+ stripblanks(orexpr(i)) + ")" + end + end + end + for kk=2:2:size(orexpr,"*") + orexpr=[orexpr(1:kk);"%shortcircuit";orexpr(kk+1:size(orexpr,"*"))] + end + tk=strcat(orexpr,"|") + if boolendsymbol then + tk=tk+endsymbol + end + end + if ~isempty(strindex(tk,"&&")) then + andexpr=tokens(tk,"&") + boolendsymbol=%f + andexprtemp=andexpr($) + indendsymbol=strindex(andexpr($),[";",","]) + if indendsymbol<>[] then + if stripblanks(part(andexpr($),indendsymbol($)+1:length(andexpr($))))=="" then + boolendsymbol=%t + endsymbol=part(andexprtemp,indendsymbol($)) + indendsymbol=indendsymbol($) + andexpr($)=part(andexpr($),1:indendsymbol($)-1) + end + end + for i=2:size(andexpr,"*") + notsymbol=strindex(stripblanks(andexpr(i)),"~") + if notsymbol<>[] + if notsymbol(1)==1 then + andexpr(i)="("+ stripblanks(andexpr(i)) + ")" + end + end + end + for kk=2:2:size(andexpr,"*") + andexpr=[andexpr(1:kk);"%shortcircuit";andexpr(kk+1:size(andexpr,"*"))] + end + tk=strcat(andexpr,"&") + if boolendsymbol then + tk=tk+endsymbol + end + end + + // varargout replaced by %varargout so that code can be compiled with varargout considered as a Cell + if isempty(strindex(tk,"function")) then + tk=strsubst(tk,"varargout","%varargout") + end + + txt(k)=tk + end + end + + // When there is just help line in txt + if ~endofhelp then + txt=[] + return + end + + // Syntax modification + + // Complex variable + txt=i_notation(txt) + + // Replace double quotes + txt=strsubst(txt,dquote,dquote+dquote) + + // Replace switch by select + txt=strsubst(txt,"switch ","select ") + txt=strsubst(txt,"switch(","select (") + + // Replace otherwise by else + txt=strsubst(txt,"otherwise","else") + + // Replace {..} by (..) or [..] : useful for cells translation + txt=replace_brackets(txt) + + // Place function definition line at first line + kc=strindex(txt(first_ncl),"function") + if kc==[] then + // Batch file + txt=["function []="+fnam+"()";txt] // fnam is defined in mfile2sci() + batch=%t + else + kc=kc(1) + batch=%f + if first_ncl<>1 then + while strindex(txt(first_ncl($)+1),ctm)<>[] then + first_ncl=[first_ncl,first_ncl($)+1] + end + txt=[txt(first_ncl);txt(1:first_ncl(1)-1);txt(first_ncl($)+1:$)] + end + // Beginning of BUG 2341 fix: function prototype with no comma between output parameters names + begb=strindex(txt(1),"["); + endb=strindex(txt(1),"]"); + if ~isempty(begb) & ~isempty(endb) + outputparams = stripblanks(part(txt(1),(begb+1):(endb-1)))+" "; + k=0; + while k[","," "])) & (k",") & (k[] then + mtlbpath=tb(k,2) + ismtlb=%t + end +endfunction \ No newline at end of file diff --git a/modules/m2sci/macros/kernel/mtlbtree2sci.bin b/modules/m2sci/macros/kernel/mtlbtree2sci.bin new file mode 100755 index 000000000..02fd232a1 Binary files /dev/null and b/modules/m2sci/macros/kernel/mtlbtree2sci.bin differ diff --git a/modules/m2sci/macros/kernel/mtlbtree2sci.sci b/modules/m2sci/macros/kernel/mtlbtree2sci.sci new file mode 100755 index 000000000..4748eecc9 --- /dev/null +++ b/modules/m2sci/macros/kernel/mtlbtree2sci.sci @@ -0,0 +1,125 @@ +// 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.1-en.txt + +function [scitree,crp]=mtlbtree2sci(mtlbtree,prettyprintoutput) + // Conversion of a Matlab function tree to Scilab (and code generation) + // Input arguments: + // - mtlbtree: tree (returned by macr2tree) representing Matlab function compiled code + // - prettyprintoutput: boolean flag for pretty printed output file if TRUE + // Output arguments: + // - scitree: Scilab equivalent for mtlbtree + // - crp: Scilab equivalent function code (function body) + + // Global variables for M2SCI + global("m2sci_to_insert_b") // To insert before current instruction + global("m2sci_to_insert_a") // To insert after current instruction + global("tmpvarnb") // Index for temporary variables + m2sci_to_insert_b=list() + m2sci_to_insert_a=list() + tmpvarnb=0 + + if typeof(mtlbtree)<>"program" then + error(gettext("wrong type of input.")) + end + + // Init Scilab tree + scitree=tlist(["program","name","outputs","inputs","statements"],mtlbtree.name,mtlbtree.outputs,mtlbtree.inputs,list()) + + ninstr=1 // Index of Matlab tree + if batch then // defined in m2sci.sci + nblines=0 + else + nblines=1 // Number of converted lines + end + + m2sci_info(gettext("Conversion of M-tree..."),-1); + + // Default value + rhs = argn(2); + if rhs<2 then + prettyprintoutput=%F + end + + crp="" + + // Function prototype + lhsstr=[] + rhsstr=[] + if scitree.name<>"" then // Not a batch file + for k=1:size(scitree.outputs) + lhsstr=[lhsstr,expression2code(scitree.outputs(k))] + end + lhsstr="["+strcat(lhsstr,",")+"]" + + for k=1:size(scitree.inputs) + rhsstr=[rhsstr,expression2code(scitree.inputs(k))] + end + rhsstr="("+strcat(rhsstr,",")+")" + + crp=lhsstr+" = "+scitree.name+rhsstr; + end + + // Convert Matlab instruction tree to Scilab + while ninstr<=size(mtlbtree.statements)-3 + //Case : sup_equal instruction + // Add converted tree to scitree and also inserted instructions + if typeof(mtlbtree.statements(ninstr))=="sup_equal" + + sci_stat=list() + for i=1:size(mtlbtree.statements(ninstr).sup_instr) + [converted_tree,nblines]=instruction2sci(mtlbtree.statements(ninstr).sup_instr(i),nblines) + + sci_stat=update_instr_list(sci_stat,converted_tree) + end + + scitree.statements($+1)=tlist(["sup_equal","sup_instr","nb_opr"],sci_stat,mtlbtree.statements(ninstr).nb_opr) + else + + [converted_tree,nblines]=instruction2sci(mtlbtree.statements(ninstr),nblines) + + // Add converted tree to scitree and also inserted instructions + + scitree.statements=update_instr_list(scitree.statements,converted_tree) + + // Generate code corresponding to scitree.statements + end + for k=1:size(scitree.statements) + if klist("EOL") then + crp = cat_code(crp,instruction2code(scitree.statements(1),prettyprintoutput)); + crp = format_txt(crp,scitree.statements(1),prettyprintoutput,list("EOL")); + end + + if scitree.name<>"" then // Not a batch file + crp=cat_code(crp,""); + crp=cat_code(crp,"endfunction"); // Replace last return + crp=cat_code(crp,""); + end + + m2sci_info(gettext("Conversion of M-tree: Done"),-1); + + + clearglobal("m2sci_to_insert_b") + clearglobal("m2sci_to_insert_a") + clearglobal("tmpvarnb") + +endfunction diff --git a/modules/m2sci/macros/kernel/multi_fun_file.bin b/modules/m2sci/macros/kernel/multi_fun_file.bin new file mode 100755 index 000000000..a2e3c915d Binary files /dev/null and b/modules/m2sci/macros/kernel/multi_fun_file.bin differ diff --git a/modules/m2sci/macros/kernel/multi_fun_file.sci b/modules/m2sci/macros/kernel/multi_fun_file.sci new file mode 100755 index 000000000..7e427e098 --- /dev/null +++ b/modules/m2sci/macros/kernel/multi_fun_file.sci @@ -0,0 +1,174 @@ +// 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.1-en.txt + +function bval=multi_fun_file(fil,res_path,Recmode,only_double,verbose_mode,prettyprintoutput) + // This function converts M-Files containing more than one functio + // Inputs are the same as mfile2sci() + // Outputs : + // - bval: boolean value, %t if file contains more than on function, %f else + + sciparam(); + + // File name + k=strindex(fil,".") + if k<>[] + ke=k($)-1 + base_name=part(fil,1:ke) + else + ke=length(fil) + base_name=fil + end + // File path + k=strindex(fil,"/") + if k==[] then + file_path="./" + else + file_path=part(fil,1:k($)) + end + base_name=part(base_name,k($)+1:ke) + + txt=mgetl(fil); + + kf=grep(txt,["function[","function "]) + + if isempty(kf) then + // Batch file + bval=%f + elseif size(kf,"*")==1 then + // Only one function defined + bval=%f + else + funcdecl=[] + for kk=kf + ind=strindex(txt(kk),["function[";"function "]) + if isacomment(txt(kk))==0 & ~isinstring(txt(kk),ind) & part(stripblanks(txt(kk),%T),1:8)=="function" then // function prototype + funcdecl=[funcdecl kk] + end + end + + if isempty(funcdecl) then + // "function" only exists in comments and strings + bval=%f + return + elseif size(funcdecl,"*")==1 then + bval=%f + return + end + + // Verify if the directory exists + dirnam = ls(pathconvert(TMPDIR)+base_name); + + sep = filesep(); + + if or(dirnam<>"") then + rmdir(pathconvert(TMPDIR)+base_name,"s") + end + mkdir(pathconvert(TMPDIR),base_name) + write(%io(2),msprintf(gettext(" -- File %s contains more than one function -- "),fil)); + + bval= %t + + // First split file into as many files as function declared + funcdecl=[funcdecl size(txt,"*")+1] + + tmpfiles=[] + for k=1:size(funcdecl,"*")-1 + functxt=txt(funcdecl(k):funcdecl(k+1)-1) + str= strindex(txt(funcdecl(k)),"(")-1 + if str==-1 then + funcname=stripblanks(part(txt(funcdecl(k)),strindex(txt(funcdecl(k)),["function[","function "])+8:length(txt(funcdecl(k))))) + else + funcname=stripblanks(part(txt(funcdecl(k)),strindex(txt(funcdecl(k)),["function[","function "])+8:str(1))) + end + + keq=strindex(funcname,"=") + if ~isempty(keq) then + funcname=stripblanks(part(funcname,keq+1:length(funcname))) + end + tmpfiles=[tmpfiles;funcname] + mputl(functxt,pathconvert(TMPDIR)+base_name+sep+tmpfiles($)+".m"); + end + + write(%io(2),msprintf(gettext(" -- Each function converted separately: %s -- "),strcat(tmpfiles," "))); + write(%io(2),msprintf(gettext(" -- Temporary files put in: %s -- "),pathconvert(TMPDIR))); + + // Conversion of each file + + for k=1:size(tmpfiles,"*") + txt=mgetl(pathconvert(TMPDIR)+base_name+sep+tmpfiles(k)+".m") + //mfile2sci(pathconvert(TMPDIR)+tmpfiles(k)+".m",res_path,Recmode,only_double,verbose_mode,prettyprintoutput) + end + + translatepaths(pathconvert(TMPDIR)+base_name,pathconvert(TMPDIR)+base_name) + + txt=[] + if isfile(pathconvert(TMPDIR)+base_name+sep+"log") then + txt=mgetl(pathconvert(TMPDIR)+base_name+sep+"log") + end + mputl(txt,res_path+"log"); + if isfile(pathconvert(TMPDIR)+base_name+sep+"resumelog") then + txt=mgetl(pathconvert(TMPDIR)+base_name+sep+"resumelog") + end + mputl(txt,res_path+"resumelog"); + + // Catenation of all .sci files to have only one output file + txt=[] + for k=1:size(tmpfiles,"*") + txt=[txt ;"";mgetl(pathconvert(TMPDIR)+base_name+sep+tmpfiles(k)+".sci")] + end + + // Delete useless .sci files + //for k=1:size(tmpfiles,"*") + //mdelete(res_path+tmpfiles(k)+".sci") + //end + + mputl(txt,res_path+base_name+".sci"); + + // Catenation of all .log files to have only one output file + //if exists("logfile")==0 then + //txt=[] + //for k=1:size(tmpfiles,"*") + //txt=[txt ; mgetl(pathconvert(TMPDIR)+base_name+sep+"m2sci_"+tmpfiles(k)+".log")] + //end + + // Delete useless .log files + //for k=1:size(tmpfiles,"*") + //mdelete(pathconvert(TMPDIR)+base_name+sep+"m2sci_"+tmpfiles(k)+".log") + //end + + //mputl(txt,res_path+"m2sci_"+base_name+".log"); + //end + + // Catenation of all resume.log files to have only one output file + //if exists("resume_logfile")==0 then + //txt=[] + //for k=1:size(tmpfiles,"*") + //txt=[txt ; mgetl(res_path+"m2sci_"+tmpfiles(k)+"_resume.log")] + //end + + // Delete useless _resume.log files + //for k=1:size(tmpfiles,"*") + //mdelete(res_path+"m2sci_"+tmpfiles(k)+"_resume.log") + //end + + //mputl(txt,res_path+"m2sci_"+base_name+"_resume.log"); + //end + + // Delete useless .m files + //for k=1:size(tmpfiles,"*") + //mdelete(pathconvert(TMPDIR)+tmpfiles(k)+".m") + //end + + rmdir(pathconvert(TMPDIR)+base_name,"s") + for k=1:size(tmpfiles,"*") + mdelete(pathconvert(TMPDIR)+tmpfiles(k)+".tree") + end + end + +endfunction diff --git a/modules/m2sci/macros/kernel/names b/modules/m2sci/macros/kernel/names new file mode 100755 index 000000000..42ef173b6 --- /dev/null +++ b/modules/m2sci/macros/kernel/names @@ -0,0 +1,87 @@ +%contents_i_funcall +%contents_i_operatio +%contents_i_variable +%cste_e +%funcall_6 +%funcall_e +%infer_i_s +%infer_i_st +%l_i_cste +%l_i_funcall +%l_i_operatio +%l_i_variable +%m2scivar_e +%operatio_6 +%operatio_e +%s_i_operatio +%s_i_variable +%type_i_cste +%type_i_funcall +%type_i_operatio +%type_i_variable +%variable_6 +%variable_e +Contents +Cste +Equal +Funcall +Infer +M2scivar +Operation +Rhs_tlist +Type +Variable +allunknown +changevarname +clause2sci +convert2double +default_trad +equal2sci +expression2sci +first_non_singleton +funcall2sci +funcallsearch +get_unknown +getoperands +getrhs +gettempvar +getvar2sci +i_notation +infer2txt +insert +instruction2sci +is_a_scalar +is_a_vector +is_complex +is_empty +is_real +isacomment +isanmfile +isdefinedvar +isinstring +lst_funcall +m2sci +m2sci_info +m2sci_syntax +mfile_path +mtlbtoolfun +mtlbtree2sci +multi_fun_file +no_equiv +not_a_scalar +not_a_vector +not_empty +not_yet_converted +old2newinstr +operation2sci +repl_poss +replace_brackets +sci_generic +sci_m2scideclare +sciparam +set_infos +transformtree +translateorder +update_instr_list +updatevarslist +variablesearch diff --git a/modules/m2sci/macros/kernel/no_equiv.bin b/modules/m2sci/macros/kernel/no_equiv.bin new file mode 100755 index 000000000..099620776 Binary files /dev/null and b/modules/m2sci/macros/kernel/no_equiv.bin differ diff --git a/modules/m2sci/macros/kernel/no_equiv.sci b/modules/m2sci/macros/kernel/no_equiv.sci new file mode 100755 index 000000000..92995848c --- /dev/null +++ b/modules/m2sci/macros/kernel/no_equiv.sci @@ -0,0 +1,14 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function []=no_equiv(expr) + + set_infos(msprintf(gettext("No Scilab equivalent for: %s"),expr),2) + +endfunction diff --git a/modules/m2sci/macros/kernel/not_a_scalar.bin b/modules/m2sci/macros/kernel/not_a_scalar.bin new file mode 100755 index 000000000..8fd43d990 Binary files /dev/null and b/modules/m2sci/macros/kernel/not_a_scalar.bin differ diff --git a/modules/m2sci/macros/kernel/not_a_scalar.sci b/modules/m2sci/macros/kernel/not_a_scalar.sci new file mode 100755 index 000000000..e8411dff6 --- /dev/null +++ b/modules/m2sci/macros/kernel/not_a_scalar.sci @@ -0,0 +1,24 @@ +// 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.1-en.txt + +function r=not_a_scalar(A) + // M2SCI function + // Checks if at least one dimension of A is greater than 1 + // Input: A = a M2SCI tlist + // Output: r = boolean value (true if A can not be a scalar) + + nb=0 + for k=1:size(A.dims) + if A.dims(k)>1 | A.dims(k)==SupToOne then + nb=nb+1 + end + end + + r=nb<>0 +endfunction diff --git a/modules/m2sci/macros/kernel/not_a_vector.bin b/modules/m2sci/macros/kernel/not_a_vector.bin new file mode 100755 index 000000000..d9d230146 Binary files /dev/null and b/modules/m2sci/macros/kernel/not_a_vector.bin differ diff --git a/modules/m2sci/macros/kernel/not_a_vector.sci b/modules/m2sci/macros/kernel/not_a_vector.sci new file mode 100755 index 000000000..c21b85a77 --- /dev/null +++ b/modules/m2sci/macros/kernel/not_a_vector.sci @@ -0,0 +1,25 @@ +// 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.1-en.txt + +function r=not_a_vector(A) + // M2SCI function + // Checks if at least two dimensions of A are greater than 1 + // Input: A = a M2SCI tlist + // Output: r = boolean value (true if A can not be a vector) + + n=size(A.dims) + nb=0 + for k=1:n + if A.dims(k)>1 | A.dims(k)==SupToOne then + nb=nb+1 + end + end + + r=nb>=2 +endfunction diff --git a/modules/m2sci/macros/kernel/not_empty.bin b/modules/m2sci/macros/kernel/not_empty.bin new file mode 100755 index 000000000..1ac782240 Binary files /dev/null and b/modules/m2sci/macros/kernel/not_empty.bin differ diff --git a/modules/m2sci/macros/kernel/not_empty.sci b/modules/m2sci/macros/kernel/not_empty.sci new file mode 100755 index 000000000..bdb03e8e3 --- /dev/null +++ b/modules/m2sci/macros/kernel/not_empty.sci @@ -0,0 +1,25 @@ +// 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.1-en.txt + +function r=not_empty(A) + // M2SCI function + // Checks if no A dimension can be 0 + // Input: A = a M2SCI tlist + // Output: r = boolean value (true if A can not be an empty matrix) + + n=size(A.dims) + nb=0 + for k=1:n + if A.dims(k)>0 | A.dims(k)==SupToOne | A.dims(k)==NotNull then + nb=nb+1 + end + end + + r=nb>0 +endfunction diff --git a/modules/m2sci/macros/kernel/not_yet_converted.bin b/modules/m2sci/macros/kernel/not_yet_converted.bin new file mode 100755 index 000000000..0701bd1fb Binary files /dev/null and b/modules/m2sci/macros/kernel/not_yet_converted.bin differ diff --git a/modules/m2sci/macros/kernel/not_yet_converted.sci b/modules/m2sci/macros/kernel/not_yet_converted.sci new file mode 100755 index 000000000..98ef7052f --- /dev/null +++ b/modules/m2sci/macros/kernel/not_yet_converted.sci @@ -0,0 +1,1337 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function allnames=not_yet_converted() + allnames=["abcdchk"; + "accumarray"; + "acosd"; + "acotd"; + "acscd"; + "actxproxy"; + "adddatadlg"; + "addpath"; + "addpref"; + "addsubplot"; + "addtodate"; + "airfoil"; + "airy"; + "align"; + "alim"; + "allchild"; + "alpha"; + "alphamap"; + "amp1dae"; + "ancestor"; + "and"; + "annotation"; + "anondemo"; + "ardemo"; + "area"; + "arith"; + "arpackc"; + "arrayviewfunc"; + "asecd"; + "asind"; + "assignin"; + "atand"; + "audiodevinfo"; + "audioplayerreg"; + "audiorecorderreg"; + "audiouniquename"; + "auditcontents"; + "aufinfo"; + "auread"; + "automesh"; + "autumn"; + "auwrite"; + "avifinfo"; + "aviinfo"; + "aviread"; + "awtinvoke"; + "axes"; + "axescheck"; + "axlimdlg"; + "ballode"; + "bar"; + "bar3"; + "bar3h"; + "barh"; + "base2dec"; + "basicfitdatastat"; + "batonode"; + "bench"; + "besschk"; + "bessel"; + "bessela"; + "besselh"; + "betacore"; + "betainc"; + "betaln"; + "bicg"; + "bicgstab"; + "bin2dec"; + "binpatch"; + "bitand"; + "bitcmp"; + "bitget"; + "bitmax"; + "bitor"; + "bitset"; + "bitshift"; + "bitxor"; + "blkdiag"; + "bone"; + "brighten"; + "brussode"; + "btndown"; + "btngroup"; + "btnicon"; + "btnpress"; + "btnresize"; + "btnstate"; + "btnup"; + "bucky"; + "buckydem"; + "builtin"; + "burgersode"; + "bvp4c"; + "bvpget"; + "bvpinit"; + "bvpset"; + "bvpval"; + "bwcontr"; + "calendar"; + "callSoapService"; + "calllib"; + "camdolly"; + "cameramenu"; + "cameratoolbar"; + "camlight"; + "camlookat"; + "camorbit"; + "campan"; + "campos"; + "camproj"; + "camroll"; + "camrotate"; + "camtarget"; + "camup"; + "camva"; + "camzoom"; + "cart2pol"; + "cart2sph"; + "cast"; + "cat"; + "catch"; + "caxis"; + "cbedit"; + "cdf2rdf"; + "cdfinfo"; + "cdfread"; + "cdfwrite"; + "cell2struct"; + "celldisp"; + "cellfun"; + "cellplot"; + "census"; + "cgs"; + "changeseriestype"; + "checkSyntacticWarnings"; + "checkin"; + "checkinwin"; + "checkout"; + "checkoutwin"; + "cholinc"; + "cholupdate"; + "circshift"; + "ckdepfun"; + "clabel"; + "class"; + "cleanupcomment"; + "clearcase"; + "clg"; + "clipboard"; + "clruprop"; + "cmapeditor"; + "cmdispatch"; + "cmdlnbgn"; + "cmdlnend"; + "cmdlnwin"; + "cmoptsdialog"; + "code2html"; + "codec"; + "colamd"; + "colmmd"; + "colon"; + "colorbar"; + "colorcube"; + "colormap"; + "colormapeditor"; + "colornone"; + "colperm"; + "colstyle"; + "comet"; + "comet3"; + "commandhistory"; + "commandwindow"; + "compan"; + "compass"; + "complex"; + "computer"; + "cond"; + "condeig"; + "condest"; + "coneplot"; + "contentsrpt"; + "contour"; + "contour3"; + "contourc"; + "contourf"; + "contours"; + "contourslice"; + "contrast"; + "conv2"; + "convertdemostodom"; + "convhull"; + "convhulln"; + "convn"; + "cool"; + "copper"; + "copyfile"; + "copyobj"; + "copyoptionsfcn"; + "corrcoef"; + "cosd"; + "cotd"; + "cov"; + "coveragerpt"; + "cplxdemo"; + "cplxgrid"; + "cplxmap"; + "cplxpair"; + "cplxroot"; + "createClassFromWsdl"; + "createSoapMessage"; + "cross"; + "cruller"; + "cscd"; + "cshelp"; + "csvread"; + "csvwrite"; + "ctlpanel"; + "ctranspose"; + "cumtrapz"; + "curl"; + "customverctrl"; + "cvs"; + "cylinder"; + "daqread"; + "daspect"; + "datachildren"; + "datacursormode"; + "dataread"; + "datatipinfo"; + "datenum"; + "datestr"; + "datetick"; + "datevec"; + "dbclear"; + "dbcont"; + "dbdown"; + "dblquad"; + "dbmex"; + "dbquit"; + "dbstack"; + "dbstatus"; + "dbstep"; + "dbstop"; + "dbtype"; + "dbup"; + "dde23"; + "ddeget"; + "ddeset"; + "ddex1"; + "ddex1de"; + "ddex1hist"; + "ddex2"; + "deal"; + "deblank"; + "debug"; + "dec2base"; + "dec2bin"; + "decic"; + "deconv"; + "del2"; + "delaunay"; + "delaunay3"; + "delaunayn"; + "deleteconfirm"; + "delsq"; + "delsqdemo"; + "demo"; + "demos"; + "demowin"; + "depdir"; + "depfun"; + "deprpt"; + "deselectall"; + "desktop"; + "desktopmenufcn"; + "detrend"; + "deval"; + "dialog"; + "diff2asv"; + "diffcode"; + "diffrpt"; + "diffuse"; + "divergence"; + "dlmread"; + "dlmwrite"; + "dmperm"; + "doclick"; + "docroot"; + "docsearch"; + "dofixrpt"; + "dokeypress"; + "domymenu"; + "doresize"; + "dot"; + "dragrect"; + "dsearch"; + "dsearchn"; + "e2pi"; + "e_handler"; + "earthmap"; + "edit"; + "editmenufcn"; + "editpath"; + "edtext"; + "eigmovie"; + "eigs"; + "eigs2"; + "eigshow"; + "ellipj"; + "ellipke"; + "ellipsoid"; + "emdenbvp"; + "enddrag"; + "eomday"; + "eq"; + "erfcinv"; + "erfcore"; + "erfinv"; + "errorbar"; + "errordlg"; + "etree"; + "etreeplot"; + "evalc"; + "evalin"; + "evalmcw"; + "expint"; + "expm1"; + "expmdemo"; + "expmdemo1"; + "expmdemo2"; + "expmdemo3"; + "export2wsdlg"; + "exportsetupdlg"; + "extent"; + "ezcontour"; + "ezcontourf"; + "ezgraph3"; + "ezmesh"; + "ezmeshc"; + "ezplot"; + "ezplot3"; + "ezpolar"; + "ezsurf"; + "ezsurfc"; + "factor"; + "factorial"; + "fcnchk"; + "feather"; + "fem1ode"; + "fem2ode"; + "fft2"; + "fftdemo"; + "fftn"; + "fftw"; + "fibodemo"; + "fieldnames"; + "fifteen"; + "figcopytemplatelistener"; + "figflag"; + "fignamer"; + "figtoolset"; + "figure"; + "figuredeletedlistener"; + "figureheaderdlg"; + "figurepalette"; + "fileattrib"; + "filebrowser"; + "fileformats"; + "filemarker"; + "filemenufcn"; + "fileread"; + "fill"; + "fill3"; + "filter"; + "filter2"; + "findall"; + "finddemo"; + "findfigs"; + "findobj"; + "finfo"; + "fitdemo"; + "fitfun"; + "fitsinfo"; + "fitsread"; + "fixcontents"; + "fixhelp"; + "fixquote"; + "flag"; + "flipdim"; + "flops"; + "flow"; + "fminbnd"; + "fminsearch"; + "fplot"; + "frame2im"; + "freeserial"; + "freqspace"; + "fsbvp"; + "func2str"; + "function_handle"; + "functions"; + "funfuns"; + "funm"; + "fzero"; + "gallery"; + "gammainc"; + "gca"; + "gcbf"; + "gcbo"; + "gcd"; + "gcf"; + "gco"; + "ge"; + "genpath"; + "genvarname"; + "get"; + "getFigureToolManager"; + "getappdata"; + "getcallinfo"; + "getcolumn"; + "getfield"; + "getframe"; + "getobj"; + "getorcreateobj"; + "getpixelposition"; + "getplottool"; + "getpref"; + "getprinttemplate"; + "getptr"; + "getscribecontextmenu"; + "getscribeobjectdata"; + "getselectobjects"; + "getstatus"; + "getuprop"; + "ginput"; + "gmres"; + "gplot"; + "grabcode"; + "gradient"; + "graf2d"; + "graf2d2"; + "graf3d"; + "graph2dhelper"; + "gray"; + "griddata"; + "griddata3"; + "griddatan"; + "gsvd"; + "gt"; + "gtext"; + "gui_mainfcn"; + "guidata"; + "guide"; + "guidefunc"; + "guidemfile"; + "guideopts"; + "guidetemplate"; + "guidetemplate0"; + "guidetemplate1"; + "guidetemplate2"; + "guidetemplate3"; + "guihandles"; + "hadamard"; + "handle2struct"; + "hardcopy"; + "hasbehavior"; + "hb1dae"; + "hb1ode"; + "hdf"; + "hdf5info"; + "hdf5read"; + "hdf5write"; + "hdfan"; + "hdfdf24"; + "hdfdfr8"; + "hdfgd"; + "hdfh"; + "hdfhd"; + "hdfhe"; + "hdfhx"; + "hdfinfo"; + "hdfml"; + "hdfpt"; + "hdfread"; + "hdfsd"; + "hdfsw"; + "hdftool"; + "hdftoolswitchyard"; + "hdfv"; + "hdfvf"; + "hdfvh"; + "hdfvs"; + "helpdlg"; + "helpinfo"; + "helpmenufcn"; + "helprpt"; + "helpview"; + "hex2dec"; + "hex2num"; + "hgaddbehavior"; + "hgbehaviorfactory"; + "hgconvertunits"; + "hgexport"; + "hgfeval"; + "hggetbehavior"; + "hgline2lineseries"; + "hgload"; + "hgsave"; + "hgtransform"; + "hidden"; + "hidegui"; + "hilb"; + "hist"; + "histc"; + "hndlaxis"; + "hndlgraf"; + "hot"; + "hsv"; + "hsv2rgb"; + "hthelp"; + "htpp"; + "humps"; + "iburgersode"; + "icondisp"; + "ifft2"; + "ifftn"; + "ihb1dae"; + "im2frame"; + "im2java"; + "image"; + "imagedemo"; + "imageext"; + "imagesc"; + "imageview"; + "imfinfo"; + "imformats"; + "import"; + "importdata"; + "imread"; + "imtext"; + "imwrite"; + "ind2rgb"; + "ind2sub"; + "indexhelper"; + "inferiorto"; + "info"; + "initdesktoputils"; + "inlineeval"; + "inmem"; + "inpolygon"; + "inputdlg"; + "inputname"; + "insertmenufcn"; + "inside"; + "inspect"; + "instrcb"; + "instrfind"; + "instrfindall"; + "int2str"; + "int64"; + "integerMath"; + "interp1q"; + "interp2"; + "interp3"; + "interpft"; + "interpn"; + "interpstreamspeed"; + "intersect"; + "intmax"; + "intmin"; + "intro"; + "intwarning"; + "invalidateaxis"; + "inverter"; + "invhilb"; + "ipermute"; + "is2D"; + "isappdata"; + "iscellstr"; + "isdeployed"; + "isequalwithequalnans"; + "isfloat"; + "ishghandle"; + "isjava"; + "iskeyword"; + "ismethod"; + "isobject"; + "isocaps"; + "isocolors"; + "isonormals"; + "isosurface"; + "ispref"; + "isprime"; + "isprop"; + "ispuma"; + "issorted"; + "issourcecontrolconfigured"; + "isstrprop"; + "isstudent"; + "isvarname"; + "java"; + "javaAddLsnrsToFigure"; + "javaArray"; + "javaGetHandles"; + "javaMethod"; + "javaObject"; + "javaaddpath"; + "javachk"; + "javaclasspath"; + "javacomponent"; + "javafigurequeue"; + "javarmpath"; + "jet"; + "jpropeditutils"; + "klein1"; + "knot"; + "lasterr"; + "lasterror"; + "lastwarn"; + "layout"; + "lcm"; + "ldivide"; + "le"; + "legend"; + "legendcolorbarlayout"; + "legendinfo"; + "legendre"; + "libfunctions"; + "libfunctionsview"; + "libisloaded"; + "libpointer"; + "libstruct"; + "life"; + "light"; + "lightangle"; + "lighting"; + "lin2mu"; + "line"; + "lines"; + "lineseries"; + "linkaxes"; + "linkprop"; + "linsolve"; + "listdlg"; + "listfonts"; + "lists"; + "loadhtml"; + "loadlibrary"; + "loadobj"; + "log1p"; + "loglog"; + "logm"; + "logo"; + "logspace"; + "lorenz"; + "lotka"; + "lotkademo"; + "ls"; + "lscan"; + "lscov"; + "lsqnonneg"; + "lsqr"; + "lt"; + "ltitr"; + "luinc"; + "m2struct"; + "magic"; + "makebars"; + "makecontentsfile"; + "makecounter"; + "makedisplaynames"; + "makefcn"; + "makehgtform"; + "makemcode"; + "makemenu"; + "makeshow"; + "makevase"; + "mat2cell"; + "mat2str"; + "mat4bvp"; + "material"; + "matfinfo"; + "matlabpath"; + "matlabroot"; + "matmanip"; + "matq2ws"; + "matqdlg"; + "matqparse"; + "matqueue"; + "mdbfileonpath"; + "mdbpublish"; + "mdbstatus"; + "mean"; + "median"; + "membrane"; + "memory"; + "menu"; + "menubar"; + "menuedit"; + "menueditfunc"; + "menulabel"; + "mesh"; + "meshc"; + "meshgrid"; + "meshz"; + "methods"; + "methodsview"; + "mex"; + "mexdebug"; + "mexext"; + "mfilename"; + "mfiletemplate"; + "middrag"; + "mimofr"; + "minres"; + "minus"; + "mislocked"; + "mkpp"; + "mlcomiface"; + "mldivide"; + "mlint"; + "mlintrpt"; + "mlock"; + "mmcompinfo"; + "mmfileinfo"; + "modes"; + "moveaxis"; + "movefile"; + "movegui"; + "movie"; + "movie2avi"; + "moviein"; + "movieview"; + "mpoles"; + "mpower"; + "mrdivide"; + "msgbox"; + "mtimes"; + "mu2lin"; + "multibandread"; + "multibandwrite"; + "munlock"; + "namelengthmax"; + "namelengthmax"; + "nargchk"; + "nargoutchk"; + "native2unicode"; + "nchoosek"; + "nddemo"; + "ndgrid"; + "ne"; + "nestdiss"; + "nested"; + "nesteddemo"; + "newfun"; + "newplot"; + "nextpow2"; + "nnload"; + "nnz"; + "noanimate"; + "nodither"; + "nonzeros"; + "normest"; + "normest1"; + "not"; + "notebook"; + "notebookCaptureFigures"; + "notebookCompareFigures"; + "now"; + "nthroot"; + "null"; + "num2cell"; + "num2hex"; + "numel"; + "numgrid"; + "numjac"; + "nzmax"; + "objbounds"; + "ode113"; + "ode15i"; + "ode15s"; + "ode23"; + "ode23s"; + "ode23t"; + "ode23tb"; + "ode45"; + "odedemo"; + "odeexamples"; + "odefile"; + "odeget"; + "odephas2"; + "odephas3"; + "odeplot"; + "odeprint"; + "odeset"; + "odextend"; + "open"; + "openfig"; + "opengl"; + "opentoline"; + "openvar"; + "optimget"; + "optimset"; + "or"; + "orbitode"; + "orderfields"; + "ordqz"; + "ordschur"; + "orient"; + "orth"; + "overobj"; + "pack"; + "padecoef"; + "pagedlg"; + "pagesetupdlg"; + "pan"; + "paren"; + "pareto"; + "parseSoapResponse"; + "parseparams"; + "partialpath"; + "pascal"; + "patch"; + "path"; + "path2rc"; + "pathsep"; + "pathtool"; + "pbaspect"; + "pcg"; + "pchip"; + "pcode"; + "pcolor"; + "pde"; + "pdepe"; + "pdeval"; + "pdex1"; + "pdex1bc"; + "pdex1ic"; + "pdex1pde"; + "pdex2"; + "pdex3"; + "pdex4"; + "pdex5"; + "peaks"; + "penny"; + "perl"; + "perms"; + "permute"; + "persistent"; + "pie"; + "pie3"; + "pink"; + "pinv"; + "planerot"; + "playbackdemo"; + "playshow"; + "plot3"; + "plotbrowser"; + "plotchild"; + "plotdoneevent"; + "plotedit"; + "plotmatrix"; + "plottoolfunc"; + "plottools"; + "plotutils"; + "plotyy"; + "plus"; + "pol2cart"; + "polar"; + "poly"; + "polyarea"; + "polyder"; + "polyeig"; + "polyfit"; + "polyint"; + "polyval"; + "polyvalm"; + "popupstr"; + "power"; + "ppval"; + "precedence"; + "prefdir"; + "preferences"; + "prefspanel"; + "prepdrag"; + "prepender"; + "primes"; + "print"; + "printdlg"; + "printdmfile"; + "printjob"; + "printprepare"; + "printpreview"; + "printrestore"; + "printtables"; + "printtemplate"; + "prism"; + "profile"; + "profreport"; + "profsave"; + "profview"; + "profviewgateway"; + "propedit"; + "propertyeditor"; + "psi"; + "publish"; + "punct"; + "putdowntext"; + "pvcs"; + "pwch"; + "pwd"; + "qhull"; + "qhulldemo"; + "qmr"; + "qrdelete"; + "qrinsert"; + "qrupdate"; + "quad"; + "quad8"; + "quadl"; + "quadv"; + "quake"; + "quatdemo"; + "questdlg"; + "quivdemo"; + "quiver"; + "quiver3"; + "qz"; + "randperm"; + "rank"; + "rat"; + "rats"; + "rbbox"; + "rcs"; + "rdivide"; + "reallog"; + "realpow"; + "realsqrt"; + "rectangle"; + "rectint"; + "recycle"; + "reducepatch"; + "reducevolume"; + "refresh"; + "refreshdata"; + "regexp"; + "regexpi"; + "regexprep"; + "rehash"; + "reloadsys"; + "relop"; + "remapfig"; + "render_basicaudiotoolbar"; + "render_fullaudiotoolbar"; + "reset"; + "resetplotview"; + "resi2"; + "residue"; + "rethrow"; + "rgb2hsv"; + "rgbplot"; + "ribbon"; + "rigidode"; + "rjr"; + "rmappdata"; + "rmdir"; + "rmfield"; + "rmpath"; + "rmpref"; + "roots"; + "rose"; + "rosser"; + "rot90"; + "rotate"; + "rotate3d"; + "rref"; + "rrefmovie"; + "rsf2csf"; + "run"; + "runreport"; + "saveas"; + "saveobj"; + "savepath"; + "savtoner"; + "scatter"; + "scatter3"; + "scribealign"; + "scribeaxesdlg"; + "scribeclearmode"; + "scribecursors"; + "scribeeventhandler"; + "scribefiglisten"; + "scribelinedlg"; + "scriberestoresavefcns"; + "scribetextdlg"; + "script"; + "sec"; + "secd"; + "sech"; + "selectmoveresize"; + "selectobject"; + "semilogx"; + "semilogy"; + "sendmail"; + "sepplot"; + "set"; + "setappdata"; + "setdiff"; + "setfield"; + "setpixelposition"; + "setpref"; + "setptr"; + "setscribecontextmenu"; + "setscribeobjectdata"; + "setstatus"; + "setuprop"; + "setxor"; + "shading"; + "shg"; + "shiftdim"; + "shockbvp"; + "showplottool"; + "shrinkfaces"; + "sind"; + "single"; + "singleMath"; + "slash"; + "slice"; + "slide2script"; + "smooth3"; + "snapshot"; + "snaptogrid"; + "soma"; + "somasols"; + "sortrows"; + "sound"; + "soundsc"; + "soundview"; + "sourcesafe"; + "spalloc"; + "sparsfun"; + "sparsity"; + "spaugment"; + "spconvert"; + "spdiags"; + "specular"; + "speye"; + "spfun"; + "sph2cart"; + "spharm2"; + "sphere"; + "spinmap"; + "spiral"; + "spline"; + "spline2d"; + "splncore"; + "spones"; + "spparms"; + "sprand"; + "sprandn"; + "sprandsym"; + "sprank"; + "spring"; + "sprintf"; + "spy"; + "spypart"; + "sqrtm"; + "squeeze"; + "ss2tf"; + "ss2zp"; + "sscanf"; + "ssdisp"; + "sshow"; + "ssinit"; + "sspause"; + "stairs"; + "standardrpt"; + "startscribeobject"; + "startscribepinning"; + "std"; + "stem"; + "stem3"; + "str2double"; + "str2func"; + "str2mat"; + "str2num"; + "str2rng"; + "strcat"; + "stream2"; + "stream3"; + "streamline"; + "streamparticles"; + "streamribbon"; + "streamslice"; + "streamtube"; + "strings"; + "stripanchors"; + "strjust"; + "strmatch"; + "strncmp"; + "strncmpi"; + "strread"; + "strtok"; + "strtrim"; + "strucdem"; + "strucdem_helper"; + "struct2cell"; + "struct2handle"; + "strvcat"; + "sub2ind"; + "subplot"; + "subsasgn"; + "subsindex"; + "subspace"; + "subsref"; + "substruct"; + "subvolume"; + "summer"; + "sunspots"; + "superiorfloat"; + "superiorto"; + "superquad"; + "support"; + "surf"; + "surf2patch"; + "surface"; + "surfc"; + "surfl"; + "surfnorm"; + "svds"; + "symamd"; + "symbfact"; + "symmlq"; + "symmmd"; + "symrcm"; + "symvar"; + "syntax"; + "system"; + "tabdlg"; + "table1"; + "table2"; + "tand"; + "taxDemo"; + "teapotdemo"; + "tempdir"; + "tempname"; + "tetramesh"; + "tex"; + "texlabel"; + "text"; + "textread"; + "textscan"; + "textscanDemo"; + "textwrap"; + "tf2ss"; + "tf2zp"; + "tfchk"; + "threebvp"; + "timerfind"; + "timerfindall"; + "times"; + "title"; + "toolsmenufcn"; + "tori4"; + "trace"; + "transpdemo"; + "transpose"; + "trapz"; + "travel"; + "treelayout"; + "treeplot"; + "trimesh"; + "triplequad"; + "triplot"; + "trisurf"; + "truss"; + "try"; + "tsearch"; + "tsearchn"; + "tube"; + "twobc"; + "twobvp"; + "twoode"; + "tzero"; + "uibuttongroup"; + "uiclearmode"; + "uicontainer"; + "uicontextmenu"; + "uicontrol"; + "uigetfile"; + "uigetpref"; + "uigettool"; + "uigettoolbar"; + "uiimport"; + "uiload"; + "uimenu"; + "uint64"; + "uiopen"; + "uipanel"; + "uipushtool"; + "uiputfile"; + "uirestore"; + "uiresume"; + "uisave"; + "uisetcolor"; + "uisetfont"; + "uisetpref"; + "uistack"; + "uisuspend"; + "uitable"; + "uitoggletool"; + "uitoolbar"; + "uitoolfactory"; + "uitree"; + "uitreefigure"; + "uitreenode"; + "uiundo"; + "uiwait"; + "umfpack"; + "uminus"; + "umtoggle"; + "undocheckout"; + "unicode2native"; + "union"; + "unique"; + "unloadlibrary"; + "unmesh"; + "unmkpp"; + "unwrap"; + "unzip"; + "uplus"; + "urlread"; + "urlwrite"; + "usejava"; + "usev6plotapi"; + "vander"; + "vanderpoldemo"; + "var"; + "vdp1"; + "vdp1000"; + "vdpode"; + "vectorize"; + "ver"; + "vertexpicker"; + "vga"; + "vibes"; + "view"; + "viewmenufcn"; + "viewmtx"; + "visdiff"; + "visdir"; + "visdirformhandler"; + "visdirrefresh"; + "vissuite"; + "volumebounds"; + "volvec"; + "voronoi"; + "voronoin"; + "vrml"; + "waitbar"; + "waitfor"; + "warndlg"; + "watchoff"; + "watchon"; + "waterfall"; + "wavfinfo"; + "wavplay"; + "wavread"; + "wavrecord"; + "wavwrite"; + "web"; + "webmenufcn"; + "weekday"; + "weissinger"; + "wernerboy"; + "what"; + "whatsnew"; + "which"; + "white"; + "whitebg"; + "why"; + "wilkinson"; + "winmenu"; + "winter"; + "wizard"; + "wk1const"; + "wk1finfo"; + "wk1read"; + "wk1wrec"; + "wk1write"; + "workspace"; + "workspacefunc"; + "wrldtrv"; + "ws2matq"; + "xfourier"; + "xgetselection"; + "xlabel"; + "xlim"; + "xlsfinfo"; + "xlsread"; + "xlswrite"; + "xmlread"; + "xmlwrite"; + "xor"; + "xpbombs"; + "xpklein"; + "xppage"; + "xpquad"; + "xpsound"; + "xpsubplt"; + "xptext"; + "xsetselection"; + "xslt"; + "xychk"; + "xycrull"; + "xyklein"; + "xyzchk"; + "xyzvchk"; + "ylabel"; + "ylim"; + "zip"; + "zlabel"; + "zlim"; + "zoom"; + "zp2ss"; + "zp2tf"] +endfunction diff --git a/modules/m2sci/macros/kernel/old2newinstr.bin b/modules/m2sci/macros/kernel/old2newinstr.bin new file mode 100755 index 000000000..0190897f1 Binary files /dev/null and b/modules/m2sci/macros/kernel/old2newinstr.bin differ diff --git a/modules/m2sci/macros/kernel/old2newinstr.sci b/modules/m2sci/macros/kernel/old2newinstr.sci new file mode 100755 index 000000000..a425bc5db --- /dev/null +++ b/modules/m2sci/macros/kernel/old2newinstr.sci @@ -0,0 +1,94 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2004-2006 - INRIA - Farid BELAHCENE +// +// 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.1-en.txt + +function instr=old2newinstr(instr,oldname,newname) + // This function replaces by a new name (given in a input argument:newname) in a Scilab instruction all the variables names and functions names matching to a given name in a input argument:oldname + // INPUTS: + // -instr: Scilab instruction + // -oldname: a string, matching to the name variable which must be replaced + // -newname: a string, matching to the new variable name + // OUTPUT: + // -instr: Scilab instruction after modification + + // VARIABLE tlist // + // If the variable name matches to the oldname argument then replace the variable name by the newname argument + if typeof(instr)=="variable" then + if instr.name==oldname then + instr.name=newname + end + // FUNCALL tlist // + // If the function name matches to oldname argument then replace the function name by newname argument + elseif typeof(instr)=="funcall" + if instr.name==oldname then + instr.name=newname + end + // ex: function return has not rhs: return.rhs is not a list + if typeof(instr.rhs)=="list" then + for i=1:size(instr.rhs) + instr.rhs(i)=old2newinstr(instr.rhs(i),oldname,newname) + end + end + // OPERATION tlist// + elseif typeof(instr)=="operation" then + for i=1:size(instr.operands) + instr.operands(i)=old2newinstr(instr.operands(i),oldname,newname) + end + // IF-THEN-ELSE instruction // + elseif typeof(instr)=="ifthenelse" then + instr.expression=old2newinstr(instr.expression,oldname,newname) + for i=1:size(instr.then) + instr.then(i)=old2newinstr(instr.then(i),oldname,newname) + end + for i=1:size(instr.elseifs) + for k=1:size(instr.elseifs(i).then) + instr.elseifs(i).then(k)=old2newinstr((instr.elseifs(i).then(k)),oldname,newname) + end + end + for i=1:size(instr.else) + instr.else(i)=old2newinstr((instr.else(i)),oldname,newname) + end + // SELECT-CASE instruction // + elseif typeof(instr)=="selectcase" then + instr.expression=old2newinstr(instr.expression,oldname,newname) + for i=1:size(instr.cases) + for j=1:size(instr.cases(i).then) + instr.cases(i).then(j)=old2newinstr((instr.cases(i).then(j)),oldname,newname) + end + end + for i=1:size(instr.else) + instr.else(i)=old2newinstr(instr.else(i),oldname,newname) + end + // WHILE instruction // + elseif typeof(instr)=="while" then + instr.expression=old2newinstr(instr.expression,oldname,newname) + for i=1:size(instr.statements) + instr.statements(i)=old2newinstr(instr.statements(i),oldname,newname) + end + // TRY-CATCH instruction // + elseif typeof(instr)=="trycatch" + for i=1:size(instr.trystat) + instr.trystat(i)=old2newinstr(instr.trystat(i),oldname,newname) + end + for i=1:size(instr.catchstat) + instr.catchstat(i)=old2newinstr(instr.catchstat(i),oldname,newname) + end + // FOR instruction // + elseif typeof(instr)=="for" then + instr.expression=old2newinstr(instr.expression,oldname,newname) + for i=1:size(instr.statements) + instr.statements(i)=old2newinstr(instr.statements(i),oldname,newname) + end + // EQUAL instruction // + elseif typeof(instr)=="equal" then + instr.expression=old2newinstr(instr.expression,oldname,newname) + for i=1:size(instr.lhs) + instr.lhs(i)=old2newinstr(instr.lhs(i),oldname,newname) + end + end +endfunction \ No newline at end of file diff --git a/modules/m2sci/macros/kernel/operation2sci.bin b/modules/m2sci/macros/kernel/operation2sci.bin new file mode 100755 index 000000000..9d6972a29 Binary files /dev/null and b/modules/m2sci/macros/kernel/operation2sci.bin differ diff --git a/modules/m2sci/macros/kernel/operation2sci.sci b/modules/m2sci/macros/kernel/operation2sci.sci new file mode 100755 index 000000000..7705c4300 --- /dev/null +++ b/modules/m2sci/macros/kernel/operation2sci.sci @@ -0,0 +1,72 @@ +// 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.1-en.txt + +function [sci_equiv]=operation2sci(mtlb_expr) + // M2SCI function + // Convert a function call in an instruction or in an expression from Matlab to Scilab + // Input: + // - mtlb_instr: Matlab instr or expression to convert + // Output: + // - sci_instr: Scilab equivalent for mtlb_instr + + sci_equiv=mtlb_expr + + nboperands=size(mtlb_expr.operands) + + // Special case for extraction + if mtlb_expr.operator=="ext" then + [bval,index]=isdefinedvar(mtlb_expr.operands(1)) + + // Variable is unknown + if ~bval then + // Try to find what is this variable + [tmp]=getvar2sci(mtlb_expr.operands(1),lhslist) + if typeof(tmp)=="funcall" then + newname=mtlb_expr.operands(1).name + mtlb_expr.operands(1)=null() + mtlb_expr=Funcall(newname,size(lhslist),mtlb_expr.operands,lhslist) + [sci_equiv]=expression2sci(mtlb_expr,lhslist) + return + else + end + end + end + + opind=1 + while opind<=nboperands + [sci_operand]=expression2sci(mtlb_expr.operands(opind)) + mtlb_expr.operands(opind)=sci_operand + opind=opind+1 + // Special case for insertion, is this case, last operand (right expression) is not converted + if mtlb_expr.operator=="ins" & opind==nboperands then + break + end + + end + + // Function find is not used because does not work with strings + ind=-1 + for kop=1:size(ops,1) + if ops(kop,1)==mtlb_expr.operator then + ind=kop + break + end + end + if ind==-1 then + error(msprintf(gettext("operator %s not found."),mtlb_expr.operator)) + end + rhs=size(mtlb_expr.operands) + execstr("[sci_equiv]=%"+ops(ind,2)+"2sci(mtlb_expr)"); + + // Update lhsnb if Scilab equivalent is a function call + if typeof(sci_equiv)=="funcall" then + sci_equiv.lhsnb=size(sci_equiv.lhs) + end + +endfunction diff --git a/modules/m2sci/macros/kernel/repl_poss.bin b/modules/m2sci/macros/kernel/repl_poss.bin new file mode 100755 index 000000000..9c67a3373 Binary files /dev/null and b/modules/m2sci/macros/kernel/repl_poss.bin differ diff --git a/modules/m2sci/macros/kernel/repl_poss.sci b/modules/m2sci/macros/kernel/repl_poss.sci new file mode 100755 index 000000000..d7d8e2807 --- /dev/null +++ b/modules/m2sci/macros/kernel/repl_poss.sci @@ -0,0 +1,40 @@ +// 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.1-en.txt + +function []=repl_poss(expr,varargin) + // Display information for replacement for a statement in converted file + + txt=[] + nposs=size(varargin) + + if nposs==0 | fix(nposs/3)*3~=nposs then + error(gettext("Wrong number of inputs.")) + end + + txt=[expression2code(expr)+gettext(" may be replaced by:")] + for k=1:3:nposs + vars="" + if typeof(varargin(k+1))<>"list" then + vars=expression2code(varargin(k+1)) + else + for l=1:size(varargin(k+1)) + vars=vars+expression2code(varargin(k+1)(l)) + if l "+expression2code(varargin(k))+" "+gettext("if")+" "+vars+" "+varargin(k+2)] + end + + set_infos(txt,1) + +endfunction diff --git a/modules/m2sci/macros/kernel/replace_brackets.bin b/modules/m2sci/macros/kernel/replace_brackets.bin new file mode 100755 index 000000000..b83f831f0 Binary files /dev/null and b/modules/m2sci/macros/kernel/replace_brackets.bin differ diff --git a/modules/m2sci/macros/kernel/replace_brackets.sci b/modules/m2sci/macros/kernel/replace_brackets.sci new file mode 100755 index 000000000..084923e06 --- /dev/null +++ b/modules/m2sci/macros/kernel/replace_brackets.sci @@ -0,0 +1,52 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function txt=replace_brackets(txt) + + symbs=[",",";","=",")","]","("] + // This file will be use to deal with cells... + for k=1:size(txt,"r") + + // select-case + if strindex(txt(k),"case")<>[] then + txt(k)=strsubst(strsubst(txt(k),"{","makecell("),"}",")") + else + tk=strsubst(txt(k)," ","") + + ko=strindex(tk,"{") + if ko<>[] then + teq=strindex(tk,"=") + + /// + if ko(1)==1 then + txt(k)=strsubst(txt(k),"{}","makecell()") + txt(k)=strsubst(strsubst(txt(k),"{","(makecell([cell(),"),"}","]))") + elseif or(part(tk,ko(1)-1)==symbs) then + txt(k)=strsubst(txt(k),"{}","makecell()") + txt(k)=strsubst(strsubst(txt(k),"{","(makecell([cell(),"),"}","]))") + else // Cell index + txt(k)=strsubst(strsubst(txt(k),"{","("),"}",").entries") + end + + //// + + for kk=2:size(ko,"*") + if or(part(tk,ko(kk)-1)==symbs) then // Cell creation + txt(k)=strsubst(txt(k),"{}","makecell()") + txt(k)=strsubst(strsubst(txt(k),"{","(makecell([cell(),"),"}","]))") + else // Cell index + txt(k)=strsubst(strsubst(txt(k),"{","("),"}",").entries") + end + end + elseif ~isempty(strindex(txt(k),"}")) then + txt(k)=strsubst(txt(k),"}","]))") + end + end + end +endfunction diff --git a/modules/m2sci/macros/kernel/sci_generic.bin b/modules/m2sci/macros/kernel/sci_generic.bin new file mode 100755 index 000000000..cca08126d Binary files /dev/null and b/modules/m2sci/macros/kernel/sci_generic.bin differ diff --git a/modules/m2sci/macros/kernel/sci_generic.sci b/modules/m2sci/macros/kernel/sci_generic.sci new file mode 100755 index 000000000..ffe4d8307 --- /dev/null +++ b/modules/m2sci/macros/kernel/sci_generic.sci @@ -0,0 +1,25 @@ +// 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.1-en.txt + +function [tree]=sci_generic(tree) + // M2SCI function + // Generic conversion function for unknown Matlab functions + // Input: tree = Matlab funcall tree + // Output: tree = Scilab equivalent for tree + + if typeof(tree)=="operation" + tree.out(1).dims=list(-1,-1) + tree.out(1).type=Type(-1,-1) + else + for i=1:size(tree.lhs) + tree.lhs(i).dims=list(-1,-1) + tree.lhs(i).type=Type(-1,-1) + end + end +endfunction diff --git a/modules/m2sci/macros/kernel/sci_m2scideclare.bin b/modules/m2sci/macros/kernel/sci_m2scideclare.bin new file mode 100755 index 000000000..a6849403e Binary files /dev/null and b/modules/m2sci/macros/kernel/sci_m2scideclare.bin differ diff --git a/modules/m2sci/macros/kernel/sci_m2scideclare.sci b/modules/m2sci/macros/kernel/sci_m2scideclare.sci new file mode 100755 index 000000000..c1c41bcc0 --- /dev/null +++ b/modules/m2sci/macros/kernel/sci_m2scideclare.sci @@ -0,0 +1,342 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - 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.1-en.txt + +function []=sci_m2scideclare(def) + // This function translate calls to m2scideclare + // which can be used by the user to influence translation + // by adding a comment which begins by m2scideclare + + // Global variable for M2SCI + global("varslist") + + //variable_name|dimensions|datatype|property + + //dimensions: variable dimensions separated by blanks (Unknown dimension is ?) + + //datatype: + // - double: scalar/vector/matrix/hypermatrix containing double values + // - string: scalar/vector/matrix/hypermatrix containing character strings + // - boolean: scalar/vector/matrix/hypermatrix containing boolean values + // - int: scalar/vector/matrix/hypermatrix containing integer values + // - handle: matrix of graphics handles or graphics handle + // - sparse: sparse scalar/vector/matrix/hypermatrix + // - cell: cell array + // - struct: struct array + // - ? if unknown + + //property: + // - real/complex/? for double and int datatype + // - real for string and boolean datatype (ignored if not) + // - NOT USED for struct/cell/handle datatype + + // def is the comment added by the user + userdata=def.rhs(1).value + // Remove all multiple blanks + while strindex(userdata," ")<>[] + userdata=strsubst(userdat," "," ") + end + + seppos=strindex(userdata,"|") + + seppos=[seppos,length(userdata)+1] + + nbsep=size(seppos,"*") + + if nbsep<3 then + error(gettext("not enough data, you should give at least variable_name|dimensions|datatype.")); + elseif nbsep>4 then + error(gettext("too much data.")); + end + + name=stripblanks(part(userdata,1:seppos(1)-1)) + + dimstxt=part(userdata,seppos(1)+1:seppos(2)-1) + + datatypetxt=part(userdata,seppos(2)+1:seppos(3)-1) + + if nbsep==4 then + proptxt=part(userdata,seppos(3)+1:seppos(4)-1) + else + proptxt="?" + end + + // Dimensions + dimstxt=strsubst(dimstxt,"?","-1") + dimstxt=strsubst(dimstxt,"*","-2") + dimstxt=strsubst(dimstxt,"#","-3") + blpos=strindex(dimstxt," ") + nbblanks=size(blpos) + blpos=[1,blpos,length(dimstxt)+1] + fmt="%d" + dims=list() + for kbl=1:size(blpos,"*")-1 + dims($+1)=evstr(part(dimstxt,blpos(kbl):blpos(kbl+1))) + end + + // Datatype + datatypetxt=strsubst(datatypetxt,"?","Unknown") + datatype=convstr(datatypetxt,"l") + if or(datatype==["double","boolean","string","int","handle","sparse","cell","struct","unknown"]) then + datatype=convstr(part(datatype,1),"u")+convstr(part(datatype,2:length(datatype)),"l") + vtype=evstr(datatype) + else + error(msprintf(gettext("Unknown datatype %s."),datatypetxt)); + end + + // Property + proptxt=strsubst(proptxt,"?","Unknown") + prop=convstr(proptxt,"l") + if or(prop==["real","complex","homogen","unknown"]) then + prop=convstr(part(prop,1),"u")+part(prop,2:length(prop)) + property=evstr(prop) + else + error(msprintf(gettext("Unknown property %s."),proptxt)); + end + // Property correction + if or(vtype==[Boolean,String]) then + property=Real + end + + if strindex(name,".")<>[] then // Cell or Struct m2scideclare + // Get varname + endofname=min([strindex(name,[".","("])])-1 + varname=part(name,1:endofname) + + // First field name (if is 'entries' then a cell else a struct) + firstpoint=min(strindex(name,".")) + secpoint=min(strindex(part(name,firstpoint+1:length(name)),".")) + par=min(strindex(part(name,firstpoint+1:length(name)),"(")) + if isempty(secpoint) & isempty(par) then //x.fieldname + firstfield=part(name,firstpoint:length(name)) + elseif isempty(secpoint) then //x.fieldname(p...) + firstfield=part(name,firstpoint:par-1) + elseif isempty(par) then //x.fieldname.fieldname2 + firstfield=part(name,firstpoint:secpoint-1) + else //x.fieldname(p...).fieldname2 + firstfield=part(name,firstpoint:min([secpoint par])-1) + end + if firstfield==".entries" then // Cell + vartype=Cell + else // Struct + vartype=Struct + end + + // Indexes for varname ? myvar(1,2).field.... + if or(strindex(name,"(")Unknown then + err=%T + break + end + end + + // Update dimensions + if err then + set_infos(msprintf(gettext("Dimensions current value and m2scideclare statements conflict for: %s\n m2scideclare given dimension: %s\n Current dimension: %s\n m2scideclare IGNORED"),varname,dims2str(vardims),dims2str(infereddims)),2) + else + varslist(index)=M2scivar(varslist(index).matname,varslist(index).matname,Infer(vardims,Type(varslist(index).type.vtype,property))) + end + + // Update vtype + if varslist(index).type.vtype==Unknown then + varslist(index)=M2scivar(varslist(index).matname,varslist(index).matname,Infer(vardims,Type(vartype,varslist(index).property))) + elseif varslist(index).type.vtype~=vartype then + set_infos(msprintf(gettext("Type current value and m2scideclare statements conflict for: %s\n m2scideclare given type: %s\n current type: %s\n m2scideclare IGNORED"),varname,tp2str(vartype),tp2str(varslist(index).type.vtype)),2) + end + + // Update property + if varslist(index).property==Unknown then + varslist(index).infer.type.property=property + elseif property==Unknown then + varslist(index).type.property=Unknown + elseif varslist(index).type.property~=property then + set_infos(msprintf(gettext("Property current value and m2scideclare statements conflict for: %s\n m2scideclare given type: %s\n current type: %s\n m2scideclare IGNORED"),name,prop2str(Unknown),prop2str(varslist(index).type.property)),2) + end + + // Update contents (no verification made...too complex) + contents=varslist(index).contents + name=strsubst(name,"*","%genericm2sciindex") + deff("m2scitmp",name) + t=macr2tree(m2scitmp); + if isempty(firstpoint) then + contents.index($+1)=t.statements(2).expression.rhs; + else + contents.index($+1)=t.statements(2).expression.rhs(1); + end + clear m2scitmp + for k=1:lstsize(contents.index($)) + if typeof(contents.index($)(k))=="variable" & contents.index($)(k).name=="%genericm2sciindex" then + contents.index($)(k)=Cste("*") + elseif typeof(contents.index($)(k))=="cste" then + contents.index($)(k)=Cste(contents.index($)(k).value) + elseif typeof(contents.index($)(k))=="list" then + for kk=1:lstsize(contents.index($)(k)) + if typeof(contents.index($)(k)(kk))=="variable" & contents.index($)(k)(kk).name=="%genericm2sciindex" then + contents.index($)(k)(kk)=Cste("*") + elseif typeof(contents.index($)(k)(kk))=="cste" then + contents.index($)(k)(kk)=Cste(contents.index($)(k)(kk).value) + end + end + end + end + contents.data($+1)=Infer(dims,Type(vtype,property)) + varslist(index)=M2scivar(varname,varname,Infer(vardims,Type(vartype,Unknown),contents)) + + end + else // Variable m2scideclare + + // Special part for %graphicswindow + if name=="%graphicswindow" then + global %graphicswindow + if and(vtype<>[Handle,Double]) then + set_infos(gettext("%graphicswindow set to default value Handle."),2); + else + %graphicswindow=vtype + end + return + end + + [isvar,index]=isdefinedvar(Variable(name,Infer())) + + if ~isvar then // If variable does not exist it is added to varslist + varslist($+1)=M2scivar(name,name,Infer(dims,Type(vtype,property))) + else // Try to compare with already infered data + // Update dims + infereddims=varslist(index).dims + + err=%F + for kd=1:min([lstsize(dims) lstsize(infereddims)]) + if infereddims(kd)~=dims(kd) & infereddims(kd)<>Unknown then + err=%T + break + end + end + + if err then + set_infos(msprintf(gettext("Dimensions current value and m2scideclare statements conflict for: %s\n m2scideclare given dimension: %s\n Current dimension: %s\n m2scideclare IGNORED"),name,dims2str(dims),dims2str(infereddims)),2) + else + varslist(index)=M2scivar(varslist(index).matname,varslist(index).sciname,Infer(dims,varslist(index).type)) + end + + // Update vtype + if varslist(index).type.vtype==Unknown then + varslist(index)=M2scivar(varslist(index).matname,varslist(index).sciname,Infer(varslist(index).dims,Type(vtype,varslist(index).type.property))) + elseif varslist(index).type.vtype~=vtype then + set_infos(msprintf(gettext("Type current value and m2scideclare statements conflict for: %s\n m2scideclare given type: %s\n current type: %s\n m2scideclare IGNORED"),name,tp2str(vtype),tp2str(varslist(index).type.vtype)),2) + end + + // Update property + if varslist(index).type.property==Unknown then + varslist(index)=M2scivar(varslist(index).matname,varslist(index).sciname,Infer(varslist(index).dims,Type(varslist(index).type.vtype,property))) + elseif varslist(index).type.property~=property then + set_infos(msprintf(gettext("Property current value and m2scideclare statements conflict for: %s\n m2scideclare given type: %s\n current type: %s\n m2scideclare IGNORED"),name,prop2str(property),prop2str(varslist(index).type.property)),2) + end + end + end +endfunction + + +function str=tp2str(tp) + // Returns equivalent of typeof() from data coming from type() + + if tp==1 then + str="Double" + elseif tp==4 then + str="Boolean" + elseif tp==6 then + str="Sparse" + elseif tp==8 then + str="Int" + elseif tp==9 then + str="Handle" + elseif tp==10 then + str="String" + elseif tp==16 then + str="Struct" + elseif tp==17 then + str="Cell" + elseif tp==-1 then + str="Unknown" + else + error(msprintf(gettext("type %d is not implemented."),tp)) + end +endfunction + +function str=prop2str(prop) + if type(prop)==10 then + str=prop + elseif prop==-1 then + str="Unknown" + else + error(msprintf(gettext("type %d is not implemented."),prop)) + end +endfunction + +function str=dims2str(dims) + str="" + for kd=1:lstsize(dims) + str=str+string(dims(kd))+" " + end +endfunction diff --git a/modules/m2sci/macros/kernel/sciparam.bin b/modules/m2sci/macros/kernel/sciparam.bin new file mode 100755 index 000000000..e028f558c Binary files /dev/null and b/modules/m2sci/macros/kernel/sciparam.bin differ diff --git a/modules/m2sci/macros/kernel/sciparam.sci b/modules/m2sci/macros/kernel/sciparam.sci new file mode 100755 index 000000000..4c420376a --- /dev/null +++ b/modules/m2sci/macros/kernel/sciparam.sci @@ -0,0 +1,56 @@ +// 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.1-en.txt + +function sciparam() + // M2SCI variable declaration + // All variables listed below can be accessed for reading from all macros called from m2sci() macro + + quote="''" + logics=["==","<",">","<=",">=","<>"] + + // Operations code + // [ operation symbol, operation translation function code ; ...] + // e.g. : translation function for addition (+) is named %a2sci()... + ops = [ "+" , "a" ; + "-" , "s" ; + "*" , "m" ; + ".*" , "x" ; + "*." , "u" ; + ".*." , "k" ; + "/" , "r" ; + "./" , "d" ; + "/." , "v" ; + "./." , "y" ; + "\" , "l" ; + ".\" , "q" ; + "\." , "w" ; + ".\." , "z" ; + "^" , "p" ; + "==" , "log" ; + "<" , "log" ; + ">" , "log" ; + "<=" , "log" ; + ">=" , "log" ; + "~=" , "log" ; + ":" , "imp" ; + "rc" , "rc" ; + "ins" , "i" ; + "ext" , "e" ; + quote , "t" ; + "cc" , "cc" ; + "|" , "g" ; + "&" , "h" ; + "~" , "5" ; + ".^" , "j" ; + "."+quote , "0" ; + "cceol" , "cc" ] // Column Concatenation with EOL between Rows + + [logics,ops,quote]=resume(logics,ops,quote) + +endfunction diff --git a/modules/m2sci/macros/kernel/set_infos.bin b/modules/m2sci/macros/kernel/set_infos.bin new file mode 100755 index 000000000..ff1c90da4 Binary files /dev/null and b/modules/m2sci/macros/kernel/set_infos.bin differ diff --git a/modules/m2sci/macros/kernel/set_infos.sci b/modules/m2sci/macros/kernel/set_infos.sci new file mode 100755 index 000000000..927e49414 --- /dev/null +++ b/modules/m2sci/macros/kernel/set_infos.sci @@ -0,0 +1,27 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function []=set_infos(t,level) + + // Add warning and error messages obtained while translating to display it in the end of file translation + global("m2sci_infos") + + t(1)="L."+string(nblines)+": "+t(1) + + select level + case 0 then + case 1 then + m2sci_infos(level)=%t + t="! "+t + case 2 then + m2sci_infos(level)=%t + t="!! "+t + end + m2sci_info(t,verbose_mode); +endfunction diff --git a/modules/m2sci/macros/kernel/transformtree.bin b/modules/m2sci/macros/kernel/transformtree.bin new file mode 100755 index 000000000..51744bad8 Binary files /dev/null and b/modules/m2sci/macros/kernel/transformtree.bin differ diff --git a/modules/m2sci/macros/kernel/transformtree.sci b/modules/m2sci/macros/kernel/transformtree.sci new file mode 100755 index 000000000..5478ebb31 --- /dev/null +++ b/modules/m2sci/macros/kernel/transformtree.sci @@ -0,0 +1,84 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2004-2006 - INRIA - Farid BELAHCENE +// +// 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.1-en.txt + +function instr=transformtree(instr) + //TRANSFORMTREE function + //This function research and transform the equal instructions(if the lhs are a multi_operation and expression is a funcall) + //of the matlab tree to a sup_equal instructions + //sup_equal is a tlist : tlist([sup_equal,sup_instr,nb_op],sup_instr,nb_op) + //i.e : the equal instruction [a(1),b(2:3)]=f() is replaced by + //sup_equal, whith sup_intr list is composed to : + //[%v1,%v2]=f() + //a(1)=%v1 + //b(2:3)=%v2 + //and nb_op is: the number of insert operation (in this case 2) + //Input + //instr : instruction of matlab tree before tranformation + //Output + //instr : instruction of matlab tree after transformation + + Unknown=-1; + // Browse all the instrucions of the matlab tree: + if typeof(instr)=="ifthenelse" then + for i=1:size(instr.then) + instr.then(i)=transformtree((instr.then(i))) + end + for i=1:size(instr.elseifs) + for k=1:size(instr.elseifs(i).then) + instr.elseifs(i).then(k)=transformtree((instr.elseifs(i).then(k))) + end + end + for i=1:size(instr.else) + instr.else(i)=transformtree((instr.else(i))) + end + elseif typeof(instr)=="selectcase" then + for i=1:size(instr.cases) + for j=1:size(instr.cases(i).then) + instr.cases(i).then(j)=transformtree((instr.cases(i).then(j))) + end + end + for i=1:size(instr.else) + instr.else(i)=transformtree(instr.else(i)) + end + elseif typeof(instr)=="while" then + for i=1:size(instr.statements) + instr.statements(i)=transformtree(instr.statements(i)) + end + elseif typeof(instr)=="for" then + for i=1:size(instr.statements) + instr.statements(i)=transformtree(instr.statements(i)) + end + //instruction is an equal instruction + elseif typeof(instr)=="equal" then + if typeof(instr.expression)=="funcall" then //expression is a funcall + nb_opr=0; + for ind=1:size(instr.lhs) + if typeof(instr.lhs(ind))=="operation" then + nb_opr=nb_opr+1 + end + end + if nb_opr>1 then //more than one lhs insert operation + sup_instr=list(""); + lhstemp=list(); + for j=1:size(instr.lhs) + if typeof(instr.lhs(j))=="operation" then + x=gettempvar(); + sup_instr($+1)=Equal(list(instr.lhs(j)),x); + lhstemp(j)=x; + else + lhstemp(j)=instr.lhs(j) + end + end + sup_instr(1)=Equal(lhstemp,instr.expression) + //creation of the sup_equal + instr=tlist(["sup_equal","sup_instr","nb_opr"],sup_instr,nb_opr) + end + end + end +endfunction \ No newline at end of file diff --git a/modules/m2sci/macros/kernel/translateorder.bin b/modules/m2sci/macros/kernel/translateorder.bin new file mode 100755 index 000000000..3b1d7665f Binary files /dev/null and b/modules/m2sci/macros/kernel/translateorder.bin differ diff --git a/modules/m2sci/macros/kernel/translateorder.sci b/modules/m2sci/macros/kernel/translateorder.sci new file mode 100755 index 000000000..89acd5d8b --- /dev/null +++ b/modules/m2sci/macros/kernel/translateorder.sci @@ -0,0 +1,49 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function [transorder]=translateorder(transorder,funtxt,overfunname) + // TRANSLATEORDER Recursive function + // Determinates a translate order of the M-files found in Paths (used by "translatepaths" function) + // Output-Input + // -transorder : a vector containing the M-files names which are arranged in order to respect an priority order of translation + // Input + // -funtxt : a vector which contains the name of a M-file found in the Paths (its first component: funtxt(1)), and the called functions by this file (the others components : funtxt(2:$)) + // -overfunname : a vector which contains the files names being passed like argument of "translateorder" function + + // the file is already in the list + if or(transorder==funtxt(1)) then + return + end + + if size(funtxt,"*")>1 then + for i=2:size(funtxt,1) + // the called function is already in the list + if find(funtxt(i)==transorder)<>[] then + continue + // the called function is already passed in argument of "translateorder" function (a loop) + elseif find(funtxt(i)==overfunname)<>[] then + disp([overfunname;funtxt(i)],"loop: ") + //return + continue + // order the under level, also we call translateorder (recursive) + else + overfunname($+1)=funtxt(1) + execstr("[transorder]=translateorder(transorder,"+funtxt(i)+"vect,overfunname)") + end + end + transorder($+1)=funtxt(1) + else + // no called function by the M-file, also we put the M-file name in the transorder vector + transorder($+1)=funtxt(1) + end + +endfunction + + + diff --git a/modules/m2sci/macros/kernel/update_instr_list.bin b/modules/m2sci/macros/kernel/update_instr_list.bin new file mode 100755 index 000000000..4f950bce2 Binary files /dev/null and b/modules/m2sci/macros/kernel/update_instr_list.bin differ diff --git a/modules/m2sci/macros/kernel/update_instr_list.sci b/modules/m2sci/macros/kernel/update_instr_list.sci new file mode 100755 index 000000000..87526ae45 --- /dev/null +++ b/modules/m2sci/macros/kernel/update_instr_list.sci @@ -0,0 +1,45 @@ +// 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.1-en.txt + +function [instr_list]=update_instr_list(instr_list,instr) + // M2SCI function + + // Global variables for M2SCI + global("m2sci_to_insert_b") + if isempty(m2sci_to_insert_b) + m2sci_to_insert_b = list(); + end + global("m2sci_to_insert_a") + if isempty(m2sci_to_insert_a) + m2sci_to_insert_a = list(); + end + + // Get instructions that must be inserted before converted instruction + for k=1:lstsize(m2sci_to_insert_b) + if m2sci_to_insert_b(k)<>list() then + instr_list($+1)=m2sci_to_insert_b(k) + end + end + m2sci_to_insert_b=list() + + // Insert converted instruction + // instr can be an empty list if a call to 'm2scideclare' or convertion made in m2sci_to_insert_b + if instr<>list() then + instr_list($+1)=instr + end + + // Get instructions that must be inserted after converted instruction + for k=1:lstsize(m2sci_to_insert_a) + if m2sci_to_insert_a(k)<>list() then + instr_list($+1)=m2sci_to_insert_a(k) + end + end + m2sci_to_insert_a=list() + +endfunction diff --git a/modules/m2sci/macros/kernel/updatevarslist.bin b/modules/m2sci/macros/kernel/updatevarslist.bin new file mode 100755 index 000000000..949389aa7 Binary files /dev/null and b/modules/m2sci/macros/kernel/updatevarslist.bin differ diff --git a/modules/m2sci/macros/kernel/updatevarslist.sci b/modules/m2sci/macros/kernel/updatevarslist.sci new file mode 100755 index 000000000..a19d331b3 --- /dev/null +++ b/modules/m2sci/macros/kernel/updatevarslist.sci @@ -0,0 +1,233 @@ +// 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.1-en.txt + +function []=updatevarslist(instr_lhs) + // (2 functions in this file: merge_vars() at the end) + // Update list of M2SCI variables with converted instruction lhs + // Input: + // - instr_lhs: list of lhs of current instruction + // - in_a_clause: boolean value + // Set to 1 if instruction is in a clause + // In this case, type and dimensions are set to unknown if differ from those already stored in varslist + // (Default value is %F) + + // Global variable for M2SCI + global("varslist") + if isempty(varslist) + varslist = list() + end + // level is declared in m2sci.sci and modified in clause2sci.sci + level; + + rhs=argn(2) + if rhs==2 then + in_a_clause=%F + end + + // Merge infered data from the last two parts of clause which are above the current part + // if we are in the third part of clause (current), then : merge the first and second part of clause + // when end of conversion of a clause : merge infered data from the last two parts of clause + levelsize=size(level,1) + changepartclause=%F + + for i=size(varslist):-1:1 + if size(varslist(i).level,1)==levelsize then + varlevel=varslist(i).level + if varlevel($)<>level($) + changepartclause=%T + else + changepartclause=%F + break + end + end + end + if changepartclause | instr_lhs=="END OF CLAUSE" then + index=[] // Search variables from two part above current part clause + for k=size(varslist):-1:1 + if size(varslist(k).level,1)==levelsize then + varlevel=varslist(k).level + if and(varlevel(1:$-1)==level(1:$-1)) & varlevel($)==level($)-2 then + index=[index;k] + end + end + end + if index<>[] then // Found variables from the second part above current part of a clause + for k=1:size(index,1) + boolmerge =%F + for i=size(varslist):-1:1 // Search variables from the first part above current part of a clause, and which have the same name than variables from the second part above current part of a clause + varlevel=varslist(i).level + if varslist(i).matname==varslist(index(k)).matname & and(varlevel(1:$-1)==level(1:$-1)) & varlevel($)==level($)-1 then + boolmerge =%T // Found the same variable name from the last two parts above the current part : Merge + merge_vars(index(k),varslist(i)) + varslist(i)=null() + break + end + end + if ~boolmerge then + varslist(index(k)).level=[level(1:$-1);level($)-1] + end + end + end + end + + // Special case when end of conversion of a clause + // Merge infered data from clause and those from level-1 + if instr_lhs=="END OF CLAUSE" then // Search variables in the last part of a clause (above end of conversion of a clause) + index=[] // + for k=size(varslist):-1:1 // Search variables from level-1 which have the same name than variables from the last part of current level + varlevel=varslist(k).level + if varlevel==[level(1:$-1);level($)-1] then + index=[index;k] + end + end + if index<>[] then + for j=1:size(index,1) + boolmerge=%F + for k=size(varslist):-1:1 // + varlevel=varslist(k).level + if varslist(k).matname==varslist(index(j)).matname & and(varlevel==level(1:$-1)) then + boolmerge=%T // Found variables from level-1 which have the same name than variables from the last part of current level : Merge + index_lower_level=k + merge_vars(index_lower_level,varslist(index(j))) + varslist(k).level=level(1:$-1) + varslist(index(j))=null() + break + end + end + if boolmerge==%F then + varslist(index(j)).level=level(1:$-1) + end + end + end + return + end + + // Expression: lhs name is empty => nothing to do + if instr_lhs==list() then + return + end + + // Remove lhs which are not variables + k=1 + while k<=size(instr_lhs) + // Insertion operation + if typeof(instr_lhs(k))=="operation" then + instr_lhs(k)=null() + else + k=k+1 + end + end + + if size(instr_lhs)==0 then + return + end + + // Update varslist + for k=1:size(instr_lhs) + [bval,index]=isdefinedvar(instr_lhs(k)) + ierr=execstr("zz=instr_lhs(k).contents.index","errcatch") + if ierr<>0 then pause;end + // Remove multiple entries from contents + for kcont=lstsize(instr_lhs(k).contents.index):-1:1 + [infertlist,pos]=get_contents_infer(instr_lhs(k),instr_lhs(k).contents.index(kcont)) + if pos<>0 & pos<>kcont then + instr_lhs(k).contents.index(pos)=null() + instr_lhs(k).contents.data(pos)=null() + end + end + // If variable exists for the current level in the same part of clause then update exixting variable + if bval + boolupdate=%F + for l=1:size(varslist) + if varslist(l).matname==instr_lhs(k).name & varslist(l).level==level then + varslist(l)=M2scivar(varslist(l).sciname,.. + varslist(l).matname,.. + Infer(instr_lhs(k).infer.dims,instr_lhs(k).infer.type,instr_lhs(k).infer.contents),.. + varslist(l).level) + boolupdate=%T + break + end + end + // If variable exists, but not for the current level or not in the same part of clause then Update variable then create new variable + if ~boolupdate then + varslist($+1)=M2scivar(varslist(index).sciname,.. + varslist(index).matname,.. + instr_lhs(k).infer,.. + level) + end + else + // Variable added to varslist if as a name (not done for expressions + if execstr("f=instr_lhs(k).name","errcatch")<>0 then pause;end;errclear(); + if instr_lhs(k).name<>"ans" then + varslist($+1)=M2scivar(instr_lhs(k).name,.. + instr_lhs(k).name,.. + instr_lhs(k).infer,.. + level) + end + end + end +endfunction + +function []=merge_vars(oldvarindex,newvar) + // M2SCI function + // Merge two variables inference properties, if different then set to Unknown + // Input: + // - oldvarindex: index of old variable in varslist + // - newvar: new variable to take in account to update oldvar properties + + // Global variable for M2SCI + global("varslist") + oldvar=varslist(oldvarindex) + + olddims=oldvar.dims + oldvtype=oldvar.vtype + oldprop=oldvar.property + + newdims=newvar.dims + newvtype=newvar.vtype + newprop=newvar.property + + // Verify dims + for l=1:min(size(newdims),size(olddims)) + if newdims(l)<>olddims(l) then + newdims(l)=Unknown + end + end + if size(newdims)>size(olddims) then + for l=size(olddims):size(newdims) + newdims(l)=null() + end + end + + // Verify vtype + if newvtype<>oldvtype then + newvtype=Unknown + end + + // Verify property + if newprop<>oldprop then + newprop=Unknown + end + + // Verify contents + for k=1:lstsize(newvar.contents.index) + olddata=get_contents_infer(oldvar,newvar.contents.index(k)) + newdata=newvar.contents.data(k) + + if or(olddata<>newdata) then + newvar.infer.contents.data(k)=Infer() + end + end + + // Write result in varslist + varslist(oldvarindex)=M2scivar(oldvar.sciname,.. + oldvar.matname,.. + Infer(newdims,Type(newvtype,newprop),newvar.contents),.. + newvar.level) +endfunction diff --git a/modules/m2sci/macros/kernel/variablesearch.bin b/modules/m2sci/macros/kernel/variablesearch.bin new file mode 100755 index 000000000..55207abd5 Binary files /dev/null and b/modules/m2sci/macros/kernel/variablesearch.bin differ diff --git a/modules/m2sci/macros/kernel/variablesearch.sci b/modules/m2sci/macros/kernel/variablesearch.sci new file mode 100755 index 000000000..87eeba661 --- /dev/null +++ b/modules/m2sci/macros/kernel/variablesearch.sci @@ -0,0 +1,71 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ???? - INRIA - Scilab +// +// 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.1-en.txt + +function variablename=variablesearch(instr,variablename) + // VARIABLESEARCH recursive function (used by "translatepaths" function) + // Searches names of declared variables for each instruction of mtlbtree + // Output + // -variablename : a vector which contains the names of declared variables + // -instr : mtlbtree instruction + + // case : ifthenelse instruction + if typeof(instr) == "ifthenelse" then + for i=1:size(instr.then) + [variablename]=variablesearch((instr.then(i)),variablename) + end + for i=1:size(instr.elseifs) + for k=1:size(instr.elseifs(i).then) + [variablename]=variablesearch((instr.elseifs(i).then(k)),variablename) + end + end + for i=1:size(instr.else) + [variablename]=variablesearch((instr.else(i)),variablename) + end + // case : selectcase instruction + elseif typeof(instr) == "selectcase" then + for i=1:size(instr.cases) + [variablename]=variablesearch(instr.cases(i).expression,variablename) + for j=1:size(instr.cases(i).then) + [variablename]=variablesearch((instr.cases(i).then(j)),variablename) + end + end + for i=1:size(instr.else) + [variablename]=variablesearch(instr.else(i),variablename) + end + // case : while instruction + elseif typeof(instr) == "while" then + for i=1:size(instr.statements) + [variablename]=variablesearch(instr.statements(i),variablename) + end + // case : for instruction + elseif typeof(instr) == "for" then + [variablename]=variablesearch(instr.expression,variablename) + for i=1:size(instr.statements) + [variablename]=variablesearch(instr.statements(i),variablename) + end + // case : equal instruction + elseif typeof(instr) == "equal" then + for i=1:size(instr.lhs) + [variablename]=variablesearch(instr.lhs(i),variablename) + end + // case : operation instruction + elseif typeof(instr) == "operation" then + if instr.operator=="ins" then + if find(instr.operands(1).name==variablename)==[] then + variablename($+1)=instr.operands(1).name + end + end + // case : variable instruction + elseif typeof(instr) == "variable" then + if find(instr.name==variablename)==[] & instr.name<>"ans" then + variablename($+1)=instr.name + end + end + +endfunction -- cgit