| 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; | 9 import '../common/resolution.dart' show Resolution; |
| 10 import '../compiler.dart' show Compiler; | 10 import '../compiler.dart' show Compiler; |
| 11 import '../core_types.dart' show CommonElements; | 11 import '../core_types.dart' show CommonElements; |
| 12 import '../elements/elements.dart' | 12 import '../elements/elements.dart' |
| 13 show | 13 show |
| 14 AbstractFieldElement, | 14 AbstractFieldElement, |
| 15 ClassElement, | 15 ClassElement, |
| 16 ConstructorElement, | 16 ConstructorElement, |
| 17 Element, | 17 Element, |
| 18 EnumClassElement, | 18 EnumClassElement, |
| 19 FunctionElement, | 19 FunctionElement, |
| 20 LibraryElement, | 20 LibraryElement, |
| 21 MemberElement, | 21 MemberElement, |
| 22 MethodElement, | 22 MethodElement, |
| 23 Name, | 23 Name, |
| 24 PublicName; | 24 PublicName; |
| 25 import '../library_loader.dart' show LoadedLibraries; | 25 import '../library_loader.dart' show LoadedLibraries; |
| 26 import '../universe/call_structure.dart' show CallStructure; | 26 import '../universe/call_structure.dart' show CallStructure; |
| 27 import '../universe/selector.dart' show Selector; | 27 import '../universe/selector.dart' show Selector; |
| 28 import 'constant_system_javascript.dart'; |
| 28 import 'js_backend.dart'; | 29 import 'js_backend.dart'; |
| 29 | 30 |
| 30 /// Helper classes and functions for the JavaScript backend. | 31 /// Helper classes and functions for the JavaScript backend. |
| 31 class BackendHelpers { | 32 class BackendHelpers { |
| 32 static final Uri DART_JS_HELPER = new Uri(scheme: 'dart', path: '_js_helper'); | 33 static final Uri DART_JS_HELPER = new Uri(scheme: 'dart', path: '_js_helper'); |
| 33 static final Uri DART_INTERCEPTORS = | 34 static final Uri DART_INTERCEPTORS = |
| 34 new Uri(scheme: 'dart', path: '_interceptors'); | 35 new Uri(scheme: 'dart', path: '_interceptors'); |
| 35 static final Uri DART_FOREIGN_HELPER = | 36 static final Uri DART_FOREIGN_HELPER = |
| 36 new Uri(scheme: 'dart', path: '_foreign_helper'); | 37 new Uri(scheme: 'dart', path: '_foreign_helper'); |
| 37 static final Uri DART_JS_MIRRORS = | 38 static final Uri DART_JS_MIRRORS = |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 FunctionElement requiresPreambleMarker; | 175 FunctionElement requiresPreambleMarker; |
| 175 | 176 |
| 176 /// Holds the class for the [JsGetName] enum. | 177 /// Holds the class for the [JsGetName] enum. |
| 177 EnumClassElement jsGetNameEnum; | 178 EnumClassElement jsGetNameEnum; |
| 178 | 179 |
| 179 /// Holds the class for the [JsBuiltins] enum. | 180 /// Holds the class for the [JsBuiltins] enum. |
| 180 EnumClassElement jsBuiltinEnum; | 181 EnumClassElement jsBuiltinEnum; |
| 181 | 182 |
| 182 ClassElement _symbolImplementationClass; | 183 ClassElement _symbolImplementationClass; |
| 183 ClassElement get symbolImplementationClass { | 184 ClassElement get symbolImplementationClass { |
| 184 return _symbolImplementationClass ??= find(internalLibrary, 'Symbol'); | 185 return _symbolImplementationClass ??= _find(internalLibrary, 'Symbol'); |
| 185 } | 186 } |
| 186 | 187 |
| 187 final Selector symbolValidatedConstructorSelector = | 188 final Selector symbolValidatedConstructorSelector = |
| 188 new Selector.call(const PublicName('validated'), CallStructure.ONE_ARG); | 189 new Selector.call(const PublicName('validated'), CallStructure.ONE_ARG); |
| 189 | 190 |
| 190 ConstructorElement _symbolValidatedConstructor; | 191 ConstructorElement _symbolValidatedConstructor; |
| 191 | 192 |
| 192 bool isSymbolValidatedConstructor(Element element) { | 193 bool isSymbolValidatedConstructor(Element element) { |
| 193 if (_symbolValidatedConstructor != null) { | 194 if (_symbolValidatedConstructor != null) { |
| 194 return element == _symbolValidatedConstructor; | 195 return element == _symbolValidatedConstructor; |
| 195 } | 196 } |
| 196 return false; | 197 return false; |
| 197 } | 198 } |
| 198 | 199 |
| 199 ConstructorElement get symbolValidatedConstructor { | 200 ConstructorElement get symbolValidatedConstructor { |
| 200 return _symbolValidatedConstructor ??= _findConstructor( | 201 return _symbolValidatedConstructor ??= _findConstructor( |
| 201 symbolImplementationClass, symbolValidatedConstructorSelector.name); | 202 symbolImplementationClass, symbolValidatedConstructorSelector.name); |
| 202 } | 203 } |
| 203 | 204 |
| 204 // TODO(johnniwinther): Make these private. | 205 // TODO(johnniwinther): Make these private. |
| 205 // TODO(johnniwinther): Split into findHelperFunction and findHelperClass and | 206 // TODO(johnniwinther): Split into _findHelperFunction and _findHelperClass an
d |
| 206 // add a check that the element has the expected kind. | 207 // add a check that the element has the expected kind. |
| 207 Element findHelper(String name) => find(jsHelperLibrary, name); | 208 Element _findHelper(String name) => _find(jsHelperLibrary, name); |
| 208 Element findAsyncHelper(String name) => find(asyncLibrary, name); | 209 FunctionElement _findHelperFunction(String name) => |
| 209 Element findInterceptor(String name) => find(interceptorsLibrary, name); | 210 _find(jsHelperLibrary, name); |
| 210 Element find(LibraryElement library, String name) { | 211 Element _findAsyncHelper(String name) => _find(asyncLibrary, name); |
| 212 Element _findInterceptor(String name) => _find(interceptorsLibrary, name); |
| 213 Element _find(LibraryElement library, String name) { |
| 211 Element element = library.implementation.findLocal(name); | 214 Element element = library.implementation.findLocal(name); |
| 212 assert(invariant(library, element != null, | 215 assert(invariant(library, element != null, |
| 213 message: "Element '$name' not found in '${library.canonicalUri}'.")); | 216 message: "Element '$name' not found in '${library.canonicalUri}'.")); |
| 214 return element; | 217 return element; |
| 215 } | 218 } |
| 216 | 219 |
| 217 Element findCoreHelper(String name) => | 220 Element findCoreHelper(String name) => |
| 218 compiler.commonElements.coreLibrary.implementation.localLookup(name); | 221 compiler.commonElements.coreLibrary.implementation.localLookup(name); |
| 219 | 222 |
| 220 ConstructorElement _findConstructor(ClassElement cls, String name) { | 223 ConstructorElement _findConstructor(ClassElement cls, String name) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 238 } else if (uri == DART_FOREIGN_HELPER) { | 241 } else if (uri == DART_FOREIGN_HELPER) { |
| 239 foreignLibrary = library; | 242 foreignLibrary = library; |
| 240 } else if (uri == DART_ISOLATE_HELPER) { | 243 } else if (uri == DART_ISOLATE_HELPER) { |
| 241 isolateHelperLibrary = library; | 244 isolateHelperLibrary = library; |
| 242 } | 245 } |
| 243 } | 246 } |
| 244 | 247 |
| 245 void initializeHelperClasses(DiagnosticReporter reporter) { | 248 void initializeHelperClasses(DiagnosticReporter reporter) { |
| 246 final List missingHelperClasses = []; | 249 final List missingHelperClasses = []; |
| 247 ClassElement lookupHelperClass(String name) { | 250 ClassElement lookupHelperClass(String name) { |
| 248 ClassElement result = findHelper(name); | 251 ClassElement result = _findHelper(name); |
| 249 if (result == null) { | 252 if (result == null) { |
| 250 missingHelperClasses.add(name); | 253 missingHelperClasses.add(name); |
| 251 } | 254 } |
| 252 return result; | 255 return result; |
| 253 } | 256 } |
| 254 | 257 |
| 255 jsInvocationMirrorClass = lookupHelperClass('JSInvocationMirror'); | 258 jsInvocationMirrorClass = lookupHelperClass('JSInvocationMirror'); |
| 256 boundClosureClass = lookupHelperClass('BoundClosure'); | 259 boundClosureClass = lookupHelperClass('BoundClosure'); |
| 257 closureClass = lookupHelperClass('Closure'); | 260 closureClass = lookupHelperClass('Closure'); |
| 258 if (!missingHelperClasses.isEmpty) { | 261 if (!missingHelperClasses.isEmpty) { |
| 259 reporter.internalError( | 262 reporter.internalError( |
| 260 jsHelperLibrary, | 263 jsHelperLibrary, |
| 261 'dart:_js_helper library does not contain required classes: ' | 264 'dart:_js_helper library does not contain required classes: ' |
| 262 '$missingHelperClasses'); | 265 '$missingHelperClasses'); |
| 263 } | 266 } |
| 264 } | 267 } |
| 265 | 268 |
| 266 void onLibraryScanned(LibraryElement library) { | 269 void onLibraryScanned(LibraryElement library) { |
| 267 Uri uri = library.canonicalUri; | 270 Uri uri = library.canonicalUri; |
| 268 | 271 |
| 269 FunctionElement findMethod(String name) { | 272 FunctionElement findMethod(String name) { |
| 270 return find(library, name); | 273 return _find(library, name); |
| 271 } | 274 } |
| 272 | 275 |
| 273 ClassElement findClass(String name) { | 276 ClassElement findClass(String name) { |
| 274 return find(library, name); | 277 return _find(library, name); |
| 275 } | 278 } |
| 276 | 279 |
| 277 if (uri == DART_INTERCEPTORS) { | 280 if (uri == DART_INTERCEPTORS) { |
| 278 getInterceptorMethod = findMethod('getInterceptor'); | 281 getInterceptorMethod = findMethod('getInterceptor'); |
| 279 getNativeInterceptorMethod = findMethod('getNativeInterceptor'); | 282 getNativeInterceptorMethod = findMethod('getNativeInterceptor'); |
| 280 jsInterceptorClass = findClass('Interceptor'); | 283 jsInterceptorClass = findClass('Interceptor'); |
| 281 jsStringClass = findClass('JSString'); | 284 jsStringClass = findClass('JSString'); |
| 282 jsArrayClass = findClass('JSArray'); | 285 jsArrayClass = findClass('JSArray'); |
| 283 // The int class must be before the double class, because the | 286 // The int class must be before the double class, because the |
| 284 // emitter relies on this list for the order of type checks. | 287 // emitter relies on this list for the order of type checks. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 295 jsExtendableArrayClass = findClass('JSExtendableArray'); | 298 jsExtendableArrayClass = findClass('JSExtendableArray'); |
| 296 jsUnmodifiableArrayClass = findClass('JSUnmodifiableArray'); | 299 jsUnmodifiableArrayClass = findClass('JSUnmodifiableArray'); |
| 297 jsPlainJavaScriptObjectClass = findClass('PlainJavaScriptObject'); | 300 jsPlainJavaScriptObjectClass = findClass('PlainJavaScriptObject'); |
| 298 jsJavaScriptObjectClass = findClass('JavaScriptObject'); | 301 jsJavaScriptObjectClass = findClass('JavaScriptObject'); |
| 299 jsJavaScriptFunctionClass = findClass('JavaScriptFunction'); | 302 jsJavaScriptFunctionClass = findClass('JavaScriptFunction'); |
| 300 jsUnknownJavaScriptObjectClass = findClass('UnknownJavaScriptObject'); | 303 jsUnknownJavaScriptObjectClass = findClass('UnknownJavaScriptObject'); |
| 301 jsIndexableClass = findClass('JSIndexable'); | 304 jsIndexableClass = findClass('JSIndexable'); |
| 302 jsMutableIndexableClass = findClass('JSMutableIndexable'); | 305 jsMutableIndexableClass = findClass('JSMutableIndexable'); |
| 303 } else if (uri == DART_JS_HELPER) { | 306 } else if (uri == DART_JS_HELPER) { |
| 304 initializeHelperClasses(reporter); | 307 initializeHelperClasses(reporter); |
| 305 assertTest = findHelper('assertTest'); | 308 assertTest = _findHelper('assertTest'); |
| 306 assertThrow = findHelper('assertThrow'); | 309 assertThrow = _findHelper('assertThrow'); |
| 307 assertHelper = findHelper('assertHelper'); | 310 assertHelper = _findHelper('assertHelper'); |
| 308 assertUnreachableMethod = findHelper('assertUnreachable'); | 311 assertUnreachableMethod = _findHelper('assertUnreachable'); |
| 309 | 312 |
| 310 typeLiteralClass = findClass('TypeImpl'); | 313 typeLiteralClass = findClass('TypeImpl'); |
| 311 constMapLiteralClass = findClass('ConstantMap'); | 314 constMapLiteralClass = findClass('ConstantMap'); |
| 312 typeVariableClass = findClass('TypeVariable'); | 315 typeVariableClass = findClass('TypeVariable'); |
| 313 | 316 |
| 314 jsIndexingBehaviorInterface = findClass('JavaScriptIndexingBehavior'); | 317 jsIndexingBehaviorInterface = findClass('JavaScriptIndexingBehavior'); |
| 315 | 318 |
| 316 noSideEffectsClass = findClass('NoSideEffects'); | 319 noSideEffectsClass = findClass('NoSideEffects'); |
| 317 noThrowsClass = findClass('NoThrows'); | 320 noThrowsClass = findClass('NoThrows'); |
| 318 noInlineClass = findClass('NoInline'); | 321 noInlineClass = findClass('NoInline'); |
| 319 forceInlineClass = findClass('ForceInline'); | 322 forceInlineClass = findClass('ForceInline'); |
| 320 irRepresentationClass = findClass('IrRepresentation'); | 323 irRepresentationClass = findClass('IrRepresentation'); |
| 321 | 324 |
| 322 getIsolateAffinityTagMarker = findMethod('getIsolateAffinityTag'); | 325 getIsolateAffinityTagMarker = findMethod('getIsolateAffinityTag'); |
| 323 | 326 |
| 324 requiresPreambleMarker = findMethod('requiresPreamble'); | 327 requiresPreambleMarker = findMethod('requiresPreamble'); |
| 325 } else if (uri == DART_JS_MIRRORS) { | 328 } else if (uri == DART_JS_MIRRORS) { |
| 326 disableTreeShakingMarker = find(library, 'disableTreeShaking'); | 329 disableTreeShakingMarker = _find(library, 'disableTreeShaking'); |
| 327 preserveMetadataMarker = find(library, 'preserveMetadata'); | 330 preserveMetadataMarker = _find(library, 'preserveMetadata'); |
| 328 preserveUrisMarker = find(library, 'preserveUris'); | 331 preserveUrisMarker = _find(library, 'preserveUris'); |
| 329 preserveLibraryNamesMarker = find(library, 'preserveLibraryNames'); | 332 preserveLibraryNamesMarker = _find(library, 'preserveLibraryNames'); |
| 330 } else if (uri == DART_JS_NAMES) { | 333 } else if (uri == DART_JS_NAMES) { |
| 331 preserveNamesMarker = find(library, 'preserveNames'); | 334 preserveNamesMarker = _find(library, 'preserveNames'); |
| 332 } else if (uri == DART_EMBEDDED_NAMES) { | 335 } else if (uri == DART_EMBEDDED_NAMES) { |
| 333 jsGetNameEnum = find(library, 'JsGetName'); | 336 jsGetNameEnum = _find(library, 'JsGetName'); |
| 334 jsBuiltinEnum = find(library, 'JsBuiltin'); | 337 jsBuiltinEnum = _find(library, 'JsBuiltin'); |
| 335 } else if (uri == Uris.dart__native_typed_data) { | 338 } else if (uri == Uris.dart__native_typed_data) { |
| 336 typedArrayClass = findClass('NativeTypedArray'); | 339 typedArrayClass = findClass('NativeTypedArray'); |
| 337 typedArrayOfIntClass = findClass('NativeTypedArrayOfInt'); | 340 typedArrayOfIntClass = findClass('NativeTypedArrayOfInt'); |
| 338 } else if (uri == PACKAGE_JS) { | 341 } else if (uri == PACKAGE_JS) { |
| 339 jsAnnotationClass = find(library, 'JS'); | 342 jsAnnotationClass = _find(library, 'JS'); |
| 340 jsAnonymousClass = find(library, '_Anonymous'); | 343 jsAnonymousClass = _find(library, '_Anonymous'); |
| 341 } | 344 } |
| 342 } | 345 } |
| 343 | 346 |
| 344 void onLibrariesLoaded(LoadedLibraries loadedLibraries) { | 347 void onLibrariesLoaded(LoadedLibraries loadedLibraries) { |
| 345 assert(loadedLibraries.containsLibrary(Uris.dart_core)); | 348 assert(loadedLibraries.containsLibrary(Uris.dart_core)); |
| 346 assert(loadedLibraries.containsLibrary(DART_INTERCEPTORS)); | 349 assert(loadedLibraries.containsLibrary(DART_INTERCEPTORS)); |
| 347 assert(loadedLibraries.containsLibrary(DART_JS_HELPER)); | 350 assert(loadedLibraries.containsLibrary(DART_JS_HELPER)); |
| 348 | 351 |
| 349 if (jsInvocationMirrorClass != null) { | 352 if (jsInvocationMirrorClass != null) { |
| 350 jsInvocationMirrorClass.ensureResolved(resolution); | 353 jsInvocationMirrorClass.ensureResolved(resolution); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 return element; | 459 return element; |
| 457 } | 460 } |
| 458 | 461 |
| 459 _mapLiteralConstructor = getFactory('_literal', 1); | 462 _mapLiteralConstructor = getFactory('_literal', 1); |
| 460 _mapLiteralConstructorEmpty = getFactory('_empty', 0); | 463 _mapLiteralConstructorEmpty = getFactory('_empty', 0); |
| 461 _mapLiteralUntypedMaker = getMember('_makeLiteral'); | 464 _mapLiteralUntypedMaker = getMember('_makeLiteral'); |
| 462 _mapLiteralUntypedEmptyMaker = getMember('_makeEmpty'); | 465 _mapLiteralUntypedEmptyMaker = getMember('_makeEmpty'); |
| 463 } | 466 } |
| 464 | 467 |
| 465 Element get badMain { | 468 Element get badMain { |
| 466 return findHelper('badMain'); | 469 return _findHelper('badMain'); |
| 467 } | 470 } |
| 468 | 471 |
| 469 Element get missingMain { | 472 Element get missingMain { |
| 470 return findHelper('missingMain'); | 473 return _findHelper('missingMain'); |
| 471 } | 474 } |
| 472 | 475 |
| 473 Element get mainHasTooManyParameters { | 476 Element get mainHasTooManyParameters { |
| 474 return findHelper('mainHasTooManyParameters'); | 477 return _findHelper('mainHasTooManyParameters'); |
| 475 } | 478 } |
| 476 | 479 |
| 477 MethodElement get loadLibraryWrapper { | 480 MethodElement get loadLibraryWrapper { |
| 478 return findHelper("_loadLibraryWrapper"); | 481 return _findHelper("_loadLibraryWrapper"); |
| 479 } | 482 } |
| 480 | 483 |
| 481 Element get boolConversionCheck { | 484 Element get boolConversionCheck { |
| 482 return findHelper('boolConversionCheck'); | 485 return _findHelper('boolConversionCheck'); |
| 483 } | 486 } |
| 484 | 487 |
| 485 MethodElement _traceHelper; | 488 MethodElement _traceHelper; |
| 486 | 489 |
| 487 MethodElement get traceHelper { | 490 MethodElement get traceHelper { |
| 488 return _traceHelper ??= JavaScriptBackend.TRACE_METHOD == 'console' | 491 return _traceHelper ??= JavaScriptBackend.TRACE_METHOD == 'console' |
| 489 ? _consoleTraceHelper | 492 ? _consoleTraceHelper |
| 490 : _postTraceHelper; | 493 : _postTraceHelper; |
| 491 } | 494 } |
| 492 | 495 |
| 493 MethodElement get _consoleTraceHelper { | 496 MethodElement get _consoleTraceHelper { |
| 494 return findHelper('consoleTraceHelper'); | 497 return _findHelper('consoleTraceHelper'); |
| 495 } | 498 } |
| 496 | 499 |
| 497 MethodElement get _postTraceHelper { | 500 MethodElement get _postTraceHelper { |
| 498 return findHelper('postTraceHelper'); | 501 return _findHelper('postTraceHelper'); |
| 499 } | 502 } |
| 500 | 503 |
| 501 FunctionElement get closureFromTearOff { | 504 FunctionElement get closureFromTearOff { |
| 502 return findHelper('closureFromTearOff'); | 505 return _findHelper('closureFromTearOff'); |
| 503 } | 506 } |
| 504 | 507 |
| 505 Element get isJsIndexable { | 508 Element get isJsIndexable { |
| 506 return findHelper('isJsIndexable'); | 509 return _findHelper('isJsIndexable'); |
| 507 } | 510 } |
| 508 | 511 |
| 509 Element get throwIllegalArgumentException { | 512 Element get throwIllegalArgumentException { |
| 510 return findHelper('iae'); | 513 return _findHelper('iae'); |
| 511 } | 514 } |
| 512 | 515 |
| 513 Element get throwIndexOutOfRangeException { | 516 Element get throwIndexOutOfRangeException { |
| 514 return findHelper('ioore'); | 517 return _findHelper('ioore'); |
| 515 } | 518 } |
| 516 | 519 |
| 517 Element get exceptionUnwrapper { | 520 Element get exceptionUnwrapper { |
| 518 return findHelper('unwrapException'); | 521 return _findHelper('unwrapException'); |
| 519 } | 522 } |
| 520 | 523 |
| 521 Element get throwRuntimeError { | 524 Element get throwRuntimeError { |
| 522 return findHelper('throwRuntimeError'); | 525 return _findHelper('throwRuntimeError'); |
| 523 } | 526 } |
| 524 | 527 |
| 525 Element get throwTypeError { | 528 Element get throwTypeError { |
| 526 return findHelper('throwTypeError'); | 529 return _findHelper('throwTypeError'); |
| 527 } | 530 } |
| 528 | 531 |
| 529 Element get throwAbstractClassInstantiationError { | 532 Element get throwAbstractClassInstantiationError { |
| 530 return findHelper('throwAbstractClassInstantiationError'); | 533 return _findHelper('throwAbstractClassInstantiationError'); |
| 531 } | 534 } |
| 532 | 535 |
| 533 Element get checkConcurrentModificationError { | 536 Element get checkConcurrentModificationError { |
| 534 if (cachedCheckConcurrentModificationError == null) { | 537 if (cachedCheckConcurrentModificationError == null) { |
| 535 cachedCheckConcurrentModificationError = | 538 cachedCheckConcurrentModificationError = |
| 536 findHelper('checkConcurrentModificationError'); | 539 _findHelper('checkConcurrentModificationError'); |
| 537 } | 540 } |
| 538 return cachedCheckConcurrentModificationError; | 541 return cachedCheckConcurrentModificationError; |
| 539 } | 542 } |
| 540 | 543 |
| 541 Element get throwConcurrentModificationError { | 544 Element get throwConcurrentModificationError { |
| 542 return findHelper('throwConcurrentModificationError'); | 545 return _findHelper('throwConcurrentModificationError'); |
| 543 } | 546 } |
| 544 | 547 |
| 545 Element get checkInt => _checkInt ??= findHelper('checkInt'); | 548 Element get checkInt => _checkInt ??= _findHelper('checkInt'); |
| 546 Element _checkInt; | 549 Element _checkInt; |
| 547 | 550 |
| 548 Element get checkNum => _checkNum ??= findHelper('checkNum'); | 551 Element get checkNum => _checkNum ??= _findHelper('checkNum'); |
| 549 Element _checkNum; | 552 Element _checkNum; |
| 550 | 553 |
| 551 Element get checkString => _checkString ??= findHelper('checkString'); | 554 Element get checkString => _checkString ??= _findHelper('checkString'); |
| 552 Element _checkString; | 555 Element _checkString; |
| 553 | 556 |
| 554 Element get stringInterpolationHelper { | 557 Element get stringInterpolationHelper { |
| 555 return findHelper('S'); | 558 return _findHelper('S'); |
| 556 } | 559 } |
| 557 | 560 |
| 558 Element get wrapExceptionHelper { | 561 Element get wrapExceptionHelper { |
| 559 return findHelper(r'wrapException'); | 562 return _findHelper(r'wrapException'); |
| 560 } | 563 } |
| 561 | 564 |
| 562 Element get throwExpressionHelper { | 565 Element get throwExpressionHelper { |
| 563 return findHelper('throwExpression'); | 566 return _findHelper('throwExpression'); |
| 564 } | 567 } |
| 565 | 568 |
| 566 Element get closureConverter { | 569 Element get closureConverter { |
| 567 return findHelper('convertDartClosureToJS'); | 570 return _findHelper('convertDartClosureToJS'); |
| 568 } | 571 } |
| 569 | 572 |
| 570 Element get traceFromException { | 573 Element get traceFromException { |
| 571 return findHelper('getTraceFromException'); | 574 return _findHelper('getTraceFromException'); |
| 572 } | 575 } |
| 573 | 576 |
| 574 Element get setRuntimeTypeInfo { | 577 Element get setRuntimeTypeInfo { |
| 575 return findHelper('setRuntimeTypeInfo'); | 578 return _findHelper('setRuntimeTypeInfo'); |
| 576 } | 579 } |
| 577 | 580 |
| 578 Element get getRuntimeTypeInfo { | 581 Element get getRuntimeTypeInfo { |
| 579 return findHelper('getRuntimeTypeInfo'); | 582 return _findHelper('getRuntimeTypeInfo'); |
| 580 } | 583 } |
| 581 | 584 |
| 582 Element get getTypeArgumentByIndex { | 585 Element get getTypeArgumentByIndex { |
| 583 return findHelper('getTypeArgumentByIndex'); | 586 return _findHelper('getTypeArgumentByIndex'); |
| 584 } | 587 } |
| 585 | 588 |
| 586 Element get computeSignature { | 589 Element get computeSignature { |
| 587 return findHelper('computeSignature'); | 590 return _findHelper('computeSignature'); |
| 588 } | 591 } |
| 589 | 592 |
| 590 Element get getRuntimeTypeArguments { | 593 Element get getRuntimeTypeArguments { |
| 591 return findHelper('getRuntimeTypeArguments'); | 594 return _findHelper('getRuntimeTypeArguments'); |
| 592 } | 595 } |
| 593 | 596 |
| 594 Element get getRuntimeTypeArgument { | 597 Element get getRuntimeTypeArgument { |
| 595 return findHelper('getRuntimeTypeArgument'); | 598 return _findHelper('getRuntimeTypeArgument'); |
| 596 } | 599 } |
| 597 | 600 |
| 598 Element get runtimeTypeToString { | 601 Element get runtimeTypeToString { |
| 599 return findHelper('runtimeTypeToString'); | 602 return _findHelper('runtimeTypeToString'); |
| 600 } | 603 } |
| 601 | 604 |
| 602 Element get assertIsSubtype { | 605 Element get assertIsSubtype { |
| 603 return findHelper('assertIsSubtype'); | 606 return _findHelper('assertIsSubtype'); |
| 604 } | 607 } |
| 605 | 608 |
| 606 Element get checkSubtype { | 609 Element get checkSubtype { |
| 607 return findHelper('checkSubtype'); | 610 return _findHelper('checkSubtype'); |
| 608 } | 611 } |
| 609 | 612 |
| 610 Element get assertSubtype { | 613 Element get assertSubtype { |
| 611 return findHelper('assertSubtype'); | 614 return _findHelper('assertSubtype'); |
| 612 } | 615 } |
| 613 | 616 |
| 614 Element get subtypeCast { | 617 Element get subtypeCast { |
| 615 return findHelper('subtypeCast'); | 618 return _findHelper('subtypeCast'); |
| 616 } | 619 } |
| 617 | 620 |
| 618 Element get checkSubtypeOfRuntimeType { | 621 Element get checkSubtypeOfRuntimeType { |
| 619 return findHelper('checkSubtypeOfRuntimeType'); | 622 return _findHelper('checkSubtypeOfRuntimeType'); |
| 620 } | 623 } |
| 621 | 624 |
| 622 Element get assertSubtypeOfRuntimeType { | 625 Element get assertSubtypeOfRuntimeType { |
| 623 return findHelper('assertSubtypeOfRuntimeType'); | 626 return _findHelper('assertSubtypeOfRuntimeType'); |
| 624 } | 627 } |
| 625 | 628 |
| 626 Element get subtypeOfRuntimeTypeCast { | 629 Element get subtypeOfRuntimeTypeCast { |
| 627 return findHelper('subtypeOfRuntimeTypeCast'); | 630 return _findHelper('subtypeOfRuntimeTypeCast'); |
| 628 } | 631 } |
| 629 | 632 |
| 630 Element get checkDeferredIsLoaded { | 633 Element get checkDeferredIsLoaded { |
| 631 return findHelper('checkDeferredIsLoaded'); | 634 return _findHelper('checkDeferredIsLoaded'); |
| 632 } | 635 } |
| 633 | 636 |
| 634 Element get throwNoSuchMethod { | 637 Element get throwNoSuchMethod { |
| 635 return findHelper('throwNoSuchMethod'); | 638 return _findHelper('throwNoSuchMethod'); |
| 636 } | 639 } |
| 637 | 640 |
| 638 Element get genericNoSuchMethod => | 641 Element get genericNoSuchMethod => |
| 639 _genericNoSuchMethod ??= findCoreHelper('_genericNoSuchMethod'); | 642 _genericNoSuchMethod ??= findCoreHelper('_genericNoSuchMethod'); |
| 640 MethodElement _genericNoSuchMethod; | 643 MethodElement _genericNoSuchMethod; |
| 641 | 644 |
| 642 Element get unresolvedConstructorError => _unresolvedConstructorError ??= | 645 Element get unresolvedConstructorError => _unresolvedConstructorError ??= |
| 643 findCoreHelper('_unresolvedConstructorError'); | 646 findCoreHelper('_unresolvedConstructorError'); |
| 644 MethodElement _unresolvedConstructorError; | 647 MethodElement _unresolvedConstructorError; |
| 645 | 648 |
| 646 Element get malformedTypeError => | 649 Element get malformedTypeError => |
| 647 _malformedTypeError ??= findCoreHelper('_malformedTypeError'); | 650 _malformedTypeError ??= findCoreHelper('_malformedTypeError'); |
| 648 MethodElement _malformedTypeError; | 651 MethodElement _malformedTypeError; |
| 649 | 652 |
| 650 Element get createRuntimeType { | 653 Element get createRuntimeType { |
| 651 return findHelper('createRuntimeType'); | 654 return _findHelper('createRuntimeType'); |
| 652 } | 655 } |
| 653 | 656 |
| 654 Element get fallThroughError { | 657 Element get fallThroughError { |
| 655 return findHelper("getFallThroughError"); | 658 return _findHelper("getFallThroughError"); |
| 656 } | 659 } |
| 657 | 660 |
| 658 Element get createInvocationMirror { | 661 Element get createInvocationMirror { |
| 659 return findHelper('createInvocationMirror'); | 662 return _findHelper('createInvocationMirror'); |
| 660 } | 663 } |
| 661 | 664 |
| 662 Element get cyclicThrowHelper { | 665 Element get cyclicThrowHelper { |
| 663 return findHelper("throwCyclicInit"); | 666 return _findHelper("throwCyclicInit"); |
| 664 } | 667 } |
| 665 | 668 |
| 666 Element get asyncHelper { | 669 Element get asyncHelper { |
| 667 return findAsyncHelper("_asyncHelper"); | 670 return _findAsyncHelper("_asyncHelper"); |
| 668 } | 671 } |
| 669 | 672 |
| 670 Element get wrapBody { | 673 Element get wrapBody { |
| 671 return findAsyncHelper("_wrapJsFunctionForAsync"); | 674 return _findAsyncHelper("_wrapJsFunctionForAsync"); |
| 672 } | 675 } |
| 673 | 676 |
| 674 Element get yieldStar { | 677 Element get yieldStar { |
| 675 ClassElement classElement = findAsyncHelper("_IterationMarker"); | 678 ClassElement classElement = _findAsyncHelper("_IterationMarker"); |
| 676 classElement.ensureResolved(resolution); | 679 classElement.ensureResolved(resolution); |
| 677 return classElement.lookupLocalMember("yieldStar"); | 680 return classElement.lookupLocalMember("yieldStar"); |
| 678 } | 681 } |
| 679 | 682 |
| 680 Element get yieldSingle { | 683 Element get yieldSingle { |
| 681 ClassElement classElement = findAsyncHelper("_IterationMarker"); | 684 ClassElement classElement = _findAsyncHelper("_IterationMarker"); |
| 682 classElement.ensureResolved(resolution); | 685 classElement.ensureResolved(resolution); |
| 683 return classElement.lookupLocalMember("yieldSingle"); | 686 return classElement.lookupLocalMember("yieldSingle"); |
| 684 } | 687 } |
| 685 | 688 |
| 686 Element get syncStarUncaughtError { | 689 Element get syncStarUncaughtError { |
| 687 ClassElement classElement = findAsyncHelper("_IterationMarker"); | 690 ClassElement classElement = _findAsyncHelper("_IterationMarker"); |
| 688 classElement.ensureResolved(resolution); | 691 classElement.ensureResolved(resolution); |
| 689 return classElement.lookupLocalMember("uncaughtError"); | 692 return classElement.lookupLocalMember("uncaughtError"); |
| 690 } | 693 } |
| 691 | 694 |
| 692 Element get asyncStarHelper { | 695 Element get asyncStarHelper { |
| 693 return findAsyncHelper("_asyncStarHelper"); | 696 return _findAsyncHelper("_asyncStarHelper"); |
| 694 } | 697 } |
| 695 | 698 |
| 696 Element get streamOfController { | 699 Element get streamOfController { |
| 697 return findAsyncHelper("_streamOfController"); | 700 return _findAsyncHelper("_streamOfController"); |
| 698 } | 701 } |
| 699 | 702 |
| 700 Element get endOfIteration { | 703 Element get endOfIteration { |
| 701 ClassElement classElement = findAsyncHelper("_IterationMarker"); | 704 ClassElement classElement = _findAsyncHelper("_IterationMarker"); |
| 702 classElement.ensureResolved(resolution); | 705 classElement.ensureResolved(resolution); |
| 703 return classElement.lookupLocalMember("endOfIteration"); | 706 return classElement.lookupLocalMember("endOfIteration"); |
| 704 } | 707 } |
| 705 | 708 |
| 706 Element get syncStarIterable { | 709 Element get syncStarIterable { |
| 707 ClassElement classElement = findAsyncHelper("_SyncStarIterable"); | 710 ClassElement classElement = _findAsyncHelper("_SyncStarIterable"); |
| 708 classElement.ensureResolved(resolution); | 711 classElement.ensureResolved(resolution); |
| 709 return classElement; | 712 return classElement; |
| 710 } | 713 } |
| 711 | 714 |
| 712 Element get futureImplementation { | 715 Element get futureImplementation { |
| 713 ClassElement classElement = findAsyncHelper('_Future'); | 716 ClassElement classElement = _findAsyncHelper('_Future'); |
| 714 classElement.ensureResolved(resolution); | 717 classElement.ensureResolved(resolution); |
| 715 return classElement; | 718 return classElement; |
| 716 } | 719 } |
| 717 | 720 |
| 718 Element get controllerStream { | 721 Element get controllerStream { |
| 719 ClassElement classElement = findAsyncHelper("_ControllerStream"); | 722 ClassElement classElement = _findAsyncHelper("_ControllerStream"); |
| 720 classElement.ensureResolved(resolution); | 723 classElement.ensureResolved(resolution); |
| 721 return classElement; | 724 return classElement; |
| 722 } | 725 } |
| 723 | 726 |
| 724 Element get syncStarIterableConstructor { | 727 Element get syncStarIterableConstructor { |
| 725 ClassElement classElement = syncStarIterable; | 728 ClassElement classElement = syncStarIterable; |
| 726 classElement.ensureResolved(resolution); | 729 classElement.ensureResolved(resolution); |
| 727 return classElement.lookupConstructor(""); | 730 return classElement.lookupConstructor(""); |
| 728 } | 731 } |
| 729 | 732 |
| 730 Element get syncCompleterConstructor { | 733 Element get syncCompleterConstructor { |
| 731 ClassElement classElement = find(asyncLibrary, "Completer"); | 734 ClassElement classElement = _find(asyncLibrary, "Completer"); |
| 732 classElement.ensureResolved(resolution); | 735 classElement.ensureResolved(resolution); |
| 733 return classElement.lookupConstructor("sync"); | 736 return classElement.lookupConstructor("sync"); |
| 734 } | 737 } |
| 735 | 738 |
| 736 Element get asyncStarController { | 739 Element get asyncStarController { |
| 737 ClassElement classElement = findAsyncHelper("_AsyncStarStreamController"); | 740 ClassElement classElement = _findAsyncHelper("_AsyncStarStreamController"); |
| 738 classElement.ensureResolved(resolution); | 741 classElement.ensureResolved(resolution); |
| 739 return classElement; | 742 return classElement; |
| 740 } | 743 } |
| 741 | 744 |
| 742 Element get asyncStarControllerConstructor { | 745 Element get asyncStarControllerConstructor { |
| 743 ClassElement classElement = asyncStarController; | 746 ClassElement classElement = asyncStarController; |
| 744 return classElement.lookupConstructor(""); | 747 return classElement.lookupConstructor(""); |
| 745 } | 748 } |
| 746 | 749 |
| 747 Element get streamIteratorConstructor { | 750 Element get streamIteratorConstructor { |
| 748 ClassElement classElement = find(asyncLibrary, "StreamIterator"); | 751 ClassElement classElement = _find(asyncLibrary, "StreamIterator"); |
| 749 classElement.ensureResolved(resolution); | 752 classElement.ensureResolved(resolution); |
| 750 return classElement.lookupConstructor(""); | 753 return classElement.lookupConstructor(""); |
| 751 } | 754 } |
| 752 | 755 |
| 753 ClassElement get VoidRuntimeType { | 756 ClassElement get VoidRuntimeType { |
| 754 return findHelper('VoidRuntimeType'); | 757 return _findHelper('VoidRuntimeType'); |
| 755 } | 758 } |
| 756 | 759 |
| 757 ClassElement get RuntimeType { | 760 ClassElement get RuntimeType { |
| 758 return findHelper('RuntimeType'); | 761 return _findHelper('RuntimeType'); |
| 759 } | 762 } |
| 760 | 763 |
| 761 ClassElement get RuntimeFunctionType { | 764 ClassElement get RuntimeFunctionType { |
| 762 return findHelper('RuntimeFunctionType'); | 765 return _findHelper('RuntimeFunctionType'); |
| 763 } | 766 } |
| 764 | 767 |
| 765 ClassElement get RuntimeTypePlain { | 768 ClassElement get RuntimeTypePlain { |
| 766 return findHelper('RuntimeTypePlain'); | 769 return _findHelper('RuntimeTypePlain'); |
| 767 } | 770 } |
| 768 | 771 |
| 769 ClassElement get RuntimeTypeGeneric { | 772 ClassElement get RuntimeTypeGeneric { |
| 770 return findHelper('RuntimeTypeGeneric'); | 773 return _findHelper('RuntimeTypeGeneric'); |
| 771 } | 774 } |
| 772 | 775 |
| 773 ClassElement get DynamicRuntimeType { | 776 ClassElement get DynamicRuntimeType { |
| 774 return findHelper('DynamicRuntimeType'); | 777 return _findHelper('DynamicRuntimeType'); |
| 778 } |
| 779 |
| 780 MethodElement get getDynamicRuntimeType { |
| 781 // TODO(johnniwinther): Support this in mocks. |
| 782 return jsHelperLibrary.find('getDynamicRuntimeType'); |
| 783 } |
| 784 |
| 785 MethodElement get getVoidRuntimeType { |
| 786 // TODO(johnniwinther): Support this in mocks. |
| 787 return jsHelperLibrary.find('getVoidRuntimeType'); |
| 788 } |
| 789 |
| 790 MethodElement get buildInterfaceType { |
| 791 // TODO(johnniwinther): Support this in mocks. |
| 792 return jsHelperLibrary.find('buildInterfaceType'); |
| 793 } |
| 794 |
| 795 MethodElement get buildFunctionType { |
| 796 // TODO(johnniwinther): Support this in mocks. |
| 797 return jsHelperLibrary.find('buildFunctionType'); |
| 798 } |
| 799 |
| 800 MethodElement get buildNamedFunctionType { |
| 801 // TODO(johnniwinther): Support this in mocks. |
| 802 return jsHelperLibrary.find('buildNamedFunctionType'); |
| 775 } | 803 } |
| 776 | 804 |
| 777 MethodElement get functionTypeTestMetaHelper { | 805 MethodElement get functionTypeTestMetaHelper { |
| 778 return findHelper('functionTypeTestMetaHelper'); | 806 return _findHelper('functionTypeTestMetaHelper'); |
| 779 } | 807 } |
| 780 | 808 |
| 781 MethodElement get defineProperty { | 809 MethodElement get defineProperty { |
| 782 return findHelper('defineProperty'); | 810 return _findHelper('defineProperty'); |
| 783 } | 811 } |
| 784 | 812 |
| 785 Element get startRootIsolate { | 813 Element get startRootIsolate { |
| 786 return find(isolateHelperLibrary, START_ROOT_ISOLATE); | 814 return _find(isolateHelperLibrary, START_ROOT_ISOLATE); |
| 787 } | 815 } |
| 788 | 816 |
| 789 Element get currentIsolate { | 817 Element get currentIsolate { |
| 790 return find(isolateHelperLibrary, '_currentIsolate'); | 818 return _find(isolateHelperLibrary, '_currentIsolate'); |
| 791 } | 819 } |
| 792 | 820 |
| 793 Element get callInIsolate { | 821 Element get callInIsolate { |
| 794 return find(isolateHelperLibrary, '_callInIsolate'); | 822 return _find(isolateHelperLibrary, '_callInIsolate'); |
| 795 } | 823 } |
| 796 | 824 |
| 797 Element get findIndexForNativeSubclassType { | 825 Element get findIndexForNativeSubclassType { |
| 798 return findInterceptor('findIndexForNativeSubclassType'); | 826 return _findInterceptor('findIndexForNativeSubclassType'); |
| 799 } | 827 } |
| 800 | 828 |
| 801 Element get convertRtiToRuntimeType { | 829 Element get convertRtiToRuntimeType { |
| 802 return findHelper('convertRtiToRuntimeType'); | 830 return _findHelper('convertRtiToRuntimeType'); |
| 803 } | 831 } |
| 804 | 832 |
| 805 ClassElement get stackTraceClass { | 833 ClassElement get stackTraceClass { |
| 806 return findHelper('_StackTrace'); | 834 return _findHelper('_StackTrace'); |
| 807 } | 835 } |
| 808 | 836 |
| 809 MethodElement _objectNoSuchMethod; | 837 MethodElement _objectNoSuchMethod; |
| 810 | 838 |
| 811 MethodElement get objectNoSuchMethod { | 839 MethodElement get objectNoSuchMethod { |
| 812 if (_objectNoSuchMethod == null) { | 840 if (_objectNoSuchMethod == null) { |
| 813 _objectNoSuchMethod = commonElements.objectClass | 841 _objectNoSuchMethod = commonElements.objectClass |
| 814 .lookupLocalMember(Identifiers.noSuchMethod_); | 842 .lookupLocalMember(Identifiers.noSuchMethod_); |
| 815 } | 843 } |
| 816 return _objectNoSuchMethod; | 844 return _objectNoSuchMethod; |
| 817 } | 845 } |
| 846 |
| 847 ClassElement get constantMapClass => |
| 848 _findHelper(JavaScriptMapConstant.DART_CLASS); |
| 849 ClassElement get constantStringMapClass => |
| 850 _findHelper(JavaScriptMapConstant.DART_STRING_CLASS); |
| 851 ClassElement get constantProtoMapClass => |
| 852 _findHelper(JavaScriptMapConstant.DART_PROTO_CLASS); |
| 853 ClassElement get generalConstantMapClass => |
| 854 _findHelper(JavaScriptMapConstant.DART_GENERAL_CLASS); |
| 855 |
| 856 ClassElement get annotationCreatesClass { |
| 857 return _findHelper('Creates'); |
| 858 } |
| 859 |
| 860 ClassElement get annotationReturnsClass { |
| 861 return _findHelper('Returns'); |
| 862 } |
| 863 |
| 864 ClassElement get annotationJSNameClass { |
| 865 return _findHelper('JSName'); |
| 866 } |
| 867 |
| 868 MethodElement get toStringForNativeObject { |
| 869 return _findHelper('toStringForNativeObject'); |
| 870 } |
| 871 |
| 872 MethodElement get hashCodeForNativeObject { |
| 873 return _findHelper('hashCodeForNativeObject'); |
| 874 } |
| 818 } | 875 } |
| OLD | NEW |