/[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 2945 by schoenebeck, Thu Jul 14 00:22:26 2016 UTC revision 3076 by schoenebeck, Thu Jan 5 18:00:52 2017 UTC
# Line 99  VMFnResult* CoreVMFunction_exit::exec(VM Line 99  VMFnResult* CoreVMFunction_exit::exec(VM
99  VMFnResult* CoreVMFunction_wait::exec(VMFnArgs* args) {  VMFnResult* CoreVMFunction_wait::exec(VMFnArgs* args) {
100      ExecContext* ctx = dynamic_cast<ExecContext*>(vm->currentVMExecContext());      ExecContext* ctx = dynamic_cast<ExecContext*>(vm->currentVMExecContext());
101      VMIntExpr* expr = dynamic_cast<VMIntExpr*>(args->arg(0));      VMIntExpr* expr = dynamic_cast<VMIntExpr*>(args->arg(0));
102      ctx->suspendMicroseconds = expr->evalInt();      int us = expr->evalInt();
103      this->result.flags = STMT_SUSPEND_SIGNALLED;      if (us < 0) {
104            wrnMsg("wait(): argument may not be negative! Aborting script!");
105            this->result.flags = STMT_ABORT_SIGNALLED;
106        } else if (us == 0) {
107            wrnMsg("wait(): argument may not be zero! Aborting script!");
108            this->result.flags = STMT_ABORT_SIGNALLED;
109        } else {
110            ctx->suspendMicroseconds = us;
111            this->result.flags = STMT_SUSPEND_SIGNALLED;
112        }
113      return &result;      return &result;
114  }  }
115    
# Line 170  VMFnResult* CoreVMFunction_dec::exec(VMF Line 179  VMFnResult* CoreVMFunction_dec::exec(VMF
179      return successResult(i);      return successResult(i);
180  }  }
181    
182    ///////////////////////////////////////////////////////////////////////////
183    // built-in script function:  in_range()
184    
185    VMFnResult* CoreVMFunction_in_range::exec(VMFnArgs* args) {
186        int i  = args->arg(0)->asInt()->evalInt();
187        int lo = args->arg(1)->asInt()->evalInt();
188        int hi = args->arg(2)->asInt()->evalInt();
189        if (lo > hi) { // swap lo and hi
190            int tmp = lo;
191            lo = hi;
192            hi = tmp;
193        }
194        return successResult(i >= lo && i <= hi);
195    }
196    
197    ///////////////////////////////////////////////////////////////////////////
198    // built-in script function:  sh_left()
199    
200    VMFnResult* CoreVMFunction_sh_left::exec(VMFnArgs* args) {
201        int i = args->arg(0)->asInt()->evalInt();
202        int n = args->arg(1)->asInt()->evalInt();
203        return successResult(i << n);
204    }
205    
206    ///////////////////////////////////////////////////////////////////////////
207    // built-in script function:  sh_right()
208    
209    VMFnResult* CoreVMFunction_sh_right::exec(VMFnArgs* args) {
210        int i = args->arg(0)->asInt()->evalInt();
211        int n = args->arg(1)->asInt()->evalInt();
212        return successResult(i >> n);
213    }
214    
215    ///////////////////////////////////////////////////////////////////////////
216    // built-in script function:  min()
217    
218    VMFnResult* CoreVMFunction_min::exec(VMFnArgs* args) {
219        int l = args->arg(0)->asInt()->evalInt();
220        int r = args->arg(1)->asInt()->evalInt();
221        return successResult(l < r ? l : r);
222    }
223    
224    ///////////////////////////////////////////////////////////////////////////
225    // built-in script function:  max()
226    
227    VMFnResult* CoreVMFunction_max::exec(VMFnArgs* args) {
228        int l = args->arg(0)->asInt()->evalInt();
229        int r = args->arg(1)->asInt()->evalInt();
230        return successResult(l > r ? l : r);
231    }
232    
233  } // namespace LinuxSampler  } // namespace LinuxSampler

Legend:
Removed from v.2945  
changed lines
  Added in v.3076

  ViewVC Help
Powered by ViewVC