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 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 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1554 // Register this invocation to collect the types used at all call sites. | 1554 // Register this invocation to collect the types used at all call sites. |
1555 backend.registerStaticInvocation(node, types); | 1555 backend.registerStaticInvocation(node, types); |
1556 } | 1556 } |
1557 use(node.target); | 1557 use(node.target); |
1558 push(new js.Call(pop(), visitArguments(node.inputs)), node); | 1558 push(new js.Call(pop(), visitArguments(node.inputs)), node); |
1559 } | 1559 } |
1560 | 1560 |
1561 visitInvokeSuper(HInvokeSuper node) { | 1561 visitInvokeSuper(HInvokeSuper node) { |
1562 Element superMethod = node.element; | 1562 Element superMethod = node.element; |
1563 Element superClass = superMethod.getEnclosingClass(); | 1563 Element superClass = superMethod.getEnclosingClass(); |
1564 // Remove the element and 'this'. | |
1565 int argumentCount = node.inputs.length - 2; | |
1566 if (superMethod.kind == ElementKind.FIELD) { | 1564 if (superMethod.kind == ElementKind.FIELD) { |
1567 ClassElement currentClass = work.element.getEnclosingClass(); | 1565 ClassElement currentClass = work.element.getEnclosingClass(); |
1568 if (currentClass.isClosure()) { | 1566 if (currentClass.isClosure()) { |
1569 ClosureClassElement closure = currentClass; | 1567 ClosureClassElement closure = currentClass; |
1570 currentClass = closure.methodElement.getEnclosingClass(); | 1568 currentClass = closure.methodElement.getEnclosingClass(); |
1571 } | 1569 } |
1572 String fieldName; | 1570 String fieldName; |
1573 if (currentClass.isShadowedByField(superMethod)) { | 1571 if (currentClass.isShadowedByField(superMethod)) { |
1574 fieldName = backend.namer.shadowedFieldName(superMethod); | 1572 fieldName = backend.namer.shadowedFieldName(superMethod); |
1575 } else { | 1573 } else { |
1576 LibraryElement library = superMethod.getLibrary(); | 1574 LibraryElement library = superMethod.getLibrary(); |
1577 SourceString name = superMethod.name; | 1575 SourceString name = superMethod.name; |
1578 fieldName = backend.namer.instanceFieldName(library, name); | 1576 fieldName = backend.namer.instanceFieldName(library, name); |
1579 } | 1577 } |
1580 use(node.inputs[1]); | 1578 use(node.inputs[1]); |
1581 js.PropertyAccess access = | 1579 js.PropertyAccess access = |
1582 new js.PropertyAccess.field(pop(), fieldName); | 1580 new js.PropertyAccess.field(pop(), fieldName); |
1583 if (node.isSetter) { | 1581 if (node.isSetter) { |
1584 use(node.value); | 1582 use(node.value); |
1585 push(new js.Assignment(access, pop()), node); | 1583 push(new js.Assignment(access, pop()), node); |
1586 } else { | 1584 } else { |
1587 push(access, node); | 1585 push(access, node); |
1588 } | 1586 } |
1589 } else { | 1587 } else { |
1590 String methodName; | 1588 String methodName; |
1591 if (superMethod.kind == ElementKind.FUNCTION || | 1589 if (superMethod.kind == ElementKind.FUNCTION || |
1592 superMethod.kind == ElementKind.GENERATIVE_CONSTRUCTOR) { | 1590 superMethod.kind == ElementKind.GENERATIVE_CONSTRUCTOR) { |
1593 methodName = backend.namer.instanceMethodName( | 1591 methodName = backend.namer.instanceMethodName(superMethod); |
1594 currentLibrary, superMethod.name, argumentCount); | |
1595 } else if (superMethod.kind == ElementKind.GETTER) { | 1592 } else if (superMethod.kind == ElementKind.GETTER) { |
1596 methodName = | 1593 methodName = |
1597 backend.namer.getterName(currentLibrary, superMethod.name); | 1594 backend.namer.getterName(currentLibrary, superMethod.name); |
1598 } else { | 1595 } else { |
1599 assert(superMethod.kind == ElementKind.SETTER); | 1596 assert(superMethod.kind == ElementKind.SETTER); |
1600 methodName = | 1597 methodName = |
1601 backend.namer.setterName(currentLibrary, superMethod.name); | 1598 backend.namer.setterName(currentLibrary, superMethod.name); |
1602 } | 1599 } |
1603 String className = backend.namer.isolateAccess(superClass); | 1600 String className = backend.namer.isolateAccess(superClass); |
1604 js.VariableUse classReference = new js.VariableUse(className); | 1601 js.VariableUse classReference = new js.VariableUse(className); |
(...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2981 if (leftType.canBeNull() && rightType.canBeNull()) { | 2978 if (leftType.canBeNull() && rightType.canBeNull()) { |
2982 if (left.isConstantNull() || right.isConstantNull() || | 2979 if (left.isConstantNull() || right.isConstantNull() || |
2983 (leftType.isPrimitive() && leftType == rightType)) { | 2980 (leftType.isPrimitive() && leftType == rightType)) { |
2984 return '=='; | 2981 return '=='; |
2985 } | 2982 } |
2986 return null; | 2983 return null; |
2987 } else { | 2984 } else { |
2988 return '==='; | 2985 return '==='; |
2989 } | 2986 } |
2990 } | 2987 } |
OLD | NEW |