24 |
* An instance of this class is returned by built-in function implementations |
* An instance of this class is returned by built-in function implementations |
25 |
* which do not return a function return value. |
* which do not return a function return value. |
26 |
*/ |
*/ |
27 |
class VMEmptyResult : public VMFnResult, public VMExpr { |
class VMEmptyResult FINAL : public VMFnResult, public VMExpr { |
28 |
public: |
public: |
29 |
StmtFlags_t flags; ///< general completion status (i.e. success or failure) of the function call |
StmtFlags_t flags; ///< general completion status (i.e. success or failure) of the function call |
30 |
|
|
39 |
* An instance of this class is returned by built-in function implementations |
* An instance of this class is returned by built-in function implementations |
40 |
* which return an integer value as function return value. |
* which return an integer value as function return value. |
41 |
*/ |
*/ |
42 |
class VMIntResult : public VMFnResult, public VMIntExpr { |
class VMIntResult FINAL : public VMFnResult, public VMIntExpr { |
43 |
public: |
public: |
44 |
StmtFlags_t flags; ///< general completion status (i.e. success or failure) of the function call |
StmtFlags_t flags; ///< general completion status (i.e. success or failure) of the function call |
45 |
vmint value; ///< result value of the function call |
vmint value; ///< result value of the function call |
46 |
|
vmfloat unitPrefixFactor; ///< unit factor of result value of the function call |
47 |
|
|
48 |
VMIntResult() : flags(STMT_SUCCESS), value(0) {} |
VMIntResult() : flags(STMT_SUCCESS), value(0), unitPrefixFactor(VM_NO_FACTOR) {} |
49 |
vmint evalInt() OVERRIDE { return value; } |
vmint evalInt() OVERRIDE { return value; } |
50 |
VMExpr* resultValue() OVERRIDE { return this; } |
VMExpr* resultValue() OVERRIDE { return this; } |
51 |
StmtFlags_t resultFlags() OVERRIDE { return flags; } |
StmtFlags_t resultFlags() OVERRIDE { return flags; } |
52 |
bool isConstExpr() const OVERRIDE { return false; } |
bool isConstExpr() const OVERRIDE { return false; } |
53 |
MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE { return VM_NO_PREFIX; } |
vmfloat unitFactor() const OVERRIDE { return unitPrefixFactor; } |
54 |
StdUnit_t unitType() const OVERRIDE { return VM_NO_UNIT; } |
StdUnit_t unitType() const OVERRIDE { return VM_NO_UNIT; } // actually never called, VMFunction::returnUnitType() is always used instead |
55 |
bool isFinal() const OVERRIDE { return false; } |
bool isFinal() const OVERRIDE { return false; } // actually never called, VMFunction::returnsFinal() is always used instead |
56 |
}; |
}; |
57 |
|
|
58 |
/** |
/** |
59 |
* An instance of this class is returned by built-in function implementations |
* An instance of this class is returned by built-in function implementations |
60 |
* which return a real number (floating point) value as function return value. |
* which return a real number (floating point) value as function return value. |
61 |
*/ |
*/ |
62 |
class VMRealResult : public VMFnResult, public VMRealExpr { |
class VMRealResult FINAL : public VMFnResult, public VMRealExpr { |
63 |
public: |
public: |
64 |
StmtFlags_t flags; ///< general completion status (i.e. success or failure) of the function call |
StmtFlags_t flags; ///< general completion status (i.e. success or failure) of the function call |
65 |
vmfloat value; ///< result value of the function call |
vmfloat value; ///< result value of the function call |
66 |
|
vmfloat unitPrefixFactor; ///< unit factor of result value of the function call |
67 |
|
|
68 |
VMRealResult() : flags(STMT_SUCCESS), value(0) {} |
VMRealResult() : flags(STMT_SUCCESS), value(0), unitPrefixFactor(VM_NO_FACTOR) {} |
69 |
vmfloat evalReal() OVERRIDE { return value; } |
vmfloat evalReal() OVERRIDE { return value; } |
70 |
VMExpr* resultValue() OVERRIDE { return this; } |
VMExpr* resultValue() OVERRIDE { return this; } |
71 |
StmtFlags_t resultFlags() OVERRIDE { return flags; } |
StmtFlags_t resultFlags() OVERRIDE { return flags; } |
72 |
bool isConstExpr() const OVERRIDE { return false; } |
bool isConstExpr() const OVERRIDE { return false; } |
73 |
MetricPrefix_t unitPrefix(vmuint i) const OVERRIDE { return VM_NO_PREFIX; } |
vmfloat unitFactor() const OVERRIDE { return unitPrefixFactor; } |
74 |
StdUnit_t unitType() const OVERRIDE { return VM_NO_UNIT; } |
StdUnit_t unitType() const OVERRIDE { return VM_NO_UNIT; } // actually never called, VMFunction::returnUnitType() is always used instead |
75 |
bool isFinal() const OVERRIDE { return false; } |
bool isFinal() const OVERRIDE { return false; } // actually never called, VMFunction::returnsFinal() is always used instead |
76 |
}; |
}; |
77 |
|
|
78 |
/** |
/** |
79 |
* An instance of this class is returned by built-in function implementations |
* An instance of this class is returned by built-in function implementations |
80 |
* which return a string value as function return value. |
* which return a string value as function return value. |
81 |
*/ |
*/ |
82 |
class VMStringResult : public VMFnResult, public VMStringExpr { |
class VMStringResult FINAL : public VMFnResult, public VMStringExpr { |
83 |
public: |
public: |
84 |
StmtFlags_t flags; ///< general completion status (i.e. success or failure) of the function call |
StmtFlags_t flags; ///< general completion status (i.e. success or failure) of the function call |
85 |
String value; ///< result value of the function call |
String value; ///< result value of the function call |
99 |
protected: |
protected: |
100 |
virtual ~VMEmptyResultFunction() {} |
virtual ~VMEmptyResultFunction() {} |
101 |
ExprType_t returnType(VMFnArgs* args) OVERRIDE { return EMPTY_EXPR; } |
ExprType_t returnType(VMFnArgs* args) OVERRIDE { return EMPTY_EXPR; } |
102 |
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; } |
103 |
|
bool returnsFinal(VMFnArgs* args) OVERRIDE { return false; } |
104 |
VMFnResult* errorResult(); |
VMFnResult* errorResult(); |
105 |
VMFnResult* successResult(); |
VMFnResult* successResult(); |
106 |
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
108 |
VMEmptyResult result; |
VMEmptyResult result; |
109 |
}; |
}; |
110 |
|
|
111 |
|
struct VMIntFnResDef { |
112 |
|
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. |
113 |
|
vmfloat unitFactor = VM_NO_FACTOR; |
114 |
|
}; |
115 |
|
|
116 |
|
struct VMRealFnResDef { |
117 |
|
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. |
118 |
|
vmfloat unitFactor = VM_NO_FACTOR; |
119 |
|
}; |
120 |
|
|
121 |
/** |
/** |
122 |
* Abstract base class for built-in script functions which return an integer |
* Abstract base class for built-in script functions which return an integer |
123 |
* (scalar) as their function return value. |
* (scalar) as their function return value. |
127 |
virtual ~VMIntResultFunction() {} |
virtual ~VMIntResultFunction() {} |
128 |
ExprType_t returnType(VMFnArgs* args) OVERRIDE { return INT_EXPR; } |
ExprType_t returnType(VMFnArgs* args) OVERRIDE { return INT_EXPR; } |
129 |
VMFnResult* errorResult(vmint i = 0); |
VMFnResult* errorResult(vmint i = 0); |
130 |
|
VMFnResult* errorResult(VMIntFnResDef res); |
131 |
VMFnResult* successResult(vmint i = 0); |
VMFnResult* successResult(vmint i = 0); |
132 |
|
VMFnResult* successResult(VMIntFnResDef res); |
133 |
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
134 |
protected: |
protected: |
135 |
VMIntResult result; |
VMIntResult result; |
144 |
virtual ~VMRealResultFunction() {} |
virtual ~VMRealResultFunction() {} |
145 |
ExprType_t returnType(VMFnArgs* args) OVERRIDE { return REAL_EXPR; } |
ExprType_t returnType(VMFnArgs* args) OVERRIDE { return REAL_EXPR; } |
146 |
VMFnResult* errorResult(vmfloat f = 0); |
VMFnResult* errorResult(vmfloat f = 0); |
147 |
|
VMFnResult* errorResult(VMRealFnResDef res); |
148 |
VMFnResult* successResult(vmfloat f = 0); |
VMFnResult* successResult(vmfloat f = 0); |
149 |
|
VMFnResult* successResult(VMRealFnResDef res); |
150 |
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
151 |
protected: |
protected: |
152 |
VMRealResult result; |
VMRealResult result; |
180 |
VMFnResult* errorResult(vmfloat f); |
VMFnResult* errorResult(vmfloat f); |
181 |
VMFnResult* successResult(vmint i); |
VMFnResult* successResult(vmint i); |
182 |
VMFnResult* successResult(vmfloat f); |
VMFnResult* successResult(vmfloat f); |
183 |
|
VMFnResult* errorIntResult(VMIntFnResDef res); |
184 |
|
VMFnResult* errorRealResult(VMRealFnResDef res); |
185 |
|
VMFnResult* successIntResult(VMIntFnResDef res); |
186 |
|
VMFnResult* successRealResult(VMRealFnResDef res); |
187 |
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
188 |
protected: |
protected: |
189 |
VMIntResult intResult; |
VMIntResult intResult; |
197 |
/** |
/** |
198 |
* Implements the built-in message() script function. |
* Implements the built-in message() script function. |
199 |
*/ |
*/ |
200 |
class CoreVMFunction_message : public VMEmptyResultFunction { |
class CoreVMFunction_message FINAL : public VMEmptyResultFunction { |
201 |
public: |
public: |
202 |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
203 |
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
209 |
/** |
/** |
210 |
* Implements the built-in exit() script function. |
* Implements the built-in exit() script function. |
211 |
*/ |
*/ |
212 |
class CoreVMFunction_exit : public VMEmptyResultFunction { |
class CoreVMFunction_exit FINAL : public VMEmptyResultFunction { |
213 |
public: |
public: |
214 |
CoreVMFunction_exit(ScriptVM* vm) : vm(vm) {} |
CoreVMFunction_exit(ScriptVM* vm) : vm(vm) {} |
215 |
vmint minRequiredArgs() const OVERRIDE { return 0; } |
vmint minRequiredArgs() const OVERRIDE { return 0; } |
216 |
vmint maxAllowedArgs() const OVERRIDE; |
vmint maxAllowedArgs() const OVERRIDE; |
217 |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
218 |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; } |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; } |
219 |
|
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 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
223 |
protected: |
protected: |
224 |
ScriptVM* vm; |
ScriptVM* vm; |
244 |
/** |
/** |
245 |
* Implements the built-in abs() script function. |
* Implements the built-in abs() script function. |
246 |
*/ |
*/ |
247 |
class CoreVMFunction_abs : public VMScalarNumberResultFunction { |
class CoreVMFunction_abs FINAL : public VMScalarNumberResultFunction { |
248 |
public: |
public: |
249 |
ExprType_t returnType(VMFnArgs* args) OVERRIDE; |
ExprType_t returnType(VMFnArgs* args) OVERRIDE; |
250 |
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
251 |
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
252 |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
253 |
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
254 |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
255 |
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
256 |
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
257 |
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
258 |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; } |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; } |
259 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
260 |
}; |
}; |
262 |
/** |
/** |
263 |
* Implements the built-in random() script function. |
* Implements the built-in random() script function. |
264 |
*/ |
*/ |
265 |
class CoreVMFunction_random : public VMIntResultFunction { |
class CoreVMFunction_random FINAL : public VMScalarNumberResultFunction { |
266 |
|
using Super = VMScalarNumberResultFunction; // just an alias for the super class |
267 |
public: |
public: |
268 |
|
ExprType_t returnType(VMFnArgs* args) OVERRIDE; |
269 |
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
270 |
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
271 |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
272 |
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
273 |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
274 |
|
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 |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; } |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; } |
278 |
|
void checkArgs(VMFnArgs* args, std::function<void(String)> err, |
279 |
|
std::function<void(String)> wrn) OVERRIDE; |
280 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
281 |
}; |
}; |
282 |
|
|
283 |
/** |
/** |
284 |
* Implements the built-in num_elements() script function. |
* Implements the built-in num_elements() script function. |
285 |
*/ |
*/ |
286 |
class CoreVMFunction_num_elements : public VMIntResultFunction { |
class CoreVMFunction_num_elements FINAL : public VMIntResultFunction { |
287 |
public: |
public: |
288 |
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; } |
289 |
|
bool returnsFinal(VMFnArgs* args) OVERRIDE { return false; } |
290 |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
291 |
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
292 |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
297 |
/** |
/** |
298 |
* Implements the built-in inc() script function. |
* Implements the built-in inc() script function. |
299 |
*/ |
*/ |
300 |
class CoreVMFunction_inc : public VMIntResultFunction { |
class CoreVMFunction_inc FINAL : public VMIntResultFunction { |
301 |
|
using Super = VMIntResultFunction; // just an alias for the super class |
302 |
public: |
public: |
303 |
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
304 |
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
305 |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
306 |
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
307 |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; } |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; } |
308 |
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
309 |
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
310 |
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
311 |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; } |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; } |
312 |
bool modifiesArg(vmint iArg) const OVERRIDE { return true; } |
bool modifiesArg(vmint iArg) const OVERRIDE { return true; } |
313 |
|
void checkArgs(VMFnArgs* args, std::function<void(String)> err, |
314 |
|
std::function<void(String)> wrn) OVERRIDE; |
315 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
316 |
}; |
}; |
317 |
|
|
318 |
/** |
/** |
319 |
* Implements the built-in dec() script function. |
* Implements the built-in dec() script function. |
320 |
*/ |
*/ |
321 |
class CoreVMFunction_dec : public VMIntResultFunction { |
class CoreVMFunction_dec FINAL : public VMIntResultFunction { |
322 |
|
using Super = VMIntResultFunction; // just an alias for the super class |
323 |
public: |
public: |
324 |
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
325 |
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
326 |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
327 |
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
328 |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; } |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; } |
329 |
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
330 |
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
331 |
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
332 |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; } |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; } |
333 |
bool modifiesArg(vmint iArg) const OVERRIDE { return true; } |
bool modifiesArg(vmint iArg) const OVERRIDE { return true; } |
334 |
|
void checkArgs(VMFnArgs* args, std::function<void(String)> err, |
335 |
|
std::function<void(String)> wrn) OVERRIDE; |
336 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
337 |
}; |
}; |
338 |
|
|
339 |
/** |
/** |
340 |
* Implements the built-in in_range() script function. |
* Implements the built-in in_range() script function. |
341 |
*/ |
*/ |
342 |
class CoreVMFunction_in_range : public VMIntResultFunction { |
class CoreVMFunction_in_range FINAL : public VMIntResultFunction { |
343 |
|
using Super = VMIntResultFunction; // just an alias for the super class |
344 |
public: |
public: |
345 |
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; } |
346 |
|
bool returnsFinal(VMFnArgs* args) OVERRIDE { return false; } |
347 |
vmint minRequiredArgs() const OVERRIDE { return 3; } |
vmint minRequiredArgs() const OVERRIDE { return 3; } |
348 |
vmint maxAllowedArgs() const OVERRIDE { return 3; } |
vmint maxAllowedArgs() const OVERRIDE { return 3; } |
349 |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; } |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
350 |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; } |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; } |
351 |
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
352 |
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
353 |
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
354 |
|
void checkArgs(VMFnArgs* args, std::function<void(String)> err, |
355 |
|
std::function<void(String)> wrn) OVERRIDE; |
356 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
357 |
}; |
}; |
358 |
|
|
359 |
/** |
/** |
360 |
* Implements the built-in sh_left() script function. |
* Implements the built-in sh_left() script function. |
361 |
*/ |
*/ |
362 |
class CoreVMFunction_sh_left : public VMIntResultFunction { |
class CoreVMFunction_sh_left FINAL : public VMIntResultFunction { |
363 |
public: |
public: |
364 |
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; } |
365 |
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
366 |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
367 |
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
368 |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; } |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; } |
369 |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; } |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; } |
370 |
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
371 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
372 |
}; |
}; |
373 |
|
|
374 |
/** |
/** |
375 |
* Implements the built-in sh_right() script function. |
* Implements the built-in sh_right() script function. |
376 |
*/ |
*/ |
377 |
class CoreVMFunction_sh_right : public VMIntResultFunction { |
class CoreVMFunction_sh_right FINAL : public VMIntResultFunction { |
378 |
public: |
public: |
379 |
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; } |
380 |
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
381 |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
382 |
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
383 |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; } |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; } |
384 |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; } |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; } |
385 |
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
386 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
387 |
}; |
}; |
388 |
|
|
389 |
/** |
/** |
390 |
* Implements the built-in min() script function. |
* Implements the built-in min() script function. |
391 |
*/ |
*/ |
392 |
class CoreVMFunction_min : public VMScalarNumberResultFunction { |
class CoreVMFunction_min FINAL : public VMScalarNumberResultFunction { |
393 |
|
using Super = VMScalarNumberResultFunction; // just an alias for the super class |
394 |
public: |
public: |
395 |
ExprType_t returnType(VMFnArgs* args) OVERRIDE; |
ExprType_t returnType(VMFnArgs* args) OVERRIDE; |
396 |
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
397 |
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
398 |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
399 |
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
400 |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
401 |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; } |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; } |
402 |
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
403 |
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
404 |
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
405 |
|
void checkArgs(VMFnArgs* args, std::function<void(String)> err, |
406 |
|
std::function<void(String)> wrn) OVERRIDE; |
407 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
408 |
}; |
}; |
409 |
|
|
410 |
/** |
/** |
411 |
* Implements the built-in max() script function. |
* Implements the built-in max() script function. |
412 |
*/ |
*/ |
413 |
class CoreVMFunction_max : public VMScalarNumberResultFunction { |
class CoreVMFunction_max FINAL : public VMScalarNumberResultFunction { |
414 |
|
using Super = VMScalarNumberResultFunction; // just an alias for the super class |
415 |
public: |
public: |
416 |
ExprType_t returnType(VMFnArgs* args) OVERRIDE; |
ExprType_t returnType(VMFnArgs* args) OVERRIDE; |
417 |
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
418 |
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
419 |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
420 |
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
421 |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
422 |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; } |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; } |
423 |
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
424 |
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
425 |
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
426 |
|
void checkArgs(VMFnArgs* args, std::function<void(String)> err, |
427 |
|
std::function<void(String)> wrn) OVERRIDE; |
428 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
429 |
}; |
}; |
430 |
|
|
431 |
/** |
/** |
432 |
* Implements the built-in array_equal() script function. |
* Implements the built-in array_equal() script function. |
433 |
*/ |
*/ |
434 |
class CoreVMFunction_array_equal : public VMIntResultFunction { |
class CoreVMFunction_array_equal FINAL : public VMIntResultFunction { |
435 |
|
using Super = VMIntResultFunction; // just an alias for the super class |
436 |
public: |
public: |
437 |
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; } |
438 |
|
bool returnsFinal(VMFnArgs* args) OVERRIDE { return false; } |
439 |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
440 |
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
441 |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_ARR_EXPR; } |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
442 |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_ARR_EXPR; } |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_ARR_EXPR; } |
443 |
|
void checkArgs(VMFnArgs* args, std::function<void(String)> err, |
444 |
|
std::function<void(String)> wrn) OVERRIDE; |
445 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
446 |
}; |
}; |
447 |
|
|
448 |
/** |
/** |
449 |
* Implements the built-in search() script function. |
* Implements the built-in search() script function. |
450 |
*/ |
*/ |
451 |
class CoreVMFunction_search : public VMIntResultFunction { |
class CoreVMFunction_search FINAL : public VMIntResultFunction { |
452 |
|
using Super = VMIntResultFunction; // just an alias for the super class |
453 |
public: |
public: |
454 |
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; } |
455 |
|
bool returnsFinal(VMFnArgs* args) OVERRIDE { return false; } |
456 |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
457 |
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
458 |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
459 |
ExprType_t argType(vmint iArg) const OVERRIDE; |
ExprType_t argType(vmint iArg) const OVERRIDE; |
460 |
|
void checkArgs(VMFnArgs* args, std::function<void(String)> err, |
461 |
|
std::function<void(String)> wrn) OVERRIDE; |
462 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
463 |
}; |
}; |
464 |
|
|
465 |
/** |
/** |
466 |
* Implements the built-in sort() script function. |
* Implements the built-in sort() script function. |
467 |
*/ |
*/ |
468 |
class CoreVMFunction_sort : public VMEmptyResultFunction { |
class CoreVMFunction_sort FINAL : public VMEmptyResultFunction { |
469 |
public: |
public: |
470 |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
471 |
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
480 |
* variant int(). The behaviour of the two built-in script functions are |
* variant int(). The behaviour of the two built-in script functions are |
481 |
* identical ATM. |
* identical ATM. |
482 |
*/ |
*/ |
483 |
class CoreVMFunction_real_to_int : public VMIntResultFunction { |
class CoreVMFunction_real_to_int FINAL : public VMIntResultFunction { |
484 |
public: |
public: |
485 |
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
486 |
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
487 |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
488 |
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
489 |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == REAL_EXPR; } |
490 |
ExprType_t argType(vmint iArg) const OVERRIDE { return REAL_EXPR; } |
ExprType_t argType(vmint iArg) const OVERRIDE { return REAL_EXPR; } |
491 |
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
492 |
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
493 |
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
494 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
495 |
}; |
}; |
496 |
|
|
499 |
* variant real(). The behaviour of the two built-in script functions are |
* variant real(). The behaviour of the two built-in script functions are |
500 |
* identical ATM. |
* identical ATM. |
501 |
*/ |
*/ |
502 |
class CoreVMFunction_int_to_real : public VMRealResultFunction { |
class CoreVMFunction_int_to_real FINAL : public VMRealResultFunction { |
503 |
public: |
public: |
504 |
|
StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE; |
505 |
|
bool returnsFinal(VMFnArgs* args) OVERRIDE; |
506 |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
507 |
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
508 |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; } |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; } |
509 |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; } |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; } |
510 |
|
bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
511 |
|
bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE { return true; } |
512 |
|
bool acceptsArgFinal(vmint iArg) const OVERRIDE { return true; } |
513 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
514 |
}; |
}; |
515 |
|
|