| OLD | NEW |
| 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 part of ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 class SsaCodeGeneratorTask extends CompilerTask { | 7 class SsaCodeGeneratorTask extends CompilerTask { |
| 8 | 8 |
| 9 final JavaScriptBackend backend; | 9 final JavaScriptBackend backend; |
| 10 | 10 |
| (...skipping 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1639 }); | 1639 }); |
| 1640 } | 1640 } |
| 1641 | 1641 |
| 1642 push(new js.VariableUse(backend.namer.isolateAccess(node.element))); | 1642 push(new js.VariableUse(backend.namer.isolateAccess(node.element))); |
| 1643 push(new js.Call(pop(), visitArguments(node.inputs, start: 0)), node); | 1643 push(new js.Call(pop(), visitArguments(node.inputs, start: 0)), node); |
| 1644 } | 1644 } |
| 1645 | 1645 |
| 1646 visitInvokeSuper(HInvokeSuper node) { | 1646 visitInvokeSuper(HInvokeSuper node) { |
| 1647 Element superMethod = node.element; | 1647 Element superMethod = node.element; |
| 1648 world.registerStaticUse(superMethod); | 1648 world.registerStaticUse(superMethod); |
| 1649 Element superClass = superMethod.getEnclosingClass(); | 1649 ClassElement superClass = superMethod.getEnclosingClass(); |
| 1650 if (superMethod.kind == ElementKind.FIELD) { | 1650 if (superMethod.kind == ElementKind.FIELD) { |
| 1651 String fieldName = node.caller.isShadowedByField(superMethod) | 1651 String fieldName = node.caller.isShadowedByField(superMethod) |
| 1652 ? backend.namer.shadowedFieldName(superMethod) | 1652 ? backend.namer.shadowedFieldName(superMethod) |
| 1653 : backend.namer.instanceFieldName(superMethod); | 1653 : backend.namer.instanceFieldName(superMethod); |
| 1654 use(node.inputs[0]); | 1654 use(node.inputs[0]); |
| 1655 js.PropertyAccess access = | 1655 js.PropertyAccess access = |
| 1656 new js.PropertyAccess.field(pop(), fieldName); | 1656 new js.PropertyAccess.field(pop(), fieldName); |
| 1657 if (node.isSetter) { | 1657 if (node.isSetter) { |
| 1658 use(node.value); | 1658 use(node.value); |
| 1659 push(new js.Assignment(access, pop()), node); | 1659 push(new js.Assignment(access, pop()), node); |
| 1660 } else { | 1660 } else { |
| 1661 push(access, node); | 1661 push(access, node); |
| 1662 } | 1662 } |
| 1663 } else { | 1663 } else { |
| 1664 String methodName = backend.namer.getNameOfInstanceMember(superMethod); | 1664 Selector selector = node.selector; |
| 1665 String className = backend.namer.isolateAccess(superClass); | 1665 String methodName; |
| 1666 js.VariableUse classReference = new js.VariableUse(className); | 1666 if (selector.isGetter()) { |
| 1667 js.PropertyAccess prototype = | 1667 // If the selector we need to register a typed getter to the |
| 1668 new js.PropertyAccess.field(classReference, "prototype"); | 1668 // [world]. The emitter needs to know if it needs to emit a |
| 1669 // bound closure for a method. |
| 1670 TypeMask receiverType = new TypeMask.nonNullExact(superClass.rawType); |
| 1671 selector = new TypedSelector(receiverType, selector); |
| 1672 world.registerDynamicGetter(selector); |
| 1673 methodName = backend.namer.invocationName(selector); |
| 1674 } else { |
| 1675 methodName = backend.namer.getNameOfInstanceMember(superMethod); |
| 1676 } |
| 1669 js.PropertyAccess method = | 1677 js.PropertyAccess method = |
| 1670 new js.PropertyAccess.field(prototype, methodName); | 1678 backend.namer.elementAccess(superClass)['prototype'][methodName]; |
| 1671 push(jsPropertyCall( | 1679 push(jsPropertyCall( |
| 1672 method, "call", visitArguments(node.inputs, start: 0)), node); | 1680 method, "call", visitArguments(node.inputs, start: 0)), node); |
| 1673 } | 1681 } |
| 1674 } | 1682 } |
| 1675 | 1683 |
| 1676 visitFieldGet(HFieldGet node) { | 1684 visitFieldGet(HFieldGet node) { |
| 1677 use(node.receiver); | 1685 use(node.receiver); |
| 1678 Element element = node.element; | 1686 Element element = node.element; |
| 1679 if (element == backend.jsIndexableLength) { | 1687 if (element == backend.jsIndexableLength) { |
| 1680 // We're accessing a native JavaScript property called 'length' | 1688 // We're accessing a native JavaScript property called 'length' |
| (...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3013 if (leftType.canBeNull() && rightType.canBeNull()) { | 3021 if (leftType.canBeNull() && rightType.canBeNull()) { |
| 3014 if (left.isConstantNull() || right.isConstantNull() || | 3022 if (left.isConstantNull() || right.isConstantNull() || |
| 3015 (leftType.isPrimitive(compiler) && leftType == rightType)) { | 3023 (leftType.isPrimitive(compiler) && leftType == rightType)) { |
| 3016 return '=='; | 3024 return '=='; |
| 3017 } | 3025 } |
| 3018 return null; | 3026 return null; |
| 3019 } else { | 3027 } else { |
| 3020 return '==='; | 3028 return '==='; |
| 3021 } | 3029 } |
| 3022 } | 3030 } |
| OLD | NEW |