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 2338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2349 // For now, native classes cannot be deferred. | 2349 // For now, native classes cannot be deferred. |
2350 nativeClasses.add(element); | 2350 nativeClasses.add(element); |
2351 } else if (isDeferred(element)) { | 2351 } else if (isDeferred(element)) { |
2352 deferredClasses.add(element); | 2352 deferredClasses.add(element); |
2353 } else { | 2353 } else { |
2354 regularClasses.add(element); | 2354 regularClasses.add(element); |
2355 } | 2355 } |
2356 } | 2356 } |
2357 } | 2357 } |
2358 | 2358 |
2359 int _compareSelectors(Selector selector1, Selector selector2) { | |
2360 int comparison = _compareSelectorNames(selector1, selector2); | |
2361 if (comparison != 0) return comparison; | |
2362 | |
2363 Set<ClassElement> classes1 = backend.getInterceptedClassesOn(selector1); | |
2364 Set<ClassElement> classes2 = backend.getInterceptedClassesOn(selector2); | |
2365 if (classes1.length != classes2.length) { | |
2366 return classes1.length - classes2.length; | |
2367 } | |
2368 String getInterceptor1 = | |
2369 namer.getInterceptorName(backend.getInterceptorMethod, classes1); | |
2370 String getInterceptor2 = | |
2371 namer.getInterceptorName(backend.getInterceptorMethod, classes2); | |
2372 return Comparable.compare(getInterceptor1, getInterceptor2); | |
2373 } | |
2374 | |
2375 // Optimize performance critical one shot interceptors. | 2359 // Optimize performance critical one shot interceptors. |
2376 jsAst.Statement tryOptimizeOneShotInterceptor(Selector selector, | 2360 jsAst.Statement tryOptimizeOneShotInterceptor(Selector selector, |
2377 Set<ClassElement> classes) { | 2361 Set<ClassElement> classes) { |
2378 jsAst.Expression isNumber(String variable) { | 2362 jsAst.Expression isNumber(String variable) { |
2379 return js[variable].typeof.equals(js.string('number')); | 2363 return js[variable].typeof.equals(js.string('number')); |
2380 } | 2364 } |
2381 | 2365 |
2382 jsAst.Expression isNotObject(String variable) { | 2366 jsAst.Expression isNotObject(String variable) { |
2383 return js[variable].typeof.equals(js.string('object')).not; | 2367 return js[variable].typeof.equals(js.string('object')).not; |
2384 } | 2368 } |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2781 """; | 2765 """; |
2782 const String HOOKS_API_USAGE = """ | 2766 const String HOOKS_API_USAGE = """ |
2783 // The code supports the following hooks: | 2767 // The code supports the following hooks: |
2784 // dartPrint(message) - if this function is defined it is called | 2768 // dartPrint(message) - if this function is defined it is called |
2785 // instead of the Dart [print] method. | 2769 // instead of the Dart [print] method. |
2786 // dartMainRunner(main) - if this function is defined, the Dart [main] | 2770 // dartMainRunner(main) - if this function is defined, the Dart [main] |
2787 // method will not be invoked directly. | 2771 // method will not be invoked directly. |
2788 // Instead, a closure that will invoke [main] is | 2772 // Instead, a closure that will invoke [main] is |
2789 // passed to [dartMainRunner]. | 2773 // passed to [dartMainRunner]. |
2790 """; | 2774 """; |
OLD | NEW |