96 |
class VMEmptyResultFunction : public VMFunction { |
class VMEmptyResultFunction : public VMFunction { |
97 |
protected: |
protected: |
98 |
virtual ~VMEmptyResultFunction() {} |
virtual ~VMEmptyResultFunction() {} |
99 |
ExprType_t returnType() OVERRIDE { return EMPTY_EXPR; } |
ExprType_t returnType(VMFnArgs* args) OVERRIDE { return EMPTY_EXPR; } |
100 |
VMFnResult* errorResult(); |
VMFnResult* errorResult(); |
101 |
VMFnResult* successResult(); |
VMFnResult* successResult(); |
102 |
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
111 |
class VMIntResultFunction : public VMFunction { |
class VMIntResultFunction : public VMFunction { |
112 |
protected: |
protected: |
113 |
virtual ~VMIntResultFunction() {} |
virtual ~VMIntResultFunction() {} |
114 |
ExprType_t returnType() OVERRIDE { return INT_EXPR; } |
ExprType_t returnType(VMFnArgs* args) OVERRIDE { return INT_EXPR; } |
115 |
VMFnResult* errorResult(vmint i = 0); |
VMFnResult* errorResult(vmint i = 0); |
116 |
VMFnResult* successResult(vmint i = 0); |
VMFnResult* successResult(vmint i = 0); |
117 |
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
126 |
class VMRealResultFunction : public VMFunction { |
class VMRealResultFunction : public VMFunction { |
127 |
protected: |
protected: |
128 |
virtual ~VMRealResultFunction() {} |
virtual ~VMRealResultFunction() {} |
129 |
ExprType_t returnType() OVERRIDE { return REAL_EXPR; } |
ExprType_t returnType(VMFnArgs* args) OVERRIDE { return REAL_EXPR; } |
130 |
VMFnResult* errorResult(vmfloat f = 0); |
VMFnResult* errorResult(vmfloat f = 0); |
131 |
VMFnResult* successResult(vmfloat f = 0); |
VMFnResult* successResult(vmfloat f = 0); |
132 |
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
141 |
class VMStringResultFunction : public VMFunction { |
class VMStringResultFunction : public VMFunction { |
142 |
protected: |
protected: |
143 |
virtual ~VMStringResultFunction() {} |
virtual ~VMStringResultFunction() {} |
144 |
ExprType_t returnType() OVERRIDE { return STRING_EXPR; } |
ExprType_t returnType(VMFnArgs* args) OVERRIDE { return STRING_EXPR; } |
145 |
VMFnResult* errorResult(const String& s = ""); |
VMFnResult* errorResult(const String& s = ""); |
146 |
VMFnResult* successResult(const String& s = ""); |
VMFnResult* successResult(const String& s = ""); |
147 |
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
149 |
VMStringResult result; |
VMStringResult result; |
150 |
}; |
}; |
151 |
|
|
152 |
|
/** |
153 |
|
* Abstract base class for built-in script functions which either return an |
154 |
|
* integer or a real number (floating point scalar) as their function return |
155 |
|
* value. The actual return type is determined at parse time once after |
156 |
|
* potential arguments were associated with the respective function call. |
157 |
|
*/ |
158 |
|
class VMScalarNumberResultFunction : public VMFunction { |
159 |
|
protected: |
160 |
|
virtual ~VMScalarNumberResultFunction() {} |
161 |
|
VMFnResult* errorResult(vmint i); |
162 |
|
VMFnResult* errorResult(vmfloat f); |
163 |
|
VMFnResult* successResult(vmint i); |
164 |
|
VMFnResult* successResult(vmfloat f); |
165 |
|
bool modifiesArg(vmint iArg) const OVERRIDE { return false; } |
166 |
|
protected: |
167 |
|
VMIntResult intResult; |
168 |
|
VMRealResult realResult; |
169 |
|
}; |
170 |
|
|
171 |
|
|
172 |
/////////////////////////////////////////////////////////////////////////// |
/////////////////////////////////////////////////////////////////////////// |
173 |
// implementations of core built-in script functions ... |
// implementations of core built-in script functions ... |
219 |
/** |
/** |
220 |
* Implements the built-in abs() script function. |
* Implements the built-in abs() script function. |
221 |
*/ |
*/ |
222 |
class CoreVMFunction_abs : public VMIntResultFunction { |
class CoreVMFunction_abs : public VMScalarNumberResultFunction { |
223 |
public: |
public: |
224 |
|
ExprType_t returnType(VMFnArgs* args) OVERRIDE; |
225 |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
vmint minRequiredArgs() const OVERRIDE { return 1; } |
226 |
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
vmint maxAllowedArgs() const OVERRIDE { return 1; } |
227 |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
318 |
/** |
/** |
319 |
* Implements the built-in min() script function. |
* Implements the built-in min() script function. |
320 |
*/ |
*/ |
321 |
class CoreVMFunction_min : public VMIntResultFunction { |
class CoreVMFunction_min : public VMScalarNumberResultFunction { |
322 |
public: |
public: |
323 |
|
ExprType_t returnType(VMFnArgs* args) OVERRIDE; |
324 |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
325 |
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
326 |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; } |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
327 |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; } |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; } |
328 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
329 |
}; |
}; |
331 |
/** |
/** |
332 |
* Implements the built-in max() script function. |
* Implements the built-in max() script function. |
333 |
*/ |
*/ |
334 |
class CoreVMFunction_max : public VMIntResultFunction { |
class CoreVMFunction_max : public VMScalarNumberResultFunction { |
335 |
public: |
public: |
336 |
|
ExprType_t returnType(VMFnArgs* args) OVERRIDE; |
337 |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
vmint minRequiredArgs() const OVERRIDE { return 2; } |
338 |
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
vmint maxAllowedArgs() const OVERRIDE { return 2; } |
339 |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; } |
bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE; |
340 |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; } |
ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; } |
341 |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
342 |
}; |
}; |