1 |
/* -*- c++ -*- |
/* -*- c++ -*- |
2 |
* |
* |
3 |
* Copyright (c) 2014 - 2017 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 |
* |
* |
37 |
STMT_BRANCH, |
STMT_BRANCH, |
38 |
STMT_LOOP, |
STMT_LOOP, |
39 |
STMT_SYNC, |
STMT_SYNC, |
40 |
|
STMT_NOOP, |
41 |
}; |
}; |
42 |
|
|
43 |
class Node { |
class Node { |
82 |
typedef Ref<StringExpr,Node> StringExprRef; |
typedef Ref<StringExpr,Node> StringExprRef; |
83 |
|
|
84 |
class IntLiteral : virtual public IntExpr { |
class IntLiteral : virtual public IntExpr { |
|
int value; |
|
85 |
public: |
public: |
86 |
|
int value; |
87 |
IntLiteral(int value) : value(value) { } |
IntLiteral(int value) : value(value) { } |
88 |
int evalInt(); |
int evalInt(); |
89 |
void dump(int level = 0); |
void dump(int level = 0); |
197 |
VMInt8Array* array; |
VMInt8Array* array; |
198 |
public: |
public: |
199 |
BuiltInIntArrayVariable(const String& name, VMInt8Array* array); |
BuiltInIntArrayVariable(const String& name, VMInt8Array* array); |
200 |
int arraySize() const { return array->size; } |
int arraySize() const OVERRIDE { return array->size; } |
201 |
int evalIntElement(uint i); |
int evalIntElement(uint i) OVERRIDE; |
202 |
bool isAssignable() const OVERRIDE { return !array->readonly; } |
bool isAssignable() const OVERRIDE { return !array->readonly; } |
203 |
void assignIntElement(uint i, int value); |
void assignIntElement(uint i, int value) OVERRIDE; |
204 |
void dump(int level = 0); |
void dump(int level = 0) OVERRIDE; |
205 |
}; |
}; |
206 |
typedef Ref<BuiltInIntArrayVariable,Node> BuiltInIntArrayVariableRef; |
typedef Ref<BuiltInIntArrayVariable,Node> BuiltInIntArrayVariableRef; |
207 |
|
|
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 |
}; |
}; |
350 |
String evalCastToStr() OVERRIDE; |
String evalCastToStr() OVERRIDE; |
351 |
int arraySize() const OVERRIDE { return dynVar->asIntArray()->arraySize(); } |
int arraySize() const OVERRIDE { return dynVar->asIntArray()->arraySize(); } |
352 |
int evalIntElement(uint i) OVERRIDE { return dynVar->asIntArray()->evalIntElement(i); } |
int evalIntElement(uint i) OVERRIDE { return dynVar->asIntArray()->evalIntElement(i); } |
353 |
void assignIntElement(uint i, int value) { return dynVar->asIntArray()->assignIntElement(i, value); } |
void assignIntElement(uint i, int value) OVERRIDE { 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; |
709 |
int stackFrame; |
int stackFrame; |
710 |
int suspendMicroseconds; |
int suspendMicroseconds; |
711 |
size_t instructionsCount; |
size_t instructionsCount; |
712 |
|
struct ExitRes { |
713 |
|
Expression* value; |
714 |
|
IntLiteral intLiteral; |
715 |
|
StringLiteral stringLiteral; |
716 |
|
|
717 |
ExecContext() : |
ExitRes() : intLiteral(0), stringLiteral("") { } |
718 |
status(VM_EXEC_NOT_RUNNING), flags(STMT_SUCCESS), stackFrame(-1), |
} exitRes; |
|
suspendMicroseconds(0), instructionsCount(0) {} |
|
719 |
|
|
720 |
|
ExecContext(); |
721 |
virtual ~ExecContext() {} |
virtual ~ExecContext() {} |
722 |
|
|
723 |
inline void pushStack(Statement* stmt) { |
inline void pushStack(Statement* stmt) { |
742 |
flags = STMT_SUCCESS; |
flags = STMT_SUCCESS; |
743 |
} |
} |
744 |
|
|
745 |
|
inline void clearExitRes() { |
746 |
|
exitRes.value = NULL; |
747 |
|
} |
748 |
|
|
749 |
int suspensionTimeMicroseconds() const OVERRIDE { |
int suspensionTimeMicroseconds() const OVERRIDE { |
750 |
return suspendMicroseconds; |
return suspendMicroseconds; |
751 |
} |
} |
764 |
} |
} |
765 |
|
|
766 |
void forkTo(VMExecContext* ectx) const OVERRIDE; |
void forkTo(VMExecContext* ectx) const OVERRIDE; |
767 |
|
|
768 |
|
VMExpr* exitResult() OVERRIDE { |
769 |
|
return exitRes.value; |
770 |
|
} |
771 |
}; |
}; |
772 |
|
|
773 |
} // namespace LinuxSampler |
} // namespace LinuxSampler |