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

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

Issue 1850653003: Provide ability to patch external functions in a class that has already been finalized. The follow… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: code-review Created 4 years, 8 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
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/raw_object.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 #include "vm/flags.h" 6 #include "vm/flags.h"
7 7
8 #ifndef DART_PRECOMPILED_RUNTIME 8 #ifndef DART_PRECOMPILED_RUNTIME
9 9
10 #include "lib/invocation_mirror.h" 10 #include "lib/invocation_mirror.h"
(...skipping 4547 matching lines...) Expand 10 before | Expand all | Expand 10 after
4558 cls.set_super_type(super_type); 4558 cls.set_super_type(super_type);
4559 4559
4560 if (CurrentToken() == Token::kIMPLEMENTS) { 4560 if (CurrentToken() == Token::kIMPLEMENTS) {
4561 ParseInterfaceList(cls); 4561 ParseInterfaceList(cls);
4562 } 4562 }
4563 4563
4564 if (is_patch) { 4564 if (is_patch) {
4565 cls.set_is_patch(); 4565 cls.set_is_patch();
4566 // Apply the changes to the patched class looked up above. 4566 // Apply the changes to the patched class looked up above.
4567 ASSERT(obj.raw() == library_.LookupLocalObject(class_name)); 4567 ASSERT(obj.raw() == library_.LookupLocalObject(class_name));
4568 // The patched class must not be finalized yet. 4568 const Class& orig_class = Class::Cast(obj);
4569 ASSERT(!Class::Cast(obj).is_finalized()); 4569 if (orig_class.is_finalized()) {
4570 orig_class.SetRefinalizeAfterPatch();
4571 pending_classes.Add(orig_class, Heap::kOld);
4572 }
4570 library_.AddPatchClass(cls); 4573 library_.AddPatchClass(cls);
4571 } 4574 }
4572 pending_classes.Add(cls, Heap::kOld); 4575 pending_classes.Add(cls, Heap::kOld);
4573 4576
4574 if (is_mixin_declaration) { 4577 if (is_mixin_declaration) {
4575 ExpectSemicolon(); 4578 ExpectSemicolon();
4576 } else { 4579 } else {
4577 CheckToken(Token::kLBRACE); 4580 CheckToken(Token::kLBRACE);
4578 SkipBlock(); 4581 SkipBlock();
4579 ExpectToken(Token::kRBRACE); 4582 ExpectToken(Token::kRBRACE);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4627 AddImplicitConstructor(cls); 4630 AddImplicitConstructor(cls);
4628 } 4631 }
4629 4632
4630 if (cls.is_patch()) { 4633 if (cls.is_patch()) {
4631 // Apply the changes to the patched class looked up above. 4634 // Apply the changes to the patched class looked up above.
4632 Object& obj = Object::Handle(Z, library_.LookupLocalObject(class_name)); 4635 Object& obj = Object::Handle(Z, library_.LookupLocalObject(class_name));
4633 // The patched class must not be finalized yet. 4636 // The patched class must not be finalized yet.
4634 const Class& orig_class = Class::Cast(obj); 4637 const Class& orig_class = Class::Cast(obj);
4635 ASSERT(!orig_class.is_finalized()); 4638 ASSERT(!orig_class.is_finalized());
4636 Error& error = Error::Handle(Z); 4639 Error& error = Error::Handle(Z);
4640 // Check if this is a case of patching a class after it has already
4641 // been finalized.
4642 if (orig_class.is_refinalize_after_patch()) {
4643 if (!cls.ValidatePostFinalizePatch(orig_class, &error)) {
4644 Report::LongJumpF(error, script_, class_pos,
4645 "patch validation failed, not applying patch.\n");
4646 }
4647 }
4637 if (!orig_class.ApplyPatch(cls, &error)) { 4648 if (!orig_class.ApplyPatch(cls, &error)) {
4638 Report::LongJumpF(error, script_, class_pos, "applying patch failed"); 4649 Report::LongJumpF(error, script_, class_pos, "applying patch failed");
4639 } 4650 }
4640 } 4651 }
4641 } 4652 }
4642 4653
4643 4654
4644 void Parser::ParseEnumDefinition(const Class& cls) { 4655 void Parser::ParseEnumDefinition(const Class& cls) {
4645 TRACE_PARSER("ParseEnumDefinition"); 4656 TRACE_PARSER("ParseEnumDefinition");
4646 INC_STAT(thread(), num_classes_parsed, 1); 4657 INC_STAT(thread(), num_classes_parsed, 1);
(...skipping 9815 matching lines...) Expand 10 before | Expand all | Expand 10 after
14462 const ArgumentListNode& function_args, 14473 const ArgumentListNode& function_args,
14463 const LocalVariable* temp_for_last_arg, 14474 const LocalVariable* temp_for_last_arg,
14464 bool is_super_invocation) { 14475 bool is_super_invocation) {
14465 UNREACHABLE(); 14476 UNREACHABLE();
14466 return NULL; 14477 return NULL;
14467 } 14478 }
14468 14479
14469 } // namespace dart 14480 } // namespace dart
14470 14481
14471 #endif // DART_PRECOMPILED_RUNTIME 14482 #endif // DART_PRECOMPILED_RUNTIME
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698