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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 13865004: Fix issue https://code.google.com/p/dart/issues/detail?id=9251, by compiling for/in correctly. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/ssa/builder.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/ssa/builder.dart (revision 21618)
+++ sdk/lib/_internal/compiler/implementation/ssa/builder.dart (working copy)
@@ -2538,25 +2538,31 @@
void generateNonInstanceSetter(SendSet send,
Element element,
- HInstruction value) {
- assert(!Elements.isInstanceSend(send, elements));
+ HInstruction value,
+ {Node location}) {
+ assert(send == null || !Elements.isInstanceSend(send, elements));
+ if (location == null) {
+ assert(send != null);
+ location = send;
+ }
if (Elements.isStaticOrTopLevelField(element)) {
if (element.isSetter()) {
HStatic target = new HStatic(element);
add(target);
addWithPosition(
new HInvokeStatic(<HInstruction>[target, value], HType.UNKNOWN),
- send);
+ location);
} else {
value = potentiallyCheckType(value, element.computeType(compiler));
- addWithPosition(new HStaticStore(element, value), send);
+ addWithPosition(new HStaticStore(element, value), location);
}
stack.add(value);
} else if (Elements.isErroneousElement(element)) {
// An erroneous element indicates an unresolved static setter.
- generateThrowNoSuchMethod(send,
- getTargetName(element, 'set'),
- argumentNodes: send.arguments);
+ generateThrowNoSuchMethod(
+ location,
+ getTargetName(element, 'set'),
+ argumentNodes: (send == null ? const Link<Node>() : send.arguments));
} else {
stack.add(value);
// If the value does not already have a name, give it here.
@@ -4121,29 +4127,25 @@
bool hasGetter = compiler.world.hasAnyUserDefinedGetter(call);
push(new HInvokeDynamicGetter(call, null, iterator, !hasGetter));
- Element variable = elements[node.declaredIdentifier];
- Selector selector = elements.getSelector(node.declaredIdentifier);
+ Node identifier = node.declaredIdentifier;
+ Element variable = elements[identifier];
+ Selector selector = elements.getSelector(identifier);
- HInstruction oldVariable = pop();
- if (Elements.isUnresolved(variable)) {
- if (Elements.isInStaticContext(currentElement)) {
- generateThrowNoSuchMethod(
- node.declaredIdentifier,
- 'set ${selector.name.slowToString()}',
- argumentValues: <HInstruction>[oldVariable]);
- } else {
- // The setter may have been defined in a subclass.
- generateInstanceSetterWithCompiledReceiver(
- null,
- localsHandler.readThis(),
- oldVariable,
- selector: selector,
- location: node.declaredIdentifier);
- }
- pop();
+ HInstruction value = pop();
+ if (identifier.asSend() != null
+ && Elements.isInstanceSend(identifier, elements)) {
+ HInstruction receiver = generateInstanceSendReceiver(identifier);
+ assert(receiver != null);
+ generateInstanceSetterWithCompiledReceiver(
+ null,
+ receiver,
+ value,
+ selector: selector,
+ location: identifier);
} else {
- localsHandler.updateLocal(variable, oldVariable);
+ generateNonInstanceSetter(null, variable, value, location: identifier);
}
+ pop(); // Pop the value pushed by the setter call.
visit(node.body);
}

Powered by Google App Engine
This is Rietveld 408576698