/[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 2619 by schoenebeck, Wed Jun 11 13:24:32 2014 UTC revision 3293 by schoenebeck, Tue Jun 27 22:19:19 2017 UTC
# Line 1  Line 1 
1  /*                                                              -*- c++ -*-  /*                                                              -*- c++ -*-
2   *   *
3   * Copyright (c) 2014 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 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  };  };
41    
42  class Node {  class Node {
# Line 42  public: Line 44  public:
44      Node();      Node();
45      virtual ~Node();      virtual ~Node();
46      virtual void dump(int level = 0) = 0;      virtual void dump(int level = 0) = 0;
47        virtual bool isPolyphonic() const = 0;
48      void printIndents(int n);      void printIndents(int n);
49  };  };
50  typedef Ref<Node> NodeRef;  typedef Ref<Node> NodeRef;
# Line 62  public: Line 65  public:
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 { return INT_ARR_EXPR; }
71        String evalCastToStr();
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 { return STRING_EXPR; }
# Line 77  public: Line 87  public:
87      int evalInt();      int evalInt();
88      void dump(int level = 0);      void dump(int level = 0);
89      bool isConstExpr() const { return true; }      bool isConstExpr() const { return true; }
90        bool isPolyphonic() const { return false; }
91  };  };
92  typedef Ref<IntLiteral,Node> IntLiteralRef;  typedef Ref<IntLiteral,Node> IntLiteralRef;
93    
# Line 87  public: Line 98  public:
98      bool isConstExpr() const { return true; }      bool isConstExpr() const { return true; }
99      void dump(int level = 0);      void dump(int level = 0);
100      String evalStr() { return value; }      String evalStr() { return value; }
101        bool isPolyphonic() const { return false; }
102  };  };
103  typedef Ref<StringLiteral,Node> StringLiteralRef;  typedef Ref<StringLiteral,Node> StringLiteralRef;
104    
# Line 95  public: Line 107  public:
107      std::vector<ExpressionRef> args;      std::vector<ExpressionRef> args;
108      void add(ExpressionRef arg) { args.push_back(arg); }      void add(ExpressionRef arg) { args.push_back(arg); }
109      void dump(int level = 0);      void dump(int level = 0);
110      int argsCount() const { return args.size(); }      int argsCount() const { return (int) args.size(); }
111      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; }
112        bool isPolyphonic() const;
113  };  };
114  typedef Ref<Args,Node> ArgsRef;  typedef Ref<Args,Node> ArgsRef;
115    
116  class Variable : virtual public Expression {  class Variable : virtual public VMVariable, virtual public Expression {
117  public:  public:
118      virtual bool isConstExpr() const { return bConst; }      bool isConstExpr() const OVERRIDE { return bConst; }
119        bool isAssignable() const OVERRIDE { return !bConst; }
120      virtual void assign(Expression* expr) = 0;      virtual void assign(Expression* expr) = 0;
121        void assignExpr(VMExpr* expr) OVERRIDE { Expression* e = dynamic_cast<Expression*>(expr); if (e) assign(e); }
122  protected:  protected:
123      Variable(ParserContext* ctx, int _memPos, bool _bConst)      Variable(ParserContext* ctx, int _memPos, bool _bConst)
124          : context(ctx), memPos(_memPos), bConst(_bConst) {}          : context(ctx), memPos(_memPos), bConst(_bConst) {}
# Line 144  class BuiltInIntVariable : public IntVar Line 159  class BuiltInIntVariable : public IntVar
159      VMIntRelPtr* ptr;      VMIntRelPtr* ptr;
160  public:  public:
161      BuiltInIntVariable(const String& name, VMIntRelPtr* ptr);      BuiltInIntVariable(const String& name, VMIntRelPtr* ptr);
162      void assign(Expression* expr);      bool isAssignable() const OVERRIDE { return !ptr->readonly; }
163      int evalInt();      void assign(Expression* expr) OVERRIDE;
164      void dump(int level = 0);      int evalInt() OVERRIDE;
165        void dump(int level = 0) OVERRIDE;
166  };  };
167  typedef Ref<BuiltInIntVariable,Node> BuiltInIntVariableRef;  typedef Ref<BuiltInIntVariable,Node> BuiltInIntVariableRef;
168    
# Line 157  public: Line 173  public:
173  };  };
174  typedef Ref<PolyphonicIntVariable,Node> PolyphonicIntVariableRef;  typedef Ref<PolyphonicIntVariable,Node> PolyphonicIntVariableRef;
175    
176  class IntArrayVariable : public Variable, virtual public VMIntArrayExpr {  class IntArrayVariable : public Variable, virtual public IntArrayExpr {
177      ArrayList<int> values;      ArrayList<int> values;
178  public:  public:
179      IntArrayVariable(ParserContext* ctx, int size);      IntArrayVariable(ParserContext* ctx, int size);
180      IntArrayVariable(ParserContext* ctx, int size, ArgsRef values);      IntArrayVariable(ParserContext* ctx, int size, ArgsRef values, bool _bConst = false);
181      void assign(Expression* expr) {} // ignore scalar assignment      void assign(Expression* expr) {} // ignore scalar assignment
182      String evalCastToStr() { return ""; } // ignore scalar cast to string      String evalCastToStr() { return ""; } // ignore scalar cast to string
183      ExprType_t exprType() const { return INT_ARR_EXPR; }      ExprType_t exprType() const { return INT_ARR_EXPR; }
# Line 169  public: Line 185  public:
185      virtual int evalIntElement(uint i);      virtual int evalIntElement(uint i);
186      virtual void assignIntElement(uint i, int value);      virtual void assignIntElement(uint i, int value);
187      void dump(int level = 0);      void dump(int level = 0);
188        bool isPolyphonic() const { return false; }
189  protected:  protected:
190      IntArrayVariable(ParserContext* ctx, bool bConst);      IntArrayVariable(ParserContext* ctx, bool bConst);
191  };  };
# Line 181  public: Line 198  public:
198      BuiltInIntArrayVariable(const String& name, VMInt8Array* array);      BuiltInIntArrayVariable(const String& name, VMInt8Array* array);
199      int arraySize() const { return array->size; }      int arraySize() const { return array->size; }
200      int evalIntElement(uint i);      int evalIntElement(uint i);
201        bool isAssignable() const OVERRIDE { return !array->readonly; }
202      void assignIntElement(uint i, int value);      void assignIntElement(uint i, int value);
203      void dump(int level = 0);      void dump(int level = 0);
204  };  };
205  typedef Ref<BuiltInIntArrayVariable,Node> BuiltInIntArrayVariableRef;  typedef Ref<BuiltInIntArrayVariable,Node> BuiltInIntArrayVariableRef;
206    
207  class IntArrayElement : public IntVariable {  class IntArrayElement : public IntVariable {
208      IntArrayVariableRef array;      IntArrayExprRef array;
209      IntExprRef index;      IntExprRef index;
210  public:  public:
211      IntArrayElement(IntArrayVariableRef array, IntExprRef arrayIndex);      IntArrayElement(IntArrayExprRef array, IntExprRef arrayIndex);
212      void assign(Expression* expr);      void assign(Expression* expr);
213      int evalInt();      int evalInt();
214      void dump(int level = 0);      void dump(int level = 0);
# Line 203  public: Line 221  public:
221      void assign(Expression* expr);      void assign(Expression* expr);
222      String evalStr();      String evalStr();
223      void dump(int level = 0);      void dump(int level = 0);
224        bool isPolyphonic() const { return false; }
225  protected:  protected:
226      StringVariable(ParserContext* ctx, bool bConst);      StringVariable(ParserContext* ctx, bool bConst);
227  };  };
# Line 226  protected: Line 245  protected:
245  public:  public:
246      BinaryOp(ExpressionRef lhs, ExpressionRef rhs) : lhs(lhs), rhs(rhs) { }      BinaryOp(ExpressionRef lhs, ExpressionRef rhs) : lhs(lhs), rhs(rhs) { }
247      bool isConstExpr() const { return lhs->isConstExpr() && rhs->isConstExpr(); }      bool isConstExpr() const { return lhs->isConstExpr() && rhs->isConstExpr(); }
248        bool isPolyphonic() const { return lhs->isPolyphonic() || rhs->isPolyphonic(); }
249  };  };
250  typedef Ref<BinaryOp,Node> BinaryOpRef;  typedef Ref<BinaryOp,Node> BinaryOpRef;
251    
# Line 282  public: Line 302  public:
302      NoOperation() : Statement() {}      NoOperation() : Statement() {}
303      StmtType_t statementType() const { return STMT_LEAF; }      StmtType_t statementType() const { return STMT_LEAF; }
304      void dump(int level = 0) {}      void dump(int level = 0) {}
305        bool isPolyphonic() const { return false; }
306  };  };
307  typedef Ref<NoOperation,Node> NoOperationRef;  typedef Ref<NoOperation,Node> NoOperationRef;
308    
# Line 301  public: Line 322  public:
322      void dump(int level = 0);      void dump(int level = 0);
323      StmtType_t statementType() const { return STMT_LIST; }      StmtType_t statementType() const { return STMT_LIST; }
324      virtual Statement* statement(uint i);      virtual Statement* statement(uint i);
325        bool isPolyphonic() const;
326  };  };
327  typedef Ref<Statements,Node> StatementsRef;  typedef Ref<Statements,Node> StatementsRef;
328    
# Line 311  public: Line 333  public:
333      virtual Statements* branch(uint i) const = 0;      virtual Statements* branch(uint i) const = 0;
334  };  };
335    
336    class DynamicVariableCall : public Variable, virtual public IntExpr, virtual public StringExpr, virtual public IntArrayExpr {
337        VMDynVar* dynVar;
338        String varName;
339    public:
340        DynamicVariableCall(const String& name, ParserContext* ctx, VMDynVar* v);
341        ExprType_t exprType() const OVERRIDE { return dynVar->exprType(); }
342        bool isConstExpr() const OVERRIDE { return dynVar->isConstExpr(); }
343        bool isAssignable() const OVERRIDE { return dynVar->isAssignable(); }
344        bool isPolyphonic() const OVERRIDE { return false; }
345        void assign(Expression* expr) OVERRIDE { dynVar->assignExpr(expr); }
346        VMIntArrayExpr* asIntArray() const OVERRIDE { return dynVar->asIntArray(); }
347        int evalInt() OVERRIDE;
348        String evalStr() OVERRIDE;
349        String evalCastToStr() OVERRIDE;
350        int arraySize() const OVERRIDE { return dynVar->asIntArray()->arraySize(); }
351        int evalIntElement(uint i) OVERRIDE { return dynVar->asIntArray()->evalIntElement(i); }
352        void assignIntElement(uint i, int value) { return dynVar->asIntArray()->assignIntElement(i, value); }
353        void dump(int level = 0) OVERRIDE;
354    };
355    typedef Ref<DynamicVariableCall,Node> DynamicVariableCallRef;
356    
357  class FunctionCall : virtual public LeafStatement, virtual public IntExpr, virtual public StringExpr {  class FunctionCall : virtual public LeafStatement, virtual public IntExpr, virtual public StringExpr {
358      String functionName;      String functionName;
359      ArgsRef args;      ArgsRef args;
# Line 318  class FunctionCall : virtual public Leaf Line 361  class FunctionCall : virtual public Leaf
361  public:  public:
362      FunctionCall(const char* function, ArgsRef args, VMFunction* fn) :      FunctionCall(const char* function, ArgsRef args, VMFunction* fn) :
363          functionName(function), args(args), fn(fn) { }          functionName(function), args(args), fn(fn) { }
364      void dump(int level = 0);      void dump(int level = 0) OVERRIDE;
365      StmtFlags_t exec();      StmtFlags_t exec() OVERRIDE;
366      int evalInt();      int evalInt() OVERRIDE;
367      String evalStr();      VMIntArrayExpr* asIntArray() const OVERRIDE;
368      bool isConstExpr() const { return false; }      String evalStr() OVERRIDE;
369      ExprType_t exprType() const;      bool isConstExpr() const OVERRIDE { return false; }
370      String evalCastToStr();      ExprType_t exprType() const OVERRIDE;
371        String evalCastToStr() OVERRIDE;
372        bool isPolyphonic() const OVERRIDE { return args->isPolyphonic(); }
373  protected:  protected:
374      VMFnResult* execVMFn();      VMFnResult* execVMFn();
375  };  };
# Line 332  typedef Ref<FunctionCall,Node> FunctionC Line 377  typedef Ref<FunctionCall,Node> FunctionC
377    
378  class EventHandler : virtual public Statements, virtual public VMEventHandler {  class EventHandler : virtual public Statements, virtual public VMEventHandler {
379      StatementsRef statements;      StatementsRef statements;
380        bool usingPolyphonics;
381  public:  public:
382      void dump(int level = 0);      void dump(int level = 0);
383      StmtFlags_t exec();      StmtFlags_t exec();
384      EventHandler(StatementsRef statements) { this->statements = statements; }      EventHandler(StatementsRef statements);
385      Statement* statement(uint i) { return statements->statement(i); }      Statement* statement(uint i) { return statements->statement(i); }
386        bool isPolyphonic() const { return usingPolyphonics; }
387  };  };
388  typedef Ref<EventHandler,Node> EventHandlerRef;  typedef Ref<EventHandler,Node> EventHandlerRef;
389    
390  class OnNote : public EventHandler {  class OnNote : public EventHandler {
391  public:  public:
392      OnNote(StatementsRef statements) : EventHandler(statements) {}      OnNote(StatementsRef statements) : EventHandler(statements) {}
393        VMEventHandlerType_t eventHandlerType() const { return VM_EVENT_HANDLER_NOTE; }
394      String eventHandlerName() const { return "note"; }      String eventHandlerName() const { return "note"; }
395  };  };
396  typedef Ref<OnNote,Node> OnNoteRef;  typedef Ref<OnNote,Node> OnNoteRef;
# Line 350  typedef Ref<OnNote,Node> OnNoteRef; Line 398  typedef Ref<OnNote,Node> OnNoteRef;
398  class OnInit : public EventHandler {  class OnInit : public EventHandler {
399  public:  public:
400      OnInit(StatementsRef statements) : EventHandler(statements) {}      OnInit(StatementsRef statements) : EventHandler(statements) {}
401        VMEventHandlerType_t eventHandlerType() const { return VM_EVENT_HANDLER_INIT; }
402      String eventHandlerName() const { return "init"; }      String eventHandlerName() const { return "init"; }
403  };  };
404  typedef Ref<OnInit,Node> OnInitRef;  typedef Ref<OnInit,Node> OnInitRef;
# Line 357  typedef Ref<OnInit,Node> OnInitRef; Line 406  typedef Ref<OnInit,Node> OnInitRef;
406  class OnRelease : public EventHandler {  class OnRelease : public EventHandler {
407  public:  public:
408      OnRelease(StatementsRef statements) : EventHandler(statements) {}      OnRelease(StatementsRef statements) : EventHandler(statements) {}
409        VMEventHandlerType_t eventHandlerType() const { return VM_EVENT_HANDLER_RELEASE; }
410      String eventHandlerName() const { return "release"; }      String eventHandlerName() const { return "release"; }
411  };  };
412  typedef Ref<OnRelease,Node> OnReleaseRef;  typedef Ref<OnRelease,Node> OnReleaseRef;
# Line 364  typedef Ref<OnRelease,Node> OnReleaseRef Line 414  typedef Ref<OnRelease,Node> OnReleaseRef
414  class OnController : public EventHandler {  class OnController : public EventHandler {
415  public:  public:
416      OnController(StatementsRef statements) : EventHandler(statements) {}      OnController(StatementsRef statements) : EventHandler(statements) {}
417        VMEventHandlerType_t eventHandlerType() const { return VM_EVENT_HANDLER_CONTROLLER; }
418      String eventHandlerName() const { return "controller"; }      String eventHandlerName() const { return "controller"; }
419  };  };
420  typedef Ref<OnController,Node> OnControllerRef;  typedef Ref<OnController,Node> OnControllerRef;
# Line 378  public: Line 429  public:
429      int evalInt() { return 0; }      int evalInt() { return 0; }
430      EventHandler* eventHandlerByName(const String& name) const;      EventHandler* eventHandlerByName(const String& name) const;
431      EventHandler* eventHandler(uint index) const;      EventHandler* eventHandler(uint index) const;
432      inline uint size() const { return args.size(); }      inline uint size() const { return (int) args.size(); }
433        bool isPolyphonic() const;
434  };  };
435  typedef Ref<EventHandlers,Node> EventHandlersRef;  typedef Ref<EventHandlers,Node> EventHandlersRef;
436    
# Line 390  public: Line 442  public:
442      Assignment(VariableRef variable, ExpressionRef value);      Assignment(VariableRef variable, ExpressionRef value);
443      void dump(int level = 0);      void dump(int level = 0);
444      StmtFlags_t exec();      StmtFlags_t exec();
445        bool isPolyphonic() const { return (variable && variable->isPolyphonic()) || (value && value->isPolyphonic()); }
446  };  };
447  typedef Ref<Assignment,Node> AssignmentRef;  typedef Ref<Assignment,Node> AssignmentRef;
448    
# Line 405  public: Line 458  public:
458      void dump(int level = 0);      void dump(int level = 0);
459      int evalBranch();      int evalBranch();
460      Statements* branch(uint i) const;      Statements* branch(uint i) const;
461        bool isPolyphonic() const;
462  };  };
463  typedef Ref<If,Node> IfRef;  typedef Ref<If,Node> IfRef;
464    
# Line 428  public: Line 482  public:
482      //void addBranch(IntExprRef from, IntExprRef to, StatementsRef statements);      //void addBranch(IntExprRef from, IntExprRef to, StatementsRef statements);
483      //void addBranch(CaseBranchRef branch);      //void addBranch(CaseBranchRef branch);
484      //void addBranches(CaseBranchesRef branches);      //void addBranches(CaseBranchesRef branches);
485        bool isPolyphonic() const;
486  };  };
487  typedef Ref<SelectCase,Node> SelectCaseRef;  typedef Ref<SelectCase,Node> SelectCaseRef;
488    
# Line 441  public: Line 496  public:
496      void dump(int level = 0);      void dump(int level = 0);
497      bool evalLoopStartCondition();      bool evalLoopStartCondition();
498      Statements* statements() const;      Statements* statements() const;
499        bool isPolyphonic() const { return m_condition->isPolyphonic() || m_statements->isPolyphonic(); }
500  };  };
501    
502    class SyncBlock : public Statement {
503        StatementsRef m_statements;
504    public:
505        SyncBlock(StatementsRef statements) : m_statements(statements) {}
506        StmtType_t statementType() const { return STMT_SYNC; }
507        void dump(int level = 0);
508        Statements* statements() const;
509        bool isPolyphonic() const { return m_statements->isPolyphonic(); }
510    };
511    typedef Ref<SyncBlock,Node> SyncBlockRef;
512    
513  class Neg : public IntExpr {  class Neg : public IntExpr {
514      IntExprRef expr;      IntExprRef expr;
515  public:  public:
# Line 450  public: Line 517  public:
517      int evalInt() { return (expr) ? -expr->evalInt() : 0; }      int evalInt() { return (expr) ? -expr->evalInt() : 0; }
518      void dump(int level = 0);      void dump(int level = 0);
519      bool isConstExpr() const { return expr->isConstExpr(); }      bool isConstExpr() const { return expr->isConstExpr(); }
520        bool isPolyphonic() const { return expr->isPolyphonic(); }
521  };  };
522  typedef Ref<Neg,Node> NegRef;  typedef Ref<Neg,Node> NegRef;
523    
# Line 461  public: Line 529  public:
529      String evalStr();      String evalStr();
530      void dump(int level = 0);      void dump(int level = 0);
531      bool isConstExpr() const;      bool isConstExpr() const;
532        bool isPolyphonic() const { return lhs->isPolyphonic() || rhs->isPolyphonic(); }
533  };  };
534  typedef Ref<ConcatString,Node> ConcatStringRef;  typedef Ref<ConcatString,Node> ConcatStringRef;
535    
# Line 479  public: Line 548  public:
548      int evalInt();      int evalInt();
549      void dump(int level = 0);      void dump(int level = 0);
550      bool isConstExpr() const;      bool isConstExpr() const;
551        bool isPolyphonic() const { return lhs->isPolyphonic() || rhs->isPolyphonic(); }
552  private:  private:
553      IntExprRef lhs;      IntExprRef lhs;
554      IntExprRef rhs;      IntExprRef rhs;
# Line 494  public: Line 564  public:
564  };  };
565  typedef Ref<Or,Node> OrRef;  typedef Ref<Or,Node> OrRef;
566    
567    class BitwiseOr : virtual public BinaryOp, virtual public IntExpr {
568    public:
569        BitwiseOr(IntExprRef lhs, IntExprRef rhs) : BinaryOp(lhs,rhs) {}
570        int evalInt();
571        void dump(int level = 0);
572    };
573    typedef Ref<BitwiseOr,Node> BitwiseOrRef;
574    
575  class And : virtual public BinaryOp, virtual public IntExpr {  class And : virtual public BinaryOp, virtual public IntExpr {
576  public:  public:
577      And(IntExprRef lhs, IntExprRef rhs) : BinaryOp(lhs,rhs) {}      And(IntExprRef lhs, IntExprRef rhs) : BinaryOp(lhs,rhs) {}
# Line 502  public: Line 580  public:
580  };  };
581  typedef Ref<And,Node> AndRef;  typedef Ref<And,Node> AndRef;
582    
583    class BitwiseAnd : virtual public BinaryOp, virtual public IntExpr {
584    public:
585        BitwiseAnd(IntExprRef lhs, IntExprRef rhs) : BinaryOp(lhs,rhs) {}
586        int evalInt();
587        void dump(int level = 0);
588    };
589    typedef Ref<BitwiseAnd,Node> BitwiseAndRef;
590    
591  class Not : virtual public IntExpr {  class Not : virtual public IntExpr {
592      IntExprRef expr;      IntExprRef expr;
593  public:  public:
# Line 509  public: Line 595  public:
595      int evalInt() { return !expr->evalInt(); }      int evalInt() { return !expr->evalInt(); }
596      void dump(int level = 0);      void dump(int level = 0);
597      bool isConstExpr() const { return expr->isConstExpr(); }      bool isConstExpr() const { return expr->isConstExpr(); }
598        bool isPolyphonic() const { return expr->isPolyphonic(); }
599  };  };
600  typedef Ref<Not,Node> NotRef;  typedef Ref<Not,Node> NotRef;
601    
602    class BitwiseNot : virtual public IntExpr {
603        IntExprRef expr;
604    public:
605        BitwiseNot(IntExprRef expr) : expr(expr) {}
606        int evalInt() { return ~expr->evalInt(); }
607        void dump(int level = 0);
608        bool isConstExpr() const { return expr->isConstExpr(); }
609        bool isPolyphonic() const { return expr->isPolyphonic(); }
610    };
611    typedef Ref<BitwiseNot,Node> BitwiseNotRef;
612    
613  class ParserContext : public VMParserContext {  class ParserContext : public VMParserContext {
614  public:  public:
615      struct Error {      struct Error {
# Line 525  public: Line 623  public:
623      std::vector<ParserIssue> vErrors;      std::vector<ParserIssue> vErrors;
624      std::vector<ParserIssue> vWarnings;      std::vector<ParserIssue> vWarnings;
625      std::vector<ParserIssue> vIssues;      std::vector<ParserIssue> vIssues;
626        std::vector<CodeBlock>   vPreprocessorComments;
627    
628      std::set<String> builtinPreprocessorConditions;      std::set<String> builtinPreprocessorConditions;
629      std::set<String> userPreprocessorConditions;      std::set<String> userPreprocessorConditions;
630    
631      std::map<String,VariableRef> vartable;      std::map<String,VariableRef> vartable;
632        std::map<String,StatementsRef> userFnTable;
633      int globalIntVarCount;      int globalIntVarCount;
634      int globalStrVarCount;      int globalStrVarCount;
635      int polyphonicIntVarCount;      int polyphonicIntVarCount;
# Line 561  public: Line 661  public:
661      IntVariableRef globalIntVar(const String& name);      IntVariableRef globalIntVar(const String& name);
662      StringVariableRef globalStrVar(const String& name);      StringVariableRef globalStrVar(const String& name);
663      VariableRef variableByName(const String& name);      VariableRef variableByName(const String& name);
664      void addErr(int line, const char* txt);      StatementsRef userFunctionByName(const String& name);
665      void addWrn(int line, const char* txt);      void addErr(int firstLine, int lastLine, int firstColumn, int lastColumn, const char* txt);
666        void addWrn(int firstLine, int lastLine, int firstColumn, int lastColumn, const char* txt);
667        void addPreprocessorComment(int firstLine, int lastLine, int firstColumn, int lastColumn);
668      void createScanner(std::istream* is);      void createScanner(std::istream* is);
669      void destroyScanner();      void destroyScanner();
670      bool setPreprocessorCondition(const char* name);      bool setPreprocessorCondition(const char* name);
# Line 571  public: Line 673  public:
673      std::vector<ParserIssue> issues() const OVERRIDE;      std::vector<ParserIssue> issues() const OVERRIDE;
674      std::vector<ParserIssue> errors() const OVERRIDE;      std::vector<ParserIssue> errors() const OVERRIDE;
675      std::vector<ParserIssue> warnings() const OVERRIDE;      std::vector<ParserIssue> warnings() const OVERRIDE;
676        std::vector<CodeBlock> preprocessorComments() const OVERRIDE;
677      VMEventHandler* eventHandler(uint index) OVERRIDE;      VMEventHandler* eventHandler(uint index) OVERRIDE;
678      VMEventHandler* eventHandlerByName(const String& name) OVERRIDE;      VMEventHandler* eventHandlerByName(const String& name) OVERRIDE;
679      void registerBuiltInConstIntVariables(const std::map<String,int>& vars);      void registerBuiltInConstIntVariables(const std::map<String,int>& vars);
680      void registerBuiltInIntVariables(const std::map<String,VMIntRelPtr*>& vars);      void registerBuiltInIntVariables(const std::map<String,VMIntRelPtr*>& vars);
681      void registerBuiltInIntArrayVariables(const std::map<String,VMInt8Array*>& vars);      void registerBuiltInIntArrayVariables(const std::map<String,VMInt8Array*>& vars);
682        void registerBuiltInDynVariables(const std::map<String,VMDynVar*>& vars);
683  };  };
684    
685  class ExecContext : public VMExecContext {  class ExecContext : public VMExecContext {
# Line 592  public: Line 696  public:
696    
697      ArrayList<int> polyphonicIntMemory;      ArrayList<int> polyphonicIntMemory;
698      VMExecStatus_t status;      VMExecStatus_t status;
699        StmtFlags_t flags;
700      ArrayList<StackFrame> stack;      ArrayList<StackFrame> stack;
701      int stackFrame;      int stackFrame;
702      int suspendMicroseconds;      int suspendMicroseconds;
703        size_t instructionsCount;
704    
705      ExecContext() :      ExecContext() :
706          status(VM_EXEC_NOT_RUNNING), stackFrame(-1), suspendMicroseconds(0) {}          status(VM_EXEC_NOT_RUNNING), flags(STMT_SUCCESS), stackFrame(-1),
707            suspendMicroseconds(0), instructionsCount(0) {}
708    
709      virtual ~ExecContext() {}      virtual ~ExecContext() {}
710    
# Line 620  public: Line 727  public:
727          stack[0].statement = NULL;          stack[0].statement = NULL;
728          stack[0].subindex  = -1;          stack[0].subindex  = -1;
729          stackFrame = -1;          stackFrame = -1;
730            flags = STMT_SUCCESS;
731      }      }
732    
733      int suspensionTimeMicroseconds() const OVERRIDE {      int suspensionTimeMicroseconds() const OVERRIDE {
734          return suspendMicroseconds;          return suspendMicroseconds;
735      }      }
736    
737        void resetPolyphonicData() OVERRIDE {
738            if (polyphonicIntMemory.empty()) return;
739            memset(&polyphonicIntMemory[0], 0, polyphonicIntMemory.size() * sizeof(int));
740        }
741    
742        size_t instructionsPerformed() const OVERRIDE {
743            return instructionsCount;
744        }
745    
746        void signalAbort() OVERRIDE {
747            flags = StmtFlags_t(flags | STMT_ABORT_SIGNALLED);
748        }
749    
750        void forkTo(VMExecContext* ectx) const OVERRIDE;
751  };  };
752    
753  } // namespace LinuxSampler  } // namespace LinuxSampler

Legend:
Removed from v.2619  
changed lines
  Added in v.3293

  ViewVC Help
Powered by ViewVC