types::Dollar removed 26/16726/6
Cedric Delamarre [Thu, 25 Jun 2015 10:20:27 +0000 (12:20 +0200)]
Change-Id: Icdce5c5c65edbff310bd0f4c6cdd764e322e6600

15 files changed:
scilab/modules/api_scilab/src/cpp/api_common.cpp
scilab/modules/ast/Makefile.am
scilab/modules/ast/Makefile.in
scilab/modules/ast/ast.vcxproj
scilab/modules/ast/ast.vcxproj.filters
scilab/modules/ast/includes/ast/runvisitor.hxx
scilab/modules/ast/includes/types/alltypes.hxx
scilab/modules/ast/includes/types/colon.hxx
scilab/modules/ast/includes/types/dollar.hxx [deleted file]
scilab/modules/ast/includes/types/internal.hxx
scilab/modules/ast/includes/types/polynom.hxx
scilab/modules/ast/src/cpp/ast/visitor_common.cpp
scilab/modules/ast/src/cpp/operations/types_divide.cpp
scilab/modules/ast/src/cpp/operations/types_multiplication.cpp
scilab/modules/ast/src/cpp/types/polynom.cpp

index 425cb46..2f29807 100644 (file)
@@ -501,7 +501,6 @@ SciErr getVarType(void *_pvCtx, int *_piAddress, int *_piType)
         case GenericType::ScilabDouble :
             *_piType = sci_matrix;
             break;
-        case GenericType::ScilabDollar :
         case GenericType::ScilabPolynom :
             *_piType = sci_poly;
             break;
index 3889145..7dce2c2 100644 (file)
@@ -344,7 +344,6 @@ includes/types/c_gateway_prototype.h \
 includes/types/colon.hxx \
 includes/types/container.hxx \
 includes/types/cpp_gateway_prototype.hxx \
-includes/types/dollar.hxx \
 includes/types/double.hxx \
 includes/types/file.hxx \
 includes/types/function.hxx \
index 3bc3c16..420dfa7 100644 (file)
@@ -1061,7 +1061,6 @@ includes/types/c_gateway_prototype.h \
 includes/types/colon.hxx \
 includes/types/container.hxx \
 includes/types/cpp_gateway_prototype.hxx \
-includes/types/dollar.hxx \
 includes/types/double.hxx \
 includes/types/file.hxx \
 includes/types/function.hxx \
index 8bf6037..518194f 100644 (file)
@@ -531,7 +531,6 @@ lib /DEF:"$(ProjectDir)string_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform
     <ClInclude Include="includes\types\container.hxx" />
     <ClInclude Include="includes\types\cpp_gateway_prototype.hxx" />
     <ClInclude Include="includes\types\c_gateway_prototype.h" />
-    <ClInclude Include="includes\types\dollar.hxx" />
     <ClInclude Include="includes\types\double.hxx" />
     <ClInclude Include="includes\types\file.hxx" />
     <ClInclude Include="includes\types\function.hxx" />
index 943a4c8..5528151 100644 (file)
     <ClInclude Include="includes\types\cpp_gateway_prototype.hxx">
       <Filter>Header Files\types</Filter>
     </ClInclude>
-    <ClInclude Include="includes\types\dollar.hxx">
-      <Filter>Header Files\types</Filter>
-    </ClInclude>
     <ClInclude Include="includes\types\double.hxx">
       <Filter>Header Files\types</Filter>
     </ClInclude>
index 23142ae..26bfa8d 100644 (file)
@@ -18,7 +18,7 @@
 #include "types.hxx"
 #include "double.hxx"
 #include "bool.hxx"
-#include "dollar.hxx"
+#include "polynom.hxx"
 #include "colon.hxx"
 #include "string.hxx"
 #include "void.hxx"
@@ -459,8 +459,7 @@ public :
 
     void visitprivate(const DollarVar &/*e*/)
     {
-        Dollar* pVar = new Dollar();
-        setResult(pVar);
+        setResult(Polynom::Dollar());
     }
 
     void visitprivate(const TryCatchExp  &e)
index cbe810d..ab05ebb 100644 (file)
@@ -46,7 +46,6 @@
 #include "int.hxx"
 #include "cell.hxx"
 #include "colon.hxx"
-#include "dollar.hxx"
 #include "sparse.hxx"
 #include "graphichandle.hxx"
 #include "void.hxx"
index b86903d..00b9774 100644 (file)
@@ -24,7 +24,7 @@
 
 #include "implicitlist.hxx"
 #include "double.hxx"
-#include "dollar.hxx"
+#include "polynom.hxx"
 
 namespace types
 {
@@ -36,7 +36,7 @@ public :
     {
         setStart(new Double(1));
         setStep(new Double(1));
-        setEnd(new Dollar());
+        setEnd(Polynom::Dollar());
         compute();
     }
 
diff --git a/scilab/modules/ast/includes/types/dollar.hxx b/scilab/modules/ast/includes/types/dollar.hxx
deleted file mode 100644 (file)
index 252347b..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- *  Copyright (C) 2011 - DIGITEO - Antoine ELIAS
- *
- *  This file must be used under the terms of the CeCILL.
- *  This source file is licensed as described in the file COPYING, which
- *  you should have received as part of this distribution.  The terms
- *  are also available at
- *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-
-#ifndef __DOLLAR_HXX__
-#define __DOLLAR_HXX__
-
-#include "polynom.hxx"
-
-namespace types
-{
-class EXTERN_AST Dollar : public Polynom
-{
-public :
-
-    Dollar()
-    {
-        int piDims[2] = {1, 1};
-        m_szVarName   = L"$";
-        SinglePoly** pPoly = NULL;
-        create(piDims, 2, &pPoly, NULL);
-
-        double* pdblCoef = NULL;
-        SinglePoly* SPCoef = new SinglePoly(&pdblCoef, 1);
-        pdblCoef[0] = 0;
-        pdblCoef[1] = 1.0;
-
-        m_pRealData[0] = SPCoef;
-    }
-
-    Dollar* clone()
-    {
-        return new Dollar();
-    }
-
-    inline ScilabType getType()
-    {
-        return ScilabDollar;
-    }
-    inline ScilabId getId()
-    {
-        return IdScalarPolynom;
-    }
-
-    bool isDollar()
-    {
-        return true;
-    }
-};
-}
-#endif /* !__DOLLAR_HXX__ */
index 506284a..cd935b6 100644 (file)
@@ -99,7 +99,6 @@ public :
         ScilabListUndefinedOperation,
         ScilabFile,
         ScilabColon,
-        ScilabDollar,
         ScilabThreadId,
         ScilabSparse,
         ScilabSparseBool,
@@ -170,7 +169,6 @@ public :
         IdListUndefinedOperation,
         IdFile,
         IdColon,
-        IdDollar,
         IdThreadId,
         IdSparse,
         IdSparseComplex,
index c0c4f28..dc72145 100644 (file)
@@ -37,10 +37,10 @@ class EXTERN_AST Polynom : public ArrayOf<SinglePoly*>
 {
 public :
     Polynom();
-    Polynom(std::wstring& _szVarName, int _iRows, int _iCols);
-    Polynom(std::wstring& _szVarName, int _iRows, int _iCols, const int *_piRank);
-    Polynom(std::wstring& _szVarName, int _iDims, int* _piDims);
-    Polynom(std::wstring& _szVarName, int _iDims, int* _piDims, const int *_piRank);
+    Polynom(const std::wstring& _szVarName, int _iRows, int _iCols);
+    Polynom(const std::wstring& _szVarName, int _iRows, int _iCols, const int *_piRank);
+    Polynom(const std::wstring& _szVarName, int _iDims, int* _piDims);
+    Polynom(const std::wstring& _szVarName, int _iDims, int* _piDims, const int *_piRank);
 
     virtual                 ~Polynom();
 
@@ -61,12 +61,13 @@ public :
     {
         return isScalar() ? isComplex() ? IdScalarPolynomComplex
                : IdScalarPolynom
-               : isComplex() ? IdPolynomComplex
+       : isComplex() ? IdPolynomComplex
                : IdPolynom;
     }
 
     bool isComplex(void);
 
+    bool isDollar();
     inline bool             isPoly()
     {
         return true;
@@ -118,9 +119,11 @@ public :
     bool transpose(InternalType *& out);
     bool adjoint(InternalType *& out);
 
+    static Polynom* Dollar();
+
 protected :
     std::wstring            m_szVarName;
-    void                    createPoly(std::wstring& _szVarName, int _iDims, int* _piDims, const int *_piRank);
+    void                    createPoly(const std::wstring& _szVarName, int _iDims, int* _piDims, const int *_piRank);
 
 private :
     virtual bool            subMatrixToString(std::wostringstream& ostr, int* _piDims, int _iDims);
index 55eed3c..9e1c62b 100644 (file)
@@ -248,14 +248,6 @@ InternalType* AddElementToVariable(InternalType* _poDest, InternalType* _poSourc
             case GenericType::ScilabHandle :
                 poResult = new GraphicHandle(_iRows, _iCols);
                 break;
-            case GenericType::ScilabDollar :
-            {
-                int* piRank = new int[_iRows * _iCols];
-                memset(piRank, 0x00, _iRows * _iCols * sizeof(int));
-                poResult = new Polynom(_poSource->getAs<Polynom>()->getVariableName(), _iRows, _iCols, piRank);
-                delete[] piRank;
-                break;
-            }
             default :
                 // FIXME What should we do here ...
                 break;
@@ -368,11 +360,6 @@ InternalType* AddElementToVariable(InternalType* _poDest, InternalType* _poSourc
 
                     return poResult;
                 }
-                else if (TypeSource == GenericType::ScilabDollar)
-                {
-                    poResult->getAs<Polynom>()->append(iCurRow, iCurCol, _poSource->getAs<Dollar>());
-                    return poResult;
-                }
                 break;
             case GenericType::ScilabSparse :
                 if (TypeSource == GenericType::ScilabDouble)
@@ -529,11 +516,6 @@ InternalType* AddElementToVariable(InternalType* _poDest, InternalType* _poSourc
             case GenericType::ScilabHandle :
                 poResult->getAs<GraphicHandle>()->append(iCurRow, iCurCol, _poSource);
                 break;
-            case GenericType::ScilabDollar:
-            {
-                poResult->getAs<Polynom>()->append(iCurRow, iCurCol, _poSource);
-                break;
-            }
             default:
                 // call overload
                 return NULL;
index 6087f40..a12afa4 100644 (file)
@@ -59,8 +59,7 @@ InternalType *GenericRDivide(InternalType *_pLeftOperand, InternalType *_pRightO
     /*
     ** POLY / DOUBLE
     */
-    else if ((TypeL == GenericType::ScilabDollar || TypeL == GenericType::ScilabPolynom )
-             && TypeR == GenericType::ScilabDouble)
+    else if (TypeL == GenericType::ScilabPolynom && TypeR == GenericType::ScilabDouble)
     {
         Polynom *pL = _pLeftOperand->getAs<types::Polynom>();
         Double *pR  = _pRightOperand->getAs<Double>();
@@ -71,8 +70,7 @@ InternalType *GenericRDivide(InternalType *_pLeftOperand, InternalType *_pRightO
     /*
     ** DOUBLE / POLY
     */
-    else if (TypeL == GenericType::ScilabDouble
-             && (TypeR == GenericType::ScilabDollar || TypeR == GenericType::ScilabPolynom))
+    else if (TypeL == GenericType::ScilabDouble && TypeR == GenericType::ScilabPolynom)
     {
         Double *pL  = _pLeftOperand->getAs<Double>();
         Polynom *pR = _pRightOperand->getAs<types::Polynom>();
index ff9cbd0..e1bb09f 100644 (file)
@@ -70,7 +70,7 @@ InternalType *GenericTimes(InternalType *_pLeftOperand, InternalType *_pRightOpe
     /*
     ** DOUBLE * POLY
     */
-    else if (TypeL == InternalType::ScilabDouble && (TypeR == InternalType::ScilabPolynom || TypeR == InternalType::ScilabDollar))
+    else if (TypeL == InternalType::ScilabDouble && TypeR == InternalType::ScilabPolynom)
     {
         Double *pL   = _pLeftOperand->getAs<Double>();
         Polynom *pR     = _pRightOperand->getAs<types::Polynom>();
@@ -87,7 +87,7 @@ InternalType *GenericTimes(InternalType *_pLeftOperand, InternalType *_pRightOpe
     /*
     ** POLY * DOUBLE
     */
-    else if ((TypeL == InternalType::ScilabPolynom || TypeL == InternalType::ScilabDollar) && TypeR == InternalType::ScilabDouble)
+    else if (TypeL == InternalType::ScilabPolynom && TypeR == InternalType::ScilabDouble)
     {
         Polynom *pL          = _pLeftOperand->getAs<types::Polynom>();
         Double *pR              = _pRightOperand->getAs<Double>();
index 5b308fd..cd0b09a 100644 (file)
@@ -28,24 +28,24 @@ Polynom::Polynom()
 #endif
 }
 
-Polynom::Polynom(wstring& _szVarName, int _iRows, int _iCols)
+Polynom::Polynom(const wstring& _szVarName, int _iRows, int _iCols)
 {
     int piDims[2]   = {_iRows, _iCols};
     createPoly(_szVarName, 2, piDims, NULL);
 }
 
-Polynom::Polynom(wstring& _szVarName, int _iRows, int _iCols, const int *_piRank)
+Polynom::Polynom(const wstring& _szVarName, int _iRows, int _iCols, const int *_piRank)
 {
     int piDims[2]   = {_iRows, _iCols};
     createPoly(_szVarName, 2, piDims, _piRank);
 }
 
-Polynom::Polynom(wstring& _szVarName, int _iDims, int* _piDims)
+Polynom::Polynom(const wstring& _szVarName, int _iDims, int* _piDims)
 {
     createPoly(_szVarName, _iDims, _piDims, NULL);
 }
 
-Polynom::Polynom(wstring& _szVarName, int _iDims, int* _piDims, const int *_piRank)
+Polynom::Polynom(const wstring& _szVarName, int _iDims, int* _piDims, const int *_piRank)
 {
     createPoly(_szVarName, _iDims, _piDims, _piRank);
 }
@@ -61,7 +61,7 @@ Polynom::~Polynom()
 #endif
 }
 
-void Polynom::createPoly(wstring& _szVarName, int _iDims, int* _piDims, const int *_piRank)
+void Polynom::createPoly(const wstring& _szVarName, int _iDims, int* _piDims, const int *_piRank)
 {
     m_szVarName = _szVarName;
     SinglePoly** pPoly = NULL;
@@ -994,5 +994,33 @@ InternalType* Polynom::insert(typed_list* _pArgs, InternalType* _pSource)
     return ArrayOf<SinglePoly*>::insert(_pArgs, _pSource);
 }
 
+Polynom* Polynom::Dollar()
+{
+    int iRank = 1;
+    Polynom* pDollar = new Polynom(L"$", 1, 1, &iRank);
+    double* pdblCoef = pDollar->get(0)->get();
+    pdblCoef[0] = 0;
+    pdblCoef[1] = 1;
+
+    return pDollar;
+}
+
+bool Polynom::isDollar()
+{
+    if (m_szVarName != L"$" || getSize() != 1)
+    {
+        return false;
+    }
+
+    double* pCoef = get(0)->get();
+
+    if (pCoef[0] != 0 && pCoef[1] != 1)
+    {
+        return false;
+    }
+
+    return true;
+}
+
 }