/[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 2727 by schoenebeck, Tue Mar 31 17:46:11 2015 UTC revision 2972 by schoenebeck, Fri Jul 22 14:37:34 2016 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 142  VMFnResult* CoreVMFunction_num_elements: Line 151  VMFnResult* CoreVMFunction_num_elements:
151      return successResult( args->arg(0)->asIntArray()->arraySize() );      return successResult( args->arg(0)->asIntArray()->arraySize() );
152  }  }
153    
154    ///////////////////////////////////////////////////////////////////////////
155    // built-in script function:  inc()
156    
157    VMFnResult* CoreVMFunction_inc::exec(VMFnArgs* args) {
158        VMExpr* arg = args->arg(0);
159        VMIntExpr* in = dynamic_cast<VMIntExpr*>(arg);
160        VMVariable* out = dynamic_cast<VMVariable*>(arg);
161        if (!in || !out) successResult(0);
162        int i = in->evalInt() + 1;
163        IntLiteral tmp(i);
164        out->assignExpr(&tmp);
165        return successResult(i);
166    }
167    
168    ///////////////////////////////////////////////////////////////////////////
169    // built-in script function:  dec()
170    
171    VMFnResult* CoreVMFunction_dec::exec(VMFnArgs* args) {
172        VMExpr* arg = args->arg(0);
173        VMIntExpr* in = dynamic_cast<VMIntExpr*>(arg);
174        VMVariable* out = dynamic_cast<VMVariable*>(arg);
175        if (!in || !out) successResult(0);
176        int i = in->evalInt() - 1;
177        IntLiteral tmp(i);
178        out->assignExpr(&tmp);
179        return successResult(i);
180    }
181    
182    ///////////////////////////////////////////////////////////////////////////
183    // built-in script function:  sh_left()
184    
185    VMFnResult* CoreVMFunction_sh_left::exec(VMFnArgs* args) {
186        int i = args->arg(0)->asInt()->evalInt();
187        int n = args->arg(1)->asInt()->evalInt();
188        return successResult(i << n);
189    }
190    
191    ///////////////////////////////////////////////////////////////////////////
192    // built-in script function:  sh_right()
193    
194    VMFnResult* CoreVMFunction_sh_right::exec(VMFnArgs* args) {
195        int i = args->arg(0)->asInt()->evalInt();
196        int n = args->arg(1)->asInt()->evalInt();
197        return successResult(i >> n);
198    }
199    
200    ///////////////////////////////////////////////////////////////////////////
201    // built-in script function:  min()
202    
203    VMFnResult* CoreVMFunction_min::exec(VMFnArgs* args) {
204        int l = args->arg(0)->asInt()->evalInt();
205        int r = args->arg(1)->asInt()->evalInt();
206        return successResult(l < r ? l : r);
207    }
208    
209    ///////////////////////////////////////////////////////////////////////////
210    // built-in script function:  max()
211    
212    VMFnResult* CoreVMFunction_max::exec(VMFnArgs* args) {
213        int l = args->arg(0)->asInt()->evalInt();
214        int r = args->arg(1)->asInt()->evalInt();
215        return successResult(l > r ? l : r);
216    }
217    
218  } // namespace LinuxSampler  } // namespace LinuxSampler

Legend:
Removed from v.2727  
changed lines
  Added in v.2972

  ViewVC Help
Powered by ViewVC