/[svn]/linuxsampler/trunk/src/scriptvm/CoreVMFunctions.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/scriptvm/CoreVMFunctions.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3076 by schoenebeck, Thu Jan 5 18:00:52 2017 UTC revision 3557 by schoenebeck, Sun Aug 18 00:06:04 2019 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (c) 2014-2016 Christian Schoenebeck   * Copyright (c) 2014-2019 Christian Schoenebeck
3   *   *
4   * http://www.linuxsampler.org   * http://www.linuxsampler.org
5   *   *
# Line 42  public: Line 42  public:
42  class VMIntResult : public VMFnResult, public VMIntExpr {  class VMIntResult : 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      int value; ///< result value of the function call      vmint value; ///< result value of the function call
46    
47      VMIntResult() : flags(STMT_SUCCESS) {}      VMIntResult() : flags(STMT_SUCCESS) {}
48      int evalInt() OVERRIDE { return value; }      vmint evalInt() OVERRIDE { return value; }
49      VMExpr* resultValue() OVERRIDE { return this; }      VMExpr* resultValue() OVERRIDE { return this; }
50      StmtFlags_t resultFlags() OVERRIDE { return flags; }      StmtFlags_t resultFlags() OVERRIDE { return flags; }
51      bool isConstExpr() const OVERRIDE { return false; }      bool isConstExpr() const OVERRIDE { return false; }
# Line 77  protected: Line 77  protected:
77      ExprType_t returnType() OVERRIDE { return EMPTY_EXPR; }      ExprType_t returnType() OVERRIDE { return EMPTY_EXPR; }
78      VMFnResult* errorResult();      VMFnResult* errorResult();
79      VMFnResult* successResult();      VMFnResult* successResult();
80      bool modifiesArg(int iArg) const OVERRIDE { return false; }      bool modifiesArg(vmint iArg) const OVERRIDE { return false; }
81  protected:  protected:
82      VMEmptyResult result;      VMEmptyResult result;
83  };  };
# Line 90  class VMIntResultFunction : public VMFun Line 90  class VMIntResultFunction : public VMFun
90  protected:  protected:
91      virtual ~VMIntResultFunction() {}      virtual ~VMIntResultFunction() {}
92      ExprType_t returnType() OVERRIDE { return INT_EXPR; }      ExprType_t returnType() OVERRIDE { return INT_EXPR; }
93      VMFnResult* errorResult(int i = 0);      VMFnResult* errorResult(vmint i = 0);
94      VMFnResult* successResult(int i = 0);      VMFnResult* successResult(vmint i = 0);
95      bool modifiesArg(int iArg) const OVERRIDE { return false; }      bool modifiesArg(vmint iArg) const OVERRIDE { return false; }
96  protected:  protected:
97      VMIntResult result;      VMIntResult result;
98  };  };
# Line 107  protected: Line 107  protected:
107      ExprType_t returnType() OVERRIDE { return STRING_EXPR; }      ExprType_t returnType() OVERRIDE { return STRING_EXPR; }
108      VMFnResult* errorResult(const String& s = "");      VMFnResult* errorResult(const String& s = "");
109      VMFnResult* successResult(const String& s = "");      VMFnResult* successResult(const String& s = "");
110      bool modifiesArg(int iArg) const OVERRIDE { return false; }      bool modifiesArg(vmint iArg) const OVERRIDE { return false; }
111  protected:  protected:
112      VMStringResult result;      VMStringResult result;
113  };  };
# Line 121  protected: Line 121  protected:
121   */   */
122  class CoreVMFunction_message : public VMEmptyResultFunction {  class CoreVMFunction_message : public VMEmptyResultFunction {
123  public:  public:
124      int minRequiredArgs() const { return 1; }      vmint minRequiredArgs() const OVERRIDE { return 1; }
125      int maxAllowedArgs() const { return 1; }      vmint maxAllowedArgs() const OVERRIDE { return 1; }
126      bool acceptsArgType(int iArg, ExprType_t type) const;      bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE;
127      ExprType_t argType(int iArg) const { return STRING_EXPR; }      ExprType_t argType(vmint iArg) const OVERRIDE { return STRING_EXPR; }
128      VMFnResult* exec(VMFnArgs* args);      VMFnResult* exec(VMFnArgs* args) OVERRIDE;
129  };  };
130    
131  /**  /**
# Line 133  public: Line 133  public:
133   */   */
134  class CoreVMFunction_exit : public VMEmptyResultFunction {  class CoreVMFunction_exit : public VMEmptyResultFunction {
135  public:  public:
136      int minRequiredArgs() const { return 0; }      CoreVMFunction_exit(ScriptVM* vm) : vm(vm) {}
137      int maxAllowedArgs() const { return 0; }      vmint minRequiredArgs() const OVERRIDE { return 0; }
138      bool acceptsArgType(int iArg, ExprType_t type) const { return false; }      vmint maxAllowedArgs() const OVERRIDE;
139      ExprType_t argType(int iArg) const { return INT_EXPR; /*whatever*/ }      bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE;
140      VMFnResult* exec(VMFnArgs* args);      ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; }
141        VMFnResult* exec(VMFnArgs* args) OVERRIDE;
142    protected:
143        ScriptVM* vm;
144  };  };
145    
146  /**  /**
# Line 146  public: Line 149  public:
149  class CoreVMFunction_wait : public VMEmptyResultFunction {  class CoreVMFunction_wait : public VMEmptyResultFunction {
150  public:  public:
151      CoreVMFunction_wait(ScriptVM* vm) : vm(vm) {}      CoreVMFunction_wait(ScriptVM* vm) : vm(vm) {}
152      int minRequiredArgs() const { return 1; }      vmint minRequiredArgs() const OVERRIDE { return 1; }
153      int maxAllowedArgs() const { return 1; }      vmint maxAllowedArgs() const OVERRIDE { return 1; }
154      bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR; }      bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; }
155      ExprType_t argType(int iArg) const { return INT_EXPR; }      ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; }
156      VMFnResult* exec(VMFnArgs* args);      VMFnResult* exec(VMFnArgs* args) OVERRIDE;
157  protected:  protected:
158      ScriptVM* vm;      ScriptVM* vm;
159  };  };
# Line 160  protected: Line 163  protected:
163   */   */
164  class CoreVMFunction_abs : public VMIntResultFunction {  class CoreVMFunction_abs : public VMIntResultFunction {
165  public:  public:
166      int minRequiredArgs() const { return 1; }      vmint minRequiredArgs() const OVERRIDE { return 1; }
167      int maxAllowedArgs() const { return 1; }      vmint maxAllowedArgs() const OVERRIDE { return 1; }
168      bool acceptsArgType(int iArg, ExprType_t type) const;      bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE;
169      ExprType_t argType(int iArg) const { return INT_EXPR; }      ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; }
170      VMFnResult* exec(VMFnArgs* args);      VMFnResult* exec(VMFnArgs* args) OVERRIDE;
171  };  };
172    
173  /**  /**
# Line 172  public: Line 175  public:
175   */   */
176  class CoreVMFunction_random : public VMIntResultFunction {  class CoreVMFunction_random : public VMIntResultFunction {
177  public:  public:
178      int minRequiredArgs() const { return 2; }      vmint minRequiredArgs() const OVERRIDE { return 2; }
179      int maxAllowedArgs() const { return 2; }      vmint maxAllowedArgs() const OVERRIDE { return 2; }
180      bool acceptsArgType(int iArg, ExprType_t type) const;      bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE;
181      ExprType_t argType(int iArg) const { return INT_EXPR; }      ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; }
182      VMFnResult* exec(VMFnArgs* args);      VMFnResult* exec(VMFnArgs* args) OVERRIDE;
183  };  };
184    
185  /**  /**
# Line 184  public: Line 187  public:
187   */   */
188  class CoreVMFunction_num_elements : public VMIntResultFunction {  class CoreVMFunction_num_elements : public VMIntResultFunction {
189  public:  public:
190      int minRequiredArgs() const { return 1; }      vmint minRequiredArgs() const OVERRIDE { return 1; }
191      int maxAllowedArgs() const { return 1; }      vmint maxAllowedArgs() const OVERRIDE { return 1; }
192      bool acceptsArgType(int iArg, ExprType_t type) const;      bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE;
193      ExprType_t argType(int iArg) const { return INT_ARR_EXPR; }      ExprType_t argType(vmint iArg) const OVERRIDE { return INT_ARR_EXPR; }
194      VMFnResult* exec(VMFnArgs* args);      VMFnResult* exec(VMFnArgs* args) OVERRIDE;
195  };  };
196    
197  /**  /**
# Line 196  public: Line 199  public:
199   */   */
200  class CoreVMFunction_inc : public VMIntResultFunction {  class CoreVMFunction_inc : public VMIntResultFunction {
201  public:  public:
202      int minRequiredArgs() const { return 1; }      vmint minRequiredArgs() const OVERRIDE { return 1; }
203      int maxAllowedArgs() const { return 1; }      vmint maxAllowedArgs() const OVERRIDE { return 1; }
204      bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR; }      bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; }
205      ExprType_t argType(int iArg) const { return INT_EXPR; }      ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; }
206      bool modifiesArg(int iArg) const { return true; }      bool modifiesArg(vmint iArg) const OVERRIDE { return true; }
207      VMFnResult* exec(VMFnArgs* args);      VMFnResult* exec(VMFnArgs* args) OVERRIDE;
208  };  };
209    
210  /**  /**
# Line 209  public: Line 212  public:
212   */   */
213  class CoreVMFunction_dec : public VMIntResultFunction {  class CoreVMFunction_dec : public VMIntResultFunction {
214  public:  public:
215      int minRequiredArgs() const { return 1; }      vmint minRequiredArgs() const OVERRIDE { return 1; }
216      int maxAllowedArgs() const { return 1; }      vmint maxAllowedArgs() const OVERRIDE { return 1; }
217      bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR; }      bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; }
218      ExprType_t argType(int iArg) const { return INT_EXPR; }      ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; }
219      bool modifiesArg(int iArg) const { return true; }      bool modifiesArg(vmint iArg) const OVERRIDE { return true; }
220      VMFnResult* exec(VMFnArgs* args);      VMFnResult* exec(VMFnArgs* args) OVERRIDE;
221  };  };
222    
223  /**  /**
# Line 222  public: Line 225  public:
225   */   */
226  class CoreVMFunction_in_range : public VMIntResultFunction {  class CoreVMFunction_in_range : public VMIntResultFunction {
227  public:  public:
228      int minRequiredArgs() const { return 3; }      vmint minRequiredArgs() const OVERRIDE { return 3; }
229      int maxAllowedArgs() const { return 3; }      vmint maxAllowedArgs() const OVERRIDE { return 3; }
230      bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR; }      bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; }
231      ExprType_t argType(int iArg) const { return INT_EXPR; }      ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; }
232      VMFnResult* exec(VMFnArgs* args);      VMFnResult* exec(VMFnArgs* args) OVERRIDE;
233  };  };
234    
235  /**  /**
# Line 234  public: Line 237  public:
237   */   */
238  class CoreVMFunction_sh_left : public VMIntResultFunction {  class CoreVMFunction_sh_left : public VMIntResultFunction {
239  public:  public:
240      int minRequiredArgs() const { return 2; }      vmint minRequiredArgs() const OVERRIDE { return 2; }
241      int maxAllowedArgs() const { return 2; }      vmint maxAllowedArgs() const OVERRIDE { return 2; }
242      bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR; }      bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; }
243      ExprType_t argType(int iArg) const { return INT_EXPR; }      ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; }
244      VMFnResult* exec(VMFnArgs* args);      VMFnResult* exec(VMFnArgs* args) OVERRIDE;
245  };  };
246    
247  /**  /**
# Line 246  public: Line 249  public:
249   */   */
250  class CoreVMFunction_sh_right : public VMIntResultFunction {  class CoreVMFunction_sh_right : public VMIntResultFunction {
251  public:  public:
252      int minRequiredArgs() const { return 2; }      vmint minRequiredArgs() const OVERRIDE { return 2; }
253      int maxAllowedArgs() const { return 2; }      vmint maxAllowedArgs() const OVERRIDE { return 2; }
254      bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR; }      bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; }
255      ExprType_t argType(int iArg) const { return INT_EXPR; }      ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; }
256      VMFnResult* exec(VMFnArgs* args);      VMFnResult* exec(VMFnArgs* args) OVERRIDE;
257  };  };
258    
259  /**  /**
# Line 258  public: Line 261  public:
261   */   */
262  class CoreVMFunction_min : public VMIntResultFunction {  class CoreVMFunction_min : public VMIntResultFunction {
263  public:  public:
264      int minRequiredArgs() const { return 2; }      vmint minRequiredArgs() const OVERRIDE { return 2; }
265      int maxAllowedArgs() const { return 2; }      vmint maxAllowedArgs() const OVERRIDE { return 2; }
266      bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR; }      bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; }
267      ExprType_t argType(int iArg) const { return INT_EXPR; }      ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; }
268      VMFnResult* exec(VMFnArgs* args);      VMFnResult* exec(VMFnArgs* args) OVERRIDE;
269  };  };
270    
271  /**  /**
# Line 270  public: Line 273  public:
273   */   */
274  class CoreVMFunction_max : public VMIntResultFunction {  class CoreVMFunction_max : public VMIntResultFunction {
275  public:  public:
276      int minRequiredArgs() const { return 2; }      vmint minRequiredArgs() const OVERRIDE { return 2; }
277      int maxAllowedArgs() const { return 2; }      vmint maxAllowedArgs() const OVERRIDE { return 2; }
278      bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR; }      bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; }
279      ExprType_t argType(int iArg) const { return INT_EXPR; }      ExprType_t argType(vmint iArg) const OVERRIDE { return INT_EXPR; }
280      VMFnResult* exec(VMFnArgs* args);      VMFnResult* exec(VMFnArgs* args) OVERRIDE;
281    };
282    
283    /**
284     * Implements the built-in array_equal() script function.
285     */
286    class CoreVMFunction_array_equal : public VMIntResultFunction {
287    public:
288        vmint minRequiredArgs() const OVERRIDE { return 2; }
289        vmint maxAllowedArgs() const OVERRIDE { return 2; }
290        bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_ARR_EXPR; }
291        ExprType_t argType(vmint iArg) const OVERRIDE { return INT_ARR_EXPR; }
292        VMFnResult* exec(VMFnArgs* args) OVERRIDE;
293    };
294    
295    /**
296     * Implements the built-in search() script function.
297     */
298    class CoreVMFunction_search : public VMIntResultFunction {
299    public:
300        vmint minRequiredArgs() const OVERRIDE { return 2; }
301        vmint maxAllowedArgs() const OVERRIDE { return 2; }
302        bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE;
303        ExprType_t argType(vmint iArg) const OVERRIDE;
304        VMFnResult* exec(VMFnArgs* args) OVERRIDE;
305    };
306    
307    /**
308     * Implements the built-in sort() script function.
309     */
310    class CoreVMFunction_sort : public VMEmptyResultFunction {
311    public:
312        vmint minRequiredArgs() const OVERRIDE { return 1; }
313        vmint maxAllowedArgs() const OVERRIDE { return 2; }
314        bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE;
315        ExprType_t argType(vmint iArg) const OVERRIDE;
316        bool modifiesArg(vmint iArg) const OVERRIDE { return iArg == 0; }
317        VMFnResult* exec(VMFnArgs* args) OVERRIDE;
318  };  };
319    
320  } // namespace LinuxSampler  } // namespace LinuxSampler

Legend:
Removed from v.3076  
changed lines
  Added in v.3557

  ViewVC Help
Powered by ViewVC