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

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

Issue 11299220: Add @JSName annotation for native fields and methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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 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 1711 matching lines...) Expand 10 before | Expand all | Expand 10 after
1722 1722
1723 visitFieldGet(HFieldGet node) { 1723 visitFieldGet(HFieldGet node) {
1724 use(node.receiver); 1724 use(node.receiver);
1725 if (node.element == backend.jsArrayLength 1725 if (node.element == backend.jsArrayLength
1726 || node.element == backend.jsStringLength) { 1726 || node.element == backend.jsStringLength) {
1727 // We're accessing a native JavaScript property called 'length' 1727 // We're accessing a native JavaScript property called 'length'
1728 // on a JS String or a JS array. Therefore, the name of that 1728 // on a JS String or a JS array. Therefore, the name of that
1729 // property should not be mangled. 1729 // property should not be mangled.
1730 push(new js.PropertyAccess.field(pop(), 'length'), node); 1730 push(new js.PropertyAccess.field(pop(), 'length'), node);
1731 } else { 1731 } else {
1732 String name = backend.namer.getName(node.element); 1732 String name = node.element.isNative()
1733 ? node.element.nativeName()
1734 : backend.namer.getName(node.element);
1733 push(new js.PropertyAccess.field(pop(), name), node); 1735 push(new js.PropertyAccess.field(pop(), name), node);
1734 HType receiverHType = types[node.receiver]; 1736 HType receiverHType = types[node.receiver];
1735 DartType type = receiverHType.computeType(compiler); 1737 DartType type = receiverHType.computeType(compiler);
1736 if (type != null) { 1738 if (type != null) {
1737 world.registerFieldGetter( 1739 world.registerFieldGetter(
1738 node.element.name, node.element.getLibrary(), type); 1740 node.element.name, node.element.getLibrary(), type);
1739 } 1741 }
1740 } 1742 }
1741 } 1743 }
1742 1744
1743 visitFieldSet(HFieldSet node) { 1745 visitFieldSet(HFieldSet node) {
1744 String name = backend.namer.getName(node.element); 1746 String name = node.element.isNative()
1747 ? node.element.nativeName()
1748 : backend.namer.getName(node.element);
1745 DartType type = types[node.receiver].computeType(compiler); 1749 DartType type = types[node.receiver].computeType(compiler);
1746 if (type != null) { 1750 if (type != null) {
1747 // Field setters in the generative constructor body are handled in a 1751 // Field setters in the generative constructor body are handled in a
1748 // step "SsaConstructionFieldTypes" in the ssa optimizer. 1752 // step "SsaConstructionFieldTypes" in the ssa optimizer.
1749 if (!work.element.isGenerativeConstructorBody()) { 1753 if (!work.element.isGenerativeConstructorBody()) {
1750 world.registerFieldSetter( 1754 world.registerFieldSetter(
1751 node.element.name, node.element.getLibrary(), type); 1755 node.element.name, node.element.getLibrary(), type);
1752 backend.registerFieldSetter( 1756 backend.registerFieldSetter(
1753 work.element, node.element, types[node.value]); 1757 work.element, node.element, types[node.value]);
1754 } 1758 }
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698