/[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 2879 by schoenebeck, Tue Apr 19 14:07:53 2016 UTC revision 3561 by schoenebeck, Fri Aug 23 11:44:00 2019 UTC
# Line 1  Line 1 
1  /*                                                              -*- c++ -*-  /*                                                              -*- c++ -*-
2   *   *
3   * Copyright (c) 2014 - 2016 Christian Schoenebeck and Andreas Persson   * Copyright (c) 2014 - 2019 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 35  enum StmtType_t { Line 36  enum StmtType_t {
36      STMT_LIST,      STMT_LIST,
37      STMT_BRANCH,      STMT_BRANCH,
38      STMT_LOOP,      STMT_LOOP,
39        STMT_SYNC,
40        STMT_NOOP,
41  };  };
42    
43  class Node {  class Node {
# Line 57  typedef Ref<Expression,Node> ExpressionR Line 60  typedef Ref<Expression,Node> ExpressionR
60    
61  class IntExpr : virtual public VMIntExpr, virtual public Expression {  class IntExpr : virtual public VMIntExpr, virtual public Expression {
62  public:  public:
63      ExprType_t exprType() const { return INT_EXPR; }      ExprType_t exprType() const OVERRIDE { return INT_EXPR; }
64      virtual int evalInt() = 0;      String evalCastToStr() OVERRIDE;
     String evalCastToStr();  
65  };  };
66  typedef Ref<IntExpr,Node> IntExprRef;  typedef Ref<IntExpr,Node> IntExprRef;
67    
68    class IntArrayExpr : virtual public VMIntArrayExpr, virtual public Expression {
69    public:
70        ExprType_t exprType() const OVERRIDE { return INT_ARR_EXPR; }
71        String evalCastToStr() OVERRIDE;
72    };
73    typedef Ref<IntArrayExpr,Node> IntArrayExprRef;
74    
75  class StringExpr : virtual public VMStringExpr, virtual public Expression {  class StringExpr : virtual public VMStringExpr, virtual public Expression {
76  public:  public:
77      ExprType_t exprType() const { return STRING_EXPR; }      ExprType_t exprType() const OVERRIDE { return STRING_EXPR; }
78      virtual String evalStr() = 0;      String evalCastToStr() OVERRIDE { return evalStr(); }
     String evalCastToStr() { return evalStr(); }  
79  };  };
80  typedef Ref<StringExpr,Node> StringExprRef;  typedef Ref<StringExpr,Node> StringExprRef;
81    
82  class IntLiteral : virtual public IntExpr {  class Unit : virtual public VMUnit {
83      int value;      ArrayList<MetricPrefix_t> prefix;
84  public:      StdUnit_t unit;
85      IntLiteral(int value) : value(value) { }  public:
86      int evalInt();      Unit() : unit(VM_NO_UNIT) {}
87      void dump(int level = 0);      MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE;
88      bool isConstExpr() const { return true; }      StdUnit_t unitType() const OVERRIDE { return unit; }
89      bool isPolyphonic() const { return false; }      void setUnit(const std::vector<MetricPrefix_t>& prefix, StdUnit_t type);
90        void setUnit(const MetricPrefix_t* prefixes, StdUnit_t type);
91        void copyUnitFrom(const IntExprRef& src);
92    };
93    
94    class IntLiteral : public Unit, virtual public IntExpr {
95        bool finalVal;
96    public:
97        vmint value;
98        IntLiteral(vmint value) : Unit(),
99            value(value), finalVal(false) { }
100        vmint evalInt() OVERRIDE;
101        void dump(int level = 0) OVERRIDE;
102        bool isConstExpr() const OVERRIDE { return true; }
103        bool isPolyphonic() const OVERRIDE { return false; }
104        bool isFinal() const OVERRIDE { return finalVal; }
105        void setFinal(bool b = true) { finalVal = b; }
106  };  };
107  typedef Ref<IntLiteral,Node> IntLiteralRef;  typedef Ref<IntLiteral,Node> IntLiteralRef;
108    
# Line 86  class StringLiteral : virtual public Str Line 110  class StringLiteral : virtual public Str
110  public:  public:
111      String value;      String value;
112      StringLiteral(const String& value) : value(value) { }      StringLiteral(const String& value) : value(value) { }
113      bool isConstExpr() const { return true; }      bool isConstExpr() const OVERRIDE { return true; }
114      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
115      String evalStr() { return value; }      String evalStr() OVERRIDE { return value; }
116      bool isPolyphonic() const { return false; }      bool isPolyphonic() const OVERRIDE { return false; }
117  };  };
118  typedef Ref<StringLiteral,Node> StringLiteralRef;  typedef Ref<StringLiteral,Node> StringLiteralRef;
119    
# Line 97  class Args : virtual public VMFnArgs, vi Line 121  class Args : virtual public VMFnArgs, vi
121  public:  public:
122      std::vector<ExpressionRef> args;      std::vector<ExpressionRef> args;
123      void add(ExpressionRef arg) { args.push_back(arg); }      void add(ExpressionRef arg) { args.push_back(arg); }
124      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
125      int argsCount() const { return args.size(); }      vmint argsCount() const OVERRIDE { return (vmint) args.size(); }
126      VMExpr* arg(int i) { return (i >= 0 && i < argsCount()) ? &*args.at(i) : NULL; }      VMExpr* arg(vmint i) OVERRIDE { return (i >= 0 && i < argsCount()) ? &*args.at(i) : NULL; }
127      bool isPolyphonic() const;      bool isPolyphonic() const OVERRIDE;
128  };  };
129  typedef Ref<Args,Node> ArgsRef;  typedef Ref<Args,Node> ArgsRef;
130    
131  class Variable : virtual public Expression {  class Variable : virtual public VMVariable, virtual public Expression {
132  public:  public:
133      virtual bool isConstExpr() const { return bConst; }      bool isConstExpr() const OVERRIDE { return bConst; }
134        bool isAssignable() const OVERRIDE { return !bConst; }
135      virtual void assign(Expression* expr) = 0;      virtual void assign(Expression* expr) = 0;
136        void assignExpr(VMExpr* expr) OVERRIDE { Expression* e = dynamic_cast<Expression*>(expr); if (e) assign(e); }
137  protected:  protected:
138      Variable(ParserContext* ctx, int _memPos, bool _bConst)      Variable(ParserContext* ctx, vmint _memPos, bool _bConst)
139          : context(ctx), memPos(_memPos), bConst(_bConst) {}          : context(ctx), memPos(_memPos), bConst(_bConst) {}
140    
141      ParserContext* context;      ParserContext* context;
142      int memPos;      vmint memPos;
143      bool bConst;      bool bConst;
144  };  };
145  typedef Ref<Variable,Node> VariableRef;  typedef Ref<Variable,Node> VariableRef;
146    
147  class IntVariable : public Variable, virtual public IntExpr {  class IntVariable : public Variable, public Unit, virtual public IntExpr {
148      bool polyphonic;      bool polyphonic;
149        bool finalVal;
150  public:  public:
151      IntVariable(ParserContext* ctx);      IntVariable(ParserContext* ctx);
152      void assign(Expression* expr);      void assign(Expression* expr) OVERRIDE;
153      int evalInt();      vmint evalInt() OVERRIDE;
154      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
155      bool isPolyphonic() const { return polyphonic; }      bool isPolyphonic() const OVERRIDE { return polyphonic; }
156        bool isFinal() const OVERRIDE { return finalVal; }
157        void setFinal(bool b = true) { finalVal = b; }
158  protected:  protected:
159      IntVariable(ParserContext* ctx, bool polyphonic, bool bConst, int size = 1);      IntVariable(ParserContext* ctx, bool polyphonic, bool bConst, vmint size = 1);
160  };  };
161  typedef Ref<IntVariable,Node> IntVariableRef;  typedef Ref<IntVariable,Node> IntVariableRef;
162    
163  class ConstIntVariable : public IntVariable {  class ConstIntVariable : public IntVariable {
164  public:  public:
165      int value;      vmint value;
166    
167      ConstIntVariable(int value);      ConstIntVariable(vmint value);
168      //ConstIntVariable(ParserContext* ctx, int value = 0);      //ConstIntVariable(ParserContext* ctx, int value = 0);
169      void assign(Expression* expr);      void assign(Expression* expr) OVERRIDE;
170      int evalInt();      vmint evalInt() OVERRIDE;
171      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
172  };  };
173  typedef Ref<ConstIntVariable,Node> ConstIntVariableRef;  typedef Ref<ConstIntVariable,Node> ConstIntVariableRef;
174    
175  class BuiltInIntVariable : public IntVariable {  class BuiltInIntVariable : public IntVariable {
176      String name;      String name;
177      VMIntRelPtr* ptr;      VMIntPtr* ptr;
178  public:  public:
179      BuiltInIntVariable(const String& name, VMIntRelPtr* ptr);      BuiltInIntVariable(const String& name, VMIntPtr* ptr);
180      void assign(Expression* expr);      bool isAssignable() const OVERRIDE { return ptr->isAssignable(); }
181      int evalInt();      void assign(Expression* expr) OVERRIDE;
182      void dump(int level = 0);      vmint evalInt() OVERRIDE;
183        void dump(int level = 0) OVERRIDE;
184  };  };
185  typedef Ref<BuiltInIntVariable,Node> BuiltInIntVariableRef;  typedef Ref<BuiltInIntVariable,Node> BuiltInIntVariableRef;
186    
187  class PolyphonicIntVariable : public IntVariable {  class PolyphonicIntVariable : public IntVariable {
188  public:  public:
189      PolyphonicIntVariable(ParserContext* ctx);      PolyphonicIntVariable(ParserContext* ctx);
190      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
191  };  };
192  typedef Ref<PolyphonicIntVariable,Node> PolyphonicIntVariableRef;  typedef Ref<PolyphonicIntVariable,Node> PolyphonicIntVariableRef;
193    
194  class IntArrayVariable : public Variable, virtual public VMIntArrayExpr {  class IntArrayVariable : public Variable, virtual public IntArrayExpr {
195      ArrayList<int> values;      ArrayList<vmint> values;
196  public:  public:
197      IntArrayVariable(ParserContext* ctx, int size);      IntArrayVariable(ParserContext* ctx, vmint size);
198      IntArrayVariable(ParserContext* ctx, int size, ArgsRef values);      IntArrayVariable(ParserContext* ctx, vmint size, ArgsRef values, bool _bConst = false);
199      void assign(Expression* expr) {} // ignore scalar assignment      void assign(Expression* expr) OVERRIDE {} // ignore scalar assignment
200      String evalCastToStr() { return ""; } // ignore scalar cast to string      String evalCastToStr() OVERRIDE { return ""; } // ignore scalar cast to string
201      ExprType_t exprType() const { return INT_ARR_EXPR; }      ExprType_t exprType() const OVERRIDE { return INT_ARR_EXPR; }
202      virtual int arraySize() const { return values.size(); }      virtual vmint arraySize() const OVERRIDE { return values.size(); }
203      virtual int evalIntElement(uint i);      virtual vmint evalIntElement(vmuint i) OVERRIDE;
204      virtual void assignIntElement(uint i, int value);      virtual void assignIntElement(vmuint i, vmint value) OVERRIDE;
205      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
206      bool isPolyphonic() const { return false; }      bool isPolyphonic() const OVERRIDE { return false; }
207  protected:  protected:
208      IntArrayVariable(ParserContext* ctx, bool bConst);      IntArrayVariable(ParserContext* ctx, bool bConst);
209  };  };
# Line 184  class BuiltInIntArrayVariable : public I Line 214  class BuiltInIntArrayVariable : public I
214      VMInt8Array* array;      VMInt8Array* array;
215  public:  public:
216      BuiltInIntArrayVariable(const String& name, VMInt8Array* array);      BuiltInIntArrayVariable(const String& name, VMInt8Array* array);
217      int arraySize() const { return array->size; }      vmint arraySize() const OVERRIDE { return array->size; }
218      int evalIntElement(uint i);      vmint evalIntElement(vmuint i) OVERRIDE;
219      void assignIntElement(uint i, int value);      bool isAssignable() const OVERRIDE { return !array->readonly; }
220      void dump(int level = 0);      void assignIntElement(vmuint i, vmint value) OVERRIDE;
221        void dump(int level = 0) OVERRIDE;
222  };  };
223  typedef Ref<BuiltInIntArrayVariable,Node> BuiltInIntArrayVariableRef;  typedef Ref<BuiltInIntArrayVariable,Node> BuiltInIntArrayVariableRef;
224    
225  class IntArrayElement : public IntVariable {  class IntArrayElement : public IntVariable {
226      IntArrayVariableRef array;      IntArrayExprRef array;
227      IntExprRef index;      IntExprRef index;
228  public:  public:
229      IntArrayElement(IntArrayVariableRef array, IntExprRef arrayIndex);      IntArrayElement(IntArrayExprRef array, IntExprRef arrayIndex);
230      void assign(Expression* expr);      void assign(Expression* expr) OVERRIDE;
231      int evalInt();      vmint evalInt() OVERRIDE;
232      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
233  };  };
234  typedef Ref<IntArrayElement,Node> IntArrayElementRef;  typedef Ref<IntArrayElement,Node> IntArrayElementRef;
235    
236  class StringVariable : public Variable, virtual public StringExpr {  class StringVariable : public Variable, virtual public StringExpr {
237  public:  public:
238      StringVariable(ParserContext* ctx);      StringVariable(ParserContext* ctx);
239      void assign(Expression* expr);      void assign(Expression* expr) OVERRIDE;
240      String evalStr();      String evalStr() OVERRIDE;
241      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
242      bool isPolyphonic() const { return false; }      bool isPolyphonic() const OVERRIDE { return false; }
243  protected:  protected:
244      StringVariable(ParserContext* ctx, bool bConst);      StringVariable(ParserContext* ctx, bool bConst);
245  };  };
# Line 219  public: Line 250  public:
250      String value;      String value;
251    
252      ConstStringVariable(ParserContext* ctx, String value = "");      ConstStringVariable(ParserContext* ctx, String value = "");
253      void assign(Expression* expr);      void assign(Expression* expr) OVERRIDE;
254      String evalStr();      String evalStr() OVERRIDE;
255      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
256  };  };
257  typedef Ref<ConstStringVariable,Node> ConstStringVariableRef;  typedef Ref<ConstStringVariable,Node> ConstStringVariableRef;
258    
# Line 231  protected: Line 262  protected:
262      ExpressionRef rhs;      ExpressionRef rhs;
263  public:  public:
264      BinaryOp(ExpressionRef lhs, ExpressionRef rhs) : lhs(lhs), rhs(rhs) { }      BinaryOp(ExpressionRef lhs, ExpressionRef rhs) : lhs(lhs), rhs(rhs) { }
265      bool isConstExpr() const { return lhs->isConstExpr() && rhs->isConstExpr(); }      bool isConstExpr() const OVERRIDE { return lhs->isConstExpr() && rhs->isConstExpr(); }
266      bool isPolyphonic() const { return lhs->isPolyphonic() || rhs->isPolyphonic(); }      bool isPolyphonic() const OVERRIDE { return lhs->isPolyphonic() || rhs->isPolyphonic(); }
267  };  };
268  typedef Ref<BinaryOp,Node> BinaryOpRef;  typedef Ref<BinaryOp,Node> BinaryOpRef;
269    
270  class Add : virtual public BinaryOp, virtual public IntExpr {  class IntBinaryOp : public BinaryOp, virtual public IntExpr {
271  public:  public:
272      Add(IntExprRef lhs, IntExprRef rhs) : BinaryOp(lhs, rhs) { }      IntBinaryOp(IntExprRef lhs, IntExprRef rhs) : BinaryOp(lhs, rhs) { }
273      int evalInt();      MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE;
274      void dump(int level = 0);      StdUnit_t unitType() const OVERRIDE;
275        bool isFinal() const OVERRIDE;
276    };
277    typedef Ref<IntBinaryOp,Node> IntBinaryOpRef;
278    
279    class Add : public IntBinaryOp {
280    public:
281        Add(IntExprRef lhs, IntExprRef rhs) : IntBinaryOp(lhs, rhs) { }
282        vmint evalInt() OVERRIDE;
283        void dump(int level = 0) OVERRIDE;
284  };  };
285  typedef Ref<Add,Node> AddRef;  typedef Ref<Add,Node> AddRef;
286    
287  class Sub : virtual public BinaryOp, virtual public IntExpr {  class Sub : public IntBinaryOp {
288  public:  public:
289      Sub(IntExprRef lhs, IntExprRef rhs) : BinaryOp(lhs, rhs) { }      Sub(IntExprRef lhs, IntExprRef rhs) : IntBinaryOp(lhs, rhs) { }
290      int evalInt();      vmint evalInt() OVERRIDE;
291      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
292  };  };
293  typedef Ref<Sub,Node> SubRef;  typedef Ref<Sub,Node> SubRef;
294    
295  class Mul : virtual public BinaryOp, virtual public IntExpr {  class Mul : public IntBinaryOp {
296  public:  public:
297      Mul(IntExprRef lhs, IntExprRef rhs) : BinaryOp(lhs, rhs) { }      Mul(IntExprRef lhs, IntExprRef rhs) : IntBinaryOp(lhs, rhs) { }
298      int evalInt();      vmint evalInt() OVERRIDE;
299      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
300        MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE;
301        StdUnit_t unitType() const OVERRIDE;
302  };  };
303  typedef Ref<Mul,Node> MulRef;  typedef Ref<Mul,Node> MulRef;
304    
305  class Div : virtual public BinaryOp, virtual public IntExpr {  class Div : public IntBinaryOp {
306  public:  public:
307      Div(IntExprRef lhs, IntExprRef rhs) : BinaryOp(lhs, rhs) { }      Div(IntExprRef lhs, IntExprRef rhs) : IntBinaryOp(lhs, rhs) { }
308      int evalInt();      vmint evalInt() OVERRIDE;
309      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
310        MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE;
311        StdUnit_t unitType() const OVERRIDE;
312  };  };
313  typedef Ref<Div,Node> DivRef;  typedef Ref<Div,Node> DivRef;
314    
315  class Mod : virtual public BinaryOp, virtual public IntExpr {  class Mod : public IntBinaryOp {
316  public:  public:
317      Mod(IntExprRef lhs, IntExprRef rhs) : BinaryOp(lhs, rhs) { }      Mod(IntExprRef lhs, IntExprRef rhs) : IntBinaryOp(lhs, rhs) { }
318      int evalInt();      vmint evalInt() OVERRIDE;
319      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
320  };  };
321  typedef Ref<Mod,Node> ModRef;  typedef Ref<Mod,Node> ModRef;
322    
# Line 287  typedef Ref<Statement,Node> StatementRef Line 331  typedef Ref<Statement,Node> StatementRef
331  class NoOperation : public Statement {  class NoOperation : public Statement {
332  public:  public:
333      NoOperation() : Statement() {}      NoOperation() : Statement() {}
334      StmtType_t statementType() const { return STMT_LEAF; }      StmtType_t statementType() const OVERRIDE { return STMT_NOOP; }
335      void dump(int level = 0) {}      void dump(int level = 0) OVERRIDE {}
336      bool isPolyphonic() const { return false; }      bool isPolyphonic() const OVERRIDE { return false; }
337  };  };
338  typedef Ref<NoOperation,Node> NoOperationRef;  typedef Ref<NoOperation,Node> NoOperationRef;
339    
# Line 298  bool isNoOperation(StatementRef statemen Line 342  bool isNoOperation(StatementRef statemen
342  class LeafStatement : public Statement {  class LeafStatement : public Statement {
343  public:  public:
344      virtual StmtFlags_t exec() = 0;      virtual StmtFlags_t exec() = 0;
345      virtual StmtType_t statementType() const { return STMT_LEAF; }      StmtType_t statementType() const OVERRIDE { return STMT_LEAF; }
346  };  };
347  typedef Ref<LeafStatement,Node> LeafStatementRef;  typedef Ref<LeafStatement,Node> LeafStatementRef;
348    
# Line 306  class Statements : public Statement { Line 350  class Statements : public Statement {
350      std::vector<StatementRef> args;      std::vector<StatementRef> args;
351  public:  public:
352      void add(StatementRef arg) { args.push_back(arg); }      void add(StatementRef arg) { args.push_back(arg); }
353      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
354      StmtType_t statementType() const { return STMT_LIST; }      StmtType_t statementType() const OVERRIDE { return STMT_LIST; }
355      virtual Statement* statement(uint i);      virtual Statement* statement(uint i);
356      bool isPolyphonic() const;      bool isPolyphonic() const OVERRIDE;
357  };  };
358  typedef Ref<Statements,Node> StatementsRef;  typedef Ref<Statements,Node> StatementsRef;
359    
360  class BranchStatement : public Statement {  class BranchStatement : public Statement {
361  public:  public:
362      StmtType_t statementType() const { return STMT_BRANCH; }      StmtType_t statementType() const OVERRIDE { return STMT_BRANCH; }
363      virtual int evalBranch() = 0;      virtual vmint evalBranch() = 0;
364      virtual Statements* branch(uint i) const = 0;      virtual Statements* branch(vmuint i) const = 0;
365    };
366    
367    class DynamicVariableCall : public Variable, virtual public IntExpr, virtual public StringExpr, virtual public IntArrayExpr {
368        VMDynVar* dynVar;
369        String varName;
370    public:
371        DynamicVariableCall(const String& name, ParserContext* ctx, VMDynVar* v);
372        ExprType_t exprType() const OVERRIDE { return dynVar->exprType(); }
373        bool isConstExpr() const OVERRIDE { return dynVar->isConstExpr(); }
374        bool isAssignable() const OVERRIDE { return dynVar->isAssignable(); }
375        bool isPolyphonic() const OVERRIDE { return false; }
376        void assign(Expression* expr) OVERRIDE { dynVar->assignExpr(expr); }
377        VMIntArrayExpr* asIntArray() const OVERRIDE { return dynVar->asIntArray(); }
378        vmint evalInt() OVERRIDE;
379        String evalStr() OVERRIDE;
380        String evalCastToStr() OVERRIDE;
381        vmint arraySize() const OVERRIDE { return dynVar->asIntArray()->arraySize(); }
382        vmint evalIntElement(vmuint i) OVERRIDE { return dynVar->asIntArray()->evalIntElement(i); }
383        void assignIntElement(vmuint i, vmint value) OVERRIDE { return dynVar->asIntArray()->assignIntElement(i, value); }
384        void dump(int level = 0) OVERRIDE;
385        MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE { return VM_NO_PREFIX; }
386        StdUnit_t unitType() const OVERRIDE { return VM_NO_UNIT; }
387        bool isFinal() const OVERRIDE { return false; }
388  };  };
389    typedef Ref<DynamicVariableCall,Node> DynamicVariableCallRef;
390    
391  class FunctionCall : virtual public LeafStatement, virtual public IntExpr, virtual public StringExpr {  class FunctionCall : virtual public LeafStatement, virtual public IntExpr, virtual public StringExpr {
392      String functionName;      String functionName;
# Line 327  class FunctionCall : virtual public Leaf Line 395  class FunctionCall : virtual public Leaf
395  public:  public:
396      FunctionCall(const char* function, ArgsRef args, VMFunction* fn) :      FunctionCall(const char* function, ArgsRef args, VMFunction* fn) :
397          functionName(function), args(args), fn(fn) { }          functionName(function), args(args), fn(fn) { }
398      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
399      StmtFlags_t exec();      StmtFlags_t exec() OVERRIDE;
400      int evalInt();      vmint evalInt() OVERRIDE;
401      String evalStr();      VMIntArrayExpr* asIntArray() const OVERRIDE;
402      bool isConstExpr() const { return false; }      String evalStr() OVERRIDE;
403      ExprType_t exprType() const;      bool isConstExpr() const OVERRIDE { return false; }
404      String evalCastToStr();      ExprType_t exprType() const OVERRIDE;
405      bool isPolyphonic() const { return args->isPolyphonic(); }      String evalCastToStr() OVERRIDE;
406        bool isPolyphonic() const OVERRIDE { return args->isPolyphonic(); }
407        MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE { return VM_NO_PREFIX; }
408        StdUnit_t unitType() const OVERRIDE { return VM_NO_UNIT; }
409        bool isFinal() const OVERRIDE { return false; }
410  protected:  protected:
411      VMFnResult* execVMFn();      VMFnResult* execVMFn();
412  };  };
413  typedef Ref<FunctionCall,Node> FunctionCallRef;  typedef Ref<FunctionCall,Node> FunctionCallRef;
414    
415    class NoFunctionCall : public FunctionCall {
416    public:
417        NoFunctionCall() : FunctionCall("nothing", new Args, NULL) {}
418        StmtType_t statementType() const OVERRIDE { return STMT_NOOP; }
419    };
420    typedef Ref<NoFunctionCall,Node> NoFunctionCallRef;
421    
422  class EventHandler : virtual public Statements, virtual public VMEventHandler {  class EventHandler : virtual public Statements, virtual public VMEventHandler {
423      StatementsRef statements;      StatementsRef statements;
424      bool usingPolyphonics;      bool usingPolyphonics;
425  public:  public:
426      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
427      StmtFlags_t exec();      StmtFlags_t exec();
428      EventHandler(StatementsRef statements);      EventHandler(StatementsRef statements);
429      Statement* statement(uint i) { return statements->statement(i); }      Statement* statement(uint i) OVERRIDE { return statements->statement(i); }
430      bool isPolyphonic() const { return usingPolyphonics; }      bool isPolyphonic() const OVERRIDE { return usingPolyphonics; }
431  };  };
432  typedef Ref<EventHandler,Node> EventHandlerRef;  typedef Ref<EventHandler,Node> EventHandlerRef;
433    
434  class OnNote : public EventHandler {  class OnNote : public EventHandler {
435  public:  public:
436      OnNote(StatementsRef statements) : EventHandler(statements) {}      OnNote(StatementsRef statements) : EventHandler(statements) {}
437      VMEventHandlerType_t eventHandlerType() const { return VM_EVENT_HANDLER_NOTE; }      VMEventHandlerType_t eventHandlerType() const OVERRIDE { return VM_EVENT_HANDLER_NOTE; }
438      String eventHandlerName() const { return "note"; }      String eventHandlerName() const OVERRIDE { return "note"; }
439  };  };
440  typedef Ref<OnNote,Node> OnNoteRef;  typedef Ref<OnNote,Node> OnNoteRef;
441    
442  class OnInit : public EventHandler {  class OnInit : public EventHandler {
443  public:  public:
444      OnInit(StatementsRef statements) : EventHandler(statements) {}      OnInit(StatementsRef statements) : EventHandler(statements) {}
445      VMEventHandlerType_t eventHandlerType() const { return VM_EVENT_HANDLER_INIT; }      VMEventHandlerType_t eventHandlerType() const OVERRIDE { return VM_EVENT_HANDLER_INIT; }
446      String eventHandlerName() const { return "init"; }      String eventHandlerName() const OVERRIDE { return "init"; }
447  };  };
448  typedef Ref<OnInit,Node> OnInitRef;  typedef Ref<OnInit,Node> OnInitRef;
449    
450  class OnRelease : public EventHandler {  class OnRelease : public EventHandler {
451  public:  public:
452      OnRelease(StatementsRef statements) : EventHandler(statements) {}      OnRelease(StatementsRef statements) : EventHandler(statements) {}
453      VMEventHandlerType_t eventHandlerType() const { return VM_EVENT_HANDLER_RELEASE; }      VMEventHandlerType_t eventHandlerType() const OVERRIDE { return VM_EVENT_HANDLER_RELEASE; }
454      String eventHandlerName() const { return "release"; }      String eventHandlerName() const OVERRIDE { return "release"; }
455  };  };
456  typedef Ref<OnRelease,Node> OnReleaseRef;  typedef Ref<OnRelease,Node> OnReleaseRef;
457    
458  class OnController : public EventHandler {  class OnController : public EventHandler {
459  public:  public:
460      OnController(StatementsRef statements) : EventHandler(statements) {}      OnController(StatementsRef statements) : EventHandler(statements) {}
461      VMEventHandlerType_t eventHandlerType() const { return VM_EVENT_HANDLER_CONTROLLER; }      VMEventHandlerType_t eventHandlerType() const OVERRIDE { return VM_EVENT_HANDLER_CONTROLLER; }
462      String eventHandlerName() const { return "controller"; }      String eventHandlerName() const OVERRIDE { return "controller"; }
463  };  };
464  typedef Ref<OnController,Node> OnControllerRef;  typedef Ref<OnController,Node> OnControllerRef;
465    
# Line 390  public: Line 469  public:
469      EventHandlers();      EventHandlers();
470      ~EventHandlers();      ~EventHandlers();
471      void add(EventHandlerRef arg);      void add(EventHandlerRef arg);
472      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
     int evalInt() { return 0; }  
473      EventHandler* eventHandlerByName(const String& name) const;      EventHandler* eventHandlerByName(const String& name) const;
474      EventHandler* eventHandler(uint index) const;      EventHandler* eventHandler(uint index) const;
475      inline uint size() const { return args.size(); }      inline uint size() const { return (int) args.size(); }
476      bool isPolyphonic() const;      bool isPolyphonic() const OVERRIDE;
477  };  };
478  typedef Ref<EventHandlers,Node> EventHandlersRef;  typedef Ref<EventHandlers,Node> EventHandlersRef;
479    
# Line 405  protected: Line 483  protected:
483      ExpressionRef value;      ExpressionRef value;
484  public:  public:
485      Assignment(VariableRef variable, ExpressionRef value);      Assignment(VariableRef variable, ExpressionRef value);
486      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
487      StmtFlags_t exec();      StmtFlags_t exec() OVERRIDE;
488      bool isPolyphonic() const { return (variable && variable->isPolyphonic()) || (value && value->isPolyphonic()); }      bool isPolyphonic() const OVERRIDE { return (variable && variable->isPolyphonic()) || (value && value->isPolyphonic()); }
489  };  };
490  typedef Ref<Assignment,Node> AssignmentRef;  typedef Ref<Assignment,Node> AssignmentRef;
491    
# Line 420  public: Line 498  public:
498          condition(condition), ifStatements(ifStatements), elseStatements(elseStatements) { }          condition(condition), ifStatements(ifStatements), elseStatements(elseStatements) { }
499      If(IntExprRef condition, StatementsRef statements) :      If(IntExprRef condition, StatementsRef statements) :
500          condition(condition), ifStatements(statements) { }          condition(condition), ifStatements(statements) { }
501      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
502      int evalBranch();      vmint evalBranch() OVERRIDE;
503      Statements* branch(uint i) const;      Statements* branch(vmuint i) const OVERRIDE;
504      bool isPolyphonic() const;      bool isPolyphonic() const OVERRIDE;
505  };  };
506  typedef Ref<If,Node> IfRef;  typedef Ref<If,Node> IfRef;
507    
# Line 440  class SelectCase : public BranchStatemen Line 518  class SelectCase : public BranchStatemen
518      CaseBranches branches;      CaseBranches branches;
519  public:  public:
520      SelectCase(IntExprRef select, const CaseBranches& branches) : select(select), branches(branches) { }      SelectCase(IntExprRef select, const CaseBranches& branches) : select(select), branches(branches) { }
521      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
522      int evalBranch();      vmint evalBranch() OVERRIDE;
523      Statements* branch(uint i) const;      Statements* branch(vmuint i) const OVERRIDE;
524      //void addBranch(IntExprRef condition, StatementsRef statements);      //void addBranch(IntExprRef condition, StatementsRef statements);
525      //void addBranch(IntExprRef from, IntExprRef to, StatementsRef statements);      //void addBranch(IntExprRef from, IntExprRef to, StatementsRef statements);
526      //void addBranch(CaseBranchRef branch);      //void addBranch(CaseBranchRef branch);
527      //void addBranches(CaseBranchesRef branches);      //void addBranches(CaseBranchesRef branches);
528      bool isPolyphonic() const;      bool isPolyphonic() const OVERRIDE;
529  };  };
530  typedef Ref<SelectCase,Node> SelectCaseRef;  typedef Ref<SelectCase,Node> SelectCaseRef;
531    
# Line 457  class While : public Statement { Line 535  class While : public Statement {
535  public:  public:
536      While(IntExprRef condition, StatementsRef statements) :      While(IntExprRef condition, StatementsRef statements) :
537          m_condition(condition), m_statements(statements) {}          m_condition(condition), m_statements(statements) {}
538      StmtType_t statementType() const { return STMT_LOOP; }      StmtType_t statementType() const OVERRIDE { return STMT_LOOP; }
539      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
540      bool evalLoopStartCondition();      bool evalLoopStartCondition();
541      Statements* statements() const;      Statements* statements() const;
542      bool isPolyphonic() const { return m_condition->isPolyphonic() || m_statements->isPolyphonic(); }      bool isPolyphonic() const OVERRIDE { return m_condition->isPolyphonic() || m_statements->isPolyphonic(); }
543    };
544    
545    class SyncBlock : public Statement {
546        StatementsRef m_statements;
547    public:
548        SyncBlock(StatementsRef statements) : m_statements(statements) {}
549        StmtType_t statementType() const OVERRIDE { return STMT_SYNC; }
550        void dump(int level = 0) OVERRIDE;
551        Statements* statements() const;
552        bool isPolyphonic() const OVERRIDE { return m_statements->isPolyphonic(); }
553  };  };
554    typedef Ref<SyncBlock,Node> SyncBlockRef;
555    
556  class Neg : public IntExpr {  class Neg : public IntExpr {
557      IntExprRef expr;      IntExprRef expr;
558  public:  public:
559      Neg(IntExprRef expr) : expr(expr) { }      Neg(IntExprRef expr) : expr(expr) { }
560      int evalInt() { return (expr) ? -expr->evalInt() : 0; }      vmint evalInt() OVERRIDE { return (expr) ? -expr->evalInt() : 0; }
561      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
562      bool isConstExpr() const { return expr->isConstExpr(); }      bool isConstExpr() const OVERRIDE { return expr->isConstExpr(); }
563      bool isPolyphonic() const { return expr->isPolyphonic(); }      bool isPolyphonic() const OVERRIDE { return expr->isPolyphonic(); }
564        MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE { return expr->unitPrefix(i); }
565        StdUnit_t unitType() const OVERRIDE { return expr->unitType(); }
566        bool isFinal() const OVERRIDE { return expr->isFinal(); }
567  };  };
568  typedef Ref<Neg,Node> NegRef;  typedef Ref<Neg,Node> NegRef;
569    
# Line 480  class ConcatString : public StringExpr { Line 572  class ConcatString : public StringExpr {
572      ExpressionRef rhs;      ExpressionRef rhs;
573  public:  public:
574      ConcatString(ExpressionRef lhs, ExpressionRef rhs) : lhs(lhs), rhs(rhs) {}      ConcatString(ExpressionRef lhs, ExpressionRef rhs) : lhs(lhs), rhs(rhs) {}
575      String evalStr();      String evalStr() OVERRIDE;
576      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
577      bool isConstExpr() const;      bool isConstExpr() const OVERRIDE;
578      bool isPolyphonic() const { return lhs->isPolyphonic() || rhs->isPolyphonic(); }      bool isPolyphonic() const OVERRIDE { return lhs->isPolyphonic() || rhs->isPolyphonic(); }
579  };  };
580  typedef Ref<ConcatString,Node> ConcatStringRef;  typedef Ref<ConcatString,Node> ConcatStringRef;
581    
# Line 499  public: Line 591  public:
591      };      };
592      Relation(IntExprRef lhs, Type type, IntExprRef rhs) :      Relation(IntExprRef lhs, Type type, IntExprRef rhs) :
593          lhs(lhs), rhs(rhs), type(type) {}          lhs(lhs), rhs(rhs), type(type) {}
594      int evalInt();      vmint evalInt() OVERRIDE;
595      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
596      bool isConstExpr() const;      bool isConstExpr() const OVERRIDE;
597      bool isPolyphonic() const { return lhs->isPolyphonic() || rhs->isPolyphonic(); }      bool isPolyphonic() const OVERRIDE { return lhs->isPolyphonic() || rhs->isPolyphonic(); }
598        MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE { return VM_NO_PREFIX; }
599        StdUnit_t unitType() const OVERRIDE { return VM_NO_UNIT; }
600        bool isFinal() const OVERRIDE { return false; }
601  private:  private:
602      IntExprRef lhs;      IntExprRef lhs;
603      IntExprRef rhs;      IntExprRef rhs;
# Line 510  private: Line 605  private:
605  };  };
606  typedef Ref<Relation,Node> RelationRef;  typedef Ref<Relation,Node> RelationRef;
607    
608  class Or : virtual public BinaryOp, virtual public IntExpr {  class Or : public IntBinaryOp {
609  public:  public:
610      Or(IntExprRef lhs, IntExprRef rhs) : BinaryOp(lhs,rhs) {}      Or(IntExprRef lhs, IntExprRef rhs) : IntBinaryOp(lhs,rhs) {}
611      int evalInt();      vmint evalInt() OVERRIDE;
612      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
613  };  };
614  typedef Ref<Or,Node> OrRef;  typedef Ref<Or,Node> OrRef;
615    
616  class And : virtual public BinaryOp, virtual public IntExpr {  class BitwiseOr : public IntBinaryOp {
617  public:  public:
618      And(IntExprRef lhs, IntExprRef rhs) : BinaryOp(lhs,rhs) {}      BitwiseOr(IntExprRef lhs, IntExprRef rhs) : IntBinaryOp(lhs,rhs) {}
619      int evalInt();      vmint evalInt() OVERRIDE;
620      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
621        MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE { return VM_NO_PREFIX; }
622        StdUnit_t unitType() const OVERRIDE { return VM_NO_UNIT; }
623    };
624    typedef Ref<BitwiseOr,Node> BitwiseOrRef;
625    
626    class And : public IntBinaryOp {
627    public:
628        And(IntExprRef lhs, IntExprRef rhs) : IntBinaryOp(lhs,rhs) {}
629        vmint evalInt() OVERRIDE;
630        void dump(int level = 0) OVERRIDE;
631  };  };
632  typedef Ref<And,Node> AndRef;  typedef Ref<And,Node> AndRef;
633    
634    class BitwiseAnd : public IntBinaryOp {
635    public:
636        BitwiseAnd(IntExprRef lhs, IntExprRef rhs) : IntBinaryOp(lhs,rhs) {}
637        vmint evalInt() OVERRIDE;
638        void dump(int level = 0) OVERRIDE;
639        MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE { return VM_NO_PREFIX; }
640        StdUnit_t unitType() const OVERRIDE { return VM_NO_UNIT; }
641    };
642    typedef Ref<BitwiseAnd,Node> BitwiseAndRef;
643    
644  class Not : virtual public IntExpr {  class Not : virtual public IntExpr {
645      IntExprRef expr;      IntExprRef expr;
646  public:  public:
647      Not(IntExprRef expr) : expr(expr) {}      Not(IntExprRef expr) : expr(expr) {}
648      int evalInt() { return !expr->evalInt(); }      vmint evalInt() OVERRIDE { return !expr->evalInt(); }
649      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
650      bool isConstExpr() const { return expr->isConstExpr(); }      bool isConstExpr() const OVERRIDE { return expr->isConstExpr(); }
651      bool isPolyphonic() const { return expr->isPolyphonic(); }      bool isPolyphonic() const OVERRIDE { return expr->isPolyphonic(); }
652        MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE { return VM_NO_PREFIX; }
653        StdUnit_t unitType() const OVERRIDE { return VM_NO_UNIT; }
654        bool isFinal() const OVERRIDE { return expr->isFinal(); }
655  };  };
656  typedef Ref<Not,Node> NotRef;  typedef Ref<Not,Node> NotRef;
657    
658    class BitwiseNot : virtual public IntExpr {
659        IntExprRef expr;
660    public:
661        BitwiseNot(IntExprRef expr) : expr(expr) {}
662        vmint evalInt() OVERRIDE { return ~expr->evalInt(); }
663        void dump(int level = 0) OVERRIDE;
664        bool isConstExpr() const OVERRIDE { return expr->isConstExpr(); }
665        bool isPolyphonic() const OVERRIDE { return expr->isPolyphonic(); }
666        MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE { return VM_NO_PREFIX; }
667        StdUnit_t unitType() const OVERRIDE { return VM_NO_UNIT; }
668        bool isFinal() const OVERRIDE { return expr->isFinal(); }
669    };
670    typedef Ref<BitwiseNot,Node> BitwiseNotRef;
671    
672    class Final : virtual public IntExpr {
673        IntExprRef expr;
674    public:
675        Final(IntExprRef expr) : expr(expr) {}
676        vmint evalInt() OVERRIDE { return expr->evalInt(); }
677        void dump(int level = 0) OVERRIDE;
678        bool isConstExpr() const OVERRIDE { return expr->isConstExpr(); }
679        bool isPolyphonic() const OVERRIDE { return expr->isPolyphonic(); }
680        MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE { return expr->unitPrefix(i); }
681        StdUnit_t unitType() const OVERRIDE { return expr->unitType(); }
682        bool isFinal() const OVERRIDE { return true; }
683    };
684    typedef Ref<Final,Node> FinalRef;
685    
686  class ParserContext : public VMParserContext {  class ParserContext : public VMParserContext {
687  public:  public:
688      struct Error {      struct Error {
# Line 550  public: Line 696  public:
696      std::vector<ParserIssue> vErrors;      std::vector<ParserIssue> vErrors;
697      std::vector<ParserIssue> vWarnings;      std::vector<ParserIssue> vWarnings;
698      std::vector<ParserIssue> vIssues;      std::vector<ParserIssue> vIssues;
699        std::vector<CodeBlock>   vPreprocessorComments;
700    
701      std::set<String> builtinPreprocessorConditions;      std::set<String> builtinPreprocessorConditions;
702      std::set<String> userPreprocessorConditions;      std::set<String> userPreprocessorConditions;
703    
704      std::map<String,VariableRef> vartable;      std::map<String,VariableRef> vartable;
705      int globalIntVarCount;      std::map<String,StatementsRef> userFnTable;
706      int globalStrVarCount;      vmint globalIntVarCount;
707      int polyphonicIntVarCount;      vmint globalStrVarCount;
708        vmint polyphonicIntVarCount;
709    
710      EventHandlersRef handlers;      EventHandlersRef handlers;
711    
# Line 566  public: Line 714  public:
714      OnReleaseRef onRelease;      OnReleaseRef onRelease;
715      OnControllerRef onController;      OnControllerRef onController;
716    
717      ArrayList<int>* globalIntMemory;      ArrayList<vmint>* globalIntMemory;
718      ArrayList<String>* globalStrMemory;      ArrayList<String>* globalStrMemory;
719      int requiredMaxStackSize;      vmint requiredMaxStackSize;
720    
721      VMFunctionProvider* functionProvider;      VMFunctionProvider* functionProvider;
722    
# Line 586  public: Line 734  public:
734      IntVariableRef globalIntVar(const String& name);      IntVariableRef globalIntVar(const String& name);
735      StringVariableRef globalStrVar(const String& name);      StringVariableRef globalStrVar(const String& name);
736      VariableRef variableByName(const String& name);      VariableRef variableByName(const String& name);
737      void addErr(int line, const char* txt);      StatementsRef userFunctionByName(const String& name);
738      void addWrn(int line, const char* txt);      void addErr(int firstLine, int lastLine, int firstColumn, int lastColumn, const char* txt);
739        void addWrn(int firstLine, int lastLine, int firstColumn, int lastColumn, const char* txt);
740        void addPreprocessorComment(int firstLine, int lastLine, int firstColumn, int lastColumn);
741      void createScanner(std::istream* is);      void createScanner(std::istream* is);
742      void destroyScanner();      void destroyScanner();
743      bool setPreprocessorCondition(const char* name);      bool setPreprocessorCondition(const char* name);
# Line 596  public: Line 746  public:
746      std::vector<ParserIssue> issues() const OVERRIDE;      std::vector<ParserIssue> issues() const OVERRIDE;
747      std::vector<ParserIssue> errors() const OVERRIDE;      std::vector<ParserIssue> errors() const OVERRIDE;
748      std::vector<ParserIssue> warnings() const OVERRIDE;      std::vector<ParserIssue> warnings() const OVERRIDE;
749        std::vector<CodeBlock> preprocessorComments() const OVERRIDE;
750      VMEventHandler* eventHandler(uint index) OVERRIDE;      VMEventHandler* eventHandler(uint index) OVERRIDE;
751      VMEventHandler* eventHandlerByName(const String& name) OVERRIDE;      VMEventHandler* eventHandlerByName(const String& name) OVERRIDE;
752      void registerBuiltInConstIntVariables(const std::map<String,int>& vars);      void registerBuiltInConstIntVariables(const std::map<String,vmint>& vars);
753      void registerBuiltInIntVariables(const std::map<String,VMIntRelPtr*>& vars);      void registerBuiltInIntVariables(const std::map<String,VMIntPtr*>& vars);
754      void registerBuiltInIntArrayVariables(const std::map<String,VMInt8Array*>& vars);      void registerBuiltInIntArrayVariables(const std::map<String,VMInt8Array*>& vars);
755        void registerBuiltInDynVariables(const std::map<String,VMDynVar*>& vars);
756  };  };
757    
758  class ExecContext : public VMExecContext {  class ExecContext : public VMExecContext {
# Line 615  public: Line 767  public:
767          }          }
768      };      };
769    
770      ArrayList<int> polyphonicIntMemory;      ArrayList<vmint> polyphonicIntMemory;
771      VMExecStatus_t status;      VMExecStatus_t status;
772        StmtFlags_t flags;
773      ArrayList<StackFrame> stack;      ArrayList<StackFrame> stack;
774      int stackFrame;      int stackFrame;
775      int suspendMicroseconds;      vmint suspendMicroseconds;
776        size_t instructionsCount;
777        struct ExitRes {
778            Expression* value;
779            IntLiteral intLiteral;
780            StringLiteral stringLiteral;
781    
782      ExecContext() :          ExitRes() : intLiteral(0), stringLiteral("") { }
783          status(VM_EXEC_NOT_RUNNING), stackFrame(-1), suspendMicroseconds(0) {}      } exitRes;
784    
785        ExecContext();
786      virtual ~ExecContext() {}      virtual ~ExecContext() {}
787    
788      inline void pushStack(Statement* stmt) {      inline void pushStack(Statement* stmt) {
# Line 645  public: Line 804  public:
804          stack[0].statement = NULL;          stack[0].statement = NULL;
805          stack[0].subindex  = -1;          stack[0].subindex  = -1;
806          stackFrame = -1;          stackFrame = -1;
807            flags = STMT_SUCCESS;
808      }      }
809    
810      int suspensionTimeMicroseconds() const OVERRIDE {      inline void clearExitRes() {
811            exitRes.value = NULL;
812        }
813    
814        vmint suspensionTimeMicroseconds() const OVERRIDE {
815          return suspendMicroseconds;          return suspendMicroseconds;
816      }      }
817    
818        void resetPolyphonicData() OVERRIDE {
819            if (polyphonicIntMemory.empty()) return;
820            memset(&polyphonicIntMemory[0], 0, polyphonicIntMemory.size() * sizeof(vmint));
821        }
822    
823        size_t instructionsPerformed() const OVERRIDE {
824            return instructionsCount;
825        }
826    
827        void signalAbort() OVERRIDE {
828            flags = StmtFlags_t(flags | STMT_ABORT_SIGNALLED);
829        }
830    
831        void forkTo(VMExecContext* ectx) const OVERRIDE;
832    
833        VMExpr* exitResult() OVERRIDE {
834            return exitRes.value;
835        }
836  };  };
837    
838  } // namespace LinuxSampler  } // namespace LinuxSampler

Legend:
Removed from v.2879  
changed lines
  Added in v.3561

  ViewVC Help
Powered by ViewVC