1 |
/* |
/* |
2 |
* Copyright (c) 2014-2015 Christian Schoenebeck |
* Copyright (c) 2014-2016 Christian Schoenebeck |
3 |
* |
* |
4 |
* http://www.linuxsampler.org |
* http://www.linuxsampler.org |
5 |
* |
* |
29 |
StmtFlags_t flags; ///< general completion status (i.e. success or failure) of the function call |
StmtFlags_t flags; ///< general completion status (i.e. success or failure) of the function call |
30 |
|
|
31 |
VMEmptyResult() : flags(STMT_SUCCESS) {} |
VMEmptyResult() : flags(STMT_SUCCESS) {} |
32 |
ExprType_t exprType() const { return EMPTY_EXPR; } |
ExprType_t exprType() const OVERRIDE { return EMPTY_EXPR; } |
33 |
VMExpr* resultValue() { return this; } |
VMExpr* resultValue() OVERRIDE { return this; } |
34 |
StmtFlags_t resultFlags() { return flags; } |
StmtFlags_t resultFlags() OVERRIDE { return flags; } |
35 |
bool isConstExpr() const OVERRIDE { return false; } |
bool isConstExpr() const OVERRIDE { return false; } |
36 |
}; |
}; |
37 |
|
|
45 |
int value; ///< result value of the function call |
int value; ///< result value of the function call |
46 |
|
|
47 |
VMIntResult() : flags(STMT_SUCCESS) {} |
VMIntResult() : flags(STMT_SUCCESS) {} |
48 |
int evalInt() { return value; } |
int evalInt() OVERRIDE { return value; } |
49 |
VMExpr* resultValue() { return this; } |
VMExpr* resultValue() OVERRIDE { return this; } |
50 |
StmtFlags_t resultFlags() { return flags; } |
StmtFlags_t resultFlags() OVERRIDE { return flags; } |
51 |
bool isConstExpr() const OVERRIDE { return false; } |
bool isConstExpr() const OVERRIDE { return false; } |
52 |
}; |
}; |
53 |
|
|
61 |
String value; ///< result value of the function call |
String value; ///< result value of the function call |
62 |
|
|
63 |
VMStringResult() : flags(STMT_SUCCESS) {} |
VMStringResult() : flags(STMT_SUCCESS) {} |
64 |
String evalStr() { return value; } |
String evalStr() OVERRIDE { return value; } |
65 |
VMExpr* resultValue() { return this; } |
VMExpr* resultValue() OVERRIDE { return this; } |
66 |
StmtFlags_t resultFlags() { return flags; } |
StmtFlags_t resultFlags() OVERRIDE { return flags; } |
67 |
bool isConstExpr() const OVERRIDE { return false; } |
bool isConstExpr() const OVERRIDE { return false; } |
68 |
}; |
}; |
69 |
|
|
73 |
*/ |
*/ |
74 |
class VMEmptyResultFunction : public VMFunction { |
class VMEmptyResultFunction : public VMFunction { |
75 |
protected: |
protected: |
76 |
ExprType_t returnType() { return EMPTY_EXPR; } |
virtual ~VMEmptyResultFunction() {} |
77 |
|
ExprType_t returnType() OVERRIDE { return EMPTY_EXPR; } |
78 |
VMFnResult* errorResult(); |
VMFnResult* errorResult(); |
79 |
VMFnResult* successResult(); |
VMFnResult* successResult(); |
80 |
bool modifiesArg(int iArg) const OVERRIDE { return false; } |
bool modifiesArg(int iArg) const OVERRIDE { return false; } |
88 |
*/ |
*/ |
89 |
class VMIntResultFunction : public VMFunction { |
class VMIntResultFunction : public VMFunction { |
90 |
protected: |
protected: |
91 |
ExprType_t returnType() { return INT_EXPR; } |
virtual ~VMIntResultFunction() {} |
92 |
|
ExprType_t returnType() OVERRIDE { return INT_EXPR; } |
93 |
VMFnResult* errorResult(int i = 0); |
VMFnResult* errorResult(int i = 0); |
94 |
VMFnResult* successResult(int i = 0); |
VMFnResult* successResult(int i = 0); |
95 |
bool modifiesArg(int iArg) const OVERRIDE { return false; } |
bool modifiesArg(int iArg) const OVERRIDE { return false; } |
103 |
*/ |
*/ |
104 |
class VMStringResultFunction : public VMFunction { |
class VMStringResultFunction : public VMFunction { |
105 |
protected: |
protected: |
106 |
ExprType_t returnType() { return STRING_EXPR; } |
virtual ~VMStringResultFunction() {} |
107 |
|
ExprType_t returnType() OVERRIDE { return STRING_EXPR; } |
108 |
VMFnResult* errorResult(const String& s = ""); |
VMFnResult* errorResult(const String& s = ""); |
109 |
VMFnResult* successResult(const String& s = ""); |
VMFnResult* successResult(const String& s = ""); |
110 |
bool modifiesArg(int iArg) const OVERRIDE { return false; } |
bool modifiesArg(int iArg) const OVERRIDE { return false; } |
218 |
}; |
}; |
219 |
|
|
220 |
/** |
/** |
221 |
|
* Implements the built-in in_range() script function. |
222 |
|
*/ |
223 |
|
class CoreVMFunction_in_range : public VMIntResultFunction { |
224 |
|
public: |
225 |
|
int minRequiredArgs() const { return 3; } |
226 |
|
int maxAllowedArgs() const { return 3; } |
227 |
|
bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR; } |
228 |
|
ExprType_t argType(int iArg) const { return INT_EXPR; } |
229 |
|
VMFnResult* exec(VMFnArgs* args); |
230 |
|
}; |
231 |
|
|
232 |
|
/** |
233 |
* Implements the built-in sh_left() script function. |
* Implements the built-in sh_left() script function. |
234 |
*/ |
*/ |
235 |
class CoreVMFunction_sh_left : public VMIntResultFunction { |
class CoreVMFunction_sh_left : public VMIntResultFunction { |
248 |
public: |
public: |
249 |
int minRequiredArgs() const { return 2; } |
int minRequiredArgs() const { return 2; } |
250 |
int maxAllowedArgs() const { return 2; } |
int maxAllowedArgs() const { return 2; } |
251 |
|
bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR; } |
252 |
|
ExprType_t argType(int iArg) const { return INT_EXPR; } |
253 |
|
VMFnResult* exec(VMFnArgs* args); |
254 |
|
}; |
255 |
|
|
256 |
|
/** |
257 |
|
* Implements the built-in min() script function. |
258 |
|
*/ |
259 |
|
class CoreVMFunction_min : public VMIntResultFunction { |
260 |
|
public: |
261 |
|
int minRequiredArgs() const { return 2; } |
262 |
|
int maxAllowedArgs() const { return 2; } |
263 |
|
bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR; } |
264 |
|
ExprType_t argType(int iArg) const { return INT_EXPR; } |
265 |
|
VMFnResult* exec(VMFnArgs* args); |
266 |
|
}; |
267 |
|
|
268 |
|
/** |
269 |
|
* Implements the built-in max() script function. |
270 |
|
*/ |
271 |
|
class CoreVMFunction_max : public VMIntResultFunction { |
272 |
|
public: |
273 |
|
int minRequiredArgs() const { return 2; } |
274 |
|
int maxAllowedArgs() const { return 2; } |
275 |
bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR; } |
bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR; } |
276 |
ExprType_t argType(int iArg) const { return INT_EXPR; } |
ExprType_t argType(int iArg) const { return INT_EXPR; } |
277 |
VMFnResult* exec(VMFnArgs* args); |
VMFnResult* exec(VMFnArgs* args); |