/[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 3221 by schoenebeck, Fri May 26 18:30:42 2017 UTC revision 3311 by schoenebeck, Sat Jul 15 16:24:59 2017 UTC
# Line 117  namespace LinuxSampler { Line 117  namespace LinuxSampler {
117                  else                  else
118                      return 1;                      return 1;
119              }              }
120    
121                case STMT_SYNC: {
122                    #if DEBUG_SCRIPTVM_CORE
123                    _printIndents(depth);
124                    printf("-> STMT_SYNC\n");
125                    #endif
126                    SyncBlock* syncStmt = (SyncBlock*) statement;
127                    if (syncStmt->statements())
128                        return _requiredMaxStackSizeFor( syncStmt->statements() ) + 1;
129                    else
130                        return 1;
131                }
132          }          }
133    
134          return 1; // actually just to avoid compiler warning          return 1; // actually just to avoid compiler warning
# Line 281  namespace LinuxSampler { Line 293  namespace LinuxSampler {
293          return NULL;          return NULL;
294      }      }
295    
296        bool ScriptVM::isFunctionDisabled(VMFunction* fn, VMParserContext* ctx) {
297            ParserContext* parserCtx = dynamic_cast<ParserContext*>(ctx);
298            if (!parserCtx) return false;
299    
300            if (fn == m_fnMessage && parserCtx->userPreprocessorConditions.count("NKSP_NO_MESSAGE"))
301                return true;
302    
303            return false;
304        }
305    
306      std::map<String,VMIntRelPtr*> ScriptVM::builtInIntVariables() {      std::map<String,VMIntRelPtr*> ScriptVM::builtInIntVariables() {
307          return std::map<String,VMIntRelPtr*>();          return std::map<String,VMIntRelPtr*>();
308      }      }
# Line 354  namespace LinuxSampler { Line 376  namespace LinuxSampler {
376    
377          ctx->status = VM_EXEC_RUNNING;          ctx->status = VM_EXEC_RUNNING;
378          ctx->instructionsCount = 0;          ctx->instructionsCount = 0;
379          StmtFlags_t flags = STMT_SUCCESS;          StmtFlags_t& flags = ctx->flags;
380          int instructionsCounter = 0;          int instructionsCounter = 0;
381            int synced = m_autoSuspend ? 0 : 1;
382    
383          int& frameIdx = ctx->stackFrame;          int& frameIdx = ctx->stackFrame;
384          if (frameIdx < 0) { // start condition ...          if (frameIdx < 0) { // start condition ...
# Line 432  namespace LinuxSampler { Line 455  namespace LinuxSampler {
455                          ctx->pushStack(                          ctx->pushStack(
456                              whileStmt->statements()                              whileStmt->statements()
457                          );                          );
458                          if (flags == STMT_SUCCESS && m_autoSuspend &&                          if (flags == STMT_SUCCESS && !synced &&
459                              instructionsCounter > SCRIPTVM_MAX_INSTR_PER_CYCLE_SOFT)                              instructionsCounter > SCRIPTVM_MAX_INSTR_PER_CYCLE_SOFT)
460                          {                          {
461                              flags = StmtFlags_t(STMT_SUSPEND_SIGNALLED);                              flags = StmtFlags_t(STMT_SUSPEND_SIGNALLED);
# Line 441  namespace LinuxSampler { Line 464  namespace LinuxSampler {
464                      } else ctx->popStack();                      } else ctx->popStack();
465                      break;                      break;
466                  }                  }
467    
468                    case STMT_SYNC: {
469                        #if DEBUG_SCRIPTVM_CORE
470                        _printIndents(frameIdx);
471                        printf("-> STMT_SYNC\n");
472                        #endif
473                        SyncBlock* syncStmt = (SyncBlock*) frame.statement;
474                        if (!frame.subindex++ && syncStmt->statements()) {
475                            ++synced;
476                            ctx->pushStack(
477                                syncStmt->statements()
478                            );
479                        } else {
480                            ctx->popStack();
481                            --synced;
482                        }
483                        break;
484                    }
485              }              }
486    
487              if (flags == STMT_SUCCESS && m_autoSuspend &&              if (flags == STMT_SUCCESS && !synced &&
488                  instructionsCounter > SCRIPTVM_MAX_INSTR_PER_CYCLE_HARD)                  instructionsCounter > SCRIPTVM_MAX_INSTR_PER_CYCLE_HARD)
489              {              {
490                  flags = StmtFlags_t(STMT_SUSPEND_SIGNALLED);                  flags = StmtFlags_t(STMT_SUSPEND_SIGNALLED);
# Line 453  namespace LinuxSampler { Line 494  namespace LinuxSampler {
494              ++instructionsCounter;              ++instructionsCounter;
495          }          }
496    
497          if (flags & STMT_SUSPEND_SIGNALLED) {          if ((flags & STMT_SUSPEND_SIGNALLED) && !(flags & STMT_ABORT_SIGNALLED)) {
498              ctx->status = VM_EXEC_SUSPENDED;              ctx->status = VM_EXEC_SUSPENDED;
499                ctx->flags  = STMT_SUCCESS;
500          } else {          } else {
501              ctx->status = VM_EXEC_NOT_RUNNING;              ctx->status = VM_EXEC_NOT_RUNNING;
502              if (flags & STMT_ERROR_OCCURRED)              if (flags & STMT_ERROR_OCCURRED)

Legend:
Removed from v.3221  
changed lines
  Added in v.3311

  ViewVC Help
Powered by ViewVC