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

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

Issue 227703010: Fix instance method resolution with abstract accessors and methods (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/language/abstract_method_test.dart » ('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 9096 matching lines...) Expand 10 before | Expand all | Expand 10 after
9107 } else { 9107 } else {
9108 *node = GenerateStaticFieldLookup(field, ident_pos); 9108 *node = GenerateStaticFieldLookup(field, ident_pos);
9109 } 9109 }
9110 } 9110 }
9111 return true; 9111 return true;
9112 } 9112 }
9113 9113
9114 // Check if an instance/static function exists. 9114 // Check if an instance/static function exists.
9115 func = cls.LookupFunction(ident); 9115 func = cls.LookupFunction(ident);
9116 if (!func.IsNull() && 9116 if (!func.IsNull() &&
9117 (func.IsDynamicFunction() || func.IsStaticFunction())) { 9117 (func.IsDynamicFunction() ||
9118 func.IsStaticFunction() ||
9119 func.is_abstract())) {
9118 if (node != NULL) { 9120 if (node != NULL) {
9119 *node = new PrimaryNode(ident_pos, 9121 *node = new PrimaryNode(ident_pos,
9120 Function::ZoneHandle(isolate(), func.raw())); 9122 Function::ZoneHandle(isolate(), func.raw()));
9121 } 9123 }
9122 return true; 9124 return true;
9123 } 9125 }
9124 9126
9125 // Now check if a getter/setter method exists for it in which case 9127 // Now check if a getter/setter method exists for it in which case
9126 // it is still a field. 9128 // it is still a field.
9127 func = cls.LookupGetterFunction(ident); 9129 func = cls.LookupGetterFunction(ident);
9128 if (!func.IsNull()) { 9130 if (!func.IsNull()) {
9129 if (func.IsDynamicFunction()) { 9131 if (func.IsDynamicFunction() || func.is_abstract()) {
9130 if (node != NULL) { 9132 if (node != NULL) {
9131 CheckInstanceFieldAccess(ident_pos, ident); 9133 CheckInstanceFieldAccess(ident_pos, ident);
9132 ASSERT(AbstractType::Handle(func.result_type()).IsResolved()); 9134 ASSERT(AbstractType::Handle(func.result_type()).IsResolved());
9133 *node = CallGetter(ident_pos, LoadReceiver(ident_pos), ident); 9135 *node = CallGetter(ident_pos, LoadReceiver(ident_pos), ident);
9134 } 9136 }
9135 return true; 9137 return true;
9136 } else if (func.IsStaticFunction()) { 9138 } else if (func.IsStaticFunction()) {
9137 if (node != NULL) { 9139 if (node != NULL) {
9138 ASSERT(AbstractType::Handle(func.result_type()).IsResolved()); 9140 ASSERT(AbstractType::Handle(func.result_type()).IsResolved());
9139 // The static getter may later be changed into a dynamically 9141 // The static getter may later be changed into a dynamically
9140 // resolved instance setter if no static setter can 9142 // resolved instance setter if no static setter can
9141 // be found. 9143 // be found.
9142 AstNode* receiver = NULL; 9144 AstNode* receiver = NULL;
9143 const bool kTestOnly = true; 9145 const bool kTestOnly = true;
9144 if (!current_function().is_static() && 9146 if (!current_function().is_static() &&
9145 (LookupReceiver(current_block_->scope, kTestOnly) != NULL)) { 9147 (LookupReceiver(current_block_->scope, kTestOnly) != NULL)) {
9146 receiver = LoadReceiver(ident_pos); 9148 receiver = LoadReceiver(ident_pos);
9147 } 9149 }
9148 *node = new StaticGetterNode(ident_pos, 9150 *node = new StaticGetterNode(ident_pos,
9149 receiver, 9151 receiver,
9150 false, 9152 false,
9151 Class::ZoneHandle(isolate(), cls.raw()), 9153 Class::ZoneHandle(isolate(), cls.raw()),
9152 ident); 9154 ident);
9153 } 9155 }
9154 return true; 9156 return true;
9155 } 9157 }
9156 } 9158 }
9157 func = cls.LookupSetterFunction(ident); 9159 func = cls.LookupSetterFunction(ident);
9158 if (!func.IsNull()) { 9160 if (!func.IsNull()) {
9159 if (func.IsDynamicFunction()) { 9161 if (func.IsDynamicFunction() || func.is_abstract()) {
9160 if (node != NULL) { 9162 if (node != NULL) {
9161 // We create a getter node even though a getter doesn't exist as 9163 // We create a getter node even though a getter doesn't exist as
9162 // it could be followed by an assignment which will convert it to 9164 // it could be followed by an assignment which will convert it to
9163 // a setter node. If there is no assignment we will get an error 9165 // a setter node. If there is no assignment we will get an error
9164 // when we try to invoke the getter. 9166 // when we try to invoke the getter.
9165 CheckInstanceFieldAccess(ident_pos, ident); 9167 CheckInstanceFieldAccess(ident_pos, ident);
9166 ASSERT(AbstractType::Handle(func.result_type()).IsResolved()); 9168 ASSERT(AbstractType::Handle(func.result_type()).IsResolved());
9167 *node = CallGetter(ident_pos, LoadReceiver(ident_pos), ident); 9169 *node = CallGetter(ident_pos, LoadReceiver(ident_pos), ident);
9168 } 9170 }
9169 return true; 9171 return true;
(...skipping 1743 matching lines...) Expand 10 before | Expand all | Expand 10 after
10913 void Parser::SkipQualIdent() { 10915 void Parser::SkipQualIdent() {
10914 ASSERT(IsIdentifier()); 10916 ASSERT(IsIdentifier());
10915 ConsumeToken(); 10917 ConsumeToken();
10916 if (CurrentToken() == Token::kPERIOD) { 10918 if (CurrentToken() == Token::kPERIOD) {
10917 ConsumeToken(); // Consume the kPERIOD token. 10919 ConsumeToken(); // Consume the kPERIOD token.
10918 ExpectIdentifier("identifier expected after '.'"); 10920 ExpectIdentifier("identifier expected after '.'");
10919 } 10921 }
10920 } 10922 }
10921 10923
10922 } // namespace dart 10924 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/language/abstract_method_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698