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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2581 - (hide annotations) (download) (as text)
Fri May 30 12:48:05 2014 UTC (9 years, 10 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 2566 byte(s)
* (WIP) Implemented parser and VM for upcoming new real-time instrument
  script support. It needs yet to be integrated into the sampler's
  sampler engines. You can toy around for now with the command line tool
  "ls_instr_script" and i.e. examples showing the core language features
  under src/scriptvm/examples/.
* Bumped version (1.0.0.svn41).

1 schoenebeck 2581 /*
2     * Copyright (c) 2014 Christian Schoenebeck
3     *
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    
20     class VMEmptyResult : public VMFnResult, public VMExpr {
21     public:
22     StmtFlags_t flags;
23    
24     VMEmptyResult() : flags(STMT_SUCCESS) {}
25     ExprType_t exprType() const { return EMPTY_EXPR; }
26     VMExpr* resultValue() { return this; }
27     StmtFlags_t resultFlags() { return flags; }
28     };
29    
30     class VMStringResult : public VMFnResult, public VMStringExpr {
31     public:
32     StmtFlags_t flags;
33     String value;
34    
35     VMStringResult() : flags(STMT_SUCCESS) {}
36     String evalStr() { return value; }
37     VMExpr* resultValue() { return this; }
38     StmtFlags_t resultFlags() { return flags; }
39     };
40    
41     class VMEmptyResultFunction : public VMFunction {
42     protected:
43     ExprType_t returnType() { return EMPTY_EXPR; }
44     VMFnResult* errorResult();
45     VMFnResult* successResult();
46     protected:
47     VMEmptyResult result;
48     };
49    
50     class VMStringResultFunction : public VMFunction {
51     protected:
52     ExprType_t returnType() { return STRING_EXPR; }
53     VMFnResult* errorResult(const String& s = "");
54     VMFnResult* successResult(const String& s = "");
55     protected:
56     VMStringResult result;
57     };
58    
59     class CoreVMFunction_message : public VMEmptyResultFunction {
60     public:
61     int minRequiredArgs() const { return 1; }
62     int maxAllowedArgs() const { return 1; }
63     bool acceptsArgType(int iArg, ExprType_t type) const;
64     ExprType_t argType(int iArg) const { return STRING_EXPR; }
65     VMFnResult* exec(VMFnArgs* args);
66     };
67    
68     class CoreVMFunction_exit : public VMEmptyResultFunction {
69     public:
70     int minRequiredArgs() const { return 0; }
71     int maxAllowedArgs() const { return 0; }
72     bool acceptsArgType(int iArg, ExprType_t type) const { return false; }
73     ExprType_t argType(int iArg) const { return INT_EXPR; /*whatever*/ }
74     VMFnResult* exec(VMFnArgs* args);
75     };
76    
77     class CoreVMFunction_wait : public VMEmptyResultFunction {
78     public:
79     CoreVMFunction_wait(ScriptVM* vm) : vm(vm) {}
80     int minRequiredArgs() const { return 1; }
81     int maxAllowedArgs() const { return 1; }
82     bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR; }
83     ExprType_t argType(int iArg) const { return INT_EXPR; }
84     VMFnResult* exec(VMFnArgs* args);
85     protected:
86     ScriptVM* vm;
87     };
88    
89     } // namespace LinuxSampler
90    
91     #endif // LS_COREVMFUNCTIONS_H

  ViewVC Help
Powered by ViewVC