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) { |
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 |
|
|
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) { |