| 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 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 } | 578 } |
| 579 diffEncoding.write(short); | 579 diffEncoding.write(short); |
| 580 } | 580 } |
| 581 nameCounter++; | 581 nameCounter++; |
| 582 } | 582 } |
| 583 | 583 |
| 584 // Startup code that loops over the method names and puts handlers on the | 584 // Startup code that loops over the method names and puts handlers on the |
| 585 // Object class to catch noSuchMethod invocations. | 585 // Object class to catch noSuchMethod invocations. |
| 586 ClassElement objectClass = compiler.objectClass; | 586 ClassElement objectClass = compiler.objectClass; |
| 587 String createInvocationMirror = namer.getName( | 587 String createInvocationMirror = namer.getName( |
| 588 compiler.createInvocationMirrorElement); | 588 backend.getCreateInvocationMirror()); |
| 589 String noSuchMethodName = namer.publicInstanceMethodNameByArity( | 589 String noSuchMethodName = namer.publicInstanceMethodNameByArity( |
| 590 Compiler.NO_SUCH_METHOD, Compiler.NO_SUCH_METHOD_ARG_COUNT); | 590 Compiler.NO_SUCH_METHOD, Compiler.NO_SUCH_METHOD_ARG_COUNT); |
| 591 var type = 0; | 591 var type = 0; |
| 592 if (useDiffEncoding) { | 592 if (useDiffEncoding) { |
| 593 statements.addAll([ | 593 statements.addAll([ |
| 594 js('var objectClassObject = ' | 594 js('var objectClassObject = ' |
| 595 ' collectedClasses["${namer.getName(objectClass)}"],' | 595 ' collectedClasses["${namer.getName(objectClass)}"],' |
| 596 ' shortNames = "$diffEncoding".split(","),' | 596 ' shortNames = "$diffEncoding".split(","),' |
| 597 ' nameNumber = 0,' | 597 ' nameNumber = 0,' |
| 598 ' diffEncodedString = shortNames[0],' | 598 ' diffEncodedString = shortNames[0],' |
| (...skipping 2220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2819 return type == 0; | 2819 return type == 0; |
| 2820 } | 2820 } |
| 2821 | 2821 |
| 2822 void emitNoSuchMethodHandlers(DefineStubFunction defineStub) { | 2822 void emitNoSuchMethodHandlers(DefineStubFunction defineStub) { |
| 2823 // Do not generate no such method handlers if there is no class. | 2823 // Do not generate no such method handlers if there is no class. |
| 2824 if (compiler.codegenWorld.instantiatedClasses.isEmpty) return; | 2824 if (compiler.codegenWorld.instantiatedClasses.isEmpty) return; |
| 2825 | 2825 |
| 2826 String noSuchMethodName = namer.publicInstanceMethodNameByArity( | 2826 String noSuchMethodName = namer.publicInstanceMethodNameByArity( |
| 2827 Compiler.NO_SUCH_METHOD, Compiler.NO_SUCH_METHOD_ARG_COUNT); | 2827 Compiler.NO_SUCH_METHOD, Compiler.NO_SUCH_METHOD_ARG_COUNT); |
| 2828 | 2828 |
| 2829 Element createInvocationMirrorElement = | 2829 Element createInvocationMirrorElement = backend.getCreateInvocationMirror(); |
| 2830 compiler.findHelper(const SourceString("createInvocationMirror")); | |
| 2831 String createInvocationMirrorName = | 2830 String createInvocationMirrorName = |
| 2832 namer.getName(createInvocationMirrorElement); | 2831 namer.getName(createInvocationMirrorElement); |
| 2833 | 2832 |
| 2834 // Keep track of the JavaScript names we've already added so we | 2833 // Keep track of the JavaScript names we've already added so we |
| 2835 // do not introduce duplicates (bad for code size). | 2834 // do not introduce duplicates (bad for code size). |
| 2836 Map<String, Selector> addedJsNames = new Map<String, Selector>(); | 2835 Map<String, Selector> addedJsNames = new Map<String, Selector>(); |
| 2837 | 2836 |
| 2838 void addNoSuchMethodHandlers(SourceString ignore, Set<Selector> selectors) { | 2837 void addNoSuchMethodHandlers(SourceString ignore, Set<Selector> selectors) { |
| 2839 // Cache the object class and type. | 2838 // Cache the object class and type. |
| 2840 ClassElement objectClass = compiler.objectClass; | 2839 ClassElement objectClass = compiler.objectClass; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2881 | 2880 |
| 2882 String methodName = selector.invocationMirrorMemberName; | 2881 String methodName = selector.invocationMirrorMemberName; |
| 2883 String internalName = namer.invocationMirrorInternalName(selector); | 2882 String internalName = namer.invocationMirrorInternalName(selector); |
| 2884 if (!haveVeryFewNoSuchMemberHandlers && | 2883 if (!haveVeryFewNoSuchMemberHandlers && |
| 2885 isTrivialNsmHandler(type, argNames, selector, internalName)) { | 2884 isTrivialNsmHandler(type, argNames, selector, internalName)) { |
| 2886 trivialNsmHandlers.add(selector); | 2885 trivialNsmHandlers.add(selector); |
| 2887 return null; | 2886 return null; |
| 2888 } | 2887 } |
| 2889 | 2888 |
| 2890 String createInvocationMirror = namer.getName( | 2889 String createInvocationMirror = namer.getName( |
| 2891 compiler.createInvocationMirrorElement); | 2890 backend.getCreateInvocationMirror()); |
| 2892 | 2891 |
| 2893 assert(backend.isInterceptedName(Compiler.NO_SUCH_METHOD)); | 2892 assert(backend.isInterceptedName(Compiler.NO_SUCH_METHOD)); |
| 2894 jsAst.Expression expression = js('this.$noSuchMethodName')( | 2893 jsAst.Expression expression = js('this.$noSuchMethodName')( |
| 2895 [js('this'), | 2894 [js('this'), |
| 2896 js(namer.CURRENT_ISOLATE)[createInvocationMirror]([ | 2895 js(namer.CURRENT_ISOLATE)[createInvocationMirror]([ |
| 2897 js.string(compiler.enableMinification ? | 2896 js.string(compiler.enableMinification ? |
| 2898 internalName : methodName), | 2897 internalName : methodName), |
| 2899 js.string(internalName), | 2898 js.string(internalName), |
| 2900 type, | 2899 type, |
| 2901 new jsAst.ArrayInitializer.from( | 2900 new jsAst.ArrayInitializer.from( |
| (...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4162 | 4161 |
| 4163 const String HOOKS_API_USAGE = """ | 4162 const String HOOKS_API_USAGE = """ |
| 4164 // The code supports the following hooks: | 4163 // The code supports the following hooks: |
| 4165 // dartPrint(message) - if this function is defined it is called | 4164 // dartPrint(message) - if this function is defined it is called |
| 4166 // instead of the Dart [print] method. | 4165 // instead of the Dart [print] method. |
| 4167 // dartMainRunner(main) - if this function is defined, the Dart [main] | 4166 // dartMainRunner(main) - if this function is defined, the Dart [main] |
| 4168 // method will not be invoked directly. | 4167 // method will not be invoked directly. |
| 4169 // Instead, a closure that will invoke [main] is | 4168 // Instead, a closure that will invoke [main] is |
| 4170 // passed to [dartMainRunner]. | 4169 // passed to [dartMainRunner]. |
| 4171 """; | 4170 """; |
| OLD | NEW |