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

Unified Diff: runtime/vm/parser.cc

Issue 10689083: Compile an instance setter call when a static getter is declared, but no field (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/ast.cc ('k') | tests/language/getter_no_setter_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 9375)
+++ runtime/vm/parser.cc (working copy)
@@ -750,8 +750,7 @@
// receiver was captured.
const bool kTestOnly = true;
LocalVariable* receiver =
- parser.LookupReceiver(node_sequence->scope(),
- kTestOnly);
+ parser.LookupReceiver(node_sequence->scope(), kTestOnly);
if (!parser.current_function().IsLocalFunction() ||
((receiver != NULL) && receiver->is_captured())) {
parsed_function->set_instantiator(
@@ -4027,16 +4026,15 @@
// Now add the NativeBodyNode and return statement.
current_block_->statements->Add(
new ReturnNode(TokenPos(), new NativeBodyNode(TokenPos(),
- native_name,
- native_function,
- num_parameters,
- has_opt_params,
- is_instance_closure)));
+ native_name,
+ native_function,
+ num_parameters,
+ has_opt_params,
+ is_instance_closure)));
}
-LocalVariable* Parser::LookupReceiver(LocalScope* from_scope,
- bool test_only) {
+LocalVariable* Parser::LookupReceiver(LocalScope* from_scope, bool test_only) {
const String& this_name = String::Handle(String::NewSymbol(kThisName));
return from_scope->LookupVariable(this_name, test_only);
}
@@ -6410,6 +6408,7 @@
ASSERT(func.kind() != RawFunction::kConstImplicitGetter);
EnsureExpressionTemp();
closure = new StaticGetterNode(call_pos,
+ NULL,
Class::ZoneHandle(cls.raw()),
func_name);
return new ClosureCallNode(call_pos, closure, arguments);
@@ -6546,6 +6545,7 @@
// is used as part of, e.g., "+=", and the explicit getter does not
// exist, and error will be reported by the code generator.
load_access = new StaticGetterNode(call_pos,
+ NULL,
Class::ZoneHandle(cls.raw()),
String::ZoneHandle(field_name.raw()));
} else {
@@ -6588,6 +6588,7 @@
} else {
ASSERT(func.kind() != RawFunction::kConstImplicitGetter);
access = new StaticGetterNode(call_pos,
+ NULL,
Class::ZoneHandle(cls.raw()),
field_name);
}
@@ -6964,6 +6965,7 @@
} else {
// The implicit static getter will throw the exception if necessary.
return new StaticGetterNode(TokenPos(),
+ NULL,
Class::ZoneHandle(field.owner()),
String::ZoneHandle(field.name()));
}
@@ -7012,6 +7014,7 @@
field.set_value(instance);
} else {
return new StaticGetterNode(TokenPos(),
+ NULL,
Class::ZoneHandle(field.owner()),
String::ZoneHandle(field.name()));
}
@@ -7135,7 +7138,16 @@
} else if (func.IsStaticFunction()) {
if (node != NULL) {
ASSERT(AbstractType::Handle(func.result_type()).IsResolved());
+ // The static getter may be changed later into an instance setter.
+ AstNode* receiver = NULL;
+ const bool kTestOnly = true;
+ if ((!current_function().is_static() ||
+ current_function().IsInFactoryScope()) &&
+ (LookupReceiver(current_block_->scope, kTestOnly) != NULL)) {
+ receiver = LoadReceiver(ident_pos);
+ }
*node = new StaticGetterNode(ident_pos,
+ receiver,
Class::ZoneHandle(isolate, cls.raw()),
ident);
}
@@ -7162,6 +7174,7 @@
// a setter node. If there is no assignment we will get an error
// when we try to invoke the getter.
*node = new StaticGetterNode(ident_pos,
+ NULL,
Class::ZoneHandle(isolate, cls.raw()),
ident);
}
@@ -7233,6 +7246,7 @@
ASSERT(func.is_static());
ASSERT(AbstractType::Handle(func.result_type()).IsResolved());
return new StaticGetterNode(qual_ident.ident_pos,
+ NULL,
Class::ZoneHandle(func.owner()),
*qual_ident.ident);
}
« no previous file with comments | « runtime/vm/ast.cc ('k') | tests/language/getter_no_setter_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698