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

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

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

revision 3743 by schoenebeck, Fri Jan 31 10:57:53 2020 UTC revision 3744 by schoenebeck, Sat Feb 15 11:50:02 2020 UTC
# Line 13  Line 13 
13  #include "../common/global_private.h"  #include "../common/global_private.h"
14  #include "../common/RTMath.h"  #include "../common/RTMath.h"
15  #include <assert.h>  #include <assert.h>
16    #include "CoreVMFunctions.h" // for VMIntResult, VMRealResult
17    
18  namespace LinuxSampler {  namespace LinuxSampler {
19            
# Line 122  static String _unitFactorToShortStr(vmfl Line 123  static String _unitFactorToShortStr(vmfl
123      }      }
124  }  }
125    
126  static String _unitToStr(Unit* unit) {  static String _unitToStr(VMUnit* unit) {
127      const StdUnit_t type = unit->unitType();      const StdUnit_t type = unit->unitType();
128      String sType;      String sType;
129      switch (type) {      switch (type) {
# Line 612  VMFnResult* FunctionCall::execVMFn() { Line 613  VMFnResult* FunctionCall::execVMFn() {
613      if (!fn) return NULL;      if (!fn) return NULL;
614      // assuming here that all argument checks (amount and types) have been made      // assuming here that all argument checks (amount and types) have been made
615      // at parse time, to avoid time intensive checks on each function call      // at parse time, to avoid time intensive checks on each function call
616      return fn->exec(dynamic_cast<VMFnArgs*>(&*args));      VMFnResult* res = fn->exec(dynamic_cast<VMFnArgs*>(&*args));
617        if (!res) return res;
618    
619        VMExpr* expr = res->resultValue();
620        if (!expr) return res;
621    
622        // For performance reasons we always only let 'FunctionCall' assign the unit
623        // type to the function's result expression, never by the function
624        // implementation itself, nor by other classes, because a FunctionCall
625        // object solely knows the unit type in O(1).
626        ExprType_t type = expr->exprType();
627        if (type == INT_EXPR) {
628            VMIntResult* intRes = dynamic_cast<VMIntResult*>(res);
629            intRes->unitBaseType = unitType();
630        } else if (type == REAL_EXPR) {
631            VMRealResult* realRes = dynamic_cast<VMRealResult*>(res);
632            realRes->unitBaseType = unitType();
633        }
634    
635        return res;
636  }  }
637    
638  StmtFlags_t FunctionCall::exec() {  StmtFlags_t FunctionCall::exec() {
# Line 685  String FunctionCall::evalCastToStr() { Line 705  String FunctionCall::evalCastToStr() {
705          return strExpr ? strExpr->evalStr() : "";          return strExpr ? strExpr->evalStr() : "";
706      } else if (resultType == REAL_EXPR) {      } else if (resultType == REAL_EXPR) {
707          VMRealExpr* realExpr = dynamic_cast<VMRealExpr*>(result->resultValue());          VMRealExpr* realExpr = dynamic_cast<VMRealExpr*>(result->resultValue());
708          return realExpr ? ToString(realExpr->evalReal()) : "";          return realExpr ? ToString(realExpr->evalReal()) + _unitToStr(realExpr) : "";
709      } else {      } else {
710          VMIntExpr* intExpr = dynamic_cast<VMIntExpr*>(result->resultValue());          VMIntExpr* intExpr = dynamic_cast<VMIntExpr*>(result->resultValue());
711          return intExpr ? ToString(intExpr->evalInt()) : "";          return intExpr ? ToString(intExpr->evalInt()) + _unitToStr(intExpr) : "";
712      }      }
713  }  }
714    

Legend:
Removed from v.3743  
changed lines
  Added in v.3744

  ViewVC Help
Powered by ViewVC