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 |
3034 |
virtual ~VMEmptyResultFunction() {} |
103 |
schoenebeck |
3577 |
ExprType_t returnType(VMFnArgs* args) OVERRIDE { return EMPTY_EXPR; } |
104 |
schoenebeck |
3581 |
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; } |
105 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE { return false; } |
106 |
schoenebeck |
2581 |
VMFnResult* errorResult(); |
107 |
|
|
VMFnResult* successResult(); |
108 |
schoenebeck |
3557 |
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
109 |
schoenebeck |
2581 |
protected: |
110 |
|
|
VMEmptyResult result; |
111 |
|
|
}; |
112 |
|
|
|
113 |
schoenebeck |
3581 |
struct VMIntFnResDef { |
114 |
|
|
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. |
115 |
|
|
vmfloat unitFactor = VM_NO_FACTOR; |
116 |
|
|
}; |
117 |
|
|
|
118 |
|
|
struct VMRealFnResDef { |
119 |
|
|
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. |
120 |
|
|
vmfloat unitFactor = VM_NO_FACTOR; |
121 |
|
|
}; |
122 |
|
|
|
123 |
schoenebeck |
2727 |
/** |
124 |
|
|
* Abstract base class for built-in script functions which return an integer |
125 |
|
|
* (scalar) as their function return value. |
126 |
|
|
*/ |
127 |
schoenebeck |
2598 |
class VMIntResultFunction : public VMFunction { |
128 |
|
|
protected: |
129 |
schoenebeck |
3034 |
virtual ~VMIntResultFunction() {} |
130 |
schoenebeck |
3577 |
ExprType_t returnType(VMFnArgs* args) OVERRIDE { return INT_EXPR; } |
131 |
schoenebeck |
3557 |
VMFnResult* errorResult(vmint i = 0); |
132 |
schoenebeck |
3581 |
VMFnResult* errorResult(VMIntFnResDef res); |
133 |
schoenebeck |
3557 |
VMFnResult* successResult(vmint i = 0); |
134 |
schoenebeck |
3581 |
VMFnResult* successResult(VMIntFnResDef res); |
135 |
schoenebeck |
3557 |
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
136 |
schoenebeck |
2598 |
protected: |
137 |
|
|
VMIntResult result; |
138 |
|
|
}; |
139 |
|
|
|
140 |
schoenebeck |
2727 |
/** |
141 |
schoenebeck |
3573 |
* Abstract base class for built-in script functions which return a real number |
142 |
|
|
* (floating point scalar) as their function return value. |
143 |
|
|
*/ |
144 |
|
|
class VMRealResultFunction : public VMFunction { |
145 |
|
|
protected: |
146 |
|
|
virtual ~VMRealResultFunction() {} |
147 |
schoenebeck |
3577 |
ExprType_t returnType(VMFnArgs* args) OVERRIDE { return REAL_EXPR; } |
148 |
schoenebeck |
3573 |
VMFnResult* errorResult(vmfloat f = 0); |
149 |
schoenebeck |
3581 |
VMFnResult* errorResult(VMRealFnResDef res); |
150 |
schoenebeck |
3573 |
VMFnResult* successResult(vmfloat f = 0); |
151 |
schoenebeck |
3581 |
VMFnResult* successResult(VMRealFnResDef res); |
152 |
schoenebeck |
3573 |
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
153 |
|
|
protected: |
154 |
|
|
VMRealResult result; |
155 |
|
|
}; |
156 |
|
|
|
157 |
|
|
/** |
158 |
schoenebeck |
2727 |
* Abstract base class for built-in script functions which return a string as |
159 |
|
|
* their function return value. |
160 |
|
|
*/ |
161 |
schoenebeck |
2581 |
class VMStringResultFunction : public VMFunction { |
162 |
|
|
protected: |
163 |
schoenebeck |
3034 |
virtual ~VMStringResultFunction() {} |
164 |
schoenebeck |
3577 |
ExprType_t returnType(VMFnArgs* args) OVERRIDE { return STRING_EXPR; } |
165 |
schoenebeck |
2581 |
VMFnResult* errorResult(const String& s = ""); |
166 |
|
|
VMFnResult* successResult(const String& s = ""); |
167 |
schoenebeck |
3557 |
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
168 |
schoenebeck |
2581 |
protected: |
169 |
|
|
VMStringResult result; |
170 |
|
|
}; |
171 |
|
|
|
172 |
schoenebeck |
3577 |
/** |
173 |
|
|
* Abstract base class for built-in script functions which either return an |
174 |
|
|
* integer or a real number (floating point scalar) as their function return |
175 |
|
|
* value. The actual return type is determined at parse time once after |
176 |
|
|
* potential arguments were associated with the respective function call. |
177 |
|
|
*/ |
178 |
schoenebeck |
3582 |
class VMNumberResultFunction : public VMFunction { |
179 |
schoenebeck |
3577 |
protected: |
180 |
schoenebeck |
3582 |
virtual ~VMNumberResultFunction() {} |
181 |
schoenebeck |
3577 |
VMFnResult* errorResult(vmint i); |
182 |
|
|
VMFnResult* errorResult(vmfloat f); |
183 |
|
|
VMFnResult* successResult(vmint i); |
184 |
|
|
VMFnResult* successResult(vmfloat f); |
185 |
schoenebeck |
3581 |
VMFnResult* errorIntResult(VMIntFnResDef res); |
186 |
|
|
VMFnResult* errorRealResult(VMRealFnResDef res); |
187 |
|
|
VMFnResult* successIntResult(VMIntFnResDef res); |
188 |
|
|
VMFnResult* successRealResult(VMRealFnResDef res); |
189 |
schoenebeck |
3577 |
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
190 |
|
|
protected: |
191 |
|
|
VMIntResult intResult; |
192 |
|
|
VMRealResult realResult; |
193 |
|
|
}; |
194 |
schoenebeck |
2727 |
|
195 |
schoenebeck |
3577 |
|
196 |
schoenebeck |
2727 |
/////////////////////////////////////////////////////////////////////////// |
197 |
|
|
// implementations of core built-in script functions ... |
198 |
|
|
|
199 |
|
|
/** |
200 |
|
|
* Implements the built-in message() script function. |
201 |
|
|
*/ |
202 |
schoenebeck |
3581 |
class CoreVMFunction_message FINAL : public VMEmptyResultFunction { |
203 |
schoenebeck |
2581 |
public: |
204 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
205 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
206 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
207 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
208 |
schoenebeck |
2581 |
}; |
209 |
|
|
|
210 |
schoenebeck |
2727 |
/** |
211 |
|
|
* Implements the built-in exit() script function. |
212 |
|
|
*/ |
213 |
schoenebeck |
3581 |
class CoreVMFunction_exit FINAL : public VMEmptyResultFunction { |
214 |
schoenebeck |
2581 |
public: |
215 |
schoenebeck |
3551 |
CoreVMFunction_exit(ScriptVM* vm) : vm(vm) {} |
216 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 0; } |
217 |
|
|
vmint maxAllowedArgs() const OVERRIDE; |
218 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
219 |
schoenebeck |
3581 |
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE; |
220 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE; |
221 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE; |
222 |
schoenebeck |
3557 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
223 |
schoenebeck |
3551 |
protected: |
224 |
|
|
ScriptVM* vm; |
225 |
schoenebeck |
2581 |
}; |
226 |
|
|
|
227 |
schoenebeck |
2727 |
/** |
228 |
|
|
* Implements the built-in wait() script function. |
229 |
|
|
*/ |
230 |
schoenebeck |
2581 |
class CoreVMFunction_wait : public VMEmptyResultFunction { |
231 |
|
|
public: |
232 |
|
|
CoreVMFunction_wait(ScriptVM* vm) : vm(vm) {} |
233 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
234 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
235 |
schoenebeck |
3584 |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
236 |
schoenebeck |
3561 |
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE; |
237 |
schoenebeck |
3564 |
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE; |
238 |
schoenebeck |
3557 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
239 |
schoenebeck |
2581 |
protected: |
240 |
|
|
ScriptVM* vm; |
241 |
|
|
}; |
242 |
|
|
|
243 |
schoenebeck |
2727 |
/** |
244 |
|
|
* Implements the built-in abs() script function. |
245 |
|
|
*/ |
246 |
schoenebeck |
3582 |
class CoreVMFunction_abs FINAL : public VMNumberResultFunction { |
247 |
schoenebeck |
2619 |
public: |
248 |
schoenebeck |
3577 |
ExprType_t returnType(VMFnArgs* args) OVERRIDE; |
249 |
schoenebeck |
3581 |
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
250 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
251 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
252 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
253 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
254 |
schoenebeck |
3581 |
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
255 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
256 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
257 |
schoenebeck |
3557 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
258 |
schoenebeck |
2619 |
}; |
259 |
|
|
|
260 |
schoenebeck |
2727 |
/** |
261 |
|
|
* Implements the built-in random() script function. |
262 |
|
|
*/ |
263 |
schoenebeck |
3582 |
class CoreVMFunction_random FINAL : public VMNumberResultFunction { |
264 |
|
|
using Super = VMNumberResultFunction; // just an alias for the super class |
265 |
schoenebeck |
2619 |
public: |
266 |
schoenebeck |
3581 |
ExprType_t returnType(VMFnArgs* args) OVERRIDE; |
267 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
268 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
269 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
270 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
271 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
272 |
schoenebeck |
3581 |
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
273 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
274 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
275 |
|
|
void checkArgs(VMFnArgs* args, std::function<void(String)> err, |
276 |
|
|
std::function<void(String)> wrn) OVERRIDE; |
277 |
schoenebeck |
3557 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
278 |
schoenebeck |
2619 |
}; |
279 |
|
|
|
280 |
schoenebeck |
2727 |
/** |
281 |
|
|
* Implements the built-in num_elements() script function. |
282 |
|
|
*/ |
283 |
schoenebeck |
3581 |
class CoreVMFunction_num_elements FINAL : public VMIntResultFunction { |
284 |
schoenebeck |
2619 |
public: |
285 |
schoenebeck |
3581 |
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; } |
286 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE { return false; } |
287 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
288 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
289 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
290 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
291 |
schoenebeck |
2619 |
}; |
292 |
|
|
|
293 |
schoenebeck |
2945 |
/** |
294 |
|
|
* Implements the built-in inc() script function. |
295 |
|
|
*/ |
296 |
schoenebeck |
3581 |
class CoreVMFunction_inc FINAL : public VMIntResultFunction { |
297 |
|
|
using Super = VMIntResultFunction; // just an alias for the super class |
298 |
schoenebeck |
2945 |
public: |
299 |
schoenebeck |
3581 |
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
300 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
301 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
302 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
303 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; } |
304 |
schoenebeck |
3581 |
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
305 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
306 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
307 |
schoenebeck |
3557 |
bool modifiesArg(vmint iArg) const OVERRIDE { return true; } |
308 |
schoenebeck |
3581 |
void checkArgs(VMFnArgs* args, std::function<void(String)> err, |
309 |
|
|
std::function<void(String)> wrn) OVERRIDE; |
310 |
schoenebeck |
3557 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
311 |
schoenebeck |
2945 |
}; |
312 |
|
|
|
313 |
|
|
/** |
314 |
|
|
* Implements the built-in dec() script function. |
315 |
|
|
*/ |
316 |
schoenebeck |
3581 |
class CoreVMFunction_dec 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 |
schoenebeck |
2965 |
/** |
334 |
schoenebeck |
3076 |
* Implements the built-in in_range() script function. |
335 |
|
|
*/ |
336 |
schoenebeck |
3581 |
class CoreVMFunction_in_range FINAL : public VMIntResultFunction { |
337 |
|
|
using Super = VMIntResultFunction; // just an alias for the super class |
338 |
schoenebeck |
3076 |
public: |
339 |
schoenebeck |
3581 |
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; } |
340 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE { return false; } |
341 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 3; } |
342 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 3; } |
343 |
schoenebeck |
3581 |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
344 |
|
|
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 |
|
|
void checkArgs(VMFnArgs* args, std::function<void(String)> err, |
348 |
|
|
std::function<void(String)> wrn) OVERRIDE; |
349 |
schoenebeck |
3557 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
350 |
schoenebeck |
3076 |
}; |
351 |
|
|
|
352 |
|
|
/** |
353 |
schoenebeck |
2965 |
* Implements the built-in sh_left() script function. |
354 |
|
|
*/ |
355 |
schoenebeck |
3581 |
class CoreVMFunction_sh_left FINAL : public VMIntResultFunction { |
356 |
schoenebeck |
2965 |
public: |
357 |
schoenebeck |
3581 |
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; } |
358 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
359 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
360 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
361 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; } |
362 |
schoenebeck |
3581 |
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
363 |
schoenebeck |
3557 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
364 |
schoenebeck |
2965 |
}; |
365 |
|
|
|
366 |
|
|
/** |
367 |
|
|
* Implements the built-in sh_right() script function. |
368 |
|
|
*/ |
369 |
schoenebeck |
3581 |
class CoreVMFunction_sh_right FINAL : public VMIntResultFunction { |
370 |
schoenebeck |
2965 |
public: |
371 |
schoenebeck |
3581 |
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; } |
372 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
373 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
374 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
375 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; } |
376 |
schoenebeck |
3581 |
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
377 |
schoenebeck |
3557 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
378 |
schoenebeck |
2965 |
}; |
379 |
|
|
|
380 |
schoenebeck |
2970 |
/** |
381 |
schoenebeck |
3678 |
* Implements the built-in msb() script function. |
382 |
|
|
*/ |
383 |
|
|
class CoreVMFunction_msb FINAL : public VMIntResultFunction { |
384 |
|
|
public: |
385 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; } |
386 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE { return false; } |
387 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
388 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
389 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; } |
390 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return false; } |
391 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
392 |
|
|
}; |
393 |
|
|
|
394 |
|
|
/** |
395 |
|
|
* Implements the built-in lsb() script function. |
396 |
|
|
*/ |
397 |
|
|
class CoreVMFunction_lsb FINAL : public VMIntResultFunction { |
398 |
|
|
public: |
399 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; } |
400 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE { return false; } |
401 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
402 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
403 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; } |
404 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return false; } |
405 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
406 |
|
|
}; |
407 |
|
|
|
408 |
|
|
/** |
409 |
schoenebeck |
2970 |
* Implements the built-in min() script function. |
410 |
|
|
*/ |
411 |
schoenebeck |
3582 |
class CoreVMFunction_min FINAL : public VMNumberResultFunction { |
412 |
|
|
using Super = VMNumberResultFunction; // just an alias for the super class |
413 |
schoenebeck |
2970 |
public: |
414 |
schoenebeck |
3577 |
ExprType_t returnType(VMFnArgs* args) OVERRIDE; |
415 |
schoenebeck |
3581 |
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
416 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
417 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
418 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
419 |
schoenebeck |
3577 |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
420 |
schoenebeck |
3581 |
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
421 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
422 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
423 |
|
|
void checkArgs(VMFnArgs* args, std::function<void(String)> err, |
424 |
|
|
std::function<void(String)> wrn) OVERRIDE; |
425 |
schoenebeck |
3557 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
426 |
schoenebeck |
2970 |
}; |
427 |
|
|
|
428 |
|
|
/** |
429 |
|
|
* Implements the built-in max() script function. |
430 |
|
|
*/ |
431 |
schoenebeck |
3582 |
class CoreVMFunction_max 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 |
schoenebeck |
3221 |
/** |
449 |
|
|
* Implements the built-in array_equal() script function. |
450 |
|
|
*/ |
451 |
schoenebeck |
3581 |
class CoreVMFunction_array_equal FINAL : public VMIntResultFunction { |
452 |
|
|
using Super = VMIntResultFunction; // just an alias for the super class |
453 |
schoenebeck |
3221 |
public: |
454 |
schoenebeck |
3581 |
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; } |
455 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE { return false; } |
456 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
457 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
458 |
schoenebeck |
3581 |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
459 |
|
|
void checkArgs(VMFnArgs* args, std::function<void(String)> err, |
460 |
|
|
std::function<void(String)> wrn) OVERRIDE; |
461 |
schoenebeck |
3557 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
462 |
schoenebeck |
3221 |
}; |
463 |
|
|
|
464 |
|
|
/** |
465 |
|
|
* Implements the built-in search() script function. |
466 |
|
|
*/ |
467 |
schoenebeck |
3581 |
class CoreVMFunction_search FINAL : public VMIntResultFunction { |
468 |
|
|
using Super = VMIntResultFunction; // just an alias for the super class |
469 |
schoenebeck |
3221 |
public: |
470 |
schoenebeck |
3581 |
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; } |
471 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE { return false; } |
472 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
473 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
474 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
475 |
schoenebeck |
3581 |
void checkArgs(VMFnArgs* args, std::function<void(String)> err, |
476 |
|
|
std::function<void(String)> wrn) OVERRIDE; |
477 |
schoenebeck |
3557 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
478 |
schoenebeck |
3221 |
}; |
479 |
|
|
|
480 |
|
|
/** |
481 |
|
|
* Implements the built-in sort() script function. |
482 |
|
|
*/ |
483 |
schoenebeck |
3581 |
class CoreVMFunction_sort FINAL : public VMEmptyResultFunction { |
484 |
schoenebeck |
3221 |
public: |
485 |
schoenebeck |
3557 |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
486 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
487 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
488 |
|
|
bool modifiesArg(vmint iArg) const OVERRIDE { return iArg == 0; } |
489 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
490 |
schoenebeck |
3221 |
}; |
491 |
|
|
|
492 |
schoenebeck |
3573 |
/** |
493 |
|
|
* Implements the built-in real_to_int() script function and its short hand |
494 |
|
|
* variant int(). The behaviour of the two built-in script functions are |
495 |
|
|
* identical ATM. |
496 |
|
|
*/ |
497 |
schoenebeck |
3581 |
class CoreVMFunction_real_to_int FINAL : public VMIntResultFunction { |
498 |
schoenebeck |
3573 |
public: |
499 |
schoenebeck |
3581 |
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
500 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
501 |
schoenebeck |
3573 |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
502 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
503 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
504 |
schoenebeck |
3581 |
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
505 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
506 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
507 |
schoenebeck |
3573 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
508 |
|
|
}; |
509 |
|
|
|
510 |
|
|
/** |
511 |
|
|
* Implements the built-in int_to_real() script function and its short hand |
512 |
|
|
* variant real(). The behaviour of the two built-in script functions are |
513 |
|
|
* identical ATM. |
514 |
|
|
*/ |
515 |
schoenebeck |
3581 |
class CoreVMFunction_int_to_real FINAL : public VMRealResultFunction { |
516 |
schoenebeck |
3573 |
public: |
517 |
schoenebeck |
3581 |
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
518 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
519 |
schoenebeck |
3573 |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
520 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
521 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; } |
522 |
schoenebeck |
3581 |
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
523 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
524 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
525 |
schoenebeck |
3573 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
526 |
|
|
}; |
527 |
|
|
|
528 |
schoenebeck |
3590 |
/** |
529 |
|
|
* Implements the built-in round() script function. |
530 |
|
|
*/ |
531 |
|
|
class CoreVMFunction_round FINAL : public VMRealResultFunction { |
532 |
|
|
public: |
533 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
534 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
535 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
536 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
537 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
538 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
539 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
540 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
541 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
542 |
|
|
}; |
543 |
|
|
|
544 |
|
|
/** |
545 |
|
|
* Implements the built-in ceil() script function. |
546 |
|
|
*/ |
547 |
|
|
class CoreVMFunction_ceil FINAL : public VMRealResultFunction { |
548 |
|
|
public: |
549 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
550 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
551 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
552 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
553 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
554 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
555 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
556 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
557 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
558 |
|
|
}; |
559 |
|
|
|
560 |
|
|
/** |
561 |
|
|
* Implements the built-in floor() script function. |
562 |
|
|
*/ |
563 |
|
|
class CoreVMFunction_floor FINAL : public VMRealResultFunction { |
564 |
|
|
public: |
565 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
566 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
567 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
568 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
569 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
570 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
571 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
572 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
573 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
574 |
|
|
}; |
575 |
|
|
|
576 |
|
|
/** |
577 |
|
|
* Implements the built-in sqrt() script function. |
578 |
|
|
*/ |
579 |
|
|
class CoreVMFunction_sqrt FINAL : public VMRealResultFunction { |
580 |
|
|
public: |
581 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
582 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
583 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
584 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
585 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
586 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
587 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
588 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
589 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
590 |
|
|
}; |
591 |
|
|
|
592 |
|
|
/** |
593 |
|
|
* Implements the built-in log() script function. |
594 |
|
|
*/ |
595 |
|
|
class CoreVMFunction_log FINAL : public VMRealResultFunction { |
596 |
|
|
public: |
597 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
598 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
599 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
600 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
601 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
602 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
603 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
604 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
605 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
606 |
|
|
}; |
607 |
|
|
|
608 |
|
|
/** |
609 |
|
|
* Implements the built-in log2() script function. |
610 |
|
|
*/ |
611 |
|
|
class CoreVMFunction_log2 FINAL : public VMRealResultFunction { |
612 |
|
|
public: |
613 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
614 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
615 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
616 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
617 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
618 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
619 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
620 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
621 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
622 |
|
|
}; |
623 |
|
|
|
624 |
|
|
/** |
625 |
|
|
* Implements the built-in log10() script function. |
626 |
|
|
*/ |
627 |
|
|
class CoreVMFunction_log10 FINAL : public VMRealResultFunction { |
628 |
|
|
public: |
629 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
630 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
631 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
632 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
633 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
634 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
635 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
636 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
637 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
638 |
|
|
}; |
639 |
|
|
|
640 |
|
|
/** |
641 |
|
|
* Implements the built-in exp() script function. |
642 |
|
|
*/ |
643 |
|
|
class CoreVMFunction_exp FINAL : public VMRealResultFunction { |
644 |
|
|
public: |
645 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
646 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
647 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
648 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
649 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
650 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
651 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
652 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
653 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
654 |
|
|
}; |
655 |
|
|
|
656 |
|
|
/** |
657 |
|
|
* Implements the built-in pow() script function. |
658 |
|
|
*/ |
659 |
|
|
class CoreVMFunction_pow FINAL : public VMRealResultFunction { |
660 |
|
|
using Super = VMRealResultFunction; // just an alias for the super class |
661 |
|
|
public: |
662 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
663 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
664 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 2; } |
665 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
666 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
667 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE; |
668 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE; |
669 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return iArg == 0; } |
670 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
671 |
|
|
}; |
672 |
|
|
|
673 |
|
|
/** |
674 |
|
|
* Implements the built-in sin() script function. |
675 |
|
|
*/ |
676 |
|
|
class CoreVMFunction_sin FINAL : public VMRealResultFunction { |
677 |
|
|
public: |
678 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
679 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
680 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
681 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
682 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
683 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
684 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
685 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
686 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
687 |
|
|
}; |
688 |
|
|
|
689 |
|
|
/** |
690 |
|
|
* Implements the built-in cos() script function. |
691 |
|
|
*/ |
692 |
|
|
class CoreVMFunction_cos FINAL : public VMRealResultFunction { |
693 |
|
|
public: |
694 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
695 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
696 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
697 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
698 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
699 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
700 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
701 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
702 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
703 |
|
|
}; |
704 |
|
|
|
705 |
|
|
/** |
706 |
|
|
* Implements the built-in tan() script function. |
707 |
|
|
*/ |
708 |
|
|
class CoreVMFunction_tan FINAL : public VMRealResultFunction { |
709 |
|
|
public: |
710 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
711 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
712 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
713 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
714 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
715 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
716 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
717 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
718 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
719 |
|
|
}; |
720 |
|
|
|
721 |
|
|
/** |
722 |
|
|
* Implements the built-in asin() script function. |
723 |
|
|
*/ |
724 |
|
|
class CoreVMFunction_asin FINAL : public VMRealResultFunction { |
725 |
|
|
public: |
726 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
727 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
728 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
729 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
730 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
731 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
732 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
733 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
734 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
735 |
|
|
}; |
736 |
|
|
|
737 |
|
|
/** |
738 |
|
|
* Implements the built-in acos() script function. |
739 |
|
|
*/ |
740 |
|
|
class CoreVMFunction_acos FINAL : public VMRealResultFunction { |
741 |
|
|
public: |
742 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
743 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
744 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
745 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
746 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
747 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
748 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
749 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
750 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
751 |
|
|
}; |
752 |
|
|
|
753 |
|
|
/** |
754 |
|
|
* Implements the built-in atan() script function. |
755 |
|
|
*/ |
756 |
|
|
class CoreVMFunction_atan FINAL : public VMRealResultFunction { |
757 |
|
|
public: |
758 |
|
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
759 |
|
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
760 |
|
|
vmint minRequiredArgs() const OVERRIDE { return 1; } |
761 |
|
|
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
762 |
|
|
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
763 |
|
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
764 |
|
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
765 |
|
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
766 |
|
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
767 |
|
|
}; |
768 |
|
|
|
769 |
schoenebeck |
2581 |
} // namespace LinuxSampler |
770 |
|
|
|
771 |
|
|
#endif // LS_COREVMFUNCTIONS_H |