Index: runtime/vm/parser.cc |
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc |
index 6c0bd7df21a00ac562e3cb86218b3022b1bb842c..1707067583b8c481ab5ddfeed7aaecd4745d9360 100644 |
--- a/runtime/vm/parser.cc |
+++ b/runtime/vm/parser.cc |
@@ -625,6 +625,13 @@ RawInteger* Parser::CurrentIntegerLiteral() const { |
} |
+RawFraction* Parser::CurrentRationalLiteral() const { |
+ literal_token_ ^= tokens_iterator_.CurrentToken(); |
+ ASSERT(literal_token_.kind() == Token::kRATIONAL); |
+ return Fraction::RawCast(literal_token_.value()); |
+} |
+ |
+ |
struct ParamDesc { |
ParamDesc() |
: type(NULL), |
@@ -4524,6 +4531,7 @@ void Parser::ParseClassDeclaration(const GrowableObjectArray& pending_classes, |
// Not patching a class, but it has been found. This must be one of the |
// pre-registered classes from object.cc or a duplicate definition. |
if (!(cls.is_prefinalized() || |
+ cls.is_refinalize_after_patch() || // TODO(regis): Remove. |
RawObject::IsImplicitFieldClassId(cls.id()))) { |
ReportError(classname_pos, "class '%s' is already defined", |
class_name.ToCString()); |
@@ -7928,6 +7936,9 @@ bool Parser::IsSimpleLiteral(const AbstractType& type, Instance* value) { |
if (CurrentToken() == Token::kINTEGER) { |
*value = CurrentIntegerLiteral(); |
return true; |
+ } else if (CurrentToken() == Token::kRATIONAL) { |
+ *value = CurrentRationalLiteral(); |
+ return true; |
} else if (CurrentToken() == Token::kDOUBLE) { |
*value = CurrentDoubleLiteral(); |
return true; |
@@ -14083,6 +14094,14 @@ AstNode* Parser::ParsePrimary() { |
primary = ParseExpr(kAllowConst, kConsumeCascades); |
SetAllowFunctionLiterals(saved_mode); |
ExpectToken(Token::kRPAREN); |
+ } else if (token == Token::kRATIONAL) { |
+ const Fraction& rational_value = |
+ Fraction::ZoneHandle(Z, CurrentRationalLiteral()); |
+ if (rational_value.IsNull()) { |
+ ReportError("invalid rational literal"); |
+ } |
+ primary = new(Z) LiteralNode(TokenPos(), rational_value); |
+ ConsumeToken(); |
} else if (token == Token::kDOUBLE) { |
const Double& double_value = Double::ZoneHandle(Z, CurrentDoubleLiteral()); |
if (double_value.IsNull()) { |
@@ -14376,6 +14395,7 @@ void Parser::SkipPrimary() { |
case Token::kTRUE: |
case Token::kFALSE: |
case Token::kINTEGER: |
+ case Token::kRATIONAL: |
case Token::kDOUBLE: |
ConsumeToken(); |
break; |