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 { |
66 |
}; |
}; |
67 |
typedef Ref<IntExpr,Node> IntExprRef; |
typedef Ref<IntExpr,Node> IntExprRef; |
68 |
|
|
69 |
/*class IntArrayExpr : virtual public VMIntArrayExpr, virtual public Expression { |
class IntArrayExpr : virtual public VMIntArrayExpr, virtual public Expression { |
70 |
public: |
public: |
71 |
ExprType_t exprType() const { return INT_ARR_EXPR; } |
ExprType_t exprType() const { return INT_ARR_EXPR; } |
72 |
String evalCastToStr(); |
String evalCastToStr(); |
73 |
}; |
}; |
74 |
typedef Ref<IntArrayExpr,Node> IntArrayExprRef;*/ |
typedef Ref<IntArrayExpr,Node> IntArrayExprRef; |
75 |
|
|
76 |
class StringExpr : virtual public VMStringExpr, virtual public Expression { |
class StringExpr : virtual public VMStringExpr, virtual public Expression { |
77 |
public: |
public: |
174 |
}; |
}; |
175 |
typedef Ref<PolyphonicIntVariable,Node> PolyphonicIntVariableRef; |
typedef Ref<PolyphonicIntVariable,Node> PolyphonicIntVariableRef; |
176 |
|
|
177 |
class IntArrayVariable : public Variable, virtual public VMIntArrayExpr { |
class IntArrayVariable : public Variable, virtual public IntArrayExpr { |
178 |
ArrayList<int> values; |
ArrayList<int> values; |
179 |
public: |
public: |
180 |
IntArrayVariable(ParserContext* ctx, int size); |
IntArrayVariable(ParserContext* ctx, int size); |
181 |
IntArrayVariable(ParserContext* ctx, int size, ArgsRef values); |
IntArrayVariable(ParserContext* ctx, int size, ArgsRef values, bool _bConst = false); |
182 |
void assign(Expression* expr) {} // ignore scalar assignment |
void assign(Expression* expr) {} // ignore scalar assignment |
183 |
String evalCastToStr() { return ""; } // ignore scalar cast to string |
String evalCastToStr() { return ""; } // ignore scalar cast to string |
184 |
ExprType_t exprType() const { return INT_ARR_EXPR; } |
ExprType_t exprType() const { return INT_ARR_EXPR; } |
199 |
BuiltInIntArrayVariable(const String& name, VMInt8Array* array); |
BuiltInIntArrayVariable(const String& name, VMInt8Array* array); |
200 |
int arraySize() const { return array->size; } |
int arraySize() const { return array->size; } |
201 |
int evalIntElement(uint i); |
int evalIntElement(uint i); |
202 |
|
bool isAssignable() const OVERRIDE { return !array->readonly; } |
203 |
void assignIntElement(uint i, int value); |
void assignIntElement(uint i, int value); |
204 |
void dump(int level = 0); |
void dump(int level = 0); |
205 |
}; |
}; |
206 |
typedef Ref<BuiltInIntArrayVariable,Node> BuiltInIntArrayVariableRef; |
typedef Ref<BuiltInIntArrayVariable,Node> BuiltInIntArrayVariableRef; |
207 |
|
|
208 |
class IntArrayElement : public IntVariable { |
class IntArrayElement : public IntVariable { |
209 |
IntArrayVariableRef array; |
IntArrayExprRef array; |
210 |
IntExprRef index; |
IntExprRef index; |
211 |
public: |
public: |
212 |
IntArrayElement(IntArrayVariableRef array, IntExprRef arrayIndex); |
IntArrayElement(IntArrayExprRef array, IntExprRef arrayIndex); |
213 |
void assign(Expression* expr); |
void assign(Expression* expr); |
214 |
int evalInt(); |
int evalInt(); |
215 |
void dump(int level = 0); |
void dump(int level = 0); |
301 |
class NoOperation : public Statement { |
class NoOperation : public Statement { |
302 |
public: |
public: |
303 |
NoOperation() : Statement() {} |
NoOperation() : Statement() {} |
304 |
StmtType_t statementType() const { return STMT_LEAF; } |
StmtType_t statementType() const { return STMT_NOOP; } |
305 |
void dump(int level = 0) {} |
void dump(int level = 0) {} |
306 |
bool isPolyphonic() const { return false; } |
bool isPolyphonic() const { return false; } |
307 |
}; |
}; |
334 |
virtual Statements* branch(uint i) const = 0; |
virtual Statements* branch(uint i) const = 0; |
335 |
}; |
}; |
336 |
|
|
337 |
class DynamicVariableCall : public Variable, virtual public IntExpr, virtual public StringExpr { |
class DynamicVariableCall : public Variable, virtual public IntExpr, virtual public StringExpr, virtual public IntArrayExpr { |
338 |
VMDynVar* dynVar; |
VMDynVar* dynVar; |
339 |
String varName; |
String varName; |
340 |
public: |
public: |
348 |
int evalInt() OVERRIDE; |
int evalInt() OVERRIDE; |
349 |
String evalStr() OVERRIDE; |
String evalStr() OVERRIDE; |
350 |
String evalCastToStr() OVERRIDE; |
String evalCastToStr() OVERRIDE; |
351 |
|
int arraySize() const OVERRIDE { return dynVar->asIntArray()->arraySize(); } |
352 |
|
int evalIntElement(uint i) OVERRIDE { return dynVar->asIntArray()->evalIntElement(i); } |
353 |
|
void assignIntElement(uint i, int value) { return dynVar->asIntArray()->assignIntElement(i, value); } |
354 |
void dump(int level = 0) OVERRIDE; |
void dump(int level = 0) OVERRIDE; |
355 |
}; |
}; |
356 |
typedef Ref<DynamicVariableCall,Node> DynamicVariableCallRef; |
typedef Ref<DynamicVariableCall,Node> DynamicVariableCallRef; |
376 |
}; |
}; |
377 |
typedef Ref<FunctionCall,Node> FunctionCallRef; |
typedef Ref<FunctionCall,Node> FunctionCallRef; |
378 |
|
|
379 |
|
class NoFunctionCall : public FunctionCall { |
380 |
|
public: |
381 |
|
NoFunctionCall() : FunctionCall("nothing", new Args, NULL) {} |
382 |
|
StmtType_t statementType() const { return STMT_NOOP; } |
383 |
|
}; |
384 |
|
typedef Ref<NoFunctionCall,Node> NoFunctionCallRef; |
385 |
|
|
386 |
class EventHandler : virtual public Statements, virtual public VMEventHandler { |
class EventHandler : virtual public Statements, virtual public VMEventHandler { |
387 |
StatementsRef statements; |
StatementsRef statements; |
388 |
bool usingPolyphonics; |
bool usingPolyphonics; |
507 |
bool isPolyphonic() const { return m_condition->isPolyphonic() || m_statements->isPolyphonic(); } |
bool isPolyphonic() const { return m_condition->isPolyphonic() || m_statements->isPolyphonic(); } |
508 |
}; |
}; |
509 |
|
|
510 |
|
class SyncBlock : public Statement { |
511 |
|
StatementsRef m_statements; |
512 |
|
public: |
513 |
|
SyncBlock(StatementsRef statements) : m_statements(statements) {} |
514 |
|
StmtType_t statementType() const { return STMT_SYNC; } |
515 |
|
void dump(int level = 0); |
516 |
|
Statements* statements() const; |
517 |
|
bool isPolyphonic() const { return m_statements->isPolyphonic(); } |
518 |
|
}; |
519 |
|
typedef Ref<SyncBlock,Node> SyncBlockRef; |
520 |
|
|
521 |
class Neg : public IntExpr { |
class Neg : public IntExpr { |
522 |
IntExprRef expr; |
IntExprRef expr; |
523 |
public: |
public: |
631 |
std::vector<ParserIssue> vErrors; |
std::vector<ParserIssue> vErrors; |
632 |
std::vector<ParserIssue> vWarnings; |
std::vector<ParserIssue> vWarnings; |
633 |
std::vector<ParserIssue> vIssues; |
std::vector<ParserIssue> vIssues; |
634 |
|
std::vector<CodeBlock> vPreprocessorComments; |
635 |
|
|
636 |
std::set<String> builtinPreprocessorConditions; |
std::set<String> builtinPreprocessorConditions; |
637 |
std::set<String> userPreprocessorConditions; |
std::set<String> userPreprocessorConditions; |
672 |
StatementsRef userFunctionByName(const String& name); |
StatementsRef userFunctionByName(const String& name); |
673 |
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); |
674 |
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); |
675 |
|
void addPreprocessorComment(int firstLine, int lastLine, int firstColumn, int lastColumn); |
676 |
void createScanner(std::istream* is); |
void createScanner(std::istream* is); |
677 |
void destroyScanner(); |
void destroyScanner(); |
678 |
bool setPreprocessorCondition(const char* name); |
bool setPreprocessorCondition(const char* name); |
681 |
std::vector<ParserIssue> issues() const OVERRIDE; |
std::vector<ParserIssue> issues() const OVERRIDE; |
682 |
std::vector<ParserIssue> errors() const OVERRIDE; |
std::vector<ParserIssue> errors() const OVERRIDE; |
683 |
std::vector<ParserIssue> warnings() const OVERRIDE; |
std::vector<ParserIssue> warnings() const OVERRIDE; |
684 |
|
std::vector<CodeBlock> preprocessorComments() const OVERRIDE; |
685 |
VMEventHandler* eventHandler(uint index) OVERRIDE; |
VMEventHandler* eventHandler(uint index) OVERRIDE; |
686 |
VMEventHandler* eventHandlerByName(const String& name) OVERRIDE; |
VMEventHandler* eventHandlerByName(const String& name) OVERRIDE; |
687 |
void registerBuiltInConstIntVariables(const std::map<String,int>& vars); |
void registerBuiltInConstIntVariables(const std::map<String,int>& vars); |
704 |
|
|
705 |
ArrayList<int> polyphonicIntMemory; |
ArrayList<int> polyphonicIntMemory; |
706 |
VMExecStatus_t status; |
VMExecStatus_t status; |
707 |
|
StmtFlags_t flags; |
708 |
ArrayList<StackFrame> stack; |
ArrayList<StackFrame> stack; |
709 |
int stackFrame; |
int stackFrame; |
710 |
int suspendMicroseconds; |
int suspendMicroseconds; |
711 |
size_t instructionsCount; |
size_t instructionsCount; |
712 |
|
|
713 |
ExecContext() : |
ExecContext() : |
714 |
status(VM_EXEC_NOT_RUNNING), stackFrame(-1), suspendMicroseconds(0), |
status(VM_EXEC_NOT_RUNNING), flags(STMT_SUCCESS), stackFrame(-1), |
715 |
instructionsCount(0) {} |
suspendMicroseconds(0), instructionsCount(0) {} |
716 |
|
|
717 |
virtual ~ExecContext() {} |
virtual ~ExecContext() {} |
718 |
|
|
735 |
stack[0].statement = NULL; |
stack[0].statement = NULL; |
736 |
stack[0].subindex = -1; |
stack[0].subindex = -1; |
737 |
stackFrame = -1; |
stackFrame = -1; |
738 |
|
flags = STMT_SUCCESS; |
739 |
} |
} |
740 |
|
|
741 |
int suspensionTimeMicroseconds() const OVERRIDE { |
int suspensionTimeMicroseconds() const OVERRIDE { |
750 |
size_t instructionsPerformed() const OVERRIDE { |
size_t instructionsPerformed() const OVERRIDE { |
751 |
return instructionsCount; |
return instructionsCount; |
752 |
} |
} |
753 |
|
|
754 |
|
void signalAbort() OVERRIDE { |
755 |
|
flags = StmtFlags_t(flags | STMT_ABORT_SIGNALLED); |
756 |
|
} |
757 |
|
|
758 |
|
void forkTo(VMExecContext* ectx) const OVERRIDE; |
759 |
}; |
}; |
760 |
|
|
761 |
} // namespace LinuxSampler |
} // namespace LinuxSampler |