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

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

Issue 444793002: Report compile time error if const class has non-const initializer (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/language/language.status » ('j') | 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 "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/bootstrap.h" 9 #include "vm/bootstrap.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 2361 matching lines...) Expand 10 before | Expand all | Expand 10 after
2372 initialized_fields->Add(&field); 2372 initialized_fields->Add(&field);
2373 } 2373 }
2374 AstNode* init_expr = NULL; 2374 AstNode* init_expr = NULL;
2375 if (current_class().raw() != field.origin()) { 2375 if (current_class().raw() != field.origin()) {
2376 init_expr = ParseExternalInitializedField(field); 2376 init_expr = ParseExternalInitializedField(field);
2377 } else { 2377 } else {
2378 SetPosition(field.token_pos()); 2378 SetPosition(field.token_pos());
2379 ASSERT(IsIdentifier()); 2379 ASSERT(IsIdentifier());
2380 ConsumeToken(); 2380 ConsumeToken();
2381 ExpectToken(Token::kASSIGN); 2381 ExpectToken(Token::kASSIGN);
2382 if (field.is_const()) { 2382 if (current_class().is_const()) {
2383 // If the class has a const contructor, the initializer
2384 // expression must be a compile-time constant.
2383 init_expr = ParseConstExpr(); 2385 init_expr = ParseConstExpr();
2384 } else { 2386 } else {
2385 intptr_t expr_pos = TokenPos(); 2387 intptr_t expr_pos = TokenPos();
2386 init_expr = ParseExpr(kAllowConst, kConsumeCascades); 2388 init_expr = ParseExpr(kAllowConst, kConsumeCascades);
2387 if (init_expr->EvalConstExpr() != NULL) { 2389 if (init_expr->EvalConstExpr() != NULL) {
2388 init_expr = new LiteralNode(field.token_pos(), 2390 init_expr = new LiteralNode(field.token_pos(),
2389 EvaluateConstExpr(expr_pos, init_expr)); 2391 EvaluateConstExpr(expr_pos, init_expr));
2390 } 2392 }
2391 } 2393 }
2392 } 2394 }
(...skipping 8930 matching lines...) Expand 10 before | Expand all | Expand 10 after
11323 void Parser::SkipQualIdent() { 11325 void Parser::SkipQualIdent() {
11324 ASSERT(IsIdentifier()); 11326 ASSERT(IsIdentifier());
11325 ConsumeToken(); 11327 ConsumeToken();
11326 if (CurrentToken() == Token::kPERIOD) { 11328 if (CurrentToken() == Token::kPERIOD) {
11327 ConsumeToken(); // Consume the kPERIOD token. 11329 ConsumeToken(); // Consume the kPERIOD token.
11328 ExpectIdentifier("identifier expected after '.'"); 11330 ExpectIdentifier("identifier expected after '.'");
11329 } 11331 }
11330 } 11332 }
11331 11333
11332 } // namespace dart 11334 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698