| 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 1817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1828 // Values match JSInvocationMirror in js-helper library. | 1828 // Values match JSInvocationMirror in js-helper library. |
| 1829 int type = selector.invocationMirrorKind; | 1829 int type = selector.invocationMirrorKind; |
| 1830 String methodName = selector.invocationMirrorMemberName; | 1830 String methodName = selector.invocationMirrorMemberName; |
| 1831 List<js.Parameter> parameters = <js.Parameter>[]; | 1831 List<js.Parameter> parameters = <js.Parameter>[]; |
| 1832 CodeBuffer args = new CodeBuffer(); | 1832 CodeBuffer args = new CodeBuffer(); |
| 1833 for (int i = 0; i < selector.argumentCount; i++) { | 1833 for (int i = 0; i < selector.argumentCount; i++) { |
| 1834 parameters.add(new js.Parameter('\$$i')); | 1834 parameters.add(new js.Parameter('\$$i')); |
| 1835 } | 1835 } |
| 1836 | 1836 |
| 1837 List<js.Expression> argNames = | 1837 List<js.Expression> argNames = |
| 1838 selector.getOrderedNamedArguments().mappedBy((SourceString name) => | 1838 selector.getOrderedNamedArguments().map((SourceString name) => |
| 1839 js.string(name.slowToString())).toList(); | 1839 js.string(name.slowToString())).toList(); |
| 1840 | 1840 |
| 1841 String internalName = namer.invocationMirrorInternalName(selector); | 1841 String internalName = namer.invocationMirrorInternalName(selector); |
| 1842 | 1842 |
| 1843 String createInvocationMirror = namer.getName( | 1843 String createInvocationMirror = namer.getName( |
| 1844 compiler.createInvocationMirrorElement); | 1844 compiler.createInvocationMirrorElement); |
| 1845 | 1845 |
| 1846 js.Expression expression = | 1846 js.Expression expression = |
| 1847 new js.This() | 1847 new js.This() |
| 1848 .dot(noSuchMethodName) | 1848 .dot(noSuchMethodName) |
| 1849 .callWith( | 1849 .callWith( |
| 1850 <js.Expression>[ | 1850 <js.Expression>[ |
| 1851 new js.VariableUse(namer.CURRENT_ISOLATE) | 1851 new js.VariableUse(namer.CURRENT_ISOLATE) |
| 1852 .dot(createInvocationMirror) | 1852 .dot(createInvocationMirror) |
| 1853 .callWith( | 1853 .callWith( |
| 1854 <js.Expression>[ | 1854 <js.Expression>[ |
| 1855 js.string(methodName), | 1855 js.string(methodName), |
| 1856 js.string(internalName), | 1856 js.string(internalName), |
| 1857 new js.LiteralNumber('$type'), | 1857 new js.LiteralNumber('$type'), |
| 1858 new js.ArrayInitializer.from( | 1858 new js.ArrayInitializer.from( |
| 1859 parameters.mappedBy((param) => js.use(param.name)) | 1859 parameters.map((param) => js.use(param.name)) |
| 1860 .toList()), | 1860 .toList()), |
| 1861 new js.ArrayInitializer.from(argNames)])]); | 1861 new js.ArrayInitializer.from(argNames)])]); |
| 1862 js.Expression function = | 1862 js.Expression function = |
| 1863 new js.Fun(parameters, | 1863 new js.Fun(parameters, |
| 1864 new js.Block(<js.Statement>[new js.Return(expression)])); | 1864 new js.Block(<js.Statement>[new js.Return(expression)])); |
| 1865 return function; | 1865 return function; |
| 1866 } | 1866 } |
| 1867 | 1867 |
| 1868 void addNoSuchMethodHandlers(SourceString ignore, Set<Selector> selectors) { | 1868 void addNoSuchMethodHandlers(SourceString ignore, Set<Selector> selectors) { |
| 1869 // Cache the object class and type. | 1869 // Cache the object class and type. |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2305 """; | 2305 """; |
| 2306 const String HOOKS_API_USAGE = """ | 2306 const String HOOKS_API_USAGE = """ |
| 2307 // The code supports the following hooks: | 2307 // The code supports the following hooks: |
| 2308 // dartPrint(message) - if this function is defined it is called | 2308 // dartPrint(message) - if this function is defined it is called |
| 2309 // instead of the Dart [print] method. | 2309 // instead of the Dart [print] method. |
| 2310 // dartMainRunner(main) - if this function is defined, the Dart [main] | 2310 // dartMainRunner(main) - if this function is defined, the Dart [main] |
| 2311 // method will not be invoked directly. | 2311 // method will not be invoked directly. |
| 2312 // Instead, a closure that will invoke [main] is | 2312 // Instead, a closure that will invoke [main] is |
| 2313 // passed to [dartMainRunner]. | 2313 // passed to [dartMainRunner]. |
| 2314 """; | 2314 """; |
| OLD | NEW |