/[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 2581 by schoenebeck, Fri May 30 12:48:05 2014 UTC revision 2620 by schoenebeck, Wed Jun 11 13:31:27 2014 UTC
# Line 10  Line 10 
10  #include "CoreVMFunctions.h"  #include "CoreVMFunctions.h"
11    
12  #include <iostream>  #include <iostream>
13    #include <math.h>
14    #include <stdlib.h>
15  #include "tree.h"  #include "tree.h"
16  #include "ScriptVM.h"  #include "ScriptVM.h"
17    
# Line 25  VMFnResult* VMEmptyResultFunction::succe Line 27  VMFnResult* VMEmptyResultFunction::succe
27      return &result;      return &result;
28  }  }
29    
30    VMFnResult* VMIntResultFunction::errorResult(int i) {
31        result.flags = StmtFlags_t(STMT_ABORT_SIGNALLED | STMT_ERROR_OCCURRED);
32        result.value = i;
33        return &result;
34    }
35    
36    VMFnResult* VMIntResultFunction::successResult(int i) {
37        result.flags = STMT_SUCCESS;
38        result.value = i;
39        return &result;
40    }
41    
42  VMFnResult* VMStringResultFunction::errorResult(const String& s) {  VMFnResult* VMStringResultFunction::errorResult(const String& s) {
43      result.flags = StmtFlags_t(STMT_ABORT_SIGNALLED | STMT_ERROR_OCCURRED);      result.flags = StmtFlags_t(STMT_ABORT_SIGNALLED | STMT_ERROR_OCCURRED);
44      result.value = s;      result.value = s;
# Line 72  VMFnResult* CoreVMFunction_wait::exec(VM Line 86  VMFnResult* CoreVMFunction_wait::exec(VM
86      return &result;      return &result;
87  }  }
88    
89    bool CoreVMFunction_abs::acceptsArgType(int iArg, ExprType_t type) const {
90        return type == INT_EXPR;
91    }
92    
93    VMFnResult* CoreVMFunction_abs::exec(VMFnArgs* args) {
94        return successResult( ::abs(args->arg(0)->asInt()->evalInt()) );
95    }
96    
97    bool CoreVMFunction_random::acceptsArgType(int iArg, ExprType_t type) const {
98        return type == INT_EXPR;
99    }
100    
101    VMFnResult* CoreVMFunction_random::exec(VMFnArgs* args) {
102        int iMin = args->arg(0)->asInt()->evalInt();
103        int iMax = args->arg(1)->asInt()->evalInt();
104        float f = float(::rand()) / float(RAND_MAX);
105        return successResult(
106            iMin + roundf( f * float(iMax - iMin) )
107        );
108    }
109    
110    bool CoreVMFunction_num_elements::acceptsArgType(int iArg, ExprType_t type) const {
111        return type == INT_ARR_EXPR;
112    }
113    
114    VMFnResult* CoreVMFunction_num_elements::exec(VMFnArgs* args) {
115        return successResult( args->arg(0)->asIntArray()->arraySize() );
116    }
117    
118  } // namespace LinuxSampler  } // namespace LinuxSampler

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

  ViewVC Help
Powered by ViewVC