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

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

Issue 38563005: Throw CyclicInitializationError instead of string (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 | « runtime/lib/errors_patch.dart ('k') | runtime/vm/symbols.h » ('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 "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 950 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 new LiteralNode(ident_pos, Object::transition_sentinel())); 961 new LiteralNode(ident_pos, Object::transition_sentinel()));
962 // Set field to null prior to throwing exception, so that subsequent 962 // Set field to null prior to throwing exception, so that subsequent
963 // accesses to the field do not throw again, since initializers should only 963 // accesses to the field do not throw again, since initializers should only
964 // be executed once. 964 // be executed once.
965 SequenceNode* report_circular = new SequenceNode(ident_pos, NULL); 965 SequenceNode* report_circular = new SequenceNode(ident_pos, NULL);
966 report_circular->Add( 966 report_circular->Add(
967 new StoreStaticFieldNode( 967 new StoreStaticFieldNode(
968 ident_pos, 968 ident_pos,
969 field, 969 field,
970 new LiteralNode(ident_pos, Instance::ZoneHandle()))); 970 new LiteralNode(ident_pos, Instance::ZoneHandle())));
971 // TODO(regis, 5802): Exception to throw is not specified by spec. 971 // Call CyclicInitializationError._throwNew(field_name).
972 const String& circular_error = String::ZoneHandle( 972 ArgumentListNode* error_arguments = new ArgumentListNode(ident_pos);
973 Symbols::New("circular dependency in field initialization")); 973 error_arguments->Add(new LiteralNode(ident_pos, field_name));
974 report_circular->Add( 974 report_circular->Add(
975 new ThrowNode(ident_pos, 975 MakeStaticCall(Symbols::CyclicInitializationError(),
976 new LiteralNode(ident_pos, circular_error), 976 Library::PrivateCoreLibName(Symbols::ThrowNew()),
977 NULL)); 977 error_arguments));
978 AstNode* circular_check = 978 AstNode* circular_check =
979 new IfNode(ident_pos, compare_circular, report_circular, NULL); 979 new IfNode(ident_pos, compare_circular, report_circular, NULL);
980 current_block_->statements->Add(circular_check); 980 current_block_->statements->Add(circular_check);
981 981
982 // Generate code checking for uninitialized field. 982 // Generate code checking for uninitialized field.
983 AstNode* compare_uninitialized = new ComparisonNode( 983 AstNode* compare_uninitialized = new ComparisonNode(
984 ident_pos, 984 ident_pos,
985 Token::kEQ_STRICT, 985 Token::kEQ_STRICT,
986 new LoadStaticFieldNode(ident_pos, field), 986 new LoadStaticFieldNode(ident_pos, field),
987 new LiteralNode(ident_pos, Object::sentinel())); 987 new LiteralNode(ident_pos, Object::sentinel()));
(...skipping 9600 matching lines...) Expand 10 before | Expand all | Expand 10 after
10588 void Parser::SkipQualIdent() { 10588 void Parser::SkipQualIdent() {
10589 ASSERT(IsIdentifier()); 10589 ASSERT(IsIdentifier());
10590 ConsumeToken(); 10590 ConsumeToken();
10591 if (CurrentToken() == Token::kPERIOD) { 10591 if (CurrentToken() == Token::kPERIOD) {
10592 ConsumeToken(); // Consume the kPERIOD token. 10592 ConsumeToken(); // Consume the kPERIOD token.
10593 ExpectIdentifier("identifier expected after '.'"); 10593 ExpectIdentifier("identifier expected after '.'");
10594 } 10594 }
10595 } 10595 }
10596 10596
10597 } // namespace dart 10597 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/errors_patch.dart ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698