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

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

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

revision 3583 by schoenebeck, Fri Aug 30 12:23:40 2019 UTC revision 3584 by schoenebeck, Fri Aug 30 13:33:32 2019 UTC
# Line 277  VMFnResult* CoreVMFunction_exit::exec(VM Line 277  VMFnResult* CoreVMFunction_exit::exec(VM
277  ///////////////////////////////////////////////////////////////////////////  ///////////////////////////////////////////////////////////////////////////
278  // built-in script function:  wait()  // built-in script function:  wait()
279    
280    bool CoreVMFunction_wait::acceptsArgType(vmint iArg, ExprType_t type) const {
281        return type == INT_EXPR || type == REAL_EXPR;
282    }
283    
284  bool CoreVMFunction_wait::acceptsArgUnitType(vmint iArg, StdUnit_t type) const {  bool CoreVMFunction_wait::acceptsArgUnitType(vmint iArg, StdUnit_t type) const {
285      if (iArg == 0)      return type == VM_NO_UNIT || type == VM_SECOND;
         return type == VM_NO_UNIT || type == VM_SECOND;  
     else  
         return type == VM_NO_UNIT;  
286  }  }
287    
288  bool CoreVMFunction_wait::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {  bool CoreVMFunction_wait::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {
289      return iArg == 0 && type == VM_SECOND;      return type == VM_SECOND; // only allow metric prefix(es) if 'seconds' is used as unit type
290  }  }
291    
292  VMFnResult* CoreVMFunction_wait::exec(VMFnArgs* args) {  VMFnResult* CoreVMFunction_wait::exec(VMFnArgs* args) {
293      ExecContext* ctx = dynamic_cast<ExecContext*>(vm->currentVMExecContext());      ExecContext* ctx = dynamic_cast<ExecContext*>(vm->currentVMExecContext());
294      VMIntExpr* expr = dynamic_cast<VMIntExpr*>(args->arg(0));      VMNumberExpr* expr = args->arg(0)->asNumber();
295      StdUnit_t unit = expr->unitType();      StdUnit_t unit = expr->unitType();
296      vmint us = (unit) ? expr->evalInt(VM_MICRO) : expr->evalInt();      vmint us = (unit) ? expr->evalCastInt(VM_MICRO) : expr->evalCastInt();
297      if (us < 0) {      if (us < 0) {
298          wrnMsg("wait(): argument may not be negative! Aborting script!");          wrnMsg("wait(): argument may not be negative! Aborting script!");
299          this->result.flags = STMT_ABORT_SIGNALLED;          this->result.flags = STMT_ABORT_SIGNALLED;

Legend:
Removed from v.3583  
changed lines
  Added in v.3584

  ViewVC Help
Powered by ViewVC