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 dart2js.js_emitter; | 5 part of dart2js.js_emitter; |
6 | 6 |
7 class NativeEmitter { | 7 class NativeEmitter { |
8 | 8 |
9 // TODO(floitsch): the native-emitter should not know about ClassBuilders. | 9 // TODO(floitsch): the native-emitter should not know about ClassBuilders. |
10 final Map<Element, full_js_emitter.ClassBuilder> cachedBuilders; | 10 final Map<Element, full_js_emitter.ClassBuilder> cachedBuilders; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 // Compute a pre-order traversal of the subclass forest. We actually want a | 79 // Compute a pre-order traversal of the subclass forest. We actually want a |
80 // post-order traversal but it is easier to compute the pre-order and use it | 80 // post-order traversal but it is easier to compute the pre-order and use it |
81 // in reverse. | 81 // in reverse. |
82 List<Class> preOrder = <Class>[]; | 82 List<Class> preOrder = <Class>[]; |
83 Set<Class> seen = new Set<Class>(); | 83 Set<Class> seen = new Set<Class>(); |
84 | 84 |
85 Class objectClass = null; | 85 Class objectClass = null; |
86 Class jsInterceptorClass = null; | 86 Class jsInterceptorClass = null; |
87 | 87 |
88 void walk(Class cls) { | 88 void walk(Class cls) { |
89 if (cls.element == compiler.objectClass) { | 89 if (cls.element == compiler.coreClasses.objectClass) { |
90 objectClass = cls; | 90 objectClass = cls; |
91 return; | 91 return; |
92 } | 92 } |
93 if (cls.element == backend.jsInterceptorClass) { | 93 if (cls.element == backend.jsInterceptorClass) { |
94 jsInterceptorClass = cls; | 94 jsInterceptorClass = cls; |
95 return; | 95 return; |
96 } | 96 } |
97 if (seen.contains(cls)) return; | 97 if (seen.contains(cls)) return; |
98 seen.add(cls); | 98 seen.add(cls); |
99 walk(cls.superclass); | 99 walk(cls.superclass); |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 // used. We should also use an interceptor if the check can't be satisfied | 357 // used. We should also use an interceptor if the check can't be satisfied |
358 // by a native class in case we get a native instance that tries to spoof | 358 // by a native class in case we get a native instance that tries to spoof |
359 // the type info. i.e the criteria for whether or not to use an interceptor | 359 // the type info. i.e the criteria for whether or not to use an interceptor |
360 // is whether the receiver can be native, not the type of the test. | 360 // is whether the receiver can be native, not the type of the test. |
361 if (element == null || !element.isClass) return false; | 361 if (element == null || !element.isClass) return false; |
362 ClassElement cls = element; | 362 ClassElement cls = element; |
363 if (backend.isNativeOrExtendsNative(cls)) return true; | 363 if (backend.isNativeOrExtendsNative(cls)) return true; |
364 return isSupertypeOfNativeClass(element); | 364 return isSupertypeOfNativeClass(element); |
365 } | 365 } |
366 } | 366 } |
OLD | NEW |