Chromium Code Reviews| 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 library _interceptors; | 5 library _interceptors; |
| 6 | 6 |
| 7 import 'dart:_js_embedded_names' show | 7 import 'dart:_js_embedded_names' show |
| 8 DISPATCH_PROPERTY_NAME; | 8 DISPATCH_PROPERTY_NAME, |
| 9 MAP_TYPE_TO_INTERCEPTOR; | |
| 9 | 10 |
| 10 import 'dart:collection'; | 11 import 'dart:collection'; |
| 11 import 'dart:_internal' hide Symbol; | 12 import 'dart:_internal' hide Symbol; |
| 12 import "dart:_internal" as _symbol_dev show Symbol; | 13 import "dart:_internal" as _symbol_dev show Symbol; |
| 13 import 'dart:_js_helper' show allMatchesInStringUnchecked, | 14 import 'dart:_js_helper' show allMatchesInStringUnchecked, |
| 14 Null, | 15 Null, |
| 15 JSSyntaxRegExp, | 16 JSSyntaxRegExp, |
| 16 Primitives, | 17 Primitives, |
| 17 checkInt, | 18 checkInt, |
| 18 checkNull, | 19 checkNull, |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 * JavaScript object map for the constructors. | 190 * JavaScript object map for the constructors. |
| 190 * | 191 * |
| 191 * The value of this variable is set by the compiler and contains only types | 192 * The value of this variable is set by the compiler and contains only types |
| 192 * that are user extensions of native classes where the type occurs as a | 193 * that are user extensions of native classes where the type occurs as a |
| 193 * constant in the program. | 194 * constant in the program. |
| 194 * | 195 * |
| 195 * The compiler, in CustomElementsAnalysis, assumes that [mapTypeToInterceptor] | 196 * The compiler, in CustomElementsAnalysis, assumes that [mapTypeToInterceptor] |
| 196 * is accessed only by code that also calls [findIndexForWebComponentType]. If | 197 * is accessed only by code that also calls [findIndexForWebComponentType]. If |
| 197 * this assumption is invalidated, the compiler will have to be updated. | 198 * this assumption is invalidated, the compiler will have to be updated. |
| 198 */ | 199 */ |
| 199 // TODO(sra): Mark this as initialized to a constant with unknown value. | 200 dynamic get mapTypeToInterceptor { |
|
ahe
2015/01/08 08:43:08
Why add "dynamic"? It is the default. It serves no
floitsch
2015/01/08 13:30:29
It also makes it clear to the reader that there is
| |
| 200 var mapTypeToInterceptor; | 201 return JS_EMBEDDED_GLOBAL('', MAP_TYPE_TO_INTERCEPTOR); |
| 202 } | |
| 201 | 203 |
| 202 int findIndexForNativeSubclassType(Type type) { | 204 int findIndexForNativeSubclassType(Type type) { |
| 203 if (JS('bool', '# == null', mapTypeToInterceptor)) return null; | 205 if (JS('bool', '# == null', mapTypeToInterceptor)) return null; |
| 204 List map = JS('JSFixedArray', '#', mapTypeToInterceptor); | 206 List map = JS('JSFixedArray', '#', mapTypeToInterceptor); |
| 205 for (int i = 0; i + 1 < map.length; i += 3) { | 207 for (int i = 0; i + 1 < map.length; i += 3) { |
| 206 if (type == map[i]) { | 208 if (type == map[i]) { |
| 207 return i; | 209 return i; |
| 208 } | 210 } |
| 209 } | 211 } |
| 210 return null; | 212 return null; |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 403 * Interceptor for unclassified JavaScript objects, typically objects with a | 405 * Interceptor for unclassified JavaScript objects, typically objects with a |
| 404 * non-trivial prototype chain. | 406 * non-trivial prototype chain. |
| 405 * | 407 * |
| 406 * This class also serves as a fallback for unknown JavaScript exceptions. | 408 * This class also serves as a fallback for unknown JavaScript exceptions. |
| 407 */ | 409 */ |
| 408 class UnknownJavaScriptObject extends JavaScriptObject { | 410 class UnknownJavaScriptObject extends JavaScriptObject { |
| 409 const UnknownJavaScriptObject(); | 411 const UnknownJavaScriptObject(); |
| 410 | 412 |
| 411 String toString() => JS('String', 'String(#)', this); | 413 String toString() => JS('String', 'String(#)', this); |
| 412 } | 414 } |
| OLD | NEW |