/[svn]/linuxsampler/trunk/src/ls_instr_script.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/ls_instr_script.cpp

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

revision 2581 by schoenebeck, Fri May 30 12:48:05 2014 UTC revision 2588 by schoenebeck, Sun Jun 1 14:44:38 2014 UTC
# Line 30  Line 30 
30  using namespace LinuxSampler;  using namespace LinuxSampler;
31    
32  int main() {  int main() {
33      ScriptVM script;      ScriptVM vm;
34      script.loadScript(&std::cin);      VMParserContext* parserContext = vm.loadScript(&std::cin);
35    
36      std::vector<ParserIssue> errors = script.errors();      std::vector<ParserIssue> errors = parserContext->errors();
37      std::vector<ParserIssue> warnings = script.warnings();      std::vector<ParserIssue> warnings = parserContext->warnings();
38      std::vector<ParserIssue> issues = script.issues();      std::vector<ParserIssue> issues = parserContext->issues();
39      if (warnings.empty() && errors.empty()) {      if (warnings.empty() && errors.empty()) {
40          CFmt fmt; fmt.green();          CFmt fmt; fmt.green();
41          printf("EOF. Script parse completed successfully (no errors, no warnings).\n");          printf("EOF. Script parse completed successfully (no errors, no warnings).\n");
# Line 56  int main() { Line 56  int main() {
56      }      }
57    
58      printf("[Dumping parsed VM tree]\n");      printf("[Dumping parsed VM tree]\n");
59      script.dumpParsedScript();      vm.dumpParsedScript(parserContext);
60      printf("[End of parsed VM tree]\n");      printf("[End of parsed VM tree]\n");
61    
62      if (!errors.empty()) return -1;      if (!errors.empty()) {
63            if (parserContext) delete parserContext;
64            return -1;
65        }
66    
67      if (!script.eventHandler(0)) {      if (!parserContext->eventHandler(0)) {
68          printf("No event handler exists. So nothing to execute.\n");          printf("No event handler exists. So nothing to execute.\n");
69            if (parserContext) delete parserContext;
70          return 0;          return 0;
71      }      }
72    
73      printf("Preparing execution of script.\n");      printf("Preparing execution of script.\n");
74      VMExecContext* ctx = script.createExecContext();      VMExecContext* execContext = vm.createExecContext(parserContext);
75      for (int i = 0; script.eventHandler(i); ++i) {      for (int i = 0; parserContext->eventHandler(i); ++i) {
76          VMEventHandler* handler = script.eventHandler(i);          VMEventHandler* handler = parserContext->eventHandler(i);
77          printf("[Running event handler '%s']\n", handler->eventHandlerName().c_str());          printf("[Running event handler '%s']\n", handler->eventHandlerName().c_str());
78          VMExecStatus_t result = script.exec(handler, ctx);          VMExecStatus_t result = vm.exec(parserContext, execContext, handler);
79          CFmt fmt;          CFmt fmt;
80          if (result & VM_EXEC_ERROR) {          if (result & VM_EXEC_ERROR) {
81              fmt.red();              fmt.red();
# Line 79  int main() { Line 83  int main() {
83          } else if (result & VM_EXEC_SUSPENDED) {          } else if (result & VM_EXEC_SUSPENDED) {
84              fmt.yellow();              fmt.yellow();
85              printf("[Event handler '%s' returned with SUSPENDED status: %d microseconds]\n",              printf("[Event handler '%s' returned with SUSPENDED status: %d microseconds]\n",
86                     handler->eventHandlerName().c_str(), ctx->suspensionTimeMicroseconds());                     handler->eventHandlerName().c_str(), execContext->suspensionTimeMicroseconds());
87          } else if (!(result & VM_EXEC_RUNNING)) {          } else if (!(result & VM_EXEC_RUNNING)) {
88              fmt.green();              fmt.green();
89              printf("[Event handler '%s' finished with SUCCESS status]\n", handler->eventHandlerName().c_str());              printf("[Event handler '%s' finished with SUCCESS status]\n", handler->eventHandlerName().c_str());
# Line 91  int main() { Line 95  int main() {
95              printf("[Event handler '%s' finished with UNKNOWN status]\n", handler->eventHandlerName().c_str());              printf("[Event handler '%s' finished with UNKNOWN status]\n", handler->eventHandlerName().c_str());
96          }          }
97      }      }
98      if (ctx) delete ctx;      if (parserContext) delete parserContext;
99        if (execContext) delete execContext;
100    
101      return 0;      return 0;
102  }  }

Legend:
Removed from v.2581  
changed lines
  Added in v.2588

  ViewVC Help
Powered by ViewVC