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 1831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1842 // Values match JSInvocationMirror in js-helper library. | 1842 // Values match JSInvocationMirror in js-helper library. |
1843 int type = selector.invocationMirrorKind; | 1843 int type = selector.invocationMirrorKind; |
1844 String methodName = selector.invocationMirrorMemberName; | 1844 String methodName = selector.invocationMirrorMemberName; |
1845 List<js.Parameter> parameters = <js.Parameter>[]; | 1845 List<js.Parameter> parameters = <js.Parameter>[]; |
1846 CodeBuffer args = new CodeBuffer(); | 1846 CodeBuffer args = new CodeBuffer(); |
1847 for (int i = 0; i < selector.argumentCount; i++) { | 1847 for (int i = 0; i < selector.argumentCount; i++) { |
1848 parameters.add(new js.Parameter('\$$i')); | 1848 parameters.add(new js.Parameter('\$$i')); |
1849 } | 1849 } |
1850 | 1850 |
1851 List<js.Expression> argNames = | 1851 List<js.Expression> argNames = |
1852 selector.getOrderedNamedArguments().mappedBy((SourceString name) => | 1852 selector.getOrderedNamedArguments().map((SourceString name) => |
1853 js.string(name.slowToString())).toList(); | 1853 js.string(name.slowToString())).toList(); |
1854 | 1854 |
1855 String internalName = namer.invocationMirrorInternalName(selector); | 1855 String internalName = namer.invocationMirrorInternalName(selector); |
1856 | 1856 |
1857 String createInvocationMirror = namer.getName( | 1857 String createInvocationMirror = namer.getName( |
1858 compiler.createInvocationMirrorElement); | 1858 compiler.createInvocationMirrorElement); |
1859 | 1859 |
1860 js.Expression expression = | 1860 js.Expression expression = |
1861 new js.This() | 1861 new js.This() |
1862 .dot(noSuchMethodName) | 1862 .dot(noSuchMethodName) |
1863 .callWith( | 1863 .callWith( |
1864 <js.Expression>[ | 1864 <js.Expression>[ |
1865 new js.VariableUse(namer.CURRENT_ISOLATE) | 1865 new js.VariableUse(namer.CURRENT_ISOLATE) |
1866 .dot(createInvocationMirror) | 1866 .dot(createInvocationMirror) |
1867 .callWith( | 1867 .callWith( |
1868 <js.Expression>[ | 1868 <js.Expression>[ |
1869 js.string(methodName), | 1869 js.string(methodName), |
1870 js.string(internalName), | 1870 js.string(internalName), |
1871 new js.LiteralNumber('$type'), | 1871 new js.LiteralNumber('$type'), |
1872 new js.ArrayInitializer.from( | 1872 new js.ArrayInitializer.from( |
1873 parameters.mappedBy((param) => js.use(param.name)) | 1873 parameters.map((param) => js.use(param.name)) |
1874 .toList()), | 1874 .toList()), |
1875 new js.ArrayInitializer.from(argNames)])]); | 1875 new js.ArrayInitializer.from(argNames)])]); |
1876 js.Expression function = | 1876 js.Expression function = |
1877 new js.Fun(parameters, | 1877 new js.Fun(parameters, |
1878 new js.Block(<js.Statement>[new js.Return(expression)])); | 1878 new js.Block(<js.Statement>[new js.Return(expression)])); |
1879 return function; | 1879 return function; |
1880 } | 1880 } |
1881 | 1881 |
1882 void addNoSuchMethodHandlers(SourceString ignore, Set<Selector> selectors) { | 1882 void addNoSuchMethodHandlers(SourceString ignore, Set<Selector> selectors) { |
1883 // Cache the object class and type. | 1883 // Cache the object class and type. |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2338 """; | 2338 """; |
2339 const String HOOKS_API_USAGE = """ | 2339 const String HOOKS_API_USAGE = """ |
2340 // The code supports the following hooks: | 2340 // The code supports the following hooks: |
2341 // dartPrint(message) - if this function is defined it is called | 2341 // dartPrint(message) - if this function is defined it is called |
2342 // instead of the Dart [print] method. | 2342 // instead of the Dart [print] method. |
2343 // dartMainRunner(main) - if this function is defined, the Dart [main] | 2343 // dartMainRunner(main) - if this function is defined, the Dart [main] |
2344 // method will not be invoked directly. | 2344 // method will not be invoked directly. |
2345 // Instead, a closure that will invoke [main] is | 2345 // Instead, a closure that will invoke [main] is |
2346 // passed to [dartMainRunner]. | 2346 // passed to [dartMainRunner]. |
2347 """; | 2347 """; |
OLD | NEW |