| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 dart2js.js_backend.helpers; | 5 library dart2js.js_backend.helpers; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/names.dart' show Identifiers, Uris; | 8 import '../common/names.dart' show Identifiers, Uris; |
| 9 import '../common/resolution.dart' show Resolution; | |
| 10 import '../compiler.dart' show Compiler; | 9 import '../compiler.dart' show Compiler; |
| 11 import '../core_types.dart' show CommonElements; | 10 import '../core_types.dart' show CommonElements, ElementEnvironment; |
| 12 import '../elements/elements.dart' | 11 import '../elements/elements.dart' show PublicName; |
| 13 show | 12 import '../elements/entities.dart'; |
| 14 AbstractFieldElement, | |
| 15 ClassElement, | |
| 16 ConstructorElement, | |
| 17 Element, | |
| 18 EnumClassElement, | |
| 19 FunctionElement, | |
| 20 LibraryElement, | |
| 21 MemberElement, | |
| 22 MethodElement, | |
| 23 Name, | |
| 24 PublicName; | |
| 25 import '../library_loader.dart' show LoadedLibraries; | 13 import '../library_loader.dart' show LoadedLibraries; |
| 26 import '../universe/call_structure.dart' show CallStructure; | 14 import '../universe/call_structure.dart' show CallStructure; |
| 27 import '../universe/selector.dart' show Selector; | 15 import '../universe/selector.dart' show Selector; |
| 28 import 'constant_system_javascript.dart'; | 16 import 'constant_system_javascript.dart'; |
| 29 import 'js_backend.dart'; | 17 import 'js_backend.dart'; |
| 30 | 18 |
| 31 /// Helper classes and functions for the JavaScript backend. | 19 /// Helper classes and functions for the JavaScript backend. |
| 32 class BackendHelpers { | 20 class BackendHelpers { |
| 33 static final Uri DART_JS_HELPER = new Uri(scheme: 'dart', path: '_js_helper'); | 21 static final Uri DART_JS_HELPER = new Uri(scheme: 'dart', path: '_js_helper'); |
| 34 static final Uri DART_INTERCEPTORS = | 22 static final Uri DART_INTERCEPTORS = |
| (...skipping 10 matching lines...) Expand all Loading... |
| 45 static final Uri PACKAGE_JS = new Uri(scheme: 'package', path: 'js/js.dart'); | 33 static final Uri PACKAGE_JS = new Uri(scheme: 'package', path: 'js/js.dart'); |
| 46 | 34 |
| 47 static const String INVOKE_ON = '_getCachedInvocation'; | 35 static const String INVOKE_ON = '_getCachedInvocation'; |
| 48 static const String START_ROOT_ISOLATE = 'startRootIsolate'; | 36 static const String START_ROOT_ISOLATE = 'startRootIsolate'; |
| 49 | 37 |
| 50 static const String JS = 'JS'; | 38 static const String JS = 'JS'; |
| 51 static const String JS_BUILTIN = 'JS_BUILTIN'; | 39 static const String JS_BUILTIN = 'JS_BUILTIN'; |
| 52 static const String JS_EMBEDDED_GLOBAL = 'JS_EMBEDDED_GLOBAL'; | 40 static const String JS_EMBEDDED_GLOBAL = 'JS_EMBEDDED_GLOBAL'; |
| 53 static const String JS_INTERCEPTOR_CONSTANT = 'JS_INTERCEPTOR_CONSTANT'; | 41 static const String JS_INTERCEPTOR_CONSTANT = 'JS_INTERCEPTOR_CONSTANT'; |
| 54 | 42 |
| 55 final Compiler compiler; | 43 final ElementEnvironment _env; |
| 56 | 44 |
| 57 Element cachedCheckConcurrentModificationError; | 45 // TODO(johnniwinther): Remove this. |
| 58 | 46 final JavaScriptBackend backend; |
| 59 BackendHelpers(this.compiler); | 47 |
| 60 | 48 final CommonElements commonElements; |
| 61 JavaScriptBackend get backend => compiler.backend; | 49 |
| 62 | 50 BackendHelpers(this._env, this.backend, this.commonElements); |
| 63 Resolution get resolution => backend.resolution; | 51 |
| 64 | 52 ClassEntity _findInterceptorsClass(String name) => |
| 65 CommonElements get commonElements => compiler.commonElements; | 53 _findClass(interceptorsLibrary, name); |
| 66 | 54 |
| 67 DiagnosticReporter get reporter => compiler.reporter; | 55 FunctionEntity _findInterceptorsFunction(String name) => |
| 68 | 56 _findLibraryMember(interceptorsLibrary, name); |
| 69 MethodElement assertTest; | 57 |
| 70 MethodElement assertThrow; | 58 ClassEntity _findHelperClass(String name) => |
| 71 MethodElement assertHelper; | 59 _findClass(jsHelperLibrary, name); |
| 72 | 60 |
| 73 LibraryElement jsHelperLibrary; | 61 FunctionEntity _findHelperFunction(String name) => |
| 74 LibraryElement asyncLibrary; | 62 _findLibraryMember(jsHelperLibrary, name); |
| 75 LibraryElement interceptorsLibrary; | 63 |
| 76 LibraryElement foreignLibrary; | 64 ClassEntity _findAsyncHelperClass(String name) => |
| 77 LibraryElement isolateHelperLibrary; | 65 _findClass(asyncLibrary, name); |
| 66 |
| 67 FunctionEntity _findAsyncHelperFunction(String name) => |
| 68 _findLibraryMember(asyncLibrary, name); |
| 69 |
| 70 FunctionEntity _findMirrorsFunction(String name) { |
| 71 LibraryEntity library = _env.lookupLibrary(DART_JS_MIRRORS); |
| 72 if (library == null) return null; |
| 73 return _env.lookupLibraryMember(library, name, required: true); |
| 74 } |
| 75 |
| 76 ClassEntity _findClass(LibraryEntity library, String name) { |
| 77 return _env.lookupClass(library, name, required: true); |
| 78 } |
| 79 |
| 80 MemberEntity _findClassMember(ClassEntity cls, String name) { |
| 81 return _env.lookupClassMember(cls, name, required: true); |
| 82 } |
| 83 |
| 84 MemberEntity _findLibraryMember(LibraryEntity library, String name) { |
| 85 return _env.lookupLibraryMember(library, name, required: true); |
| 86 } |
| 87 |
| 88 FunctionEntity findCoreHelper(String name) => _env |
| 89 .lookupLibraryMember(commonElements.coreLibrary, name, required: true); |
| 90 |
| 91 ConstructorEntity _findConstructor(ClassEntity cls, String name) => |
| 92 _env.lookupConstructor(cls, name, required: true); |
| 93 |
| 94 void onLibrariesLoaded(LoadedLibraries loadedLibraries) { |
| 95 assert(loadedLibraries.containsLibrary(Uris.dart_core)); |
| 96 assert(loadedLibraries.containsLibrary(DART_INTERCEPTORS)); |
| 97 assert(loadedLibraries.containsLibrary(DART_JS_HELPER)); |
| 98 |
| 99 // TODO(johnniwinther): Avoid these. Currently needed to ensure resolution |
| 100 // of the classes for various queries in native behavior computation, |
| 101 // inference and codegen. |
| 102 _env.getThisType(jsArrayClass); |
| 103 _env.getThisType(jsExtendableArrayClass); |
| 104 } |
| 105 |
| 106 LibraryEntity _jsHelperLibrary; |
| 107 LibraryEntity get jsHelperLibrary => _jsHelperLibrary ??= _env.lookupLibrary(D
ART_JS_HELPER); |
| 108 |
| 109 LibraryEntity _asyncLibrary; |
| 110 LibraryEntity get asyncLibrary => _asyncLibrary ??= _env.lookupLibrary(Uris.da
rt_async); |
| 111 |
| 112 LibraryEntity _interceptorsLibrary; |
| 113 LibraryEntity get interceptorsLibrary => _interceptorsLibrary ??= _env.lookupL
ibrary(DART_INTERCEPTORS); |
| 114 |
| 115 LibraryEntity _foreignLibrary; |
| 116 LibraryEntity get foreignLibrary => _foreignLibrary ??= _env.lookupLibrary(DAR
T_FOREIGN_HELPER); |
| 117 |
| 118 LibraryEntity _isolateHelperLibrary; |
| 119 LibraryEntity get isolateHelperLibrary => _isolateHelperLibrary ??= _env.looku
pLibrary(DART_ISOLATE_HELPER); |
| 78 | 120 |
| 79 /// Reference to the internal library to lookup functions to always inline. | 121 /// Reference to the internal library to lookup functions to always inline. |
| 80 LibraryElement internalLibrary; | 122 LibraryEntity _internalLibrary; |
| 81 | 123 LibraryEntity get internalLibrary => _internalLibrary ??= _env.lookupLibrary(U
ris.dart__internal); |
| 82 ClassElement closureClass; | 124 |
| 83 ClassElement boundClosureClass; | 125 FunctionEntity _assertTest; |
| 84 Element assertUnreachableMethod; | 126 FunctionEntity get assertTest => |
| 85 Element invokeOnMethod; | 127 _assertTest ??= _findHelperFunction('assertTest'); |
| 86 | 128 |
| 87 ClassElement jsInterceptorClass; | 129 FunctionEntity _assertThrow; |
| 88 ClassElement jsStringClass; | 130 FunctionEntity get assertThrow => |
| 89 ClassElement jsArrayClass; | 131 _assertThrow ??= _findHelperFunction('assertThrow'); |
| 90 ClassElement jsNumberClass; | 132 |
| 91 ClassElement jsIntClass; | 133 FunctionEntity _assertHelper; |
| 92 ClassElement jsDoubleClass; | 134 FunctionEntity get assertHelper => |
| 93 ClassElement jsNullClass; | 135 _assertHelper ??= _findHelperFunction('assertHelper'); |
| 94 ClassElement jsBoolClass; | 136 |
| 95 ClassElement jsPlainJavaScriptObjectClass; | 137 FunctionEntity _assertUnreachableMethod; |
| 96 ClassElement jsUnknownJavaScriptObjectClass; | 138 FunctionEntity get assertUnreachableMethod => |
| 97 ClassElement jsJavaScriptFunctionClass; | 139 _assertUnreachableMethod ??= _findHelperFunction('assertUnreachable'); |
| 98 ClassElement jsJavaScriptObjectClass; | 140 |
| 99 | 141 ClassEntity _closureClass; |
| 100 ClassElement jsIndexableClass; | 142 ClassEntity get closureClass => _closureClass ??= _findHelperClass('Closure'); |
| 101 ClassElement jsMutableIndexableClass; | 143 |
| 102 | 144 ClassEntity _boundClosureClass; |
| 103 ClassElement jsMutableArrayClass; | 145 ClassEntity get boundClosureClass => |
| 104 ClassElement jsFixedArrayClass; | 146 _boundClosureClass ??= _findHelperClass('BoundClosure'); |
| 105 ClassElement jsExtendableArrayClass; | 147 |
| 106 ClassElement jsUnmodifiableArrayClass; | 148 FunctionEntity _invokeOnMethod; |
| 107 ClassElement jsPositiveIntClass; | 149 FunctionEntity get invokeOnMethod => _invokeOnMethod ??= |
| 108 ClassElement jsUInt32Class; | 150 _env.lookupClassMember(jsInvocationMirrorClass, INVOKE_ON); |
| 109 ClassElement jsUInt31Class; | 151 |
| 110 | 152 ClassEntity _jsInterceptorClass; |
| 111 MemberElement jsIndexableLength; | 153 ClassEntity get jsInterceptorClass => |
| 112 Element jsArrayTypedConstructor; | 154 _jsInterceptorClass ??= _findInterceptorsClass('Interceptor'); |
| 113 MethodElement jsArrayRemoveLast; | 155 |
| 114 MethodElement jsArrayAdd; | 156 ClassEntity _jsStringClass; |
| 115 MethodElement jsStringSplit; | 157 ClassEntity get jsStringClass => |
| 116 MethodElement jsStringToString; | 158 _jsStringClass ??= _findInterceptorsClass('JSString'); |
| 117 MethodElement jsStringOperatorAdd; | 159 |
| 118 MethodElement objectEquals; | 160 ClassEntity _jsArrayClass; |
| 119 | 161 ClassEntity get jsArrayClass => |
| 120 ClassElement typeLiteralClass; | 162 _jsArrayClass ??= _findInterceptorsClass('JSArray'); |
| 121 ClassElement mapLiteralClass; | 163 |
| 122 ClassElement constMapLiteralClass; | 164 ClassEntity _jsNumberClass; |
| 123 ClassElement typeVariableClass; | 165 ClassEntity get jsNumberClass => |
| 124 | 166 _jsNumberClass ??= _findInterceptorsClass('JSNumber'); |
| 125 ClassElement noSideEffectsClass; | 167 |
| 126 ClassElement noThrowsClass; | 168 ClassEntity _jsIntClass; |
| 127 ClassElement noInlineClass; | 169 ClassEntity get jsIntClass => _jsIntClass ??= _findInterceptorsClass('JSInt'); |
| 128 ClassElement forceInlineClass; | 170 |
| 129 ClassElement irRepresentationClass; | 171 ClassEntity _jsDoubleClass; |
| 130 | 172 ClassEntity get jsDoubleClass => |
| 131 ClassElement jsAnnotationClass; | 173 _jsDoubleClass ??= _findInterceptorsClass('JSDouble'); |
| 132 ClassElement jsAnonymousClass; | 174 |
| 133 | 175 ClassEntity _jsNullClass; |
| 134 Element getInterceptorMethod; | 176 ClassEntity get jsNullClass => |
| 135 | 177 _jsNullClass ??= _findInterceptorsClass('JSNull'); |
| 136 ClassElement jsInvocationMirrorClass; | 178 |
| 137 | 179 ClassEntity _jsBoolClass; |
| 138 ClassElement typedArrayClass; | 180 ClassEntity get jsBoolClass => |
| 139 ClassElement typedArrayOfIntClass; | 181 _jsBoolClass ??= _findInterceptorsClass('JSBool'); |
| 182 |
| 183 ClassEntity _jsPlainJavaScriptObjectClass; |
| 184 ClassEntity get jsPlainJavaScriptObjectClass => |
| 185 _jsPlainJavaScriptObjectClass ??= |
| 186 _findInterceptorsClass('PlainJavaScriptObject'); |
| 187 |
| 188 ClassEntity _jsUnknownJavaScriptObjectClass; |
| 189 ClassEntity get jsUnknownJavaScriptObjectClass => |
| 190 _jsUnknownJavaScriptObjectClass ??= |
| 191 _findInterceptorsClass('UnknownJavaScriptObject'); |
| 192 |
| 193 ClassEntity _jsJavaScriptFunctionClass; |
| 194 ClassEntity get jsJavaScriptFunctionClass => _jsJavaScriptFunctionClass ??= |
| 195 _findInterceptorsClass('JavaScriptFunction'); |
| 196 |
| 197 ClassEntity _jsJavaScriptObjectClass; |
| 198 ClassEntity get jsJavaScriptObjectClass => |
| 199 _jsJavaScriptObjectClass ??= _findInterceptorsClass('JavaScriptObject'); |
| 200 |
| 201 ClassEntity _jsIndexableClass; |
| 202 ClassEntity get jsIndexableClass => |
| 203 _jsIndexableClass ??= _findInterceptorsClass('JSIndexable'); |
| 204 |
| 205 ClassEntity _jsMutableIndexableClass; |
| 206 ClassEntity get jsMutableIndexableClass => |
| 207 _jsMutableIndexableClass ??= _findInterceptorsClass('JSMutableIndexable'); |
| 208 |
| 209 ClassEntity _jsMutableArrayClass; |
| 210 ClassEntity get jsMutableArrayClass => |
| 211 _jsMutableArrayClass ??= _findInterceptorsClass('JSMutableArray'); |
| 212 |
| 213 ClassEntity _jsFixedArrayClass; |
| 214 ClassEntity get jsFixedArrayClass => |
| 215 _jsFixedArrayClass ??= _findInterceptorsClass('JSFixedArray'); |
| 216 |
| 217 ClassEntity _jsExtendableArrayClass; |
| 218 ClassEntity get jsExtendableArrayClass => |
| 219 _jsExtendableArrayClass ??= _findInterceptorsClass('JSExtendableArray'); |
| 220 |
| 221 ClassEntity _jsUnmodifiableArrayClass; |
| 222 ClassEntity get jsUnmodifiableArrayClass => _jsUnmodifiableArrayClass ??= |
| 223 _findInterceptorsClass('JSUnmodifiableArray'); |
| 224 |
| 225 ClassEntity _jsPositiveIntClass; |
| 226 ClassEntity get jsPositiveIntClass => |
| 227 _jsPositiveIntClass ??= _findInterceptorsClass('JSPositiveInt'); |
| 228 |
| 229 ClassEntity _jsUInt32Class; |
| 230 ClassEntity get jsUInt32Class => |
| 231 _jsUInt32Class ??= _findInterceptorsClass('JSUInt32'); |
| 232 |
| 233 ClassEntity _jsUInt31Class; |
| 234 ClassEntity get jsUInt31Class => |
| 235 _jsUInt31Class ??= _findInterceptorsClass('JSUInt31'); |
| 236 |
| 237 MemberEntity _jsIndexableLength; |
| 238 MemberEntity get jsIndexableLength => |
| 239 _jsIndexableLength ??= _findClassMember(jsIndexableClass, 'length'); |
| 240 |
| 241 ConstructorEntity _jsArrayTypedConstructor; |
| 242 ConstructorEntity get jsArrayTypedConstructor => |
| 243 _jsArrayTypedConstructor ??= _findConstructor(jsArrayClass, 'typed'); |
| 244 |
| 245 FunctionEntity _jsArrayRemoveLast; |
| 246 FunctionEntity get jsArrayRemoveLast => |
| 247 _jsArrayRemoveLast ??= _findClassMember(jsArrayClass, 'removeLast'); |
| 248 |
| 249 FunctionEntity _jsArrayAdd; |
| 250 FunctionEntity get jsArrayAdd => |
| 251 _jsArrayAdd ??= _findClassMember(jsArrayClass, 'add'); |
| 252 |
| 253 FunctionEntity _jsStringSplit; |
| 254 FunctionEntity get jsStringSplit => |
| 255 _jsStringSplit ??= _findClassMember(jsStringClass, 'split'); |
| 256 |
| 257 FunctionEntity _jsStringToString; |
| 258 FunctionEntity get jsStringToString => |
| 259 _jsStringToString ??= _findClassMember(jsStringClass, 'toString'); |
| 260 |
| 261 FunctionEntity _jsStringOperatorAdd; |
| 262 FunctionEntity get jsStringOperatorAdd => |
| 263 _jsStringOperatorAdd ??= _findClassMember(jsStringClass, '+'); |
| 264 |
| 265 FunctionEntity _objectEquals; |
| 266 FunctionEntity get objectEquals => |
| 267 _objectEquals ??= _findClassMember(commonElements.objectClass, '=='); |
| 268 |
| 269 ClassEntity _typeLiteralClass; |
| 270 ClassEntity get typeLiteralClass => |
| 271 _typeLiteralClass ??= _findHelperClass('TypeImpl'); |
| 272 |
| 273 ClassEntity _mapLiteralClass; |
| 274 ClassEntity get mapLiteralClass { |
| 275 if (_mapLiteralClass == null) { |
| 276 _mapLiteralClass = |
| 277 _env.lookupClass(commonElements.coreLibrary, 'LinkedHashMap'); |
| 278 if (_mapLiteralClass == null) { |
| 279 _mapLiteralClass = _findClass( |
| 280 _env.lookupLibrary(Uris.dart_collection), 'LinkedHashMap'); |
| 281 } |
| 282 } |
| 283 return _mapLiteralClass; |
| 284 } |
| 285 |
| 286 ClassEntity _constMapLiteralClass; |
| 287 ClassEntity get constMapLiteralClass => |
| 288 _constMapLiteralClass ??= _findHelperClass('ConstantMap'); |
| 289 |
| 290 ClassEntity _typeVariableClass; |
| 291 ClassEntity get typeVariableClass => |
| 292 _typeVariableClass ??= _findHelperClass('TypeVariable'); |
| 293 |
| 294 ClassEntity _noSideEffectsClass; |
| 295 ClassEntity get noSideEffectsClass => |
| 296 _noSideEffectsClass ??= _findHelperClass('NoSideEffects'); |
| 297 |
| 298 ClassEntity _noThrowsClass; |
| 299 ClassEntity get noThrowsClass => |
| 300 _noThrowsClass ??= _findHelperClass('NoThrows'); |
| 301 |
| 302 ClassEntity _noInlineClass; |
| 303 ClassEntity get noInlineClass => |
| 304 _noInlineClass ??= _findHelperClass('NoInline'); |
| 305 |
| 306 ClassEntity _forceInlineClass; |
| 307 ClassEntity get forceInlineClass => |
| 308 _forceInlineClass ??= _findHelperClass('ForceInline'); |
| 309 |
| 310 ClassEntity _irRepresentationClass; |
| 311 ClassEntity get irRepresentationClass => |
| 312 _irRepresentationClass ??= _findHelperClass('IrRepresentation'); |
| 313 |
| 314 ClassEntity _jsAnnotationClass; |
| 315 ClassEntity get jsAnnotationClass { |
| 316 if (_jsAnnotationClass == null) { |
| 317 LibraryEntity library = _env.lookupLibrary(PACKAGE_JS); |
| 318 if (library == null) return null; |
| 319 _jsAnnotationClass = _findClass(library, 'JS'); |
| 320 } |
| 321 return _jsAnnotationClass; |
| 322 } |
| 323 |
| 324 ClassEntity _jsAnonymousClass; |
| 325 ClassEntity get jsAnonymousClass { |
| 326 if (_jsAnonymousClass == null) { |
| 327 LibraryEntity library = _env.lookupLibrary(PACKAGE_JS); |
| 328 if (library == null) return null; |
| 329 _jsAnonymousClass = _findClass(library, '_Anonymous'); |
| 330 } |
| 331 return _jsAnonymousClass; |
| 332 } |
| 333 |
| 334 FunctionEntity _getInterceptorMethod; |
| 335 FunctionEntity get getInterceptorMethod => |
| 336 _getInterceptorMethod ??= _findInterceptorsFunction('getInterceptor'); |
| 337 |
| 338 ClassEntity _jsInvocationMirrorClass; |
| 339 ClassEntity get jsInvocationMirrorClass => |
| 340 _jsInvocationMirrorClass ??= _findHelperClass('JSInvocationMirror'); |
| 341 |
| 342 ClassEntity _typedArrayClass; |
| 343 ClassEntity get typedArrayClass => _typedArrayClass ??= _findClass( |
| 344 _env.lookupLibrary(Uris.dart__native_typed_data, required: true), |
| 345 'NativeTypedArray'); |
| 346 |
| 347 ClassEntity _typedArrayOfIntClass; |
| 348 ClassEntity get typedArrayOfIntClass => _typedArrayOfIntClass ??= _findClass( |
| 349 _env.lookupLibrary(Uris.dart__native_typed_data, required: true), |
| 350 'NativeTypedArrayOfInt'); |
| 140 | 351 |
| 141 /** | 352 /** |
| 142 * Interface used to determine if an object has the JavaScript | 353 * Interface used to determine if an object has the JavaScript |
| 143 * indexing behavior. The interface is only visible to specific | 354 * indexing behavior. The interface is only visible to specific |
| 144 * libraries. | 355 * libraries. |
| 145 */ | 356 */ |
| 146 ClassElement jsIndexingBehaviorInterface; | 357 ClassEntity _jsIndexingBehaviorInterface; |
| 147 | 358 ClassEntity get jsIndexingBehaviorInterface => |
| 148 MethodElement getNativeInterceptorMethod; | 359 _jsIndexingBehaviorInterface ??= |
| 360 _findHelperClass('JavaScriptIndexingBehavior'); |
| 361 |
| 362 FunctionEntity _getNativeInterceptorMethod; |
| 363 FunctionEntity get getNativeInterceptorMethod => |
| 364 _getNativeInterceptorMethod ??= |
| 365 _findInterceptorsFunction('getNativeInterceptor'); |
| 149 | 366 |
| 150 /// Holds the method "getIsolateAffinityTag" when dart:_js_helper has been | 367 /// Holds the method "getIsolateAffinityTag" when dart:_js_helper has been |
| 151 /// loaded. | 368 /// loaded. |
| 152 FunctionElement getIsolateAffinityTagMarker; | 369 FunctionEntity _getIsolateAffinityTagMarker; |
| 370 FunctionEntity get getIsolateAffinityTagMarker => |
| 371 _getIsolateAffinityTagMarker ??= |
| 372 _findHelperFunction('getIsolateAffinityTag'); |
| 153 | 373 |
| 154 /// Holds the method "disableTreeShaking" in js_mirrors when | 374 /// Holds the method "disableTreeShaking" in js_mirrors when |
| 155 /// dart:mirrors has been loaded. | 375 /// dart:mirrors has been loaded. |
| 156 FunctionElement disableTreeShakingMarker; | 376 FunctionEntity _disableTreeShakingMarker; |
| 377 FunctionEntity get disableTreeShakingMarker => |
| 378 _disableTreeShakingMarker ??= _findMirrorsFunction('disableTreeShaking'); |
| 157 | 379 |
| 158 /// Holds the method "preserveNames" in js_mirrors when | 380 /// Holds the method "preserveNames" in js_mirrors when |
| 159 /// dart:mirrors has been loaded. | 381 /// dart:mirrors has been loaded. |
| 160 FunctionElement preserveNamesMarker; | 382 FunctionEntity _preserveNamesMarker; |
| 383 FunctionEntity get preserveNamesMarker { |
| 384 if (_preserveNamesMarker == null) { |
| 385 LibraryEntity library = _env.lookupLibrary(DART_JS_NAMES); |
| 386 if (library != null) { |
| 387 _preserveNamesMarker = _findLibraryMember(library, 'preserveNames'); |
| 388 } |
| 389 } |
| 390 return _preserveNamesMarker; |
| 391 } |
| 161 | 392 |
| 162 /// Holds the method "preserveMetadata" in js_mirrors when | 393 /// Holds the method "preserveMetadata" in js_mirrors when |
| 163 /// dart:mirrors has been loaded. | 394 /// dart:mirrors has been loaded. |
| 164 FunctionElement preserveMetadataMarker; | 395 FunctionEntity _preserveMetadataMarker; |
| 396 FunctionEntity get preserveMetadataMarker => |
| 397 _preserveMetadataMarker ??= _findMirrorsFunction('preserveMetadata'); |
| 165 | 398 |
| 166 /// Holds the method "preserveUris" in js_mirrors when | 399 /// Holds the method "preserveUris" in js_mirrors when |
| 167 /// dart:mirrors has been loaded. | 400 /// dart:mirrors has been loaded. |
| 168 FunctionElement preserveUrisMarker; | 401 FunctionEntity _preserveUrisMarker; |
| 402 FunctionEntity get preserveUrisMarker => |
| 403 _preserveUrisMarker ??= _findMirrorsFunction('preserveUris'); |
| 169 | 404 |
| 170 /// Holds the method "preserveLibraryNames" in js_mirrors when | 405 /// Holds the method "preserveLibraryNames" in js_mirrors when |
| 171 /// dart:mirrors has been loaded. | 406 /// dart:mirrors has been loaded. |
| 172 FunctionElement preserveLibraryNamesMarker; | 407 FunctionEntity _preserveLibraryNamesMarker; |
| 408 FunctionEntity get preserveLibraryNamesMarker => |
| 409 _preserveLibraryNamesMarker ??= |
| 410 _findMirrorsFunction('preserveLibraryNames'); |
| 173 | 411 |
| 174 /// Holds the method "requiresPreamble" in _js_helper. | 412 /// Holds the method "requiresPreamble" in _js_helper. |
| 175 FunctionElement requiresPreambleMarker; | 413 FunctionEntity _requiresPreambleMarker; |
| 414 FunctionEntity get requiresPreambleMarker => |
| 415 _requiresPreambleMarker ??= _findHelperFunction('requiresPreamble'); |
| 176 | 416 |
| 177 /// Holds the class for the [JsGetName] enum. | 417 /// Holds the class for the [JsGetName] enum. |
| 178 EnumClassElement jsGetNameEnum; | 418 ClassEntity _jsGetNameEnum; |
| 419 ClassEntity get jsGetNameEnum => _jsGetNameEnum ??= _findClass( |
| 420 _env.lookupLibrary(DART_EMBEDDED_NAMES, required: true), 'JsGetName'); |
| 179 | 421 |
| 180 /// Holds the class for the [JsBuiltins] enum. | 422 /// Holds the class for the [JsBuiltins] enum. |
| 181 EnumClassElement jsBuiltinEnum; | 423 ClassEntity _jsBuiltinEnum; |
| 182 | 424 ClassEntity get jsBuiltinEnum => _jsBuiltinEnum ??= _findClass( |
| 183 ClassElement _symbolImplementationClass; | 425 _env.lookupLibrary(DART_EMBEDDED_NAMES, required: true), 'JsBuiltin'); |
| 184 ClassElement get symbolImplementationClass { | |
| 185 return _symbolImplementationClass ??= _find(internalLibrary, 'Symbol'); | |
| 186 } | |
| 187 | 426 |
| 188 final Selector symbolValidatedConstructorSelector = | 427 final Selector symbolValidatedConstructorSelector = |
| 189 new Selector.call(const PublicName('validated'), CallStructure.ONE_ARG); | 428 new Selector.call(const PublicName('validated'), CallStructure.ONE_ARG); |
| 190 | 429 |
| 191 ConstructorElement _symbolValidatedConstructor; | 430 ConstructorEntity get symbolValidatedConstructor => |
| 192 | 431 _symbolValidatedConstructor ??= _findConstructor( |
| 193 bool isSymbolValidatedConstructor(Element element) { | 432 symbolImplementationClass, symbolValidatedConstructorSelector.name); |
| 433 |
| 434 ClassEntity _symbolImplementationClass; |
| 435 ClassEntity get symbolImplementationClass => |
| 436 _symbolImplementationClass ??= _findClass(internalLibrary, 'Symbol'); |
| 437 |
| 438 ConstructorEntity _symbolValidatedConstructor; |
| 439 |
| 440 bool isSymbolValidatedConstructor(ConstructorEntity element) { |
| 194 if (_symbolValidatedConstructor != null) { | 441 if (_symbolValidatedConstructor != null) { |
| 195 return element == _symbolValidatedConstructor; | 442 return element == _symbolValidatedConstructor; |
| 196 } | 443 } |
| 197 return false; | 444 return false; |
| 198 } | 445 } |
| 199 | 446 |
| 200 ConstructorElement get symbolValidatedConstructor { | 447 ConstructorEntity _mapLiteralConstructor; |
| 201 return _symbolValidatedConstructor ??= _findConstructor( | 448 ConstructorEntity _mapLiteralConstructorEmpty; |
| 202 symbolImplementationClass, symbolValidatedConstructorSelector.name); | 449 FunctionEntity _mapLiteralUntypedMaker; |
| 203 } | 450 FunctionEntity _mapLiteralUntypedEmptyMaker; |
| 204 | 451 |
| 205 // TODO(johnniwinther): Make these private. | 452 ConstructorEntity get mapLiteralConstructor { |
| 206 // TODO(johnniwinther): Split into _findHelperFunction and _findHelperClass | |
| 207 // and add a check that the element has the expected kind. | |
| 208 Element _findHelper(String name) => _find(jsHelperLibrary, name); | |
| 209 Element _findAsyncHelper(String name) => _find(asyncLibrary, name); | |
| 210 Element _findInterceptor(String name) => _find(interceptorsLibrary, name); | |
| 211 Element _find(LibraryElement library, String name) { | |
| 212 Element element = library.implementation.findLocal(name); | |
| 213 assert(invariant(library, element != null, | |
| 214 message: "Element '$name' not found in '${library.canonicalUri}'.")); | |
| 215 return element; | |
| 216 } | |
| 217 | |
| 218 Element findCoreHelper(String name) { | |
| 219 LibraryElement coreLibrary = compiler.commonElements.coreLibrary; | |
| 220 return coreLibrary.implementation.localLookup(name); | |
| 221 } | |
| 222 | |
| 223 ConstructorElement _findConstructor(ClassElement cls, String name) { | |
| 224 cls.ensureResolved(resolution); | |
| 225 ConstructorElement constructor = cls.lookupConstructor(name); | |
| 226 assert(invariant(cls, constructor != null, | |
| 227 message: "Constructor '$name' not found in '${cls}'.")); | |
| 228 return constructor; | |
| 229 } | |
| 230 | |
| 231 void onLibraryCreated(LibraryElement library) { | |
| 232 Uri uri = library.canonicalUri; | |
| 233 if (uri == DART_JS_HELPER) { | |
| 234 jsHelperLibrary = library; | |
| 235 } else if (uri == Uris.dart_async) { | |
| 236 asyncLibrary = library; | |
| 237 } else if (uri == Uris.dart__internal) { | |
| 238 internalLibrary = library; | |
| 239 } else if (uri == DART_INTERCEPTORS) { | |
| 240 interceptorsLibrary = library; | |
| 241 } else if (uri == DART_FOREIGN_HELPER) { | |
| 242 foreignLibrary = library; | |
| 243 } else if (uri == DART_ISOLATE_HELPER) { | |
| 244 isolateHelperLibrary = library; | |
| 245 } | |
| 246 } | |
| 247 | |
| 248 void initializeHelperClasses(DiagnosticReporter reporter) { | |
| 249 final List missingHelperClasses = []; | |
| 250 ClassElement lookupHelperClass(String name) { | |
| 251 ClassElement result = _findHelper(name); | |
| 252 if (result == null) { | |
| 253 missingHelperClasses.add(name); | |
| 254 } | |
| 255 return result; | |
| 256 } | |
| 257 | |
| 258 jsInvocationMirrorClass = lookupHelperClass('JSInvocationMirror'); | |
| 259 boundClosureClass = lookupHelperClass('BoundClosure'); | |
| 260 closureClass = lookupHelperClass('Closure'); | |
| 261 if (!missingHelperClasses.isEmpty) { | |
| 262 reporter.internalError( | |
| 263 jsHelperLibrary, | |
| 264 'dart:_js_helper library does not contain required classes: ' | |
| 265 '$missingHelperClasses'); | |
| 266 } | |
| 267 } | |
| 268 | |
| 269 void onLibraryScanned(LibraryElement library) { | |
| 270 Uri uri = library.canonicalUri; | |
| 271 | |
| 272 FunctionElement findMethod(String name) { | |
| 273 return _find(library, name); | |
| 274 } | |
| 275 | |
| 276 ClassElement findClass(String name) { | |
| 277 return _find(library, name); | |
| 278 } | |
| 279 | |
| 280 if (uri == DART_INTERCEPTORS) { | |
| 281 getInterceptorMethod = findMethod('getInterceptor'); | |
| 282 getNativeInterceptorMethod = findMethod('getNativeInterceptor'); | |
| 283 jsInterceptorClass = findClass('Interceptor'); | |
| 284 jsStringClass = findClass('JSString'); | |
| 285 jsArrayClass = findClass('JSArray'); | |
| 286 // The int class must be before the double class, because the | |
| 287 // emitter relies on this list for the order of type checks. | |
| 288 jsIntClass = findClass('JSInt'); | |
| 289 jsPositiveIntClass = findClass('JSPositiveInt'); | |
| 290 jsUInt32Class = findClass('JSUInt32'); | |
| 291 jsUInt31Class = findClass('JSUInt31'); | |
| 292 jsDoubleClass = findClass('JSDouble'); | |
| 293 jsNumberClass = findClass('JSNumber'); | |
| 294 jsNullClass = findClass('JSNull'); | |
| 295 jsBoolClass = findClass('JSBool'); | |
| 296 jsMutableArrayClass = findClass('JSMutableArray'); | |
| 297 jsFixedArrayClass = findClass('JSFixedArray'); | |
| 298 jsExtendableArrayClass = findClass('JSExtendableArray'); | |
| 299 jsUnmodifiableArrayClass = findClass('JSUnmodifiableArray'); | |
| 300 jsPlainJavaScriptObjectClass = findClass('PlainJavaScriptObject'); | |
| 301 jsJavaScriptObjectClass = findClass('JavaScriptObject'); | |
| 302 jsJavaScriptFunctionClass = findClass('JavaScriptFunction'); | |
| 303 jsUnknownJavaScriptObjectClass = findClass('UnknownJavaScriptObject'); | |
| 304 jsIndexableClass = findClass('JSIndexable'); | |
| 305 jsMutableIndexableClass = findClass('JSMutableIndexable'); | |
| 306 } else if (uri == DART_JS_HELPER) { | |
| 307 initializeHelperClasses(reporter); | |
| 308 assertTest = _findHelper('assertTest'); | |
| 309 assertThrow = _findHelper('assertThrow'); | |
| 310 assertHelper = _findHelper('assertHelper'); | |
| 311 assertUnreachableMethod = _findHelper('assertUnreachable'); | |
| 312 | |
| 313 typeLiteralClass = findClass('TypeImpl'); | |
| 314 constMapLiteralClass = findClass('ConstantMap'); | |
| 315 typeVariableClass = findClass('TypeVariable'); | |
| 316 | |
| 317 jsIndexingBehaviorInterface = findClass('JavaScriptIndexingBehavior'); | |
| 318 | |
| 319 noSideEffectsClass = findClass('NoSideEffects'); | |
| 320 noThrowsClass = findClass('NoThrows'); | |
| 321 noInlineClass = findClass('NoInline'); | |
| 322 forceInlineClass = findClass('ForceInline'); | |
| 323 irRepresentationClass = findClass('IrRepresentation'); | |
| 324 | |
| 325 getIsolateAffinityTagMarker = findMethod('getIsolateAffinityTag'); | |
| 326 | |
| 327 requiresPreambleMarker = findMethod('requiresPreamble'); | |
| 328 } else if (uri == DART_JS_MIRRORS) { | |
| 329 disableTreeShakingMarker = _find(library, 'disableTreeShaking'); | |
| 330 preserveMetadataMarker = _find(library, 'preserveMetadata'); | |
| 331 preserveUrisMarker = _find(library, 'preserveUris'); | |
| 332 preserveLibraryNamesMarker = _find(library, 'preserveLibraryNames'); | |
| 333 } else if (uri == DART_JS_NAMES) { | |
| 334 preserveNamesMarker = _find(library, 'preserveNames'); | |
| 335 } else if (uri == DART_EMBEDDED_NAMES) { | |
| 336 jsGetNameEnum = _find(library, 'JsGetName'); | |
| 337 jsBuiltinEnum = _find(library, 'JsBuiltin'); | |
| 338 } else if (uri == Uris.dart__native_typed_data) { | |
| 339 typedArrayClass = findClass('NativeTypedArray'); | |
| 340 typedArrayOfIntClass = findClass('NativeTypedArrayOfInt'); | |
| 341 } else if (uri == PACKAGE_JS) { | |
| 342 jsAnnotationClass = _find(library, 'JS'); | |
| 343 jsAnonymousClass = _find(library, '_Anonymous'); | |
| 344 } | |
| 345 } | |
| 346 | |
| 347 void onLibrariesLoaded(LoadedLibraries loadedLibraries) { | |
| 348 assert(loadedLibraries.containsLibrary(Uris.dart_core)); | |
| 349 assert(loadedLibraries.containsLibrary(DART_INTERCEPTORS)); | |
| 350 assert(loadedLibraries.containsLibrary(DART_JS_HELPER)); | |
| 351 | |
| 352 if (jsInvocationMirrorClass != null) { | |
| 353 jsInvocationMirrorClass.ensureResolved(resolution); | |
| 354 invokeOnMethod = jsInvocationMirrorClass.lookupLocalMember(INVOKE_ON); | |
| 355 } | |
| 356 | |
| 357 // [LinkedHashMap] is reexported from dart:collection and can therefore not | |
| 358 // be loaded from dart:core in [onLibraryScanned]. | |
| 359 LibraryElement coreLibrary = compiler.commonElements.coreLibrary; | |
| 360 mapLiteralClass = coreLibrary.find('LinkedHashMap'); | |
| 361 assert(invariant( | |
| 362 compiler.commonElements.coreLibrary, mapLiteralClass != null, | |
| 363 message: "Element 'LinkedHashMap' not found in 'dart:core'.")); | |
| 364 | |
| 365 // TODO(kasperl): Some tests do not define the special JSArray | |
| 366 // subclasses, so we check to see if they are defined before | |
| 367 // trying to resolve them. | |
| 368 if (jsFixedArrayClass != null) { | |
| 369 jsFixedArrayClass.ensureResolved(resolution); | |
| 370 } | |
| 371 if (jsExtendableArrayClass != null) { | |
| 372 jsExtendableArrayClass.ensureResolved(resolution); | |
| 373 } | |
| 374 if (jsUnmodifiableArrayClass != null) { | |
| 375 jsUnmodifiableArrayClass.ensureResolved(resolution); | |
| 376 } | |
| 377 | |
| 378 jsIndexableClass.ensureResolved(resolution); | |
| 379 Element jsIndexableLengthElement = | |
| 380 compiler.lookupElementIn(jsIndexableClass, 'length'); | |
| 381 if (jsIndexableLengthElement != null && | |
| 382 jsIndexableLengthElement.isAbstractField) { | |
| 383 AbstractFieldElement element = jsIndexableLengthElement; | |
| 384 jsIndexableLength = element.getter; | |
| 385 } else { | |
| 386 jsIndexableLength = jsIndexableLengthElement; | |
| 387 } | |
| 388 | |
| 389 jsArrayClass.ensureResolved(resolution); | |
| 390 jsArrayTypedConstructor = compiler.lookupElementIn(jsArrayClass, 'typed'); | |
| 391 jsArrayRemoveLast = compiler.lookupElementIn(jsArrayClass, 'removeLast'); | |
| 392 jsArrayAdd = compiler.lookupElementIn(jsArrayClass, 'add'); | |
| 393 | |
| 394 jsStringClass.ensureResolved(resolution); | |
| 395 jsStringSplit = compiler.lookupElementIn(jsStringClass, 'split'); | |
| 396 jsStringOperatorAdd = compiler.lookupElementIn(jsStringClass, '+'); | |
| 397 jsStringToString = compiler.lookupElementIn(jsStringClass, 'toString'); | |
| 398 | |
| 399 ClassElement objectClass = commonElements.objectClass; | |
| 400 objectEquals = compiler.lookupElementIn(objectClass, '=='); | |
| 401 } | |
| 402 | |
| 403 ConstructorElement _mapLiteralConstructor; | |
| 404 ConstructorElement _mapLiteralConstructorEmpty; | |
| 405 Element _mapLiteralUntypedMaker; | |
| 406 Element _mapLiteralUntypedEmptyMaker; | |
| 407 | |
| 408 ConstructorElement get mapLiteralConstructor { | |
| 409 _ensureMapLiteralHelpers(); | 453 _ensureMapLiteralHelpers(); |
| 410 return _mapLiteralConstructor; | 454 return _mapLiteralConstructor; |
| 411 } | 455 } |
| 412 | 456 |
| 413 ConstructorElement get mapLiteralConstructorEmpty { | 457 ConstructorEntity get mapLiteralConstructorEmpty { |
| 414 _ensureMapLiteralHelpers(); | 458 _ensureMapLiteralHelpers(); |
| 415 return _mapLiteralConstructorEmpty; | 459 return _mapLiteralConstructorEmpty; |
| 416 } | 460 } |
| 417 | 461 |
| 418 Element get mapLiteralUntypedMaker { | 462 FunctionEntity get mapLiteralUntypedMaker { |
| 419 _ensureMapLiteralHelpers(); | 463 _ensureMapLiteralHelpers(); |
| 420 return _mapLiteralUntypedMaker; | 464 return _mapLiteralUntypedMaker; |
| 421 } | 465 } |
| 422 | 466 |
| 423 Element get mapLiteralUntypedEmptyMaker { | 467 FunctionEntity get mapLiteralUntypedEmptyMaker { |
| 424 _ensureMapLiteralHelpers(); | 468 _ensureMapLiteralHelpers(); |
| 425 return _mapLiteralUntypedEmptyMaker; | 469 return _mapLiteralUntypedEmptyMaker; |
| 426 } | 470 } |
| 427 | 471 |
| 428 void _ensureMapLiteralHelpers() { | 472 void _ensureMapLiteralHelpers() { |
| 429 if (_mapLiteralConstructor != null) return; | 473 if (_mapLiteralConstructor != null) return; |
| 430 | 474 |
| 431 // For map literals, the dependency between the implementation class | 475 _mapLiteralConstructor = |
| 432 // and [Map] is not visible, so we have to add it manually. | 476 _env.lookupConstructor(mapLiteralClass, '_literal'); |
| 433 Element getFactory(String name, int arity) { | 477 _mapLiteralConstructorEmpty = |
| 434 // The constructor is on the patch class, but dart2js unit tests don't | 478 _env.lookupConstructor(mapLiteralClass, '_empty'); |
| 435 // have a patch class. | 479 _mapLiteralUntypedMaker = |
| 436 ClassElement implementation = mapLiteralClass.implementation; | 480 _env.lookupClassMember(mapLiteralClass, '_makeLiteral'); |
| 437 ConstructorElement ctor = implementation.lookupConstructor(name); | 481 _mapLiteralUntypedEmptyMaker = |
| 438 if (ctor == null || | 482 _env.lookupClassMember(mapLiteralClass, '_makeEmpty'); |
| 439 (Name.isPrivateName(name) && | 483 } |
| 440 ctor.library != mapLiteralClass.library)) { | 484 |
| 441 reporter.internalError( | 485 FunctionEntity get badMain { |
| 442 mapLiteralClass, | 486 return _findHelperFunction('badMain'); |
| 443 "Map literal class ${mapLiteralClass} missing " | 487 } |
| 444 "'$name' constructor" | 488 |
| 445 " ${mapLiteralClass.constructors}"); | 489 FunctionEntity get missingMain { |
| 446 } | 490 return _findHelperFunction('missingMain'); |
| 447 return ctor; | 491 } |
| 448 } | 492 |
| 449 | 493 FunctionEntity get mainHasTooManyParameters { |
| 450 Element getMember(String name) { | 494 return _findHelperFunction('mainHasTooManyParameters'); |
| 451 // The constructor is on the patch class, but dart2js unit tests don't | 495 } |
| 452 // have a patch class. | 496 |
| 453 ClassElement implementation = mapLiteralClass.implementation; | 497 FunctionEntity get loadLibraryWrapper { |
| 454 Element element = implementation.lookupLocalMember(name); | 498 return _findHelperFunction("_loadLibraryWrapper"); |
| 455 if (element == null || !element.isFunction || !element.isStatic) { | 499 } |
| 456 reporter.internalError( | 500 |
| 457 mapLiteralClass, | 501 FunctionEntity get boolConversionCheck { |
| 458 "Map literal class ${mapLiteralClass} missing " | 502 return _findHelperFunction('boolConversionCheck'); |
| 459 "'$name' static member function"); | 503 } |
| 460 } | 504 |
| 461 return element; | 505 FunctionEntity _traceHelper; |
| 462 } | 506 |
| 463 | 507 FunctionEntity get traceHelper { |
| 464 _mapLiteralConstructor = getFactory('_literal', 1); | |
| 465 _mapLiteralConstructorEmpty = getFactory('_empty', 0); | |
| 466 _mapLiteralUntypedMaker = getMember('_makeLiteral'); | |
| 467 _mapLiteralUntypedEmptyMaker = getMember('_makeEmpty'); | |
| 468 } | |
| 469 | |
| 470 Element get badMain { | |
| 471 return _findHelper('badMain'); | |
| 472 } | |
| 473 | |
| 474 Element get missingMain { | |
| 475 return _findHelper('missingMain'); | |
| 476 } | |
| 477 | |
| 478 Element get mainHasTooManyParameters { | |
| 479 return _findHelper('mainHasTooManyParameters'); | |
| 480 } | |
| 481 | |
| 482 MethodElement get loadLibraryWrapper { | |
| 483 return _findHelper("_loadLibraryWrapper"); | |
| 484 } | |
| 485 | |
| 486 Element get boolConversionCheck { | |
| 487 return _findHelper('boolConversionCheck'); | |
| 488 } | |
| 489 | |
| 490 MethodElement _traceHelper; | |
| 491 | |
| 492 MethodElement get traceHelper { | |
| 493 return _traceHelper ??= JavaScriptBackend.TRACE_METHOD == 'console' | 508 return _traceHelper ??= JavaScriptBackend.TRACE_METHOD == 'console' |
| 494 ? _consoleTraceHelper | 509 ? _consoleTraceHelper |
| 495 : _postTraceHelper; | 510 : _postTraceHelper; |
| 496 } | 511 } |
| 497 | 512 |
| 498 MethodElement get _consoleTraceHelper { | 513 FunctionEntity get _consoleTraceHelper => |
| 499 return _findHelper('consoleTraceHelper'); | 514 _findHelperFunction('consoleTraceHelper'); |
| 500 } | 515 |
| 501 | 516 FunctionEntity get _postTraceHelper => _findHelperFunction('postTraceHelper'); |
| 502 MethodElement get _postTraceHelper { | 517 |
| 503 return _findHelper('postTraceHelper'); | 518 FunctionEntity get closureFromTearOff => |
| 504 } | 519 _findHelperFunction('closureFromTearOff'); |
| 505 | 520 |
| 506 MethodElement get closureFromTearOff { | 521 FunctionEntity get isJsIndexable => _findHelperFunction('isJsIndexable'); |
| 507 return _findHelper('closureFromTearOff'); | 522 |
| 508 } | 523 FunctionEntity get throwIllegalArgumentException => |
| 509 | 524 _findHelperFunction('iae'); |
| 510 MethodElement get isJsIndexable { | 525 |
| 511 return _findHelper('isJsIndexable'); | 526 FunctionEntity get throwIndexOutOfRangeException => |
| 512 } | 527 _findHelperFunction('ioore'); |
| 513 | 528 |
| 514 MethodElement get throwIllegalArgumentException { | 529 FunctionEntity get exceptionUnwrapper => |
| 515 return _findHelper('iae'); | 530 _findHelperFunction('unwrapException'); |
| 516 } | 531 |
| 517 | 532 FunctionEntity get throwRuntimeError => |
| 518 MethodElement get throwIndexOutOfRangeException { | 533 _findHelperFunction('throwRuntimeError'); |
| 519 return _findHelper('ioore'); | 534 |
| 520 } | 535 FunctionEntity get throwTypeError => _findHelperFunction('throwTypeError'); |
| 521 | 536 |
| 522 Element get exceptionUnwrapper { | 537 FunctionEntity get throwAbstractClassInstantiationError => |
| 523 return _findHelper('unwrapException'); | 538 _findHelperFunction('throwAbstractClassInstantiationError'); |
| 524 } | 539 |
| 525 | 540 FunctionEntity _cachedCheckConcurrentModificationError; |
| 526 Element get throwRuntimeError { | 541 FunctionEntity get checkConcurrentModificationError => |
| 527 return _findHelper('throwRuntimeError'); | 542 _cachedCheckConcurrentModificationError ??= |
| 528 } | 543 _findHelperFunction('checkConcurrentModificationError'); |
| 529 | 544 |
| 530 Element get throwTypeError { | 545 FunctionEntity get throwConcurrentModificationError => |
| 531 return _findHelper('throwTypeError'); | 546 _findHelperFunction('throwConcurrentModificationError'); |
| 532 } | 547 |
| 533 | 548 FunctionEntity _checkInt; |
| 534 Element get throwAbstractClassInstantiationError { | 549 FunctionEntity get checkInt => _checkInt ??= _findHelperFunction('checkInt'); |
| 535 return _findHelper('throwAbstractClassInstantiationError'); | 550 |
| 536 } | 551 FunctionEntity _checkNum; |
| 537 | 552 FunctionEntity get checkNum => _checkNum ??= _findHelperFunction('checkNum'); |
| 538 Element get checkConcurrentModificationError { | 553 |
| 539 if (cachedCheckConcurrentModificationError == null) { | 554 FunctionEntity _checkString; |
| 540 cachedCheckConcurrentModificationError = | 555 FunctionEntity get checkString => |
| 541 _findHelper('checkConcurrentModificationError'); | 556 _checkString ??= _findHelperFunction('checkString'); |
| 542 } | 557 |
| 543 return cachedCheckConcurrentModificationError; | 558 FunctionEntity get stringInterpolationHelper => _findHelperFunction('S'); |
| 544 } | 559 |
| 545 | 560 FunctionEntity get wrapExceptionHelper => |
| 546 MethodElement get throwConcurrentModificationError { | 561 _findHelperFunction('wrapException'); |
| 547 return _findHelper('throwConcurrentModificationError'); | 562 |
| 548 } | 563 FunctionEntity get throwExpressionHelper => |
| 549 | 564 _findHelperFunction('throwExpression'); |
| 550 Element get checkInt => _checkInt ??= _findHelper('checkInt'); | 565 |
| 551 Element _checkInt; | 566 FunctionEntity get closureConverter => |
| 552 | 567 _findHelperFunction('convertDartClosureToJS'); |
| 553 Element get checkNum => _checkNum ??= _findHelper('checkNum'); | 568 |
| 554 Element _checkNum; | 569 FunctionEntity get traceFromException => |
| 555 | 570 _findHelperFunction('getTraceFromException'); |
| 556 Element get checkString => _checkString ??= _findHelper('checkString'); | 571 |
| 557 Element _checkString; | 572 FunctionEntity get setRuntimeTypeInfo => |
| 558 | 573 _findHelperFunction('setRuntimeTypeInfo'); |
| 559 MethodElement get stringInterpolationHelper { | 574 |
| 560 return _findHelper('S'); | 575 FunctionEntity get getRuntimeTypeInfo => |
| 561 } | 576 _findHelperFunction('getRuntimeTypeInfo'); |
| 562 | 577 |
| 563 MethodElement get wrapExceptionHelper { | 578 FunctionEntity get getTypeArgumentByIndex => |
| 564 return _findHelper(r'wrapException'); | 579 _findHelperFunction('getTypeArgumentByIndex'); |
| 565 } | 580 |
| 566 | 581 FunctionEntity get computeSignature => |
| 567 MethodElement get throwExpressionHelper { | 582 _findHelperFunction('computeSignature'); |
| 568 return _findHelper('throwExpression'); | 583 |
| 569 } | 584 FunctionEntity get getRuntimeTypeArguments => |
| 570 | 585 _findHelperFunction('getRuntimeTypeArguments'); |
| 571 MethodElement get closureConverter { | 586 |
| 572 return _findHelper('convertDartClosureToJS'); | 587 FunctionEntity get getRuntimeTypeArgument => |
| 573 } | 588 _findHelperFunction('getRuntimeTypeArgument'); |
| 574 | 589 |
| 575 Element get traceFromException { | 590 FunctionEntity get runtimeTypeToString => |
| 576 return _findHelper('getTraceFromException'); | 591 _findHelperFunction('runtimeTypeToString'); |
| 577 } | 592 |
| 578 | 593 FunctionEntity get assertIsSubtype => _findHelperFunction('assertIsSubtype'); |
| 579 MethodElement get setRuntimeTypeInfo { | 594 |
| 580 return _findHelper('setRuntimeTypeInfo'); | 595 FunctionEntity get checkSubtype => _findHelperFunction('checkSubtype'); |
| 581 } | 596 |
| 582 | 597 FunctionEntity get assertSubtype => _findHelperFunction('assertSubtype'); |
| 583 Element get getRuntimeTypeInfo { | 598 |
| 584 return _findHelper('getRuntimeTypeInfo'); | 599 FunctionEntity get subtypeCast => _findHelperFunction('subtypeCast'); |
| 585 } | 600 |
| 586 | 601 FunctionEntity get checkSubtypeOfRuntimeType => |
| 587 MethodElement get getTypeArgumentByIndex { | 602 _findHelperFunction('checkSubtypeOfRuntimeType'); |
| 588 return _findHelper('getTypeArgumentByIndex'); | 603 |
| 589 } | 604 FunctionEntity get assertSubtypeOfRuntimeType => |
| 590 | 605 _findHelperFunction('assertSubtypeOfRuntimeType'); |
| 591 MethodElement get computeSignature { | 606 |
| 592 return _findHelper('computeSignature'); | 607 FunctionEntity get subtypeOfRuntimeTypeCast => |
| 593 } | 608 _findHelperFunction('subtypeOfRuntimeTypeCast'); |
| 594 | 609 |
| 595 Element get getRuntimeTypeArguments { | 610 FunctionEntity get checkDeferredIsLoaded => |
| 596 return _findHelper('getRuntimeTypeArguments'); | 611 _findHelperFunction('checkDeferredIsLoaded'); |
| 597 } | 612 |
| 598 | 613 FunctionEntity get throwNoSuchMethod => |
| 599 MethodElement get getRuntimeTypeArgument { | 614 _findHelperFunction('throwNoSuchMethod'); |
| 600 return _findHelper('getRuntimeTypeArgument'); | 615 |
| 601 } | 616 FunctionEntity get malformedTypeError => |
| 602 | 617 _cachedCoreHelper('_malformedTypeError'); |
| 603 Element get runtimeTypeToString { | 618 FunctionEntity get genericNoSuchMethod => |
| 604 return _findHelper('runtimeTypeToString'); | 619 _cachedCoreHelper('_genericNoSuchMethod'); |
| 605 } | 620 FunctionEntity get unresolvedConstructorError => |
| 606 | |
| 607 Element get assertIsSubtype { | |
| 608 return _findHelper('assertIsSubtype'); | |
| 609 } | |
| 610 | |
| 611 Element get checkSubtype { | |
| 612 return _findHelper('checkSubtype'); | |
| 613 } | |
| 614 | |
| 615 Element get assertSubtype { | |
| 616 return _findHelper('assertSubtype'); | |
| 617 } | |
| 618 | |
| 619 Element get subtypeCast { | |
| 620 return _findHelper('subtypeCast'); | |
| 621 } | |
| 622 | |
| 623 Element get checkSubtypeOfRuntimeType { | |
| 624 return _findHelper('checkSubtypeOfRuntimeType'); | |
| 625 } | |
| 626 | |
| 627 Element get assertSubtypeOfRuntimeType { | |
| 628 return _findHelper('assertSubtypeOfRuntimeType'); | |
| 629 } | |
| 630 | |
| 631 Element get subtypeOfRuntimeTypeCast { | |
| 632 return _findHelper('subtypeOfRuntimeTypeCast'); | |
| 633 } | |
| 634 | |
| 635 Element get checkDeferredIsLoaded { | |
| 636 return _findHelper('checkDeferredIsLoaded'); | |
| 637 } | |
| 638 | |
| 639 Element get throwNoSuchMethod { | |
| 640 return _findHelper('throwNoSuchMethod'); | |
| 641 } | |
| 642 | |
| 643 Element get malformedTypeError => _cachedCoreHelper('_malformedTypeError'); | |
| 644 Element get genericNoSuchMethod => _cachedCoreHelper('_genericNoSuchMethod'); | |
| 645 Element get unresolvedConstructorError => | |
| 646 _cachedCoreHelper('_unresolvedConstructorError'); | 621 _cachedCoreHelper('_unresolvedConstructorError'); |
| 647 Element get unresolvedStaticGetterError => | 622 FunctionEntity get unresolvedStaticGetterError => |
| 648 _cachedCoreHelper('_unresolvedStaticGetterError'); | 623 _cachedCoreHelper('_unresolvedStaticGetterError'); |
| 649 Element get unresolvedStaticSetterError => | 624 FunctionEntity get unresolvedStaticSetterError => |
| 650 _cachedCoreHelper('_unresolvedStaticSetterError'); | 625 _cachedCoreHelper('_unresolvedStaticSetterError'); |
| 651 Element get unresolvedStaticMethodError => | 626 FunctionEntity get unresolvedStaticMethodError => |
| 652 _cachedCoreHelper('_unresolvedStaticMethodError'); | 627 _cachedCoreHelper('_unresolvedStaticMethodError'); |
| 653 Element get unresolvedTopLevelGetterError => | 628 FunctionEntity get unresolvedTopLevelGetterError => |
| 654 _cachedCoreHelper('_unresolvedTopLevelGetterError'); | 629 _cachedCoreHelper('_unresolvedTopLevelGetterError'); |
| 655 Element get unresolvedTopLevelSetterError => | 630 FunctionEntity get unresolvedTopLevelSetterError => |
| 656 _cachedCoreHelper('_unresolvedTopLevelSetterError'); | 631 _cachedCoreHelper('_unresolvedTopLevelSetterError'); |
| 657 Element get unresolvedTopLevelMethodError => | 632 FunctionEntity get unresolvedTopLevelMethodError => |
| 658 _cachedCoreHelper('_unresolvedTopLevelMethodError'); | 633 _cachedCoreHelper('_unresolvedTopLevelMethodError'); |
| 659 | 634 |
| 660 Map<String, Element> _cachedCoreHelpers = <String, Element>{}; | 635 Map<String, FunctionEntity> _cachedCoreHelpers = <String, FunctionEntity>{}; |
| 661 Element _cachedCoreHelper(String name) => | 636 FunctionEntity _cachedCoreHelper(String name) => |
| 662 _cachedCoreHelpers[name] ??= findCoreHelper(name); | 637 _cachedCoreHelpers[name] ??= findCoreHelper(name); |
| 663 | 638 |
| 664 MethodElement get createRuntimeType { | 639 FunctionEntity get createRuntimeType => |
| 665 return _findHelper('createRuntimeType'); | 640 _findHelperFunction('createRuntimeType'); |
| 666 } | 641 |
| 667 | 642 FunctionEntity get fallThroughError => |
| 668 Element get fallThroughError { | 643 _findHelperFunction("getFallThroughError"); |
| 669 return _findHelper("getFallThroughError"); | 644 |
| 670 } | 645 FunctionEntity get createInvocationMirror => |
| 671 | 646 _findHelperFunction('createInvocationMirror'); |
| 672 MethodElement get createInvocationMirror { | 647 |
| 673 return _findHelper('createInvocationMirror'); | 648 FunctionEntity get cyclicThrowHelper => |
| 674 } | 649 _findHelperFunction("throwCyclicInit"); |
| 675 | 650 |
| 676 MethodElement get cyclicThrowHelper { | 651 FunctionEntity get asyncHelper => _findAsyncHelperFunction("_asyncHelper"); |
| 677 return _findHelper("throwCyclicInit"); | 652 |
| 678 } | 653 FunctionEntity get wrapBody => |
| 679 | 654 _findAsyncHelperFunction("_wrapJsFunctionForAsync"); |
| 680 MethodElement get asyncHelper { | 655 |
| 681 return _findAsyncHelper("_asyncHelper"); | 656 FunctionEntity get yieldStar => _env.lookupClassMember( |
| 682 } | 657 _findAsyncHelperClass("_IterationMarker"), "yieldStar"); |
| 683 | 658 |
| 684 MethodElement get wrapBody { | 659 FunctionEntity get yieldSingle => _env.lookupClassMember( |
| 685 return _findAsyncHelper("_wrapJsFunctionForAsync"); | 660 _findAsyncHelperClass("_IterationMarker"), "yieldSingle"); |
| 686 } | 661 |
| 687 | 662 FunctionEntity get syncStarUncaughtError => _env.lookupClassMember( |
| 688 MethodElement get yieldStar { | 663 _findAsyncHelperClass("_IterationMarker"), "uncaughtError"); |
| 689 ClassElement classElement = _findAsyncHelper("_IterationMarker"); | 664 |
| 690 classElement.ensureResolved(resolution); | 665 FunctionEntity get asyncStarHelper => |
| 691 return classElement.lookupLocalMember("yieldStar"); | 666 _findAsyncHelperFunction("_asyncStarHelper"); |
| 692 } | 667 |
| 693 | 668 FunctionEntity get streamOfController => |
| 694 MethodElement get yieldSingle { | 669 _findAsyncHelperFunction("_streamOfController"); |
| 695 ClassElement classElement = _findAsyncHelper("_IterationMarker"); | 670 |
| 696 classElement.ensureResolved(resolution); | 671 FunctionEntity get endOfIteration => _env.lookupClassMember( |
| 697 return classElement.lookupLocalMember("yieldSingle"); | 672 _findAsyncHelperClass("_IterationMarker"), "endOfIteration"); |
| 698 } | 673 |
| 699 | 674 ClassEntity get syncStarIterable => |
| 700 MethodElement get syncStarUncaughtError { | 675 _findAsyncHelperClass("_SyncStarIterable"); |
| 701 ClassElement classElement = _findAsyncHelper("_IterationMarker"); | 676 |
| 702 classElement.ensureResolved(resolution); | 677 ClassEntity get futureImplementation => _findAsyncHelperClass('_Future'); |
| 703 return classElement.lookupLocalMember("uncaughtError"); | 678 |
| 704 } | 679 ClassEntity get controllerStream => |
| 705 | 680 _findAsyncHelperClass("_ControllerStream"); |
| 706 MethodElement get asyncStarHelper { | 681 |
| 707 return _findAsyncHelper("_asyncStarHelper"); | 682 ConstructorEntity get syncStarIterableConstructor => |
| 708 } | 683 _env.lookupConstructor(syncStarIterable, ""); |
| 709 | 684 |
| 710 MethodElement get streamOfController { | 685 ConstructorEntity get syncCompleterConstructor => |
| 711 return _findAsyncHelper("_streamOfController"); | 686 _env.lookupConstructor(_findAsyncHelperClass("Completer"), "sync"); |
| 712 } | 687 |
| 713 | 688 ClassEntity get asyncStarController => |
| 714 MethodElement get endOfIteration { | 689 _findAsyncHelperClass("_AsyncStarStreamController"); |
| 715 ClassElement classElement = _findAsyncHelper("_IterationMarker"); | 690 |
| 716 classElement.ensureResolved(resolution); | 691 ConstructorEntity get asyncStarControllerConstructor => |
| 717 return classElement.lookupLocalMember("endOfIteration"); | 692 _env.lookupConstructor(asyncStarController, "", required: true); |
| 718 } | 693 |
| 719 | 694 ConstructorEntity get streamIteratorConstructor => |
| 720 ClassElement get syncStarIterable { | 695 _env.lookupConstructor(_findAsyncHelperClass("StreamIterator"), ""); |
| 721 ClassElement classElement = _findAsyncHelper("_SyncStarIterable"); | 696 |
| 722 classElement.ensureResolved(resolution); | 697 ClassEntity get VoidRuntimeType => _findHelperClass('VoidRuntimeType'); |
| 723 return classElement; | 698 |
| 724 } | 699 ClassEntity get RuntimeType => _findHelperClass('RuntimeType'); |
| 725 | 700 |
| 726 Element get futureImplementation { | 701 ClassEntity get RuntimeFunctionType => |
| 727 ClassElement classElement = _findAsyncHelper('_Future'); | 702 _findHelperClass('RuntimeFunctionType'); |
| 728 classElement.ensureResolved(resolution); | 703 |
| 729 return classElement; | 704 ClassEntity get RuntimeTypePlain => _findHelperClass('RuntimeTypePlain'); |
| 730 } | 705 |
| 731 | 706 ClassEntity get RuntimeTypeGeneric => _findHelperClass('RuntimeTypeGeneric'); |
| 732 ClassElement get controllerStream { | 707 |
| 733 ClassElement classElement = _findAsyncHelper("_ControllerStream"); | 708 ClassEntity get DynamicRuntimeType => _findHelperClass('DynamicRuntimeType'); |
| 734 classElement.ensureResolved(resolution); | 709 |
| 735 return classElement; | 710 FunctionEntity get getDynamicRuntimeType { |
| 736 } | 711 // TODO(johnniwinther): Support this in mocks. |
| 737 | 712 return _env.lookupLibraryMember(jsHelperLibrary, 'getDynamicRuntimeType'); |
| 738 ConstructorElement get syncStarIterableConstructor { | 713 } |
| 739 ClassElement classElement = syncStarIterable; | 714 |
| 740 classElement.ensureResolved(resolution); | 715 FunctionEntity get getVoidRuntimeType { |
| 741 return classElement.lookupConstructor(""); | 716 // TODO(johnniwinther): Support this in mocks. |
| 742 } | 717 return _env.lookupLibraryMember(jsHelperLibrary, 'getVoidRuntimeType'); |
| 743 | 718 } |
| 744 ConstructorElement get syncCompleterConstructor { | 719 |
| 745 ClassElement classElement = _find(asyncLibrary, "Completer"); | 720 FunctionEntity get buildInterfaceType { |
| 746 classElement.ensureResolved(resolution); | 721 // TODO(johnniwinther): Support this in mocks. |
| 747 return classElement.lookupConstructor("sync"); | 722 return _env.lookupLibraryMember(jsHelperLibrary, 'buildInterfaceType'); |
| 748 } | 723 } |
| 749 | 724 |
| 750 ClassElement get asyncStarController { | 725 FunctionEntity get buildFunctionType { |
| 751 ClassElement classElement = _findAsyncHelper("_AsyncStarStreamController"); | 726 // TODO(johnniwinther): Support this in mocks. |
| 752 classElement.ensureResolved(resolution); | 727 return _env.lookupLibraryMember(jsHelperLibrary, 'buildFunctionType'); |
| 753 return classElement; | 728 } |
| 754 } | 729 |
| 755 | 730 FunctionEntity get buildNamedFunctionType { |
| 756 ConstructorElement get asyncStarControllerConstructor { | 731 // TODO(johnniwinther): Support this in mocks. |
| 757 ClassElement classElement = asyncStarController; | 732 return _env.lookupLibraryMember(jsHelperLibrary, 'buildNamedFunctionType'); |
| 758 return classElement.lookupConstructor(""); | 733 } |
| 759 } | 734 |
| 760 | 735 FunctionEntity get functionTypeTestMetaHelper => |
| 761 ConstructorElement get streamIteratorConstructor { | 736 _findHelperFunction('functionTypeTestMetaHelper'); |
| 762 ClassElement classElement = _find(asyncLibrary, "StreamIterator"); | 737 |
| 763 classElement.ensureResolved(resolution); | 738 FunctionEntity get defineProperty => _findHelperFunction('defineProperty'); |
| 764 return classElement.lookupConstructor(""); | 739 |
| 765 } | 740 FunctionEntity get startRootIsolate => |
| 766 | 741 _findLibraryMember(isolateHelperLibrary, START_ROOT_ISOLATE); |
| 767 ClassElement get VoidRuntimeType { | 742 |
| 768 return _findHelper('VoidRuntimeType'); | 743 FunctionEntity get currentIsolate => |
| 769 } | 744 _findLibraryMember(isolateHelperLibrary, '_currentIsolate'); |
| 770 | 745 |
| 771 ClassElement get RuntimeType { | 746 FunctionEntity get callInIsolate => |
| 772 return _findHelper('RuntimeType'); | 747 _findLibraryMember(isolateHelperLibrary, '_callInIsolate'); |
| 773 } | 748 |
| 774 | 749 FunctionEntity get findIndexForNativeSubclassType => |
| 775 ClassElement get RuntimeFunctionType { | 750 _findLibraryMember(interceptorsLibrary, 'findIndexForNativeSubclassType'); |
| 776 return _findHelper('RuntimeFunctionType'); | 751 |
| 777 } | 752 FunctionEntity get convertRtiToRuntimeType => |
| 778 | 753 _findHelperFunction('convertRtiToRuntimeType'); |
| 779 ClassElement get RuntimeTypePlain { | 754 |
| 780 return _findHelper('RuntimeTypePlain'); | 755 ClassEntity get stackTraceClass => _findHelperClass('_StackTrace'); |
| 781 } | 756 |
| 782 | 757 FunctionEntity _objectNoSuchMethod; |
| 783 ClassElement get RuntimeTypeGeneric { | 758 FunctionEntity get objectNoSuchMethod { |
| 784 return _findHelper('RuntimeTypeGeneric'); | 759 return _objectNoSuchMethod ??= _env.lookupClassMember( |
| 785 } | 760 commonElements.objectClass, Identifiers.noSuchMethod_); |
| 786 | 761 } |
| 787 ClassElement get DynamicRuntimeType { | 762 |
| 788 return _findHelper('DynamicRuntimeType'); | 763 ClassEntity get constantMapClass => |
| 789 } | 764 _findHelperClass(JavaScriptMapConstant.DART_CLASS); |
| 790 | 765 ClassEntity get constantStringMapClass => |
| 791 MethodElement get getDynamicRuntimeType { | 766 _findHelperClass(JavaScriptMapConstant.DART_STRING_CLASS); |
| 792 // TODO(johnniwinther): Support this in mocks. | 767 ClassEntity get constantProtoMapClass => |
| 793 return jsHelperLibrary.find('getDynamicRuntimeType'); | 768 _findHelperClass(JavaScriptMapConstant.DART_PROTO_CLASS); |
| 794 } | 769 ClassEntity get generalConstantMapClass => |
| 795 | 770 _findHelperClass(JavaScriptMapConstant.DART_GENERAL_CLASS); |
| 796 MethodElement get getVoidRuntimeType { | 771 |
| 797 // TODO(johnniwinther): Support this in mocks. | 772 ClassEntity get annotationCreatesClass => _findHelperClass('Creates'); |
| 798 return jsHelperLibrary.find('getVoidRuntimeType'); | 773 |
| 799 } | 774 ClassEntity get annotationReturnsClass => _findHelperClass('Returns'); |
| 800 | 775 |
| 801 MethodElement get buildInterfaceType { | 776 ClassEntity get annotationJSNameClass => _findHelperClass('JSName'); |
| 802 // TODO(johnniwinther): Support this in mocks. | 777 |
| 803 return jsHelperLibrary.find('buildInterfaceType'); | 778 FunctionEntity get toStringForNativeObject => |
| 804 } | 779 _findHelperFunction('toStringForNativeObject'); |
| 805 | 780 |
| 806 MethodElement get buildFunctionType { | 781 FunctionEntity get hashCodeForNativeObject => |
| 807 // TODO(johnniwinther): Support this in mocks. | 782 _findHelperFunction('hashCodeForNativeObject'); |
| 808 return jsHelperLibrary.find('buildFunctionType'); | |
| 809 } | |
| 810 | |
| 811 MethodElement get buildNamedFunctionType { | |
| 812 // TODO(johnniwinther): Support this in mocks. | |
| 813 return jsHelperLibrary.find('buildNamedFunctionType'); | |
| 814 } | |
| 815 | |
| 816 MethodElement get functionTypeTestMetaHelper { | |
| 817 return _findHelper('functionTypeTestMetaHelper'); | |
| 818 } | |
| 819 | |
| 820 MethodElement get defineProperty { | |
| 821 return _findHelper('defineProperty'); | |
| 822 } | |
| 823 | |
| 824 MethodElement get startRootIsolate { | |
| 825 return _find(isolateHelperLibrary, START_ROOT_ISOLATE); | |
| 826 } | |
| 827 | |
| 828 Element get currentIsolate { | |
| 829 return _find(isolateHelperLibrary, '_currentIsolate'); | |
| 830 } | |
| 831 | |
| 832 Element get callInIsolate { | |
| 833 return _find(isolateHelperLibrary, '_callInIsolate'); | |
| 834 } | |
| 835 | |
| 836 Element get findIndexForNativeSubclassType { | |
| 837 return _findInterceptor('findIndexForNativeSubclassType'); | |
| 838 } | |
| 839 | |
| 840 MethodElement get convertRtiToRuntimeType { | |
| 841 return _findHelper('convertRtiToRuntimeType'); | |
| 842 } | |
| 843 | |
| 844 ClassElement get stackTraceClass { | |
| 845 return _findHelper('_StackTrace'); | |
| 846 } | |
| 847 | |
| 848 MethodElement _objectNoSuchMethod; | |
| 849 | |
| 850 MethodElement get objectNoSuchMethod { | |
| 851 if (_objectNoSuchMethod == null) { | |
| 852 ClassElement objectClass = commonElements.objectClass; | |
| 853 _objectNoSuchMethod = | |
| 854 objectClass.lookupLocalMember(Identifiers.noSuchMethod_); | |
| 855 } | |
| 856 return _objectNoSuchMethod; | |
| 857 } | |
| 858 | |
| 859 ClassElement get constantMapClass => | |
| 860 _findHelper(JavaScriptMapConstant.DART_CLASS); | |
| 861 ClassElement get constantStringMapClass => | |
| 862 _findHelper(JavaScriptMapConstant.DART_STRING_CLASS); | |
| 863 ClassElement get constantProtoMapClass => | |
| 864 _findHelper(JavaScriptMapConstant.DART_PROTO_CLASS); | |
| 865 ClassElement get generalConstantMapClass => | |
| 866 _findHelper(JavaScriptMapConstant.DART_GENERAL_CLASS); | |
| 867 | |
| 868 ClassElement get annotationCreatesClass { | |
| 869 return _findHelper('Creates'); | |
| 870 } | |
| 871 | |
| 872 ClassElement get annotationReturnsClass { | |
| 873 return _findHelper('Returns'); | |
| 874 } | |
| 875 | |
| 876 ClassElement get annotationJSNameClass { | |
| 877 return _findHelper('JSName'); | |
| 878 } | |
| 879 | |
| 880 MethodElement get toStringForNativeObject { | |
| 881 return _findHelper('toStringForNativeObject'); | |
| 882 } | |
| 883 | |
| 884 MethodElement get hashCodeForNativeObject { | |
| 885 return _findHelper('hashCodeForNativeObject'); | |
| 886 } | |
| 887 } | 783 } |
| OLD | NEW |