/[svn]/linuxsampler/trunk/src/scriptvm/ScriptVM.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/scriptvm/ScriptVM.cpp

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

revision 2879 by schoenebeck, Tue Apr 19 14:07:53 2016 UTC revision 2885 by schoenebeck, Fri Apr 22 15:37:45 2016 UTC
# Line 13  Line 13 
13  #include <assert.h>  #include <assert.h>
14  #include "../common/global_private.h"  #include "../common/global_private.h"
15  #include "tree.h"  #include "tree.h"
16    #include "CoreVMFunctions.h"
17    #include "editor/NkspScanner.h"
18    
19  #define DEBUG_SCRIPTVM_CORE 0  #define DEBUG_SCRIPTVM_CORE 0
20    
# Line 89  namespace LinuxSampler { Line 91  namespace LinuxSampler {
91          return max;          return max;
92      }      }
93    
94      ScriptVM::ScriptVM() : m_eventHandler(NULL), m_parserContext(NULL), fnWait(this) {      ScriptVM::ScriptVM() : m_eventHandler(NULL), m_parserContext(NULL) {
95            m_fnMessage = new CoreVMFunction_message;
96            m_fnExit = new CoreVMFunction_exit;
97            m_fnWait = new CoreVMFunction_wait(this);
98            m_fnAbs = new CoreVMFunction_abs;
99            m_fnRandom = new CoreVMFunction_random;
100            m_fnNumElements = new CoreVMFunction_num_elements;
101      }      }
102    
103      ScriptVM::~ScriptVM() {      ScriptVM::~ScriptVM() {
104            delete m_fnMessage;
105            delete m_fnExit;
106            delete m_fnWait;
107            delete m_fnAbs;
108            delete m_fnRandom;
109            delete m_fnNumElements;
110      }      }
111    
112      VMParserContext* ScriptVM::loadScript(const String& s) {      VMParserContext* ScriptVM::loadScript(const String& s) {
# Line 164  namespace LinuxSampler { Line 178  namespace LinuxSampler {
178          return execCtx;          return execCtx;
179      }      }
180    
181        std::vector<VMSourceToken> ScriptVM::syntaxHighlighting(const String& s) {
182            std::istringstream iss(s);
183            return syntaxHighlighting(&iss);
184        }
185    
186        std::vector<VMSourceToken> ScriptVM::syntaxHighlighting(std::istream* is) {
187            NkspScanner scanner(is);
188            std::vector<SourceToken> tokens = scanner.tokens();
189            std::vector<VMSourceToken> result;
190            result.resize(tokens.size());
191            for (int i = 0; i < tokens.size(); ++i) {
192                SourceToken* st = new SourceToken;
193                *st = tokens[i];
194                result[i] = VMSourceToken(st);
195            }
196            return result;
197        }
198    
199      VMFunction* ScriptVM::functionByName(const String& name) {      VMFunction* ScriptVM::functionByName(const String& name) {
200          if (name == "message") return &fnMessage;          if (name == "message") return m_fnMessage;
201          else if (name == "exit") return &fnExit;          else if (name == "exit") return m_fnExit;
202          else if (name == "wait") return &fnWait;          else if (name == "wait") return m_fnWait;
203          else if (name == "abs") return &fnAbs;          else if (name == "abs") return m_fnAbs;
204          else if (name == "random") return &fnRandom;          else if (name == "random") return m_fnRandom;
205          else if (name == "num_elements") return &fnNumElements;          else if (name == "num_elements") return m_fnNumElements;
206          return NULL;          return NULL;
207      }      }
208    

Legend:
Removed from v.2879  
changed lines
  Added in v.2885

  ViewVC Help
Powered by ViewVC