Index: src/parsing/parser.cc |
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc |
index 945e985e312450ee0281c7f1eae9be803ad55ac8..c80363ba2cdbd86ad5ef0ccd842d2c7959ee2a30 100644 |
--- a/src/parsing/parser.cc |
+++ b/src/parsing/parser.cc |
@@ -551,49 +551,52 @@ bool ParserTraits::ShortcutNumericLiteralBinaryExpression( |
y->AsLiteral() && y->AsLiteral()->raw_value()->IsNumber()) { |
double x_val = (*x)->AsLiteral()->raw_value()->AsNumber(); |
double y_val = y->AsLiteral()->raw_value()->AsNumber(); |
+ bool x_has_dot = (*x)->AsLiteral()->raw_value()->ContainsDot(); |
+ bool y_has_dot = y->AsLiteral()->raw_value()->ContainsDot(); |
+ bool has_dot = x_has_dot || y_has_dot; |
switch (op) { |
case Token::ADD: |
- *x = factory->NewNumberLiteral(x_val + y_val, pos); |
+ *x = factory->NewNumberLiteral(x_val + y_val, pos, has_dot); |
return true; |
case Token::SUB: |
- *x = factory->NewNumberLiteral(x_val - y_val, pos); |
+ *x = factory->NewNumberLiteral(x_val - y_val, pos, has_dot); |
return true; |
case Token::MUL: |
- *x = factory->NewNumberLiteral(x_val * y_val, pos); |
+ *x = factory->NewNumberLiteral(x_val * y_val, pos, has_dot); |
return true; |
case Token::DIV: |
- *x = factory->NewNumberLiteral(x_val / y_val, pos); |
+ *x = factory->NewNumberLiteral(x_val / y_val, pos, has_dot); |
return true; |
case Token::BIT_OR: { |
int value = DoubleToInt32(x_val) | DoubleToInt32(y_val); |
- *x = factory->NewNumberLiteral(value, pos); |
+ *x = factory->NewNumberLiteral(value, pos, has_dot); |
return true; |
} |
case Token::BIT_AND: { |
int value = DoubleToInt32(x_val) & DoubleToInt32(y_val); |
- *x = factory->NewNumberLiteral(value, pos); |
+ *x = factory->NewNumberLiteral(value, pos, has_dot); |
return true; |
} |
case Token::BIT_XOR: { |
int value = DoubleToInt32(x_val) ^ DoubleToInt32(y_val); |
- *x = factory->NewNumberLiteral(value, pos); |
+ *x = factory->NewNumberLiteral(value, pos, has_dot); |
return true; |
} |
case Token::SHL: { |
int value = DoubleToInt32(x_val) << (DoubleToInt32(y_val) & 0x1f); |
- *x = factory->NewNumberLiteral(value, pos); |
+ *x = factory->NewNumberLiteral(value, pos, has_dot); |
return true; |
} |
case Token::SHR: { |
uint32_t shift = DoubleToInt32(y_val) & 0x1f; |
uint32_t value = DoubleToUint32(x_val) >> shift; |
- *x = factory->NewNumberLiteral(value, pos); |
+ *x = factory->NewNumberLiteral(value, pos, has_dot); |
return true; |
} |
case Token::SAR: { |
uint32_t shift = DoubleToInt32(y_val) & 0x1f; |
int value = ArithmeticShiftRight(DoubleToInt32(x_val), shift); |
- *x = factory->NewNumberLiteral(value, pos); |
+ *x = factory->NewNumberLiteral(value, pos, has_dot); |
return true; |
} |
default: |
@@ -617,13 +620,14 @@ Expression* ParserTraits::BuildUnaryExpression(Expression* expression, |
} else if (literal->IsNumber()) { |
// Compute some expressions involving only number literals. |
double value = literal->AsNumber(); |
+ bool has_dot = literal->ContainsDot(); |
switch (op) { |
case Token::ADD: |
return expression; |
case Token::SUB: |
- return factory->NewNumberLiteral(-value, pos); |
+ return factory->NewNumberLiteral(-value, pos, has_dot); |
case Token::BIT_NOT: |
- return factory->NewNumberLiteral(~DoubleToInt32(value), pos); |
+ return factory->NewNumberLiteral(~DoubleToInt32(value), pos, has_dot); |
default: |
break; |
} |