/[svn]/linuxsampler/trunk/src/scriptvm/tree.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/scriptvm/tree.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2942 by schoenebeck, Wed Jul 13 15:51:06 2016 UTC revision 3118 by schoenebeck, Fri Apr 21 13:33:03 2017 UTC
# Line 1  Line 1 
1  /*                                                              -*- c++ -*-  /*                                                              -*- c++ -*-
2   *   *
3   * Copyright (c) 2014 - 2016 Christian Schoenebeck and Andreas Persson   * Copyright (c) 2014 - 2017 Christian Schoenebeck and Andreas Persson
4   *   *
5   * http://www.linuxsampler.org   * http://www.linuxsampler.org
6   *   *
# Line 63  public: Line 63  public:
63  };  };
64  typedef Ref<IntExpr,Node> IntExprRef;  typedef Ref<IntExpr,Node> IntExprRef;
65    
66    /*class IntArrayExpr : virtual public VMIntArrayExpr, virtual public Expression {
67    public:
68        ExprType_t exprType() const { return INT_ARR_EXPR; }
69        String evalCastToStr();
70    };
71    typedef Ref<IntArrayExpr,Node> IntArrayExprRef;*/
72    
73  class StringExpr : virtual public VMStringExpr, virtual public Expression {  class StringExpr : virtual public VMStringExpr, virtual public Expression {
74  public:  public:
75      ExprType_t exprType() const { return STRING_EXPR; }      ExprType_t exprType() const { return STRING_EXPR; }
# Line 98  public: Line 105  public:
105      std::vector<ExpressionRef> args;      std::vector<ExpressionRef> args;
106      void add(ExpressionRef arg) { args.push_back(arg); }      void add(ExpressionRef arg) { args.push_back(arg); }
107      void dump(int level = 0);      void dump(int level = 0);
108      int argsCount() const { return args.size(); }      int argsCount() const { return (int) args.size(); }
109      VMExpr* arg(int i) { return (i >= 0 && i < argsCount()) ? &*args.at(i) : NULL; }      VMExpr* arg(int i) { return (i >= 0 && i < argsCount()) ? &*args.at(i) : NULL; }
110      bool isPolyphonic() const;      bool isPolyphonic() const;
111  };  };
112  typedef Ref<Args,Node> ArgsRef;  typedef Ref<Args,Node> ArgsRef;
113    
114  class Variable : virtual public Expression {  class Variable : virtual public VMVariable, virtual public Expression {
115  public:  public:
116      virtual bool isConstExpr() const { return bConst; }      bool isConstExpr() const OVERRIDE { return bConst; }
117      virtual bool isAssignable() const { return !bConst; }      bool isAssignable() const OVERRIDE { return !bConst; }
118      virtual void assign(Expression* expr) = 0;      virtual void assign(Expression* expr) = 0;
119        void assignExpr(VMExpr* expr) OVERRIDE { Expression* e = dynamic_cast<Expression*>(expr); if (e) assign(e); }
120  protected:  protected:
121      Variable(ParserContext* ctx, int _memPos, bool _bConst)      Variable(ParserContext* ctx, int _memPos, bool _bConst)
122          : context(ctx), memPos(_memPos), bConst(_bConst) {}          : context(ctx), memPos(_memPos), bConst(_bConst) {}
# Line 149  class BuiltInIntVariable : public IntVar Line 157  class BuiltInIntVariable : public IntVar
157      VMIntRelPtr* ptr;      VMIntRelPtr* ptr;
158  public:  public:
159      BuiltInIntVariable(const String& name, VMIntRelPtr* ptr);      BuiltInIntVariable(const String& name, VMIntRelPtr* ptr);
160      void assign(Expression* expr);      bool isAssignable() const OVERRIDE { return !ptr->readonly; }
161      int evalInt();      void assign(Expression* expr) OVERRIDE;
162      void dump(int level = 0);      int evalInt() OVERRIDE;
163        void dump(int level = 0) OVERRIDE;
164  };  };
165  typedef Ref<BuiltInIntVariable,Node> BuiltInIntVariableRef;  typedef Ref<BuiltInIntVariable,Node> BuiltInIntVariableRef;
166    
# Line 330  public: Line 339  public:
339      bool isConstExpr() const OVERRIDE { return dynVar->isConstExpr(); }      bool isConstExpr() const OVERRIDE { return dynVar->isConstExpr(); }
340      bool isAssignable() const OVERRIDE { return dynVar->isAssignable(); }      bool isAssignable() const OVERRIDE { return dynVar->isAssignable(); }
341      bool isPolyphonic() const OVERRIDE { return false; }      bool isPolyphonic() const OVERRIDE { return false; }
342      void assign(Expression* expr) OVERRIDE { dynVar->assign(expr); }      void assign(Expression* expr) OVERRIDE { dynVar->assignExpr(expr); }
343        VMIntArrayExpr* asIntArray() const OVERRIDE { return dynVar->asIntArray(); }
344      int evalInt() OVERRIDE;      int evalInt() OVERRIDE;
345      String evalStr() OVERRIDE;      String evalStr() OVERRIDE;
346      String evalCastToStr() OVERRIDE;      String evalCastToStr() OVERRIDE;
# Line 345  class FunctionCall : virtual public Leaf Line 355  class FunctionCall : virtual public Leaf
355  public:  public:
356      FunctionCall(const char* function, ArgsRef args, VMFunction* fn) :      FunctionCall(const char* function, ArgsRef args, VMFunction* fn) :
357          functionName(function), args(args), fn(fn) { }          functionName(function), args(args), fn(fn) { }
358      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
359      StmtFlags_t exec();      StmtFlags_t exec() OVERRIDE;
360      int evalInt();      int evalInt() OVERRIDE;
361      String evalStr();      VMIntArrayExpr* asIntArray() const OVERRIDE;
362      bool isConstExpr() const { return false; }      String evalStr() OVERRIDE;
363      ExprType_t exprType() const;      bool isConstExpr() const OVERRIDE { return false; }
364      String evalCastToStr();      ExprType_t exprType() const OVERRIDE;
365      bool isPolyphonic() const { return args->isPolyphonic(); }      String evalCastToStr() OVERRIDE;
366        bool isPolyphonic() const OVERRIDE { return args->isPolyphonic(); }
367  protected:  protected:
368      VMFnResult* execVMFn();      VMFnResult* execVMFn();
369  };  };
# Line 412  public: Line 423  public:
423      int evalInt() { return 0; }      int evalInt() { return 0; }
424      EventHandler* eventHandlerByName(const String& name) const;      EventHandler* eventHandlerByName(const String& name) const;
425      EventHandler* eventHandler(uint index) const;      EventHandler* eventHandler(uint index) const;
426      inline uint size() const { return args.size(); }      inline uint size() const { return (int) args.size(); }
427      bool isPolyphonic() const;      bool isPolyphonic() const;
428  };  };
429  typedef Ref<EventHandlers,Node> EventHandlersRef;  typedef Ref<EventHandlers,Node> EventHandlersRef;
# Line 600  public: Line 611  public:
611      std::set<String> userPreprocessorConditions;      std::set<String> userPreprocessorConditions;
612    
613      std::map<String,VariableRef> vartable;      std::map<String,VariableRef> vartable;
614        std::map<String,StatementsRef> userFnTable;
615      int globalIntVarCount;      int globalIntVarCount;
616      int globalStrVarCount;      int globalStrVarCount;
617      int polyphonicIntVarCount;      int polyphonicIntVarCount;
# Line 631  public: Line 643  public:
643      IntVariableRef globalIntVar(const String& name);      IntVariableRef globalIntVar(const String& name);
644      StringVariableRef globalStrVar(const String& name);      StringVariableRef globalStrVar(const String& name);
645      VariableRef variableByName(const String& name);      VariableRef variableByName(const String& name);
646        StatementsRef userFunctionByName(const String& name);
647      void addErr(int firstLine, int lastLine, int firstColumn, int lastColumn, const char* txt);      void addErr(int firstLine, int lastLine, int firstColumn, int lastColumn, const char* txt);
648      void addWrn(int firstLine, int lastLine, int firstColumn, int lastColumn, const char* txt);      void addWrn(int firstLine, int lastLine, int firstColumn, int lastColumn, const char* txt);
649      void createScanner(std::istream* is);      void createScanner(std::istream* is);

Legend:
Removed from v.2942  
changed lines
  Added in v.3118

  ViewVC Help
Powered by ViewVC