1 |
schoenebeck |
2581 |
/* |
2 |
schoenebeck |
3744 |
* Copyright (c) 2014-2020 Christian Schoenebeck |
3 |
schoenebeck |
2581 |
* |
4 |
|
|
* http://www.linuxsampler.org |
5 |
|
|
* |
6 |
|
|
* This file is part of LinuxSampler and released under the same terms. |
7 |
|
|
* See README file for details. |
8 |
|
|
*/ |
9 |
|
|
|
10 |
|
|
#ifndef LS_COREVMFUNCTIONS_H |
11 |
|
|
#define LS_COREVMFUNCTIONS_H |
12 |
|
|
|
13 |
|
|
#include "../common/global.h" |
14 |
|
|
#include "common.h" |
15 |
|
|
|
16 |
|
|
namespace LinuxSampler { |
17 |
|
|
|
18 |
|
|
class ScriptVM; |
19 |
schoenebeck |
2727 |
|
20 |
|
|
/////////////////////////////////////////////////////////////////////////// |
21 |
|
|
// convenience base classes for built-in script functions ... |
22 |
|
|
|
23 |
|
|
/** |
24 |
|
|
* An instance of this class is returned by built-in function implementations |
25 |
|
|
* which do not return a function return value. |
26 |
|
|
*/ |
27 |
schoenebeck |
3581 |
class VMEmptyResult FINAL : public VMFnResult, public VMExpr { |
28 |
schoenebeck |
2581 |
public: |
29 |
schoenebeck |
2727 |
StmtFlags_t flags; ///< general completion status (i.e. success or failure) of the function call |
30 |
schoenebeck |
2581 |
|
31 |
|
|
VMEmptyResult() : flags(STMT_SUCCESS) {} |
32 |
schoenebeck |
3054 |
ExprType_t exprType() const OVERRIDE { return EMPTY_EXPR; } |
33 |
|
|
VMExpr* resultValue() OVERRIDE { return this; } |
34 |
|
|
StmtFlags_t resultFlags() OVERRIDE { return flags; } |
35 |
schoenebeck |
2945 |
bool isConstExpr() const OVERRIDE { return false; } |
36 |
schoenebeck |
2581 |
}; |
37 |
|
|
|
38 |
schoenebeck |
2727 |
/** |
39 |
|
|
* An instance of this class is returned by built-in function implementations |
40 |
|
|
* which return an integer value as function return value. |
41 |
|
|
*/ |
42 |
schoenebeck |
3581 |
class VMIntResult FINAL : public VMFnResult, public VMIntExpr { |
43 |
schoenebeck |
2598 |
public: |
44 |
schoenebeck |
2727 |
StmtFlags_t flags; ///< general completion status (i.e. success or failure) of the function call |
45 |
schoenebeck |
3557 |
vmint value; ///< result value of the function call |
46 |
schoenebeck |
3581 |
vmfloat unitPrefixFactor; ///< unit factor of result value of the function call |
47 |
schoenebeck |
3744 |
StdUnit_t unitBaseType; ///< fundamental standard measuring unit type (e.g. seconds), this is ALWAYS and ONLY set (to the actual unit type) by @c FunctionCall class for performance reasons. |
48 |
schoenebeck |
2598 |
|
49 |
schoenebeck |
3744 |
VMIntResult(); |
50 |
schoenebeck |
3557 |
vmint evalInt() OVERRIDE { return value; } |
51 |
schoenebeck |
3054 |
VMExpr* resultValue() OVERRIDE { return this; } |
52 |
|
|
StmtFlags_t resultFlags() OVERRIDE { return flags; } |
53 |
schoenebeck |
2945 |
bool isConstExpr() const OVERRIDE { return false; } |
54 |
schoenebeck |
3581 |
vmfloat unitFactor() const OVERRIDE { return unitPrefixFactor; } |
55 |
schoenebeck |
3744 |
StdUnit_t unitType() const OVERRIDE { return unitBaseType; } |
56 |
schoenebeck |
3581 |
bool isFinal() const OVERRIDE { return false; } // actually never called, VMFunction::returnsFinal() is always used instead |
57 |
schoenebeck |
2598 |
}; |
58 |
|
|
|
59 |
schoenebeck |
2727 |
/** |
60 |
|
|
* An instance of this class is returned by built-in function implementations |
61 |
schoenebeck |
3573 |
* which return a real number (floating point) value as function return value. |
62 |
|
|
*/ |
63 |
schoenebeck |
3581 |
class VMRealResult FINAL : public VMFnResult, public VMRealExpr { |
64 |
schoenebeck |
3573 |
public: |
65 |
|
|
StmtFlags_t flags; ///< general completion status (i.e. success or failure) of the function call |
66 |
|
|
vmfloat value; ///< result value of the function call |
67 |
schoenebeck |
3581 |
vmfloat unitPrefixFactor; ///< unit factor of result value of the function call |
68 |
schoenebeck |
3744 |
StdUnit_t unitBaseType; ///< fundamental standard measuring unit type (e.g. seconds), this is ALWAYS and ONLY set (to the actual unit type) by @c FunctionCall class for performance reasons. |
69 |
schoenebeck |
3573 |
|
70 |
schoenebeck |
3744 |
VMRealResult(); |
71 |
schoenebeck |
3573 |
vmfloat evalReal() OVERRIDE { return value; } |
72 |
|
|
VMExpr* resultValue() OVERRIDE { return this; } |
73 |
|
|
StmtFlags_t resultFlags() OVERRIDE { return flags; } |
74 |
|
|
bool isConstExpr() const OVERRIDE { return false; } |
75 |
schoenebeck |
3581 |
vmfloat unitFactor() const OVERRIDE { return unitPrefixFactor; } |
76 |
schoenebeck |
3744 |
StdUnit_t unitType() const OVERRIDE { return unitBaseType; } |
77 |
schoenebeck |
3581 |
bool isFinal() const OVERRIDE { return false; } // actually never called, VMFunction::returnsFinal() is always used instead |
78 |
schoenebeck |
3573 |
}; |
79 |
|
|
|
80 |
|
|
/** |
81 |
|
|
* An instance of this class is returned by built-in function implementations |
82 |
schoenebeck |
2727 |
* which return a string value as function return value. |
83 |
|
|
*/ |
84 |
schoenebeck |
3581 |
class VMStringResult FINAL : public VMFnResult, public VMStringExpr { |
85 |
schoenebeck |
2581 |
public: |
86 |
schoenebeck |
2727 |
StmtFlags_t flags; ///< general completion status (i.e. success or failure) of the function call |
87 |
|
|
String value; ///< result value of the function call |
88 |
schoenebeck |
2581 |
|
89 |
|
|
VMStringResult() : flags(STMT_SUCCESS) {} |
90 |
schoenebeck |
3054 |
String evalStr() OVERRIDE { return value; } |
91 |
|
|
VMExpr* resultValue() OVERRIDE { return this; } |
92 |
|
|
StmtFlags_t resultFlags() OVERRIDE { return flags; } |
93 |
schoenebeck |
2945 |
bool isConstExpr() const OVERRIDE { return false; } |
94 |
schoenebeck |
2581 |
}; |
95 |
|
|
|
96 |
schoenebeck |
2727 |
/** |
97 |
|
|
* Abstract base class for built-in script functions which do not return any |
98 |
|
|
* function return value (void). |
99 |
|
|
*/ |
100 |
schoenebeck |
2581 |
class VMEmptyResultFunction : public VMFunction { |
101 |
|
|
protected: |
102 |
schoenebeck |
3747 |
VMEmptyResultFunction() : result(NULL) {} |
103 |
schoenebeck |
3034 |
virtual ~VMEmptyResultFunction() {} |
104 |
schoenebeck |
3577 |
ExprType_t returnType(VMFnArgs* args) OVERRIDE { return EMPTY_EXPR; } |
105 |
schoenebeck |
3581 |
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; } |
106 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE { return false; } |
107 |
schoenebeck |
2581 |
VMFnResult* errorResult(); |
108 |
|
|
VMFnResult* successResult(); |
109 |
schoenebeck |
3557 |
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
110 |
schoenebeck |
3747 |
VMFnResult* allocResult(VMFnArgs* args) OVERRIDE { return new VMEmptyResult(); } |
111 |
|
|
void bindResult(VMFnResult* res) OVERRIDE; |
112 |
|
|
VMFnResult* boundResult() const OVERRIDE; |
113 |
schoenebeck |
2581 |
protected: |
114 |
schoenebeck |
3747 |
VMEmptyResult* result; |
115 |
schoenebeck |
2581 |
}; |
116 |
|
|
|
117 |
schoenebeck |
3581 |
struct VMIntFnResDef { |
118 |
|
|
vmint value = 0; //NOTE: sequence matters! Since this is usually initialized with VMIntExpr::evalInt() it should be before member unitFactor, since the latter is usually initialized with VMIntExpr::unitFactor() which does not evaluate the expression. |
119 |
|
|
vmfloat unitFactor = VM_NO_FACTOR; |
120 |
|
|
}; |
121 |
|
|
|
122 |
|
|
struct VMRealFnResDef { |
123 |
|
|
vmfloat value = vmfloat(0); //NOTE: sequence matters! Since this is usually initialized with VMRealExpr::evalReal() it should be before member unitFactor, since the latter is usually initialized with VMRealExpr::unitFactor() which does not evaluate the expression. |
124 |
|
|
vmfloat unitFactor = VM_NO_FACTOR; |
125 |
|
|
}; |
126 |
|
|
|
127 |
schoenebeck |
2727 |
/** |
128 |
|
|
* Abstract base class for built-in script functions which return an integer |
129 |
|
|
* (scalar) as their function return value. |
130 |
|
|
*/ |
131 |
schoenebeck |
2598 |
class VMIntResultFunction : public VMFunction { |
132 |
|
|
protected: |
133 |
schoenebeck |
3747 |
VMIntResultFunction() : result(NULL) {} |
134 |
schoenebeck |
3034 |
virtual ~VMIntResultFunction() {} |
135 |
schoenebeck |
3577 |
ExprType_t returnType(VMFnArgs* args) OVERRIDE { return INT_EXPR; } |
136 |
schoenebeck |
3557 |
VMFnResult* errorResult(vmint i = 0); |
137 |
schoenebeck |
3581 |
VMFnResult* errorResult(VMIntFnResDef res); |
138 |
schoenebeck |
3557 |
VMFnResult* successResult(vmint i = 0); |
139 |
schoenebeck |
3581 |
VMFnResult* successResult(VMIntFnResDef res); |
140 |
schoenebeck |
3557 |
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
141 |
schoenebeck |
3747 |
VMFnResult* allocResult(VMFnArgs* args) OVERRIDE { return new VMIntResult(); } |
142 |
|
|
void bindResult(VMFnResult* res) OVERRIDE; |
143 |
|
|
VMFnResult* boundResult() const OVERRIDE; |
144 |
schoenebeck |
2598 |
protected: |
145 |
schoenebeck |
3747 |
VMIntResult* result; |
146 |
schoenebeck |
2598 |
}; |
147 |
|
|
|
148 |
schoenebeck |
2727 |
/** |
149 |
schoenebeck |
3573 |
* Abstract base class for built-in script functions which return a real number |
150 |
|
|
* (floating point scalar) as their function return value. |
151 |
|
|
*/ |
152 |
|
|
class VMRealResultFunction : public VMFunction { |
153 |
|
|
protected: |
154 |
schoenebeck |
3747 |
VMRealResultFunction() : result(NULL) {} |
155 |
schoenebeck |
3573 |
virtual ~VMRealResultFunction() {} |
156 |
schoenebeck |
3577 |
ExprType_t returnType(VMFnArgs* args) OVERRIDE { return REAL_EXPR; } |
157 |
schoenebeck |
3573 |
VMFnResult* errorResult(vmfloat f = 0); |
158 |
schoenebeck |
3581 |
VMFnResult* errorResult(VMRealFnResDef res); |
159 |
schoenebeck |
3573 |
VMFnResult* successResult(vmfloat f = 0); |
160 |
schoenebeck |
3581 |
VMFnResult* successResult(VMRealFnResDef res); |
161 |
schoenebeck |
3573 |
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
162 |
schoenebeck |
3747 |
VMFnResult* allocResult(VMFnArgs* args) OVERRIDE { return new VMRealResult(); } |
163 |
|
|
void bindResult(VMFnResult* res) OVERRIDE; |
164 |
|
|
VMFnResult* boundResult() const OVERRIDE; |
165 |
schoenebeck |
3573 |
protected: |
166 |
schoenebeck |
3747 |
VMRealResult* result; |
167 |
schoenebeck |
3573 |
}; |
168 |
|
|
|
169 |
|
|
/** |
170 |
schoenebeck |
2727 |
* Abstract base class for built-in script functions which return a string as |
171 |
|
|
* their function return value. |
172 |
|
|
*/ |
173 |
schoenebeck |
2581 |
class VMStringResultFunction : public VMFunction { |
174 |
|
|
protected: |
175 |
schoenebeck |
3747 |
VMStringResultFunction() : result(NULL) {} |
176 |
schoenebeck |
3034 |
virtual ~VMStringResultFunction() {} |
177 |
schoenebeck |
3577 |
ExprType_t returnType(VMFnArgs* args) OVERRIDE { return STRING_EXPR; } |
178 |
schoenebeck |
2581 |
VMFnResult* errorResult(const String& s = ""); |
179 |
|
|
VMFnResult* successResult(const String& s = ""); |
180 |
schoenebeck |
3557 |
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
181 |
schoenebeck |
3747 |
VMFnResult* allocResult(VMFnArgs* args) OVERRIDE { return new VMStringResult(); } |
182 |
|
|
void bindResult(VMFnResult* res) OVERRIDE; |
183 |
|
|
VMFnResult* boundResult() const OVERRIDE; |
184 |
schoenebeck |
2581 |
protected: |
185 |
schoenebeck |
3747 |
VMStringResult* result; |
186 |
schoenebeck |
2581 |
}; |
187 |
|
|
|
188 |
schoenebeck |
3577 |
/** |
189 |
|
|
* Abstract base class for built-in script functions which either return an |
190 |
|
|
* integer or a real number (floating point scalar) as their function return |
191 |
|
|
* value. The actual return type is determined at parse time once after |
192 |
|
|
* potential arguments were associated with the respective function call. |
193 |
|
|
*/ |
194 |
schoenebeck |
3582 |
class VMNumberResultFunction : public VMFunction { |
195 |
schoenebeck |
3577 |
protected: |
196 |
schoenebeck |
3747 |
VMNumberResultFunction() : intResult(NULL), realResult(NULL) {} |
197 |
schoenebeck |
3582 |
virtual ~VMNumberResultFunction() {} |
198 |
schoenebeck |
3577 |
VMFnResult* errorResult(vmint i); |
199 |
|
|
VMFnResult* errorResult(vmfloat f); |
200 |
|
|
VMFnResult* successResult(vmint i); |
201 |
|
|
VMFnResult* successResult(vmfloat f); |
202 |
schoenebeck |
3581 |
VMFnResult* errorIntResult(VMIntFnResDef res); |
203 |
|
|
VMFnResult* errorRealResult(VMRealFnResDef res); |
204 |
|
|
VMFnResult* successIntResult(VMIntFnResDef res); |
205 |
|
|
VMFnResult* successRealResult(VMRealFnResDef res); |
206 |
schoenebeck |
3577 |
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
207 |
schoenebeck |
3747 |
VMFnResult* allocResult(VMFnArgs* args) OVERRIDE; |
208 |
|
|
void bindResult(VMFnResult* res) OVERRIDE; |
209 |
|
|
VMFnResult* boundResult() const OVERRIDE; |
210 |
schoenebeck |
3577 |
protected: |
211 |
schoenebeck |
3747 |
VMIntResult* intResult; |
212 |
|
|
VMRealResult* realResult; |
213 |
schoenebeck |
3577 |
}; |
214 |
schoenebeck |
2727 |
|
215 |
schoenebeck |
3577 |
|
216 |
schoenebeck |
2727 |
/////////////////////////////////////////////////////////////////////////// |
217 |
|
|
// implementations of core built-in script functions ... |
218 |
|
|
|
219 |
|
|
/** |
220 |
|
|
* Implements the built-in message() script function. |
221 |
|
|
*/ |
222 |
schoenebeck |
3581 |
class CoreVMFunction_message FINAL : public VMEmptyResultFunction { |
223 |
schoenebeck |
2581 |
public: |
224 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
225 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
226 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
227 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
228 |
schoenebeck |
2581 |
}; |
229 |
|
|
|
230 |
schoenebeck |
2727 |
/** |
231 |
|
|
* Implements the built-in exit() script function. |
232 |
|
|
*/ |
233 |
schoenebeck |
3581 |
class CoreVMFunction_exit FINAL : public VMEmptyResultFunction { |
234 |
schoenebeck |
2581 |
public: |
235 |
schoenebeck |
3551 |
CoreVMFunction_exit(ScriptVM* vm) : vm(vm) {} |
236 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 0; } |
237 |
|
|
vmint maxAllowedArgs() const OVERRIDE; |
238 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
239 |
schoenebeck |
3581 |
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE; |
240 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE; |
241 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE; |
242 |
schoenebeck |
3557 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
243 |
schoenebeck |
3551 |
protected: |
244 |
|
|
ScriptVM* vm; |
245 |
schoenebeck |
2581 |
}; |
246 |
|
|
|
247 |
schoenebeck |
2727 |
/** |
248 |
|
|
* Implements the built-in wait() script function. |
249 |
|
|
*/ |
250 |
schoenebeck |
2581 |
class CoreVMFunction_wait : public VMEmptyResultFunction { |
251 |
|
|
public: |
252 |
|
|
CoreVMFunction_wait(ScriptVM* vm) : vm(vm) {} |
253 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
254 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
255 |
schoenebeck |
3584 |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
256 |
schoenebeck |
3561 |
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE; |
257 |
schoenebeck |
3564 |
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE; |
258 |
schoenebeck |
3557 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
259 |
schoenebeck |
2581 |
protected: |
260 |
|
|
ScriptVM* vm; |
261 |
|
|
}; |
262 |
|
|
|
263 |
schoenebeck |
2727 |
/** |
264 |
|
|
* Implements the built-in abs() script function. |
265 |
|
|
*/ |
266 |
schoenebeck |
3582 |
class CoreVMFunction_abs FINAL : public VMNumberResultFunction { |
267 |
schoenebeck |
2619 |
public: |
268 |
schoenebeck |
3577 |
ExprType_t returnType(VMFnArgs* args) OVERRIDE; |
269 |
schoenebeck |
3581 |
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
270 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
271 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
272 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
273 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
274 |
schoenebeck |
3581 |
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
275 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
276 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
277 |
schoenebeck |
3557 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
278 |
schoenebeck |
2619 |
}; |
279 |
|
|
|
280 |
schoenebeck |
2727 |
/** |
281 |
|
|
* Implements the built-in random() script function. |
282 |
|
|
*/ |
283 |
schoenebeck |
3582 |
class CoreVMFunction_random FINAL : public VMNumberResultFunction { |
284 |
|
|
using Super = VMNumberResultFunction; // just an alias for the super class |
285 |
schoenebeck |
2619 |
public: |
286 |
schoenebeck |
3581 |
ExprType_t returnType(VMFnArgs* args) OVERRIDE; |
287 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
288 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
289 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
290 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
291 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
292 |
schoenebeck |
3581 |
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
293 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
294 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
295 |
|
|
void checkArgs(VMFnArgs* args, std::function<void(String)> err, |
296 |
|
|
std::function<void(String)> wrn) OVERRIDE; |
297 |
schoenebeck |
3557 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
298 |
schoenebeck |
2619 |
}; |
299 |
|
|
|
300 |
schoenebeck |
2727 |
/** |
301 |
|
|
* Implements the built-in num_elements() script function. |
302 |
|
|
*/ |
303 |
schoenebeck |
3581 |
class CoreVMFunction_num_elements FINAL : public VMIntResultFunction { |
304 |
schoenebeck |
2619 |
public: |
305 |
schoenebeck |
3581 |
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; } |
306 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE { return false; } |
307 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
308 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
309 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
310 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
311 |
schoenebeck |
2619 |
}; |
312 |
|
|
|
313 |
schoenebeck |
2945 |
/** |
314 |
|
|
* Implements the built-in inc() script function. |
315 |
|
|
*/ |
316 |
schoenebeck |
3581 |
class CoreVMFunction_inc FINAL : public VMIntResultFunction { |
317 |
|
|
using Super = VMIntResultFunction; // just an alias for the super class |
318 |
schoenebeck |
2945 |
public: |
319 |
schoenebeck |
3581 |
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
320 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
321 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
322 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
323 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; } |
324 |
schoenebeck |
3581 |
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
325 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
326 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
327 |
schoenebeck |
3557 |
bool modifiesArg(vmint iArg) const OVERRIDE { return true; } |
328 |
schoenebeck |
3581 |
void checkArgs(VMFnArgs* args, std::function<void(String)> err, |
329 |
|
|
std::function<void(String)> wrn) OVERRIDE; |
330 |
schoenebeck |
3557 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
331 |
schoenebeck |
2945 |
}; |
332 |
|
|
|
333 |
|
|
/** |
334 |
|
|
* Implements the built-in dec() script function. |
335 |
|
|
*/ |
336 |
schoenebeck |
3581 |
class CoreVMFunction_dec FINAL : public VMIntResultFunction { |
337 |
|
|
using Super = VMIntResultFunction; // just an alias for the super class |
338 |
schoenebeck |
2945 |
public: |
339 |
schoenebeck |
3581 |
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
340 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
341 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
342 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
343 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; } |
344 |
schoenebeck |
3581 |
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
345 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
346 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
347 |
schoenebeck |
3557 |
bool modifiesArg(vmint iArg) const OVERRIDE { return true; } |
348 |
schoenebeck |
3581 |
void checkArgs(VMFnArgs* args, std::function<void(String)> err, |
349 |
|
|
std::function<void(String)> wrn) OVERRIDE; |
350 |
schoenebeck |
3557 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
351 |
schoenebeck |
2945 |
}; |
352 |
|
|
|
353 |
schoenebeck |
2965 |
/** |
354 |
schoenebeck |
3076 |
* Implements the built-in in_range() script function. |
355 |
|
|
*/ |
356 |
schoenebeck |
3581 |
class CoreVMFunction_in_range FINAL : public VMIntResultFunction { |
357 |
|
|
using Super = VMIntResultFunction; // just an alias for the super class |
358 |
schoenebeck |
3076 |
public: |
359 |
schoenebeck |
3581 |
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; } |
360 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE { return false; } |
361 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 3; } |
362 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 3; } |
363 |
schoenebeck |
3581 |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
364 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
365 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
366 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
367 |
|
|
void checkArgs(VMFnArgs* args, std::function<void(String)> err, |
368 |
|
|
std::function<void(String)> wrn) OVERRIDE; |
369 |
schoenebeck |
3557 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
370 |
schoenebeck |
3076 |
}; |
371 |
|
|
|
372 |
|
|
/** |
373 |
schoenebeck |
2965 |
* Implements the built-in sh_left() script function. |
374 |
|
|
*/ |
375 |
schoenebeck |
3581 |
class CoreVMFunction_sh_left FINAL : public VMIntResultFunction { |
376 |
schoenebeck |
2965 |
public: |
377 |
schoenebeck |
3581 |
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; } |
378 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
379 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
380 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
381 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; } |
382 |
schoenebeck |
3581 |
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
383 |
schoenebeck |
3557 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
384 |
schoenebeck |
2965 |
}; |
385 |
|
|
|
386 |
|
|
/** |
387 |
|
|
* Implements the built-in sh_right() script function. |
388 |
|
|
*/ |
389 |
schoenebeck |
3581 |
class CoreVMFunction_sh_right FINAL : public VMIntResultFunction { |
390 |
schoenebeck |
2965 |
public: |
391 |
schoenebeck |
3581 |
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; } |
392 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
393 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
394 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
395 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; } |
396 |
schoenebeck |
3581 |
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
397 |
schoenebeck |
3557 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
398 |
schoenebeck |
2965 |
}; |
399 |
|
|
|
400 |
schoenebeck |
2970 |
/** |
401 |
schoenebeck |
3678 |
* Implements the built-in msb() script function. |
402 |
|
|
*/ |
403 |
|
|
class CoreVMFunction_msb FINAL : public VMIntResultFunction { |
404 |
|
|
public: |
405 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; } |
406 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE { return false; } |
407 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
408 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
409 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; } |
410 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return false; } |
411 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
412 |
|
|
}; |
413 |
|
|
|
414 |
|
|
/** |
415 |
|
|
* Implements the built-in lsb() script function. |
416 |
|
|
*/ |
417 |
|
|
class CoreVMFunction_lsb FINAL : public VMIntResultFunction { |
418 |
|
|
public: |
419 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; } |
420 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE { return false; } |
421 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
422 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
423 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; } |
424 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return false; } |
425 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
426 |
|
|
}; |
427 |
|
|
|
428 |
|
|
/** |
429 |
schoenebeck |
2970 |
* Implements the built-in min() script function. |
430 |
|
|
*/ |
431 |
schoenebeck |
3582 |
class CoreVMFunction_min FINAL : public VMNumberResultFunction { |
432 |
|
|
using Super = VMNumberResultFunction; // just an alias for the super class |
433 |
schoenebeck |
2970 |
public: |
434 |
schoenebeck |
3577 |
ExprType_t returnType(VMFnArgs* args) OVERRIDE; |
435 |
schoenebeck |
3581 |
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
436 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
437 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
438 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
439 |
schoenebeck |
3577 |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
440 |
schoenebeck |
3581 |
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
441 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
442 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
443 |
|
|
void checkArgs(VMFnArgs* args, std::function<void(String)> err, |
444 |
|
|
std::function<void(String)> wrn) OVERRIDE; |
445 |
schoenebeck |
3557 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
446 |
schoenebeck |
2970 |
}; |
447 |
|
|
|
448 |
|
|
/** |
449 |
|
|
* Implements the built-in max() script function. |
450 |
|
|
*/ |
451 |
schoenebeck |
3582 |
class CoreVMFunction_max FINAL : public VMNumberResultFunction { |
452 |
|
|
using Super = VMNumberResultFunction; // just an alias for the super class |
453 |
schoenebeck |
2970 |
public: |
454 |
schoenebeck |
3577 |
ExprType_t returnType(VMFnArgs* args) OVERRIDE; |
455 |
schoenebeck |
3581 |
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
456 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
457 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
458 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
459 |
schoenebeck |
3577 |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
460 |
schoenebeck |
3581 |
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
461 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
462 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
463 |
|
|
void checkArgs(VMFnArgs* args, std::function<void(String)> err, |
464 |
|
|
std::function<void(String)> wrn) OVERRIDE; |
465 |
schoenebeck |
3557 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
466 |
schoenebeck |
2970 |
}; |
467 |
|
|
|
468 |
schoenebeck |
3221 |
/** |
469 |
|
|
* Implements the built-in array_equal() script function. |
470 |
|
|
*/ |
471 |
schoenebeck |
3581 |
class CoreVMFunction_array_equal FINAL : public VMIntResultFunction { |
472 |
|
|
using Super = VMIntResultFunction; // just an alias for the super class |
473 |
schoenebeck |
3221 |
public: |
474 |
schoenebeck |
3581 |
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; } |
475 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE { return false; } |
476 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
477 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
478 |
schoenebeck |
3581 |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
479 |
|
|
void checkArgs(VMFnArgs* args, std::function<void(String)> err, |
480 |
|
|
std::function<void(String)> wrn) OVERRIDE; |
481 |
schoenebeck |
3557 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
482 |
schoenebeck |
3221 |
}; |
483 |
|
|
|
484 |
|
|
/** |
485 |
|
|
* Implements the built-in search() script function. |
486 |
|
|
*/ |
487 |
schoenebeck |
3581 |
class CoreVMFunction_search FINAL : public VMIntResultFunction { |
488 |
|
|
using Super = VMIntResultFunction; // just an alias for the super class |
489 |
schoenebeck |
3221 |
public: |
490 |
schoenebeck |
3581 |
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; } |
491 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE { return false; } |
492 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
493 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
494 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
495 |
schoenebeck |
3581 |
void checkArgs(VMFnArgs* args, std::function<void(String)> err, |
496 |
|
|
std::function<void(String)> wrn) OVERRIDE; |
497 |
schoenebeck |
3557 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
498 |
schoenebeck |
3221 |
}; |
499 |
|
|
|
500 |
|
|
/** |
501 |
|
|
* Implements the built-in sort() script function. |
502 |
|
|
*/ |
503 |
schoenebeck |
3581 |
class CoreVMFunction_sort FINAL : public VMEmptyResultFunction { |
504 |
schoenebeck |
3221 |
public: |
505 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
506 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
507 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
508 |
|
|
bool modifiesArg(vmint iArg) const OVERRIDE { return iArg == 0; } |
509 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
510 |
schoenebeck |
3221 |
}; |
511 |
|
|
|
512 |
schoenebeck |
3573 |
/** |
513 |
|
|
* Implements the built-in real_to_int() script function and its short hand |
514 |
|
|
* variant int(). The behaviour of the two built-in script functions are |
515 |
|
|
* identical ATM. |
516 |
|
|
*/ |
517 |
schoenebeck |
3581 |
class CoreVMFunction_real_to_int FINAL : public VMIntResultFunction { |
518 |
schoenebeck |
3573 |
public: |
519 |
schoenebeck |
3581 |
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
520 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
521 |
schoenebeck |
3573 |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
522 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
523 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
524 |
schoenebeck |
3581 |
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
525 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
526 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
527 |
schoenebeck |
3573 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
528 |
|
|
}; |
529 |
|
|
|
530 |
|
|
/** |
531 |
|
|
* Implements the built-in int_to_real() script function and its short hand |
532 |
|
|
* variant real(). The behaviour of the two built-in script functions are |
533 |
|
|
* identical ATM. |
534 |
|
|
*/ |
535 |
schoenebeck |
3581 |
class CoreVMFunction_int_to_real FINAL : public VMRealResultFunction { |
536 |
schoenebeck |
3573 |
public: |
537 |
schoenebeck |
3581 |
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
538 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
539 |
schoenebeck |
3573 |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
540 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
541 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; } |
542 |
schoenebeck |
3581 |
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
543 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
544 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
545 |
schoenebeck |
3573 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
546 |
|
|
}; |
547 |
|
|
|
548 |
schoenebeck |
3590 |
/** |
549 |
|
|
* Implements the built-in round() script function. |
550 |
|
|
*/ |
551 |
|
|
class CoreVMFunction_round FINAL : public VMRealResultFunction { |
552 |
|
|
public: |
553 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
554 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
555 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
556 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
557 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
558 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
559 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
560 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
561 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
562 |
|
|
}; |
563 |
|
|
|
564 |
|
|
/** |
565 |
|
|
* Implements the built-in ceil() script function. |
566 |
|
|
*/ |
567 |
|
|
class CoreVMFunction_ceil FINAL : public VMRealResultFunction { |
568 |
|
|
public: |
569 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
570 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
571 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
572 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
573 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
574 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
575 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
576 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
577 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
578 |
|
|
}; |
579 |
|
|
|
580 |
|
|
/** |
581 |
|
|
* Implements the built-in floor() script function. |
582 |
|
|
*/ |
583 |
|
|
class CoreVMFunction_floor FINAL : public VMRealResultFunction { |
584 |
|
|
public: |
585 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
586 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
587 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
588 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
589 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
590 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
591 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
592 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
593 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
594 |
|
|
}; |
595 |
|
|
|
596 |
|
|
/** |
597 |
|
|
* Implements the built-in sqrt() script function. |
598 |
|
|
*/ |
599 |
|
|
class CoreVMFunction_sqrt FINAL : public VMRealResultFunction { |
600 |
|
|
public: |
601 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
602 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
603 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
604 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
605 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
606 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
607 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
608 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
609 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
610 |
|
|
}; |
611 |
|
|
|
612 |
|
|
/** |
613 |
|
|
* Implements the built-in log() script function. |
614 |
|
|
*/ |
615 |
|
|
class CoreVMFunction_log FINAL : public VMRealResultFunction { |
616 |
|
|
public: |
617 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
618 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
619 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
620 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
621 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
622 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
623 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
624 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
625 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
626 |
|
|
}; |
627 |
|
|
|
628 |
|
|
/** |
629 |
|
|
* Implements the built-in log2() script function. |
630 |
|
|
*/ |
631 |
|
|
class CoreVMFunction_log2 FINAL : public VMRealResultFunction { |
632 |
|
|
public: |
633 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
634 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
635 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
636 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
637 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
638 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
639 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
640 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
641 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
642 |
|
|
}; |
643 |
|
|
|
644 |
|
|
/** |
645 |
|
|
* Implements the built-in log10() script function. |
646 |
|
|
*/ |
647 |
|
|
class CoreVMFunction_log10 FINAL : public VMRealResultFunction { |
648 |
|
|
public: |
649 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
650 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
651 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
652 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
653 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
654 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
655 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
656 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
657 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
658 |
|
|
}; |
659 |
|
|
|
660 |
|
|
/** |
661 |
|
|
* Implements the built-in exp() script function. |
662 |
|
|
*/ |
663 |
|
|
class CoreVMFunction_exp FINAL : public VMRealResultFunction { |
664 |
|
|
public: |
665 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
666 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
667 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
668 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
669 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
670 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
671 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
672 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
673 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
674 |
|
|
}; |
675 |
|
|
|
676 |
|
|
/** |
677 |
|
|
* Implements the built-in pow() script function. |
678 |
|
|
*/ |
679 |
|
|
class CoreVMFunction_pow FINAL : public VMRealResultFunction { |
680 |
|
|
using Super = VMRealResultFunction; // just an alias for the super class |
681 |
|
|
public: |
682 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
683 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
684 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 2; } |
685 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
686 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
687 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE; |
688 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE; |
689 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return iArg == 0; } |
690 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
691 |
|
|
}; |
692 |
|
|
|
693 |
|
|
/** |
694 |
|
|
* Implements the built-in sin() script function. |
695 |
|
|
*/ |
696 |
|
|
class CoreVMFunction_sin FINAL : public VMRealResultFunction { |
697 |
|
|
public: |
698 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
699 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
700 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
701 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
702 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
703 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
704 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
705 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
706 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
707 |
|
|
}; |
708 |
|
|
|
709 |
|
|
/** |
710 |
|
|
* Implements the built-in cos() script function. |
711 |
|
|
*/ |
712 |
|
|
class CoreVMFunction_cos FINAL : public VMRealResultFunction { |
713 |
|
|
public: |
714 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
715 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
716 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
717 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
718 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
719 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
720 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
721 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
722 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
723 |
|
|
}; |
724 |
|
|
|
725 |
|
|
/** |
726 |
|
|
* Implements the built-in tan() script function. |
727 |
|
|
*/ |
728 |
|
|
class CoreVMFunction_tan FINAL : public VMRealResultFunction { |
729 |
|
|
public: |
730 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
731 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
732 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
733 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
734 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
735 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
736 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
737 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
738 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
739 |
|
|
}; |
740 |
|
|
|
741 |
|
|
/** |
742 |
|
|
* Implements the built-in asin() script function. |
743 |
|
|
*/ |
744 |
|
|
class CoreVMFunction_asin FINAL : public VMRealResultFunction { |
745 |
|
|
public: |
746 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
747 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
748 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
749 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
750 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
751 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
752 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
753 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
754 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
755 |
|
|
}; |
756 |
|
|
|
757 |
|
|
/** |
758 |
|
|
* Implements the built-in acos() script function. |
759 |
|
|
*/ |
760 |
|
|
class CoreVMFunction_acos FINAL : public VMRealResultFunction { |
761 |
|
|
public: |
762 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
763 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
764 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
765 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
766 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
767 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
768 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
769 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
770 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
771 |
|
|
}; |
772 |
|
|
|
773 |
|
|
/** |
774 |
|
|
* Implements the built-in atan() script function. |
775 |
|
|
*/ |
776 |
|
|
class CoreVMFunction_atan FINAL : public VMRealResultFunction { |
777 |
|
|
public: |
778 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
779 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
780 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
781 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
782 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
783 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
784 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
785 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
786 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
787 |
|
|
}; |
788 |
|
|
|
789 |
schoenebeck |
2581 |
} // namespace LinuxSampler |
790 |
|
|
|
791 |
|
|
#endif // LS_COREVMFUNCTIONS_H |