| 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 js_backend; | 5 part of js_backend; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A function element that represents a closure call. The signature is copied | 8 * A function element that represents a closure call. The signature is copied |
| 9 * from the given element. | 9 * from the given element. |
| 10 */ | 10 */ |
| (...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 // generate the field getter/setter dynamically. Since this is only | 872 // generate the field getter/setter dynamically. Since this is only |
| 873 // allowed on fields that are in [classElement] we don't need to visit | 873 // allowed on fields that are in [classElement] we don't need to visit |
| 874 // superclasses for non-instantiated classes. | 874 // superclasses for non-instantiated classes. |
| 875 classElement.implementation.forEachInstanceField( | 875 classElement.implementation.forEachInstanceField( |
| 876 visitField, | 876 visitField, |
| 877 includeBackendMembers: true, | 877 includeBackendMembers: true, |
| 878 includeSuperMembers: isInstantiated && !classElement.isNative()); | 878 includeSuperMembers: isInstantiated && !classElement.isNative()); |
| 879 } | 879 } |
| 880 | 880 |
| 881 void generateGetter(Element member, String fieldName, String accessorName, | 881 void generateGetter(Element member, String fieldName, String accessorName, |
| 882 CodeBuffer buffer) { | 882 CodeBuffer buffer) { |
| 883 String getterName = namer.getterNameFromAccessorName(accessorName); | 883 String getterName = namer.getterNameFromAccessorName(accessorName); |
| 884 buffer.add("$getterName: function() { return this.$fieldName; }"); | 884 buffer.add("$getterName: function() { return this.$fieldName; }"); |
| 885 } | 885 } |
| 886 | 886 |
| 887 void generateSetter(Element member, String fieldName, String accessorName, | 887 void generateSetter(Element member, String fieldName, String accessorName, |
| 888 CodeBuffer buffer) { | 888 CodeBuffer buffer) { |
| 889 String setterName = namer.setterNameFromAccessorName(accessorName); | 889 String setterName = namer.setterNameFromAccessorName(accessorName); |
| 890 buffer.add("$setterName: function(v) { this.$fieldName = v; }"); | 890 buffer.add("$setterName: function(v) { this.$fieldName = v; }"); |
| 891 } | 891 } |
| 892 | 892 |
| 893 bool canGenerateCheckedSetter(Element member) { | 893 bool canGenerateCheckedSetter(Element member) { |
| 894 DartType type = member.computeType(compiler); | 894 DartType type = member.computeType(compiler); |
| 895 if (type.element.isTypeVariable() | 895 if (type.element.isTypeVariable() |
| 896 || type.element == compiler.dynamicClass | 896 || type.element == compiler.dynamicClass |
| 897 || type.element == compiler.objectClass) { | 897 || type.element == compiler.objectClass) { |
| 898 // TODO(ngeoffray): Support type checks on type parameters. | 898 // TODO(ngeoffray): Support type checks on type parameters. |
| 899 return false; | 899 return false; |
| 900 } | 900 } |
| 901 return true; | 901 return true; |
| 902 } | 902 } |
| (...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1732 List<js.Parameter> parameters = <js.Parameter>[]; | 1732 List<js.Parameter> parameters = <js.Parameter>[]; |
| 1733 CodeBuffer args = new CodeBuffer(); | 1733 CodeBuffer args = new CodeBuffer(); |
| 1734 for (int i = 0; i < selector.argumentCount; i++) { | 1734 for (int i = 0; i < selector.argumentCount; i++) { |
| 1735 parameters.add(new js.Parameter('\$$i')); | 1735 parameters.add(new js.Parameter('\$$i')); |
| 1736 } | 1736 } |
| 1737 | 1737 |
| 1738 List<js.Expression> argNames = | 1738 List<js.Expression> argNames = |
| 1739 selector.getOrderedNamedArguments().map((SourceString name) => | 1739 selector.getOrderedNamedArguments().map((SourceString name) => |
| 1740 new js.LiteralString('"${name.slowToString()}"')); | 1740 new js.LiteralString('"${name.slowToString()}"')); |
| 1741 | 1741 |
| 1742 String internalName = namer.instanceMethodInvocationName( | 1742 String internalName = namer.invocationMirrorInternalName(selector); |
| 1743 selector.library, new SourceString(methodName), selector); | |
| 1744 | 1743 |
| 1745 String createInvocationMirror = namer.getName( | 1744 String createInvocationMirror = namer.getName( |
| 1746 compiler.createInvocationMirrorElement); | 1745 compiler.createInvocationMirrorElement); |
| 1747 | 1746 |
| 1748 js.Expression expression = | 1747 js.Expression expression = |
| 1749 new js.This() | 1748 new js.This() |
| 1750 .dot(noSuchMethodName) | 1749 .dot(noSuchMethodName) |
| 1751 .callWith( | 1750 .callWith( |
| 1752 <js.Expression>[ | 1751 <js.Expression>[ |
| 1753 new js.VariableUse(namer.CURRENT_ISOLATE) | 1752 new js.VariableUse(namer.CURRENT_ISOLATE) |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2190 """; | 2189 """; |
| 2191 const String HOOKS_API_USAGE = """ | 2190 const String HOOKS_API_USAGE = """ |
| 2192 // The code supports the following hooks: | 2191 // The code supports the following hooks: |
| 2193 // dartPrint(message) - if this function is defined it is called | 2192 // dartPrint(message) - if this function is defined it is called |
| 2194 // instead of the Dart [print] method. | 2193 // instead of the Dart [print] method. |
| 2195 // dartMainRunner(main) - if this function is defined, the Dart [main] | 2194 // dartMainRunner(main) - if this function is defined, the Dart [main] |
| 2196 // method will not be invoked directly. | 2195 // method will not be invoked directly. |
| 2197 // Instead, a closure that will invoke [main] is | 2196 // Instead, a closure that will invoke [main] is |
| 2198 // passed to [dartMainRunner]. | 2197 // passed to [dartMainRunner]. |
| 2199 """; | 2198 """; |
| OLD | NEW |