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