--- linuxsampler/trunk/src/scriptvm/tree.h 2014/06/17 22:55:02 2644 +++ linuxsampler/trunk/src/scriptvm/tree.h 2014/06/18 00:14:57 2645 @@ -42,6 +42,7 @@ Node(); virtual ~Node(); virtual void dump(int level = 0) = 0; + virtual bool isPolyphonic() const = 0; void printIndents(int n); }; typedef Ref NodeRef; @@ -77,6 +78,7 @@ int evalInt(); void dump(int level = 0); bool isConstExpr() const { return true; } + bool isPolyphonic() const { return false; } }; typedef Ref IntLiteralRef; @@ -87,6 +89,7 @@ bool isConstExpr() const { return true; } void dump(int level = 0); String evalStr() { return value; } + bool isPolyphonic() const { return false; } }; typedef Ref StringLiteralRef; @@ -97,6 +100,7 @@ void dump(int level = 0); int argsCount() const { return args.size(); } VMExpr* arg(int i) { return (i >= 0 && i < argsCount()) ? &*args.at(i) : NULL; } + bool isPolyphonic() const; }; typedef Ref ArgsRef; @@ -169,6 +173,7 @@ virtual int evalIntElement(uint i); virtual void assignIntElement(uint i, int value); void dump(int level = 0); + bool isPolyphonic() const { return false; } protected: IntArrayVariable(ParserContext* ctx, bool bConst); }; @@ -203,6 +208,7 @@ void assign(Expression* expr); String evalStr(); void dump(int level = 0); + bool isPolyphonic() const { return false; } protected: StringVariable(ParserContext* ctx, bool bConst); }; @@ -226,6 +232,7 @@ public: BinaryOp(ExpressionRef lhs, ExpressionRef rhs) : lhs(lhs), rhs(rhs) { } bool isConstExpr() const { return lhs->isConstExpr() && rhs->isConstExpr(); } + bool isPolyphonic() const { return lhs->isPolyphonic() || rhs->isPolyphonic(); } }; typedef Ref BinaryOpRef; @@ -282,6 +289,7 @@ NoOperation() : Statement() {} StmtType_t statementType() const { return STMT_LEAF; } void dump(int level = 0) {} + bool isPolyphonic() const { return false; } }; typedef Ref NoOperationRef; @@ -301,6 +309,7 @@ void dump(int level = 0); StmtType_t statementType() const { return STMT_LIST; } virtual Statement* statement(uint i); + bool isPolyphonic() const; }; typedef Ref StatementsRef; @@ -325,6 +334,7 @@ bool isConstExpr() const { return false; } ExprType_t exprType() const; String evalCastToStr(); + bool isPolyphonic() const { return args->isPolyphonic(); } protected: VMFnResult* execVMFn(); }; @@ -332,11 +342,13 @@ class EventHandler : virtual public Statements, virtual public VMEventHandler { StatementsRef statements; + bool usingPolyphonics; public: void dump(int level = 0); StmtFlags_t exec(); - EventHandler(StatementsRef statements) { this->statements = statements; } + EventHandler(StatementsRef statements); Statement* statement(uint i) { return statements->statement(i); } + bool isPolyphonic() const { return usingPolyphonics; } }; typedef Ref EventHandlerRef; @@ -379,6 +391,7 @@ EventHandler* eventHandlerByName(const String& name) const; EventHandler* eventHandler(uint index) const; inline uint size() const { return args.size(); } + bool isPolyphonic() const; }; typedef Ref EventHandlersRef; @@ -390,6 +403,7 @@ Assignment(VariableRef variable, ExpressionRef value); void dump(int level = 0); StmtFlags_t exec(); + bool isPolyphonic() const { return variable->isPolyphonic() || value->isPolyphonic(); } }; typedef Ref AssignmentRef; @@ -405,6 +419,7 @@ void dump(int level = 0); int evalBranch(); Statements* branch(uint i) const; + bool isPolyphonic() const; }; typedef Ref IfRef; @@ -428,6 +443,7 @@ //void addBranch(IntExprRef from, IntExprRef to, StatementsRef statements); //void addBranch(CaseBranchRef branch); //void addBranches(CaseBranchesRef branches); + bool isPolyphonic() const; }; typedef Ref SelectCaseRef; @@ -441,6 +457,7 @@ void dump(int level = 0); bool evalLoopStartCondition(); Statements* statements() const; + bool isPolyphonic() const { return m_condition->isPolyphonic() || m_statements->isPolyphonic(); } }; class Neg : public IntExpr { @@ -450,6 +467,7 @@ int evalInt() { return (expr) ? -expr->evalInt() : 0; } void dump(int level = 0); bool isConstExpr() const { return expr->isConstExpr(); } + bool isPolyphonic() const { return expr->isPolyphonic(); } }; typedef Ref NegRef; @@ -461,6 +479,7 @@ String evalStr(); void dump(int level = 0); bool isConstExpr() const; + bool isPolyphonic() const { return lhs->isPolyphonic() || rhs->isPolyphonic(); } }; typedef Ref ConcatStringRef; @@ -479,6 +498,7 @@ int evalInt(); void dump(int level = 0); bool isConstExpr() const; + bool isPolyphonic() const { return lhs->isPolyphonic() || rhs->isPolyphonic(); } private: IntExprRef lhs; IntExprRef rhs; @@ -509,6 +529,7 @@ int evalInt() { return !expr->evalInt(); } void dump(int level = 0); bool isConstExpr() const { return expr->isConstExpr(); } + bool isPolyphonic() const { return expr->isPolyphonic(); } }; typedef Ref NotRef;