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

Side by Side Diff: lib/compiler/implementation/ssa/codegen.dart

Issue 10916079: Allow access to super fields inside a closure. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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
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 class SsaCodeGeneratorTask extends CompilerTask { 5 class SsaCodeGeneratorTask extends CompilerTask {
6 6
7 final JavaScriptBackend backend; 7 final JavaScriptBackend backend;
8 8
9 SsaCodeGeneratorTask(JavaScriptBackend backend) 9 SsaCodeGeneratorTask(JavaScriptBackend backend)
10 : this.backend = backend, 10 : this.backend = backend,
(...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after
1524 } 1524 }
1525 use(node.target); 1525 use(node.target);
1526 push(new js.Call(pop(), visitArguments(node.inputs)), node); 1526 push(new js.Call(pop(), visitArguments(node.inputs)), node);
1527 } 1527 }
1528 1528
1529 visitInvokeSuper(HInvokeSuper node) { 1529 visitInvokeSuper(HInvokeSuper node) {
1530 Element superMethod = node.element; 1530 Element superMethod = node.element;
1531 Element superClass = superMethod.getEnclosingClass(); 1531 Element superClass = superMethod.getEnclosingClass();
1532 // Remove the element and 'this'. 1532 // Remove the element and 'this'.
1533 int argumentCount = node.inputs.length - 2; 1533 int argumentCount = node.inputs.length - 2;
1534 String className = compiler.namer.isolateAccess(superClass);
1535 if (superMethod.kind == ElementKind.FIELD) { 1534 if (superMethod.kind == ElementKind.FIELD) {
1536 ClassElement currentClass = work.element.getEnclosingClass(); 1535 ClassElement currentClass = work.element.getEnclosingClass();
1536 if (currentClass.isClosure()) {
1537 ClosureClassElement closure = currentClass;
1538 currentClass = closure.originalElement.getEnclosingClass();
1539 }
1537 String fieldName; 1540 String fieldName;
1538 if (currentClass.isShadowedByField(superMethod)) { 1541 if (currentClass.isShadowedByField(superMethod)) {
1539 fieldName = compiler.namer.shadowedFieldName(superMethod); 1542 fieldName = compiler.namer.shadowedFieldName(superMethod);
1540 } else { 1543 } else {
1541 LibraryElement library = superMethod.getLibrary(); 1544 LibraryElement library = superMethod.getLibrary();
1542 SourceString name = superMethod.name; 1545 SourceString name = superMethod.name;
1543 fieldName = compiler.namer.instanceFieldName(library, name); 1546 fieldName = compiler.namer.instanceFieldName(library, name);
1544 } 1547 }
1548 use(node.inputs[1]);
1545 js.PropertyAccess access = 1549 js.PropertyAccess access =
1546 new js.PropertyAccess.field(new js.This(), fieldName); 1550 new js.PropertyAccess.field(pop(), fieldName);
1547 if (node.isSetter) { 1551 if (node.isSetter) {
1548 use(node.value); 1552 use(node.value);
1549 push(new js.Assignment(access, pop()), node); 1553 push(new js.Assignment(access, pop()), node);
1550 } else { 1554 } else {
1551 push(access, node); 1555 push(access, node);
1552 } 1556 }
1553 } else { 1557 } else {
1554 String methodName; 1558 String methodName;
1555 if (superMethod.kind == ElementKind.FUNCTION || 1559 if (superMethod.kind == ElementKind.FUNCTION ||
1556 superMethod.kind == ElementKind.GENERATIVE_CONSTRUCTOR) { 1560 superMethod.kind == ElementKind.GENERATIVE_CONSTRUCTOR) {
1557 methodName = compiler.namer.instanceMethodName( 1561 methodName = compiler.namer.instanceMethodName(
1558 currentLibrary, superMethod.name, argumentCount); 1562 currentLibrary, superMethod.name, argumentCount);
1559 } else if (superMethod.kind == ElementKind.GETTER) { 1563 } else if (superMethod.kind == ElementKind.GETTER) {
1560 methodName = 1564 methodName =
1561 compiler.namer.getterName(currentLibrary, superMethod.name); 1565 compiler.namer.getterName(currentLibrary, superMethod.name);
1562 } else { 1566 } else {
1563 assert(superMethod.kind == ElementKind.SETTER); 1567 assert(superMethod.kind == ElementKind.SETTER);
1564 methodName = 1568 methodName =
1565 compiler.namer.setterName(currentLibrary, superMethod.name); 1569 compiler.namer.setterName(currentLibrary, superMethod.name);
1566 } 1570 }
1571 String className = compiler.namer.isolateAccess(superClass);
1567 js.VariableUse classReference = new js.VariableUse(className); 1572 js.VariableUse classReference = new js.VariableUse(className);
1568 js.PropertyAccess prototype = 1573 js.PropertyAccess prototype =
1569 new js.PropertyAccess.field(classReference, "prototype"); 1574 new js.PropertyAccess.field(classReference, "prototype");
1570 js.PropertyAccess method = 1575 js.PropertyAccess method =
1571 new js.PropertyAccess.field(prototype, methodName); 1576 new js.PropertyAccess.field(prototype, methodName);
1572 push(jsPropertyCall(method, "call", visitArguments(node.inputs)), node); 1577 push(jsPropertyCall(method, "call", visitArguments(node.inputs)), node);
1573 } 1578 }
1574 world.registerStaticUse(superMethod); 1579 world.registerStaticUse(superMethod);
1575 } 1580 }
1576 1581
(...skipping 1310 matching lines...) Expand 10 before | Expand all | Expand 10 after
2887 if (leftType.canBeNull() && rightType.canBeNull()) { 2892 if (leftType.canBeNull() && rightType.canBeNull()) {
2888 if (left.isConstantNull() || right.isConstantNull() || 2893 if (left.isConstantNull() || right.isConstantNull() ||
2889 (leftType.isPrimitive() && leftType == rightType)) { 2894 (leftType.isPrimitive() && leftType == rightType)) {
2890 return '=='; 2895 return '==';
2891 } 2896 }
2892 return null; 2897 return null;
2893 } else { 2898 } else {
2894 return '==='; 2899 return '===';
2895 } 2900 }
2896 } 2901 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698