/[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 2942 by schoenebeck, Wed Jul 13 15:51:06 2016 UTC revision 2948 by schoenebeck, Fri Jul 15 15:29:04 2016 UTC
# Line 102  void Mul::dump(int level) { Line 102  void Mul::dump(int level) {
102    
103  int Div::evalInt() {  int Div::evalInt() {
104      IntExpr* pLHS = dynamic_cast<IntExpr*>(&*lhs);      IntExpr* pLHS = dynamic_cast<IntExpr*>(&*lhs);
105      IntExpr* pRHS = dynamic_cast<IntExpr*>(&*rhs);;      IntExpr* pRHS = dynamic_cast<IntExpr*>(&*rhs);
106      return (pLHS && pRHS) ? pRHS->evalInt() == 0 ? 0 : pLHS->evalInt() / pRHS->evalInt() : 0;      if (!pLHS || !pRHS) return 0;
107        int l = pLHS->evalInt();
108        int r = pRHS->evalInt();
109        if (r == 0) return 0;
110        return l / r;
111  }  }
112    
113  void Div::dump(int level) {  void Div::dump(int level) {
# Line 373  int IntVariable::evalInt() { Line 377  int IntVariable::evalInt() {
377    
378  void IntVariable::dump(int level) {  void IntVariable::dump(int level) {
379      printIndents(level);      printIndents(level);
380        printf("IntVariable\n");
381      //printf("IntVariable memPos=%d\n", memPos);      //printf("IntVariable memPos=%d\n", memPos);
382  }  }
383    
# Line 706  void Neg::dump(int level) { Line 711  void Neg::dump(int level) {
711  }  }
712    
713  String ConcatString::evalStr() {  String ConcatString::evalStr() {
714      return lhs->evalCastToStr() + rhs->evalCastToStr();      // temporaries required here to enforce the associative left (to right) order
715        // ( required for GCC and Visual Studio, see:
716        //   http://stackoverflow.com/questions/25842902/why-stdstring-concatenation-operator-works-like-right-associative-one
717        //   Personally I am not convinced that this is "not a bug" of the
718        //   compiler/STL implementation and the allegedly underlying "function call"
719        //   nature causing this is IMO no profound reason that the C++ language's
720        //   "+" operator's left associativity is ignored. -- Christian, 2016-07-14 )
721        String l = lhs->evalCastToStr();
722        String r = rhs->evalCastToStr();
723        return l + r;
724  }  }
725    
726  void ConcatString::dump(int level) {  void ConcatString::dump(int level) {

Legend:
Removed from v.2942  
changed lines
  Added in v.2948

  ViewVC Help
Powered by ViewVC