add runvisitor hierarchy
[scilab.git] / scilab / modules / abstractSyntaxTree / includes / execvisitor.hxx
index 9c0c0b6..db35711 100644 (file)
 #include <iostream>
 #include <sstream>
 
-#include "visitor.hxx"
 #include "allexp.hxx"
 #include "allvar.hxx"
 #include "alldec.hxx"
 #include "alltypes.hxx"
-#include "context.hxx"
+#include "runvisitor.hxx"
 
 using namespace types;
 
-int GetIndexList(std::list<ast::Exp *>const& _plstArg, int** _piIndexSeq, int** _piMaxDim, InternalType *_pRefVar, int *_iDimSize);
 void ExpandList(int ** _piList, int *_piListSize, int _iListSizeSize, int *_piResultList);
 int GetVarMaxDim(types::InternalType *_pIT, int _iCurrentDim, int _iMaxDim);
 
 namespace ast
 {
-       class EXTERN_AST ExecVisitor : public GenVisitor<const_kind>
+       class EXTERN_AST ExecVisitor : public RunVisitorT<ExecVisitor>
        {
-       public:
-               ExecVisitor()
-               {
-                       _excepted_result = -1;
-                       _resultVect.push_back(NULL);
-                       _result = NULL;
-                       m_bSingleResult = true;
-               }
-
-               ~ExecVisitor()
-               {
-                       result_clear();
-               }
-
-               void result_clear()
-               {
-                       if(is_single_result())
-                       {
-                               if(_result != NULL && _result->isDeletable() == true)
-                               {
-//                                     std::cout << "before single delete : " << _result << std::endl;
-                                       delete _result;
-//                                     std::cout << "after single delete" << std::endl;
-                               }
-                       }
-                       else
-                       {
-                               for(int i = 0 ; i < _resultVect.size() ; i++)
-                               {
-                                       if(_resultVect[i] != NULL && _resultVect[i]->isDeletable() == true)
-                                       {
-                                               delete _resultVect[i];
-                                       }
-                               }
-                       }
-
-               }
-
                /** \name Visit Matrix Expressions nodes.
                ** \{ */
        public :
@@ -144,122 +104,6 @@ namespace ast
        public:
                virtual void visit(const ListExp &e);
                /** \} */
-
-
-
-               int expected_size_get(void)
-               {
-                       return _excepted_result;
-               }
-
-               int result_size_get(void)
-               {
-                       if(is_single_result())
-                       {
-                               if(_result == NULL)
-                               {
-                                       return 0;
-                               }
-                               else
-                               {
-                                       return 1;
-                               }
-                       }
-                       else
-                       {
-                               return (int)_resultVect.size();
-                       }
-               }
-
-               void expected_size_set(int _iSize)
-               {
-                       _excepted_result = _iSize;
-               }
-
-               InternalType* result_get(void)
-               {
-                       if(is_single_result())
-                       {
-                               return _result;
-                       }
-                       else
-                       {
-                               return _resultVect[0];
-                       }
-               }
-
-               types::InternalType* result_get(int _iPos)
-               {
-                       if(_iPos >= _resultVect.size())
-                       {
-                               return NULL;
-                       }
-                       return _resultVect[_iPos];
-               }
-
-               vector<types::InternalType*>* result_list_get()
-               {
-                       return &_resultVect;
-               }
-
-               void result_set(int _iPos, const types::InternalType *gtVal)
-               {
-                       m_bSingleResult = false;
-                       if(_iPos < _resultVect.size())
-                       {
-                               if(_resultVect[_iPos] != NULL && _resultVect[_iPos]->isDeletable())
-                               {
-                                       delete _resultVect[_iPos];
-                               }
-                       }
-
-                       if(_iPos >= _resultVect.size())
-                       {
-                               _resultVect.resize(_iPos + 1, NULL);
-                       }
-
-                       _resultVect[_iPos] = (InternalType *)gtVal;
-               }
-
-               void result_set(const InternalType *gtVal)
-               {
-                       m_bSingleResult = true;
-                       _result = const_cast<InternalType *>(gtVal);
-               }
-
-               bool is_single_result()
-               {
-                       return m_bSingleResult;
-               }
-
-
-               /*
-               int result_size_get(void);
-               int expected_size_get(void);
-               void expected_size_set(int _iSize);
-               types::InternalType*            result_get(void);
-               types::InternalType*            result_get(int _iPos);
-               vector<types::InternalType*>* result_list_get();
-               void    result_set(const types::InternalType *gtVal);
-               void    result_set(int _iPos, const types::InternalType *gtVal);
-               bool    is_single_result();
-               */
-
-               /*-------------.
-               | Attributes.  |
-               `-------------*/
-       protected:
-               vector<types::InternalType*>    _resultVect;
-               types::InternalType*    _result;
-               bool m_bSingleResult;
-               int _excepted_result;
-       private :
-               ExecVisitor(ExecVisitor const& e){}
-
-       public : 
-               static ExecVisitor* m_defaultVisitor;
-               static ExecVisitor& getDefaultVisitor(){return *m_defaultVisitor;}
-               static void setDefaultVisitor(ExecVisitor& visitor){m_defaultVisitor = &visitor;}
        };
 }
 #endif // !AST_EXECVISITOR_HXX