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

Side by Side Diff: runtime/vm/parser.cc

Issue 41113002: Properly report error for certain expressions that must be const (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/parser.h" 5 #include "vm/parser.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/bootstrap.h" 9 #include "vm/bootstrap.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 7844 matching lines...) Expand 10 before | Expand all | Expand 10 after
7855 AstNode* assign_expr = 7855 AstNode* assign_expr =
7856 CreateAssignmentNode(expr, assigned_value, expr_ident, expr_pos); 7856 CreateAssignmentNode(expr, assigned_value, expr_ident, expr_pos);
7857 ASSERT(assign_expr != NULL); 7857 ASSERT(assign_expr != NULL);
7858 return assign_expr; 7858 return assign_expr;
7859 } 7859 }
7860 } 7860 }
7861 7861
7862 7862
7863 LiteralNode* Parser::ParseConstExpr() { 7863 LiteralNode* Parser::ParseConstExpr() {
7864 TRACE_PARSER("ParseConstExpr"); 7864 TRACE_PARSER("ParseConstExpr");
7865 intptr_t expr_pos = TokenPos();
7865 AstNode* expr = ParseExpr(kRequireConst, kNoCascades); 7866 AstNode* expr = ParseExpr(kRequireConst, kNoCascades);
7866 ASSERT(expr->IsLiteralNode()); 7867 if (!expr->IsLiteralNode()) {
7868 ErrorMsg(expr_pos, "expression must be a compile-time constant");
7869 }
7867 return expr->AsLiteralNode(); 7870 return expr->AsLiteralNode();
7868 } 7871 }
7869 7872
7870 7873
7871 AstNode* Parser::ParseConditionalExpr() { 7874 AstNode* Parser::ParseConditionalExpr() {
7872 TRACE_PARSER("ParseConditionalExpr"); 7875 TRACE_PARSER("ParseConditionalExpr");
7873 const intptr_t expr_pos = TokenPos(); 7876 const intptr_t expr_pos = TokenPos();
7874 AstNode* expr = ParseBinaryExpr(Token::Precedence(Token::kOR)); 7877 AstNode* expr = ParseBinaryExpr(Token::Precedence(Token::kOR));
7875 if (CurrentToken() == Token::kCONDITIONAL) { 7878 if (CurrentToken() == Token::kCONDITIONAL) {
7876 EnsureExpressionTemp(); 7879 EnsureExpressionTemp();
(...skipping 2734 matching lines...) Expand 10 before | Expand all | Expand 10 after
10611 void Parser::SkipQualIdent() { 10614 void Parser::SkipQualIdent() {
10612 ASSERT(IsIdentifier()); 10615 ASSERT(IsIdentifier());
10613 ConsumeToken(); 10616 ConsumeToken();
10614 if (CurrentToken() == Token::kPERIOD) { 10617 if (CurrentToken() == Token::kPERIOD) {
10615 ConsumeToken(); // Consume the kPERIOD token. 10618 ConsumeToken(); // Consume the kPERIOD token.
10616 ExpectIdentifier("identifier expected after '.'"); 10619 ExpectIdentifier("identifier expected after '.'");
10617 } 10620 }
10618 } 10621 }
10619 10622
10620 } // namespace dart 10623 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698