48 |
} |
} |
49 |
|
|
50 |
/////////////////////////////////////////////////////////////////////////// |
/////////////////////////////////////////////////////////////////////////// |
51 |
|
// class VMRealResultFunction |
52 |
|
|
53 |
|
VMFnResult* VMRealResultFunction::errorResult(vmfloat f) { |
54 |
|
result.flags = StmtFlags_t(STMT_ABORT_SIGNALLED | STMT_ERROR_OCCURRED); |
55 |
|
result.value = f; |
56 |
|
return &result; |
57 |
|
} |
58 |
|
|
59 |
|
VMFnResult* VMRealResultFunction::successResult(vmfloat f) { |
60 |
|
result.flags = STMT_SUCCESS; |
61 |
|
result.value = f; |
62 |
|
return &result; |
63 |
|
} |
64 |
|
|
65 |
|
/////////////////////////////////////////////////////////////////////////// |
66 |
// class VMStringResultFunction |
// class VMStringResultFunction |
67 |
|
|
68 |
VMFnResult* VMStringResultFunction::errorResult(const String& s) { |
VMFnResult* VMStringResultFunction::errorResult(const String& s) { |
81 |
// built-in script function: message() |
// built-in script function: message() |
82 |
|
|
83 |
bool CoreVMFunction_message::acceptsArgType(vmint iArg, ExprType_t type) const { |
bool CoreVMFunction_message::acceptsArgType(vmint iArg, ExprType_t type) const { |
84 |
return type == INT_EXPR || type == STRING_EXPR; |
return type == INT_EXPR || type == REAL_EXPR || type == STRING_EXPR; |
85 |
} |
} |
86 |
|
|
87 |
VMFnResult* CoreVMFunction_message::exec(VMFnArgs* args) { |
VMFnResult* CoreVMFunction_message::exec(VMFnArgs* args) { |
95 |
return successResult(); |
return successResult(); |
96 |
} |
} |
97 |
|
|
98 |
|
VMRealExpr* realExpr = dynamic_cast<VMRealExpr*>(args->arg(0)); |
99 |
|
if (realExpr) { |
100 |
|
printf("[ScriptVM %.3f] %f\n", usecs/1000000.f, realExpr->evalReal()); |
101 |
|
return successResult(); |
102 |
|
} |
103 |
|
|
104 |
VMIntExpr* intExpr = dynamic_cast<VMIntExpr*>(args->arg(0)); |
VMIntExpr* intExpr = dynamic_cast<VMIntExpr*>(args->arg(0)); |
105 |
if (intExpr) { |
if (intExpr) { |
106 |
printf("[ScriptVM %.3f] %lld\n", usecs/1000000.f, (int64_t)intExpr->evalInt()); |
printf("[ScriptVM %.3f] %lld\n", usecs/1000000.f, (int64_t)intExpr->evalInt()); |
551 |
return successResult(); |
return successResult(); |
552 |
} |
} |
553 |
|
|
554 |
|
/////////////////////////////////////////////////////////////////////////// |
555 |
|
// built-in script function: real_to_int() and int() |
556 |
|
|
557 |
|
VMFnResult* CoreVMFunction_real_to_int::exec(VMFnArgs* args) { |
558 |
|
vmfloat f = args->arg(0)->asReal()->evalReal(); |
559 |
|
return successResult(vmint(f)); |
560 |
|
} |
561 |
|
|
562 |
|
/////////////////////////////////////////////////////////////////////////// |
563 |
|
// built-in script function: int_to_real() and real() |
564 |
|
|
565 |
|
VMFnResult* CoreVMFunction_int_to_real::exec(VMFnArgs* args) { |
566 |
|
vmint i = args->arg(0)->asInt()->evalInt(); |
567 |
|
return successResult(i); |
568 |
|
} |
569 |
|
|
570 |
} // namespace LinuxSampler |
} // namespace LinuxSampler |