/[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 3208 by schoenebeck, Thu May 25 11:39: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 20  Line 20 
20  #include <iostream>  #include <iostream>
21  #include <map>  #include <map>
22  #include <set>  #include <set>
23    #include <string.h> // for memset()
24  #include "../common/global.h"  #include "../common/global.h"
25  #include "../common/Ref.h"  #include "../common/Ref.h"
26  #include "../common/ArrayList.h"  #include "../common/ArrayList.h"
# Line 63  public: Line 64  public:
64  };  };
65  typedef Ref<IntExpr,Node> IntExprRef;  typedef Ref<IntExpr,Node> IntExprRef;
66    
67    /*class IntArrayExpr : virtual public VMIntArrayExpr, virtual public Expression {
68    public:
69        ExprType_t exprType() const { return INT_ARR_EXPR; }
70        String evalCastToStr();
71    };
72    typedef Ref<IntArrayExpr,Node> IntArrayExprRef;*/
73    
74  class StringExpr : virtual public VMStringExpr, virtual public Expression {  class StringExpr : virtual public VMStringExpr, virtual public Expression {
75  public:  public:
76      ExprType_t exprType() const { return STRING_EXPR; }      ExprType_t exprType() const { return STRING_EXPR; }
# Line 98  public: Line 106  public:
106      std::vector<ExpressionRef> args;      std::vector<ExpressionRef> args;
107      void add(ExpressionRef arg) { args.push_back(arg); }      void add(ExpressionRef arg) { args.push_back(arg); }
108      void dump(int level = 0);      void dump(int level = 0);
109      int argsCount() const { return args.size(); }      int argsCount() const { return (int) args.size(); }
110      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; }
111      bool isPolyphonic() const;      bool isPolyphonic() const;
112  };  };
113  typedef Ref<Args,Node> ArgsRef;  typedef Ref<Args,Node> ArgsRef;
114    
115  class Variable : virtual public Expression {  class Variable : virtual public VMVariable, virtual public Expression {
116  public:  public:
117      virtual bool isConstExpr() const { return bConst; }      bool isConstExpr() const OVERRIDE { return bConst; }
118      virtual bool isAssignable() const { return !bConst; }      bool isAssignable() const OVERRIDE { return !bConst; }
119      virtual void assign(Expression* expr) = 0;      virtual void assign(Expression* expr) = 0;
120        void assignExpr(VMExpr* expr) OVERRIDE { Expression* e = dynamic_cast<Expression*>(expr); if (e) assign(e); }
121  protected:  protected:
122      Variable(ParserContext* ctx, int _memPos, bool _bConst)      Variable(ParserContext* ctx, int _memPos, bool _bConst)
123          : context(ctx), memPos(_memPos), bConst(_bConst) {}          : context(ctx), memPos(_memPos), bConst(_bConst) {}
# Line 149  class BuiltInIntVariable : public IntVar Line 158  class BuiltInIntVariable : public IntVar
158      VMIntRelPtr* ptr;      VMIntRelPtr* ptr;
159  public:  public:
160      BuiltInIntVariable(const String& name, VMIntRelPtr* ptr);      BuiltInIntVariable(const String& name, VMIntRelPtr* ptr);
161      void assign(Expression* expr);      bool isAssignable() const OVERRIDE { return !ptr->readonly; }
162      int evalInt();      void assign(Expression* expr) OVERRIDE;
163      void dump(int level = 0);      int evalInt() OVERRIDE;
164        void dump(int level = 0) OVERRIDE;
165  };  };
166  typedef Ref<BuiltInIntVariable,Node> BuiltInIntVariableRef;  typedef Ref<BuiltInIntVariable,Node> BuiltInIntVariableRef;
167    
# Line 330  public: Line 340  public:
340      bool isConstExpr() const OVERRIDE { return dynVar->isConstExpr(); }      bool isConstExpr() const OVERRIDE { return dynVar->isConstExpr(); }
341      bool isAssignable() const OVERRIDE { return dynVar->isAssignable(); }      bool isAssignable() const OVERRIDE { return dynVar->isAssignable(); }
342      bool isPolyphonic() const OVERRIDE { return false; }      bool isPolyphonic() const OVERRIDE { return false; }
343      void assign(Expression* expr) OVERRIDE { dynVar->assign(expr); }      void assign(Expression* expr) OVERRIDE { dynVar->assignExpr(expr); }
344        VMIntArrayExpr* asIntArray() const OVERRIDE { return dynVar->asIntArray(); }
345      int evalInt() OVERRIDE;      int evalInt() OVERRIDE;
346      String evalStr() OVERRIDE;      String evalStr() OVERRIDE;
347      String evalCastToStr() OVERRIDE;      String evalCastToStr() OVERRIDE;
# Line 345  class FunctionCall : virtual public Leaf Line 356  class FunctionCall : virtual public Leaf
356  public:  public:
357      FunctionCall(const char* function, ArgsRef args, VMFunction* fn) :      FunctionCall(const char* function, ArgsRef args, VMFunction* fn) :
358          functionName(function), args(args), fn(fn) { }          functionName(function), args(args), fn(fn) { }
359      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
360      StmtFlags_t exec();      StmtFlags_t exec() OVERRIDE;
361      int evalInt();      int evalInt() OVERRIDE;
362      String evalStr();      VMIntArrayExpr* asIntArray() const OVERRIDE;
363      bool isConstExpr() const { return false; }      String evalStr() OVERRIDE;
364      ExprType_t exprType() const;      bool isConstExpr() const OVERRIDE { return false; }
365      String evalCastToStr();      ExprType_t exprType() const OVERRIDE;
366      bool isPolyphonic() const { return args->isPolyphonic(); }      String evalCastToStr() OVERRIDE;
367        bool isPolyphonic() const OVERRIDE { return args->isPolyphonic(); }
368  protected:  protected:
369      VMFnResult* execVMFn();      VMFnResult* execVMFn();
370  };  };
# Line 412  public: Line 424  public:
424      int evalInt() { return 0; }      int evalInt() { return 0; }
425      EventHandler* eventHandlerByName(const String& name) const;      EventHandler* eventHandlerByName(const String& name) const;
426      EventHandler* eventHandler(uint index) const;      EventHandler* eventHandler(uint index) const;
427      inline uint size() const { return args.size(); }      inline uint size() const { return (int) args.size(); }
428      bool isPolyphonic() const;      bool isPolyphonic() const;
429  };  };
430  typedef Ref<EventHandlers,Node> EventHandlersRef;  typedef Ref<EventHandlers,Node> EventHandlersRef;
# Line 600  public: Line 612  public:
612      std::set<String> userPreprocessorConditions;      std::set<String> userPreprocessorConditions;
613    
614      std::map<String,VariableRef> vartable;      std::map<String,VariableRef> vartable;
615        std::map<String,StatementsRef> userFnTable;
616      int globalIntVarCount;      int globalIntVarCount;
617      int globalStrVarCount;      int globalStrVarCount;
618      int polyphonicIntVarCount;      int polyphonicIntVarCount;
# Line 631  public: Line 644  public:
644      IntVariableRef globalIntVar(const String& name);      IntVariableRef globalIntVar(const String& name);
645      StringVariableRef globalStrVar(const String& name);      StringVariableRef globalStrVar(const String& name);
646      VariableRef variableByName(const String& name);      VariableRef variableByName(const String& name);
647        StatementsRef userFunctionByName(const String& name);
648      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);
649      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);
650      void createScanner(std::istream* is);      void createScanner(std::istream* is);
# Line 696  public: Line 710  public:
710      int suspensionTimeMicroseconds() const OVERRIDE {      int suspensionTimeMicroseconds() const OVERRIDE {
711          return suspendMicroseconds;          return suspendMicroseconds;
712      }      }
713    
714        void resetPolyphonicData() OVERRIDE {
715            if (polyphonicIntMemory.empty()) return;
716            memset(&polyphonicIntMemory[0], 0, polyphonicIntMemory.size() * sizeof(int));
717        }
718  };  };
719    
720  } // namespace LinuxSampler  } // namespace LinuxSampler

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

  ViewVC Help
Powered by ViewVC