/[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 2948 by schoenebeck, Fri Jul 15 15:29:04 2016 UTC revision 3253 by schoenebeck, Tue May 30 12:08:45 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  };  };
# Line 151  class BuiltInIntVariable : public IntVar Line 159  class BuiltInIntVariable : public IntVar
159  public:  public:
160      BuiltInIntVariable(const String& name, VMIntRelPtr* ptr);      BuiltInIntVariable(const String& name, VMIntRelPtr* ptr);
161      bool isAssignable() const OVERRIDE { return !ptr->readonly; }      bool isAssignable() const OVERRIDE { return !ptr->readonly; }
162      void assign(Expression* expr);      void assign(Expression* expr) OVERRIDE;
163      int evalInt();      int evalInt() OVERRIDE;
164      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
165  };  };
166  typedef Ref<BuiltInIntVariable,Node> BuiltInIntVariableRef;  typedef Ref<BuiltInIntVariable,Node> BuiltInIntVariableRef;
167    
# Line 189  public: Line 197  public:
197      BuiltInIntArrayVariable(const String& name, VMInt8Array* array);      BuiltInIntArrayVariable(const String& name, VMInt8Array* array);
198      int arraySize() const { return array->size; }      int arraySize() const { return array->size; }
199      int evalIntElement(uint i);      int evalIntElement(uint i);
200        bool isAssignable() const OVERRIDE { return !array->readonly; }
201      void assignIntElement(uint i, int value);      void assignIntElement(uint i, int value);
202      void dump(int level = 0);      void dump(int level = 0);
203  };  };
# Line 333  public: Line 342  public:
342      bool isAssignable() const OVERRIDE { return dynVar->isAssignable(); }      bool isAssignable() const OVERRIDE { return dynVar->isAssignable(); }
343      bool isPolyphonic() const OVERRIDE { return false; }      bool isPolyphonic() const OVERRIDE { return false; }
344      void assign(Expression* expr) OVERRIDE { dynVar->assignExpr(expr); }      void assign(Expression* expr) OVERRIDE { dynVar->assignExpr(expr); }
345        VMIntArrayExpr* asIntArray() const OVERRIDE { return dynVar->asIntArray(); }
346      int evalInt() OVERRIDE;      int evalInt() OVERRIDE;
347      String evalStr() OVERRIDE;      String evalStr() OVERRIDE;
348      String evalCastToStr() OVERRIDE;      String evalCastToStr() OVERRIDE;
# Line 347  class FunctionCall : virtual public Leaf Line 357  class FunctionCall : virtual public Leaf
357  public:  public:
358      FunctionCall(const char* function, ArgsRef args, VMFunction* fn) :      FunctionCall(const char* function, ArgsRef args, VMFunction* fn) :
359          functionName(function), args(args), fn(fn) { }          functionName(function), args(args), fn(fn) { }
360      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
361      StmtFlags_t exec();      StmtFlags_t exec() OVERRIDE;
362      int evalInt();      int evalInt() OVERRIDE;
363      String evalStr();      VMIntArrayExpr* asIntArray() const OVERRIDE;
364      bool isConstExpr() const { return false; }      String evalStr() OVERRIDE;
365      ExprType_t exprType() const;      bool isConstExpr() const OVERRIDE { return false; }
366      String evalCastToStr();      ExprType_t exprType() const OVERRIDE;
367      bool isPolyphonic() const { return args->isPolyphonic(); }      String evalCastToStr() OVERRIDE;
368        bool isPolyphonic() const OVERRIDE { return args->isPolyphonic(); }
369  protected:  protected:
370      VMFnResult* execVMFn();      VMFnResult* execVMFn();
371  };  };
# Line 414  public: Line 425  public:
425      int evalInt() { return 0; }      int evalInt() { return 0; }
426      EventHandler* eventHandlerByName(const String& name) const;      EventHandler* eventHandlerByName(const String& name) const;
427      EventHandler* eventHandler(uint index) const;      EventHandler* eventHandler(uint index) const;
428      inline uint size() const { return args.size(); }      inline uint size() const { return (int) args.size(); }
429      bool isPolyphonic() const;      bool isPolyphonic() const;
430  };  };
431  typedef Ref<EventHandlers,Node> EventHandlersRef;  typedef Ref<EventHandlers,Node> EventHandlersRef;
# Line 602  public: Line 613  public:
613      std::set<String> userPreprocessorConditions;      std::set<String> userPreprocessorConditions;
614    
615      std::map<String,VariableRef> vartable;      std::map<String,VariableRef> vartable;
616        std::map<String,StatementsRef> userFnTable;
617      int globalIntVarCount;      int globalIntVarCount;
618      int globalStrVarCount;      int globalStrVarCount;
619      int polyphonicIntVarCount;      int polyphonicIntVarCount;
# Line 633  public: Line 645  public:
645      IntVariableRef globalIntVar(const String& name);      IntVariableRef globalIntVar(const String& name);
646      StringVariableRef globalStrVar(const String& name);      StringVariableRef globalStrVar(const String& name);
647      VariableRef variableByName(const String& name);      VariableRef variableByName(const String& name);
648        StatementsRef userFunctionByName(const String& name);
649      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);
650      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);
651      void createScanner(std::istream* is);      void createScanner(std::istream* is);
# Line 668  public: Line 681  public:
681      ArrayList<StackFrame> stack;      ArrayList<StackFrame> stack;
682      int stackFrame;      int stackFrame;
683      int suspendMicroseconds;      int suspendMicroseconds;
684        size_t instructionsCount;
685    
686      ExecContext() :      ExecContext() :
687          status(VM_EXEC_NOT_RUNNING), stackFrame(-1), suspendMicroseconds(0) {}          status(VM_EXEC_NOT_RUNNING), stackFrame(-1), suspendMicroseconds(0),
688            instructionsCount(0) {}
689    
690      virtual ~ExecContext() {}      virtual ~ExecContext() {}
691    
# Line 698  public: Line 713  public:
713      int suspensionTimeMicroseconds() const OVERRIDE {      int suspensionTimeMicroseconds() const OVERRIDE {
714          return suspendMicroseconds;          return suspendMicroseconds;
715      }      }
716    
717        void resetPolyphonicData() OVERRIDE {
718            if (polyphonicIntMemory.empty()) return;
719            memset(&polyphonicIntMemory[0], 0, polyphonicIntMemory.size() * sizeof(int));
720        }
721    
722        size_t instructionsPerformed() const OVERRIDE {
723            return instructionsCount;
724        }
725  };  };
726    
727  } // namespace LinuxSampler  } // namespace LinuxSampler

Legend:
Removed from v.2948  
changed lines
  Added in v.3253

  ViewVC Help
Powered by ViewVC