Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Unified Diff: runtime/vm/parser.cc

Issue 2005723004: Fraction class prototype and test (not to be committed). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: work in progress Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/parser.h ('k') | runtime/vm/parser_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « runtime/vm/parser.h ('k') | runtime/vm/parser_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698