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

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

Issue 10871005: Make ClassFinalizer indifferent on whether we are generating a snapshot or not. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | « runtime/vm/parser.h ('k') | runtime/vm/raw_object_snapshot.cc » ('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 "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/compiler_stats.h" 10 #include "vm/compiler_stats.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 DISALLOW_COPY_AND_ASSIGN(TryBlocks); 219 DISALLOW_COPY_AND_ASSIGN(TryBlocks);
220 }; 220 };
221 221
222 222
223 void Parser::TryBlocks::AddNodeForFinallyInlining(AstNode* node) { 223 void Parser::TryBlocks::AddNodeForFinallyInlining(AstNode* node) {
224 inlined_finally_nodes_.Add(node); 224 inlined_finally_nodes_.Add(node);
225 } 225 }
226 226
227 227
228 // For parsing a compilation unit. 228 // For parsing a compilation unit.
229 Parser::Parser(const Script& script, 229 Parser::Parser(const Script& script, const Library& library)
230 const Library& library)
231 : script_(script), 230 : script_(script),
232 tokens_iterator_(TokenStream::Handle(script.tokens()), 0), 231 tokens_iterator_(TokenStream::Handle(script.tokens()), 0),
233 token_kind_(Token::kILLEGAL), 232 token_kind_(Token::kILLEGAL),
234 current_block_(NULL), 233 current_block_(NULL),
235 is_top_level_(false), 234 is_top_level_(false),
236 current_member_(NULL), 235 current_member_(NULL),
237 allow_function_literals_(true), 236 allow_function_literals_(true),
238 current_function_(Function::Handle()), 237 current_function_(Function::Handle()),
239 innermost_function_(Function::Handle()), 238 innermost_function_(Function::Handle()),
240 current_class_(Class::Handle()), 239 current_class_(Class::Handle()),
(...skipping 3272 matching lines...) Expand 10 before | Expand all | Expand 10 after
3513 ErrorMsg(interface_pos, "duplicate interface '%s'", 3512 ErrorMsg(interface_pos, "duplicate interface '%s'",
3514 interface_name.ToCString()); 3513 interface_name.ToCString());
3515 } 3514 }
3516 } 3515 }
3517 interfaces.Add(interface); 3516 interfaces.Add(interface);
3518 } while (CurrentToken() == Token::kCOMMA); 3517 } while (CurrentToken() == Token::kCOMMA);
3519 return Array::MakeArray(interfaces); 3518 return Array::MakeArray(interfaces);
3520 } 3519 }
3521 3520
3522 3521
3522 // Add 'interface' to 'interface_list' if it is not already in the list.
3523 // An error is reported if the interface conflicts with an interface already in
3524 // the list with the same class, but different type arguments.
3525 // Non-conflicting duplicates are ignored without error.
3526 void Parser::AddInterfaceIfUnique(intptr_t interfaces_pos,
3527 const GrowableObjectArray& interface_list,
3528 const AbstractType& interface) {
3529 String& interface_class_name = String::Handle(interface.ClassName());
3530 String& existing_interface_class_name = String::Handle();
3531 String& interface_name = String::Handle();
3532 String& existing_interface_name = String::Handle();
3533 AbstractType& other_interface = AbstractType::Handle();
3534 for (intptr_t i = 0; i < interface_list.Length(); i++) {
3535 other_interface ^= interface_list.At(i);
3536 existing_interface_class_name = other_interface.ClassName();
3537 if (interface_class_name.Equals(existing_interface_class_name)) {
3538 // Same interface class name, now check names of type arguments.
3539 interface_name = interface.Name();
3540 existing_interface_name = other_interface.Name();
3541 // TODO(regis): Revisit depending on the outcome of issue 4905685.
3542 if (!interface_name.Equals(existing_interface_name)) {
3543 ErrorMsg(interfaces_pos,
3544 "interface '%s' conflicts with interface '%s'",
3545 String::Handle(interface.UserVisibleName()).ToCString(),
3546 String::Handle(other_interface.UserVisibleName()).ToCString());
3547 }
3548 }
3549 }
3550 interface_list.Add(interface);
3551 }
3552
3553
3523 void Parser::AddInterfaces(intptr_t interfaces_pos, 3554 void Parser::AddInterfaces(intptr_t interfaces_pos,
3524 const Class& cls, 3555 const Class& cls,
3525 const Array& interfaces) { 3556 const Array& interfaces) {
3526 const GrowableObjectArray& all_interfaces = 3557 const GrowableObjectArray& all_interfaces =
3527 GrowableObjectArray::Handle(GrowableObjectArray::New()); 3558 GrowableObjectArray::Handle(GrowableObjectArray::New());
3528 AbstractType& interface = AbstractType::Handle(); 3559 AbstractType& interface = AbstractType::Handle();
3529 // First get all the interfaces already implemented by class. 3560 // First get all the interfaces already implemented by class.
3530 Array& cls_interfaces = Array::Handle(cls.interfaces()); 3561 Array& cls_interfaces = Array::Handle(cls.interfaces());
3531 for (intptr_t i = 0; i < cls_interfaces.Length(); i++) { 3562 for (intptr_t i = 0; i < cls_interfaces.Length(); i++) {
3532 interface ^= cls_interfaces.At(i); 3563 interface ^= cls_interfaces.At(i);
3533 all_interfaces.Add(interface); 3564 all_interfaces.Add(interface);
3534 } 3565 }
3535 // Now add the new interfaces. 3566 // Now add the new interfaces.
3536 AbstractType& conflicting = AbstractType::Handle();
3537 for (intptr_t i = 0; i < interfaces.Length(); i++) { 3567 for (intptr_t i = 0; i < interfaces.Length(); i++) {
3538 AbstractType& interface = AbstractType::ZoneHandle(); 3568 AbstractType& interface = AbstractType::ZoneHandle();
3539 interface ^= interfaces.At(i); 3569 interface ^= interfaces.At(i);
3540 if (interface.IsTypeParameter()) { 3570 if (interface.IsTypeParameter()) {
3541 if (cls.is_interface()) { 3571 if (cls.is_interface()) {
3542 ErrorMsg(interfaces_pos, 3572 ErrorMsg(interfaces_pos,
3543 "interface '%s' may not extend type parameter '%s'", 3573 "interface '%s' may not extend type parameter '%s'",
3544 String::Handle(cls.Name()).ToCString(), 3574 String::Handle(cls.Name()).ToCString(),
3545 String::Handle(interface.UserVisibleName()).ToCString()); 3575 String::Handle(interface.UserVisibleName()).ToCString());
3546 } else { 3576 } else {
3547 ErrorMsg(interfaces_pos, 3577 ErrorMsg(interfaces_pos,
3548 "class '%s' may not implement type parameter '%s'", 3578 "class '%s' may not implement type parameter '%s'",
3549 String::Handle(cls.Name()).ToCString(), 3579 String::Handle(cls.Name()).ToCString(),
3550 String::Handle(interface.UserVisibleName()).ToCString()); 3580 String::Handle(interface.UserVisibleName()).ToCString());
3551 } 3581 }
3552 } 3582 }
3553 if (!ClassFinalizer::AddInterfaceIfUnique(all_interfaces, 3583 AddInterfaceIfUnique(interfaces_pos, all_interfaces, interface);
3554 interface,
3555 &conflicting)) {
3556 ASSERT(!conflicting.IsNull());
3557 ErrorMsg(interfaces_pos,
3558 "interface '%s' conflicts with interface '%s'",
3559 String::Handle(interface.UserVisibleName()).ToCString(),
3560 String::Handle(conflicting.UserVisibleName()).ToCString());
3561 }
3562 } 3584 }
3563 cls_interfaces = Array::MakeArray(all_interfaces); 3585 cls_interfaces = Array::MakeArray(all_interfaces);
3564 cls.set_interfaces(cls_interfaces); 3586 cls.set_interfaces(cls_interfaces);
3565 } 3587 }
3566 3588
3567 3589
3568 void Parser::ParseTopLevelVariable(TopLevel* top_level) { 3590 void Parser::ParseTopLevelVariable(TopLevel* top_level) {
3569 TRACE_PARSER("ParseTopLevelVariable"); 3591 TRACE_PARSER("ParseTopLevelVariable");
3570 const bool is_final = (CurrentToken() == Token::kFINAL); 3592 const bool is_final = (CurrentToken() == Token::kFINAL);
3571 const bool is_const = (CurrentToken() == Token::kCONST); 3593 const bool is_const = (CurrentToken() == Token::kCONST);
(...skipping 5616 matching lines...) Expand 10 before | Expand all | Expand 10 after
9188 void Parser::SkipQualIdent() { 9210 void Parser::SkipQualIdent() {
9189 ASSERT(IsIdentifier()); 9211 ASSERT(IsIdentifier());
9190 ConsumeToken(); 9212 ConsumeToken();
9191 if (CurrentToken() == Token::kPERIOD) { 9213 if (CurrentToken() == Token::kPERIOD) {
9192 ConsumeToken(); // Consume the kPERIOD token. 9214 ConsumeToken(); // Consume the kPERIOD token.
9193 ExpectIdentifier("identifier expected after '.'"); 9215 ExpectIdentifier("identifier expected after '.'");
9194 } 9216 }
9195 } 9217 }
9196 9218
9197 } // namespace dart 9219 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/parser.h ('k') | runtime/vm/raw_object_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698