[m2sci] bug_1082 fixed 75/18975/4
Cedric Delamarre [Thu, 26 Jan 2017 15:57:16 +0000 (16:57 +0100)]
  allow the call of overload with type troncated
  to 8 characteres for compatibility with scilab 5.

  test_run m2sci bug_1082

Change-Id: I92d71cd8548148399560eb5cfb013324528000d8

scilab/modules/ast/src/cpp/ast/visitor_common.cpp
scilab/modules/m2sci/tests/nonreg_tests/bug_1082.dia.ref

index 68435d4..36c6111 100644 (file)
@@ -595,6 +595,26 @@ types::InternalType* callOverload(const ast::Exp& e, const std::wstring& _strTyp
     }
 
     types::InternalType* pFunc = symbol::Context::getInstance()->get(symbol::Symbol(function_name));
+    if (pFunc == NULL &&
+            (_source->getShortTypeStr().size() > 8 || _dest && _dest->getShortTypeStr().size() > 8))
+    {
+        if (_source->getShortTypeStr().size() > 8)
+        {
+            function_name = L"%" + _source->getShortTypeStr().substr(0, 8) + L"_" + _strType;
+        }
+        else if (_dest)
+        {
+            function_name = L"%" + _source->getShortTypeStr() + L"_" + _strType;
+        }
+
+        if (_dest && _dest->getShortTypeStr().size() > 8)
+        {
+            function_name += L"_" + _dest->getShortTypeStr().substr(0, 8);
+        }
+
+        pFunc = symbol::Context::getInstance()->get(symbol::Symbol(function_name));
+    }
+
     // if %type_6 doesn't exist, call %l_6
     if (_dest == NULL && pFunc == NULL)
     {
index 7166c0e..a3b884b 100644 (file)
 //    Error during conversion of a very simple file. Though the
 //    syntax is the same in both languages, the converter fails to
 //    convert the rounding of the field of a structure: "round(a.b)"
-MFILECONTENTS=["structure.field = 2;" 
+MFILECONTENTS=["structure.field = 2;"
 ""
-"data = round(structure.field);"]
- MFILECONTENTS  =
-!structure.field = 2;            !
-!                                !
-!                                !
-!                                !
-!data = round(structure.field);  !
+"data = round(structure.field);"];
 MFILE=TMPDIR+"/bug1082.m";
 SCIFILE=TMPDIR+"/bug1082.sci";
 mputl(MFILECONTENTS,MFILE);
@@ -56,8 +49,7 @@ SCIFILECONTENTSREF=["";
 "structure.field = 2;";
 "";
 "data = round(structure.field);"]
- SCIFILECONTENTSREF  =
+ SCIFILECONTENTSREF  = 
 !                                                 !
 !                                                 !
 !// Display mode                                  !