* Bug 16683 fixed [m2sci] fix & improvements 51/21751/9
authorSamuel GOUGEON <sgougeon@free.fr>
Mon, 3 May 2021 03:48:41 +0000 (05:48 +0200)
committerClément David <clement.david@esi-group.com>
Mon, 3 May 2021 13:14:53 +0000 (15:14 +0200)
commit770a92864db626838719855fb48a004b0be1734a
treecb9336b0544aaf14af0132b8edfe19988794b905
parent86f450955f0c6924076faa9ab5d8f745bfc66e09
* Bug 16683 fixed [m2sci] fix & improvements

 http://bugzilla.scilab.org/16683

1) Extend the set of supported (Scilab) internal data types, without which
   some bugs can't be fixed, and improving or extending supported conversions
   won't be possible:
   a) Missing vtype=Function added, with property Macro|Builtin|?
   b) Missing vtype=Polynomial added, with property Real|Complex|?
   c) Missing properties (in addition to Unknown) added, for existing vtypes:
      Int: : "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64"
      Handle: "Figure", "Axes".
      String: String, Char (to distinguish "string" from 'char' (Matlab>2018).
          Octave has only char). This is required before implementing the
  parsing of "strings" in concurrence to to 'chars'.
      Boolean:
         - The default property is now Boolean instead of Real (was misleading).
         - New property value: Sparse. (Currently, Sparse boolean are not supported).
  d) Void: Removed. this vtype defined in m2sci() was used nowhere in the whole m2sci.
           BTW, not sure that there is a single way in Matlab/Octave to get a void element.
  e) Type(), m2sci() and m2scideclare() upgraded accordingly, to manage
     all new vtypes and properties.

2) Funcall(): the LHS argin is now optional (default = list(), to which it had often be set.
   For some known function names frequently used in sci_funs conversion functions,
   it is automatically initialized accordingly.

3) Operation(): the out argout is now optional, with default = list().

4) Conversions TO FIX:
  a) `a=1, b=2` was converted into `a = 1b = 2`, yielding a syntax error.
  b) `['abc';'def']` : the result's property is now Char instead of Unknown.
  c) The concatenation result now reflects concatenation precedence rules to set its
     vtype and property. There were formerly set to the type of the last operand.
  d) Function handles `@fun` were converted into a char 'fun'
     instead of into a function-handle object.
     ishandle(@sin) was converted into type("sin")==9 instead of type(sin)==9: Fixed.
  e) `full(Boolean)` was returning `full(bool2s(Boolean))`, instead of the same.
     `full(BooleanSparse)` conversion was yielding an error in convert2double:
    Sparse boolean were never supported.
     `full(String)` was returning `mtlb_full(String)` instead of the same.
  f) `mtlb_full()` is removed. It was useless.
  g) `sparse([true false])` conversion was yielding a `convert2double` error,
                            instead of `sparse([%t,%f])`.
  h) `isa('logical')` was ignoring sparse booleans.
     `isa('function_handle')` was ignoring builtins.
  i) `isvector(Hypermat)` conversion was wrong (making isvector(rand(1,2,3)) returning %T).
  j) `isreal` conversion was wrongly using eps=0: isreal(complex(1,0))
      returns false with Matlab/Octave.
  k) `[1 2]==1` result was having property=Real, instead of Boolean.
  m) `Cste(["abc" "de" ; "fg" "hij"])` was initializing dims=list(2,10) instead of list(2,5).
  n) `rem(a,b)` conversion was using a formula instead of `modulo(a,b)`.

5) Conversions IMPROVED:
  a) 2*3*4*5 and 2*3/4 was converted into ((2*3)*4)*5 and (2*3)/4,
     instead of staying unchanged.
  b) `a = true || false` was converted into `a = %t;if ~%t then a = %f;end`,
     instead of staying the same.
  c) `a = true && false` was converted into `a = %f;if %t then a = %f;end;`,
     instead of staying the same.
  d) `a = 1; b = 2` was converted into `a = 1;b = 2`  without space separating instructions.
  e) `for..,end;` was terminated with a parasitic ";" sticking to `end` (instruction2code).

6) Conversions COMPLETED:
  a) isa(x, 'integer') and isa(x, 'float') were not converted.
  b) isreal() was not implemented for Sparse, Boolean Sparse, Handle, Struct,
     Cell, and Function types.

7) MISC TO FIX:
  a) In case of missing sci_function, the whole database of existing
     Matlab functions (and related toolboxes) was loaded through
     mtlbtoolfun() each time that such a case is met.
    This was slow (1.12s x n).
    Now the database is loaded only once, at the first need, and then
    stored as global for direct access. New timing: (0.3ms x n).
  b)  Codes for ||, and && operators were missing in sciparam()

8) Documentation
  a) m2scideclare() can be very helpful to check the vtype/property/size of a variable,
     for instance in tests. This was deserving to be documented.
  b) The table of vtypes is now in the Type() page, instead of the m2scideclare one.
     In addition, the list of supported properties is now given in
     the same table, for each vtype.
  c) Operation(): the fields of the result were not explicitly named.

9) Conversions ADDED: deal(), gca(), gcf(), iscolumn(), isrow(), ismatrix()

10) Code style improved.

Change-Id: Ic1b24442780a2c94e500bd6b2d31b587dab0f9e5
201 files changed:
scilab/CHANGES.md
scilab/modules/functions/macros/cat_code.sci
scilab/modules/functions/macros/expression2code.sci
scilab/modules/functions/macros/instruction2code.sci
scilab/modules/m2sci/Mtbxfun_db.txt [new file with mode: 0644]
scilab/modules/m2sci/help/en_US/internals/Funcall.xml
scilab/modules/m2sci/help/en_US/internals/Operation.xml
scilab/modules/m2sci/help/en_US/internals/Type.xml
scilab/modules/m2sci/help/en_US/m2scideclare.xml
scilab/modules/m2sci/help/en_US/mfile2sci.xml
scilab/modules/m2sci/help/fr_FR/internals/Funcall.xml
scilab/modules/m2sci/help/fr_FR/internals/Operation.xml
scilab/modules/m2sci/help/fr_FR/internals/Type.xml
scilab/modules/m2sci/help/fr_FR/m2scideclare.xml
scilab/modules/m2sci/help/fr_FR/mfile2sci.xml
scilab/modules/m2sci/macros/kernel/%cste_e.sci
scilab/modules/m2sci/macros/kernel/%funcall_6.sci
scilab/modules/m2sci/macros/kernel/%funcall_e.sci
scilab/modules/m2sci/macros/kernel/%infer_e.sci [new file with mode: 0644]
scilab/modules/m2sci/macros/kernel/%infer_i_variable.sci [new file with mode: 0644]
scilab/modules/m2sci/macros/kernel/%operation_e.sci
scilab/modules/m2sci/macros/kernel/%variable_6.sci
scilab/modules/m2sci/macros/kernel/%variable_e.sci
scilab/modules/m2sci/macros/kernel/Cste.sci
scilab/modules/m2sci/macros/kernel/Funcall.sci
scilab/modules/m2sci/macros/kernel/Operation.sci
scilab/modules/m2sci/macros/kernel/Type.sci
scilab/modules/m2sci/macros/kernel/Variable.sci
scilab/modules/m2sci/macros/kernel/convert2double.sci
scilab/modules/m2sci/macros/kernel/expression2sci.sci
scilab/modules/m2sci/macros/kernel/funcall2sci.sci
scilab/modules/m2sci/macros/kernel/getPropName.sci [new file with mode: 0644]
scilab/modules/m2sci/macros/kernel/getTypeName.sci [moved from scilab/modules/m2sci/macros/kernel/%type_i_cste.sci with 62% similarity]
scilab/modules/m2sci/macros/kernel/getvar2sci.sci
scilab/modules/m2sci/macros/kernel/instruction2sci.sci
scilab/modules/m2sci/macros/kernel/is_a_scalar.sci
scilab/modules/m2sci/macros/kernel/is_complex.sci
scilab/modules/m2sci/macros/kernel/is_real.sci
scilab/modules/m2sci/macros/kernel/is_sparse.sci [new file with mode: 0644]
scilab/modules/m2sci/macros/kernel/isinstring.sci
scilab/modules/m2sci/macros/kernel/m2sci.sci
scilab/modules/m2sci/macros/kernel/m2sci_info.sci
scilab/modules/m2sci/macros/kernel/m2sci_syntax.sci
scilab/modules/m2sci/macros/kernel/m2scideclare.sci [new file with mode: 0644]
scilab/modules/m2sci/macros/kernel/mtlbtoolfun.sci [deleted file]
scilab/modules/m2sci/macros/kernel/mtlbtree2sci.sci
scilab/modules/m2sci/macros/kernel/no_equiv.sci
scilab/modules/m2sci/macros/kernel/operation2sci.sci
scilab/modules/m2sci/macros/kernel/sci_m2scideclare.sci [deleted file]
scilab/modules/m2sci/macros/kernel/sciparam.sci
scilab/modules/m2sci/macros/mfile2sci.sci
scilab/modules/m2sci/macros/percent/%52sci.sci
scilab/modules/m2sci/macros/percent/%a2sci.sci
scilab/modules/m2sci/macros/percent/%cc2sci.sci
scilab/modules/m2sci/macros/percent/%g2sci.sci
scilab/modules/m2sci/macros/percent/%h2sci.sci
scilab/modules/m2sci/macros/percent/%imp2sci.sci
scilab/modules/m2sci/macros/percent/%log2sci.sci
scilab/modules/m2sci/macros/percent/%m2sci.sci
scilab/modules/m2sci/macros/percent/%r2sci.sci
scilab/modules/m2sci/macros/percent/%rc2sci.sci
scilab/modules/m2sci/macros/percent/%s2sci.sci
scilab/modules/m2sci/macros/sci_files/sci_PROTO0.g
scilab/modules/m2sci/macros/sci_files/sci_PROTO1.g
scilab/modules/m2sci/macros/sci_files/sci_PROTO10.g
scilab/modules/m2sci/macros/sci_files/sci_PROTO11.g
scilab/modules/m2sci/macros/sci_files/sci_PROTO12.g
scilab/modules/m2sci/macros/sci_files/sci_PROTO13.g
scilab/modules/m2sci/macros/sci_files/sci_PROTO14.g
scilab/modules/m2sci/macros/sci_files/sci_PROTO15.g
scilab/modules/m2sci/macros/sci_files/sci_PROTO2.g
scilab/modules/m2sci/macros/sci_files/sci_PROTO3.g
scilab/modules/m2sci/macros/sci_files/sci_PROTO4.g
scilab/modules/m2sci/macros/sci_files/sci_PROTO6.g
scilab/modules/m2sci/macros/sci_files/sci_PROTO7.g
scilab/modules/m2sci/macros/sci_files/sci_PROTO8.g
scilab/modules/m2sci/macros/sci_files/sci_PROTO9.g
scilab/modules/m2sci/macros/sci_files/sci_all.sci
scilab/modules/m2sci/macros/sci_files/sci_any.sci
scilab/modules/m2sci/macros/sci_files/sci_beep.sci
scilab/modules/m2sci/macros/sci_files/sci_blanks.sci
scilab/modules/m2sci/macros/sci_files/sci_cd.sci
scilab/modules/m2sci/macros/sci_files/sci_char.sci
scilab/modules/m2sci/macros/sci_files/sci_cos.sci
scilab/modules/m2sci/macros/sci_files/sci_date.sci
scilab/modules/m2sci/macros/sci_files/sci_deal.sci [new file with mode: 0644]
scilab/modules/m2sci/macros/sci_files/sci_dec2bin.sci
scilab/modules/m2sci/macros/sci_files/sci_dec2hex.sci
scilab/modules/m2sci/macros/sci_files/sci_diag.sci
scilab/modules/m2sci/macros/sci_files/sci_dir.sci
scilab/modules/m2sci/macros/sci_files/sci_docopt.sci
scilab/modules/m2sci/macros/sci_files/sci_dos.sci
scilab/modules/m2sci/macros/sci_files/sci_ferror.sci
scilab/modules/m2sci/macros/sci_files/sci_fgets.sci
scilab/modules/m2sci/macros/sci_files/sci_fileparts.sci
scilab/modules/m2sci/macros/sci_files/sci_filesep.sci
scilab/modules/m2sci/macros/sci_files/sci_fopen.sci
scilab/modules/m2sci/macros/sci_files/sci_full.sci
scilab/modules/m2sci/macros/sci_files/sci_fullfile.sci
scilab/modules/m2sci/macros/sci_files/sci_gca.sci [new file with mode: 0644]
scilab/modules/m2sci/macros/sci_files/sci_gcf.sci [new file with mode: 0644]
scilab/modules/m2sci/macros/sci_files/sci_getenv.sci
scilab/modules/m2sci/macros/sci_files/sci_graymon.sci
scilab/modules/m2sci/macros/sci_files/sci_grid.sci
scilab/modules/m2sci/macros/sci_files/sci_input.sci
scilab/modules/m2sci/macros/sci_files/sci_int16.sci
scilab/modules/m2sci/macros/sci_files/sci_int32.sci
scilab/modules/m2sci/macros/sci_files/sci_int64.sci
scilab/modules/m2sci/macros/sci_files/sci_int8.sci
scilab/modules/m2sci/macros/sci_files/sci_isa.sci
scilab/modules/m2sci/macros/sci_files/sci_iscell.sci
scilab/modules/m2sci/macros/sci_files/sci_ischar.sci
scilab/modules/m2sci/macros/sci_files/sci_iscolumn.sci [new file with mode: 0644]
scilab/modules/m2sci/macros/sci_files/sci_isdir.sci
scilab/modules/m2sci/macros/sci_files/sci_isempty.sci
scilab/modules/m2sci/macros/sci_files/sci_isequal.sci
scilab/modules/m2sci/macros/sci_files/sci_isfield.sci
scilab/modules/m2sci/macros/sci_files/sci_isfinite.sci
scilab/modules/m2sci/macros/sci_files/sci_isglobal.sci
scilab/modules/m2sci/macros/sci_files/sci_ishandle.sci
scilab/modules/m2sci/macros/sci_files/sci_ishold.sci
scilab/modules/m2sci/macros/sci_files/sci_isinf.sci
scilab/modules/m2sci/macros/sci_files/sci_isinteger.sci
scilab/modules/m2sci/macros/sci_files/sci_isletter.sci
scilab/modules/m2sci/macros/sci_files/sci_islogical.sci
scilab/modules/m2sci/macros/sci_files/sci_ismac.sci
scilab/modules/m2sci/macros/sci_files/sci_ismatrix.sci [new file with mode: 0644]
scilab/modules/m2sci/macros/sci_files/sci_isnan.sci
scilab/modules/m2sci/macros/sci_files/sci_isnumeric.sci
scilab/modules/m2sci/macros/sci_files/sci_ispc.sci
scilab/modules/m2sci/macros/sci_files/sci_isreal.sci
scilab/modules/m2sci/macros/sci_files/sci_isrow.sci [new file with mode: 0644]
scilab/modules/m2sci/macros/sci_files/sci_isscalar.sci
scilab/modules/m2sci/macros/sci_files/sci_isspace.sci
scilab/modules/m2sci/macros/sci_files/sci_issparse.sci
scilab/modules/m2sci/macros/sci_files/sci_isstr.sci
scilab/modules/m2sci/macros/sci_files/sci_isstruct.sci
scilab/modules/m2sci/macros/sci_files/sci_isunix.sci
scilab/modules/m2sci/macros/sci_files/sci_isvector.sci
scilab/modules/m2sci/macros/sci_files/sci_logical.sci
scilab/modules/m2sci/macros/sci_files/sci_makecell.sci
scilab/modules/m2sci/macros/sci_files/sci_mkdir.sci
scilab/modules/m2sci/macros/sci_files/sci_rem.sci
scilab/modules/m2sci/macros/sci_files/sci_repmat.sci
scilab/modules/m2sci/macros/sci_files/sci_setstr.sci
scilab/modules/m2sci/macros/sci_files/sci_sparse.sci
scilab/modules/m2sci/macros/sci_files/sci_strcmp.sci
scilab/modules/m2sci/macros/sci_files/sci_strcmpi.sci
scilab/modules/m2sci/macros/sci_files/sci_strrep.sci
scilab/modules/m2sci/macros/sci_files/sci_uigetdir.sci
scilab/modules/m2sci/macros/sci_files/sci_uint16.sci
scilab/modules/m2sci/macros/sci_files/sci_uint32.sci
scilab/modules/m2sci/macros/sci_files/sci_uint64.sci
scilab/modules/m2sci/macros/sci_files/sci_uint8.sci
scilab/modules/m2sci/macros/sci_files/sci_unix.sci
scilab/modules/m2sci/tests/nonreg_tests/bug_1636.dia.ref
scilab/modules/m2sci/tests/nonreg_tests/bug_16683.tst [new file with mode: 0644]
scilab/modules/m2sci/tests/nonreg_tests/bug_2656.dia.ref
scilab/modules/m2sci/tests/nonreg_tests/compat_functions/bug_1725.dia.ref
scilab/modules/m2sci/tests/unit_tests/conversion/ARITHMETIC.tst [new file with mode: 0644]
scilab/modules/m2sci/tests/unit_tests/conversion/ARITHMETIC_special_syntax.tst [new file with mode: 0644]
scilab/modules/m2sci/tests/unit_tests/conversion/CLEAR.dia.ref [deleted file]
scilab/modules/m2sci/tests/unit_tests/conversion/CLEAR.tst
scilab/modules/m2sci/tests/unit_tests/conversion/COMMENTS_syntax.dia.ref
scilab/modules/m2sci/tests/unit_tests/conversion/CONCATENATIONS.tst [new file with mode: 0644]
scilab/modules/m2sci/tests/unit_tests/conversion/DEAL.tst [new file with mode: 0644]
scilab/modules/m2sci/tests/unit_tests/conversion/END_index_syntax.dia.ref
scilab/modules/m2sci/tests/unit_tests/conversion/END_index_syntax.tst
scilab/modules/m2sci/tests/unit_tests/conversion/FULL.dia.ref [deleted file]
scilab/modules/m2sci/tests/unit_tests/conversion/FULL.tst
scilab/modules/m2sci/tests/unit_tests/conversion/GCA.tst [new file with mode: 0644]
scilab/modules/m2sci/tests/unit_tests/conversion/GCF.tst [new file with mode: 0644]
scilab/modules/m2sci/tests/unit_tests/conversion/GRAYMON.dia.ref [deleted file]
scilab/modules/m2sci/tests/unit_tests/conversion/GRAYMON.tst
scilab/modules/m2sci/tests/unit_tests/conversion/INT#_booleans.tst [new file with mode: 0644]
scilab/modules/m2sci/tests/unit_tests/conversion/ISA.dia.ref [deleted file]
scilab/modules/m2sci/tests/unit_tests/conversion/ISA.tst
scilab/modules/m2sci/tests/unit_tests/conversion/ISCOLUMN.tst [new file with mode: 0644]
scilab/modules/m2sci/tests/unit_tests/conversion/ISHANDLE.dia.ref [deleted file]
scilab/modules/m2sci/tests/unit_tests/conversion/ISHANDLE.tst
scilab/modules/m2sci/tests/unit_tests/conversion/ISMAC.dia.ref [deleted file]
scilab/modules/m2sci/tests/unit_tests/conversion/ISMAC.tst
scilab/modules/m2sci/tests/unit_tests/conversion/ISMATRIX.tst [new file with mode: 0644]
scilab/modules/m2sci/tests/unit_tests/conversion/ISREAL.dia.ref [deleted file]
scilab/modules/m2sci/tests/unit_tests/conversion/ISREAL.tst
scilab/modules/m2sci/tests/unit_tests/conversion/ISROW.tst [new file with mode: 0644]
scilab/modules/m2sci/tests/unit_tests/conversion/ISSPARSE.dia.ref
scilab/modules/m2sci/tests/unit_tests/conversion/ISSPARSE.tst
scilab/modules/m2sci/tests/unit_tests/conversion/ISVECTOR.dia.ref
scilab/modules/m2sci/tests/unit_tests/conversion/ISVECTOR.tst
scilab/modules/m2sci/tests/unit_tests/conversion/OPERATORS.dia.ref [deleted file]
scilab/modules/m2sci/tests/unit_tests/conversion/OPERATORS.tst [deleted file]
scilab/modules/m2sci/tests/unit_tests/conversion/syntax.dia.ref [deleted file]
scilab/modules/m2sci/tests/unit_tests/conversion/syntax.tst [deleted file]
scilab/modules/m2sci/tests/unit_tests/execution/ISREALx.dia.ref [moved from scilab/modules/m2sci/tests/unit_tests/execution/ISREAL.dia.ref with 97% similarity]
scilab/modules/m2sci/tests/unit_tests/execution/ISREALx.tst [moved from scilab/modules/m2sci/tests/unit_tests/execution/ISREAL.tst with 95% similarity]
scilab/modules/m2sci/tests/unit_tests/mfilesnoexec/CLEAR.m [deleted file]
scilab/modules/m2sci/tests/unit_tests/mfilesnoexec/GRAYMON.m [deleted file]
scilab/modules/m2sci/tests/unit_tests/mfilesnoexec/ISA.m [deleted file]
scilab/modules/m2sci/tests/unit_tests/mfilesnoexec/ISHANDLE.m [deleted file]
scilab/modules/m2sci/tests/unit_tests/mfilesnoexec/syntax.m [deleted file]