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 1704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1715 | 1715 |
1716 visitFieldGet(HFieldGet node) { | 1716 visitFieldGet(HFieldGet node) { |
1717 use(node.receiver); | 1717 use(node.receiver); |
1718 if (node.element == backend.jsArrayLength | 1718 if (node.element == backend.jsArrayLength |
1719 || node.element == backend.jsStringLength) { | 1719 || node.element == backend.jsStringLength) { |
1720 // We're accessing a native JavaScript property called 'length' | 1720 // We're accessing a native JavaScript property called 'length' |
1721 // on a JS String or a JS array. Therefore, the name of that | 1721 // on a JS String or a JS array. Therefore, the name of that |
1722 // property should not be mangled. | 1722 // property should not be mangled. |
1723 push(new js.PropertyAccess.field(pop(), 'length'), node); | 1723 push(new js.PropertyAccess.field(pop(), 'length'), node); |
1724 } else { | 1724 } else { |
1725 String name = backend.namer.getName(node.element); | 1725 String name = node.element.isNative() |
ngeoffray
2012/11/28 20:31:23
Move this in the namer? It would avoid the code du
| |
1726 ? node.element.nativeName() | |
1727 : backend.namer.getName(node.element); | |
1726 push(new js.PropertyAccess.field(pop(), name), node); | 1728 push(new js.PropertyAccess.field(pop(), name), node); |
1727 HType receiverHType = types[node.receiver]; | 1729 HType receiverHType = types[node.receiver]; |
1728 DartType type = receiverHType.computeType(compiler); | 1730 DartType type = receiverHType.computeType(compiler); |
1729 if (type != null) { | 1731 if (type != null) { |
1730 world.registerFieldGetter( | 1732 world.registerFieldGetter( |
1731 node.element.name, node.element.getLibrary(), type); | 1733 node.element.name, node.element.getLibrary(), type); |
1732 } | 1734 } |
1733 } | 1735 } |
1734 } | 1736 } |
1735 | 1737 |
1736 visitFieldSet(HFieldSet node) { | 1738 visitFieldSet(HFieldSet node) { |
1737 String name = backend.namer.getName(node.element); | 1739 String name = node.element.isNative() |
1740 ? node.element.nativeName() | |
1741 : backend.namer.getName(node.element); | |
1738 DartType type = types[node.receiver].computeType(compiler); | 1742 DartType type = types[node.receiver].computeType(compiler); |
1739 if (type != null) { | 1743 if (type != null) { |
1740 // Field setters in the generative constructor body are handled in a | 1744 // Field setters in the generative constructor body are handled in a |
1741 // step "SsaConstructionFieldTypes" in the ssa optimizer. | 1745 // step "SsaConstructionFieldTypes" in the ssa optimizer. |
1742 if (!work.element.isGenerativeConstructorBody()) { | 1746 if (!work.element.isGenerativeConstructorBody()) { |
1743 world.registerFieldSetter( | 1747 world.registerFieldSetter( |
1744 node.element.name, node.element.getLibrary(), type); | 1748 node.element.name, node.element.getLibrary(), type); |
1745 backend.registerFieldSetter( | 1749 backend.registerFieldSetter( |
1746 work.element, node.element, types[node.value]); | 1750 work.element, node.element, types[node.value]); |
1747 } | 1751 } |
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3049 if (leftType.canBeNull() && rightType.canBeNull()) { | 3053 if (leftType.canBeNull() && rightType.canBeNull()) { |
3050 if (left.isConstantNull() || right.isConstantNull() || | 3054 if (left.isConstantNull() || right.isConstantNull() || |
3051 (leftType.isPrimitive() && leftType == rightType)) { | 3055 (leftType.isPrimitive() && leftType == rightType)) { |
3052 return '=='; | 3056 return '=='; |
3053 } | 3057 } |
3054 return null; | 3058 return null; |
3055 } else { | 3059 } else { |
3056 return '==='; | 3060 return '==='; |
3057 } | 3061 } |
3058 } | 3062 } |
OLD | NEW |