| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of dart2js; | 5 part of dart2js; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * If true, print a warning for each method that was resolved, but not | 8 * If true, print a warning for each method that was resolved, but not |
| 9 * compiled. | 9 * compiled. |
| 10 */ | 10 */ |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 ClassElement dynamicClass; | 121 ClassElement dynamicClass; |
| 122 ClassElement boolClass; | 122 ClassElement boolClass; |
| 123 ClassElement numClass; | 123 ClassElement numClass; |
| 124 ClassElement intClass; | 124 ClassElement intClass; |
| 125 ClassElement doubleClass; | 125 ClassElement doubleClass; |
| 126 ClassElement stringClass; | 126 ClassElement stringClass; |
| 127 ClassElement functionClass; | 127 ClassElement functionClass; |
| 128 ClassElement nullClass; | 128 ClassElement nullClass; |
| 129 ClassElement listClass; | 129 ClassElement listClass; |
| 130 ClassElement mapClass; | 130 ClassElement mapClass; |
| 131 ClassElement jsInvocationMirrorClass; | |
| 132 Element assertMethod; | 131 Element assertMethod; |
| 133 Element identicalFunction; | 132 Element identicalFunction; |
| 134 Element functionApplyMethod; | 133 Element functionApplyMethod; |
| 135 Element invokeOnMethod; | |
| 136 | 134 |
| 137 Element get currentElement => _currentElement; | 135 Element get currentElement => _currentElement; |
| 138 withCurrentElement(Element element, f()) { | 136 withCurrentElement(Element element, f()) { |
| 139 Element old = currentElement; | 137 Element old = currentElement; |
| 140 _currentElement = element; | 138 _currentElement = element; |
| 141 try { | 139 try { |
| 142 return f(); | 140 return f(); |
| 143 } on SpannableAssertionFailure catch (ex) { | 141 } on SpannableAssertionFailure catch (ex) { |
| 144 if (!hasCrashed) { | 142 if (!hasCrashed) { |
| 145 SourceSpan span = spanFromSpannable(ex.node); | 143 SourceSpan span = spanFromSpannable(ex.node); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 176 closureMapping.ClosureTask closureToClassMapper; | 174 closureMapping.ClosureTask closureToClassMapper; |
| 177 TypeCheckerTask checker; | 175 TypeCheckerTask checker; |
| 178 ti.TypesTask typesTask; | 176 ti.TypesTask typesTask; |
| 179 Backend backend; | 177 Backend backend; |
| 180 ConstantHandler constantHandler; | 178 ConstantHandler constantHandler; |
| 181 EnqueueTask enqueuer; | 179 EnqueueTask enqueuer; |
| 182 | 180 |
| 183 static const SourceString MAIN = const SourceString('main'); | 181 static const SourceString MAIN = const SourceString('main'); |
| 184 static const SourceString CALL_OPERATOR_NAME = const SourceString('call'); | 182 static const SourceString CALL_OPERATOR_NAME = const SourceString('call'); |
| 185 static const SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod'); | 183 static const SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod'); |
| 186 static const int NO_SUCH_METHOD_ARG_COUNT = 1; | |
| 187 static const SourceString INVOKE_ON = const SourceString('invokeOn'); | |
| 188 static const SourceString RUNTIME_TYPE = const SourceString('runtimeType'); | 184 static const SourceString RUNTIME_TYPE = const SourceString('runtimeType'); |
| 189 static const SourceString START_ROOT_ISOLATE = | 185 static const SourceString START_ROOT_ISOLATE = |
| 190 const SourceString('startRootIsolate'); | 186 const SourceString('startRootIsolate'); |
| 191 bool enabledNoSuchMethod = false; | 187 bool enabledNoSuchMethod = false; |
| 192 bool enabledRuntimeType = false; | 188 bool enabledRuntimeType = false; |
| 193 bool enabledFunctionApply = false; | 189 bool enabledFunctionApply = false; |
| 194 bool enabledInvokeOn = false; | |
| 195 | 190 |
| 196 Stopwatch progress; | 191 Stopwatch progress; |
| 197 | 192 |
| 198 static const int PHASE_SCANNING = 0; | 193 static const int PHASE_SCANNING = 0; |
| 199 static const int PHASE_RESOLVING = 1; | 194 static const int PHASE_RESOLVING = 1; |
| 200 static const int PHASE_COMPILING = 2; | 195 static const int PHASE_COMPILING = 2; |
| 201 int phase; | 196 int phase; |
| 202 | 197 |
| 203 bool compilationFailed = false; | 198 bool compilationFailed = false; |
| 204 | 199 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 // TODO(ahe): Move this method to Enqueuer. | 335 // TODO(ahe): Move this method to Enqueuer. |
| 341 if (enabledNoSuchMethod) return; | 336 if (enabledNoSuchMethod) return; |
| 342 if (identical(element.getEnclosingClass(), objectClass)) { | 337 if (identical(element.getEnclosingClass(), objectClass)) { |
| 343 enqueuer.resolution.registerDynamicInvocationOf(element); | 338 enqueuer.resolution.registerDynamicInvocationOf(element); |
| 344 return; | 339 return; |
| 345 } | 340 } |
| 346 enabledNoSuchMethod = true; | 341 enabledNoSuchMethod = true; |
| 347 Selector selector = new Selector.noSuchMethod(); | 342 Selector selector = new Selector.noSuchMethod(); |
| 348 enqueuer.resolution.registerInvocation(NO_SUCH_METHOD, selector); | 343 enqueuer.resolution.registerInvocation(NO_SUCH_METHOD, selector); |
| 349 enqueuer.codegen.registerInvocation(NO_SUCH_METHOD, selector); | 344 enqueuer.codegen.registerInvocation(NO_SUCH_METHOD, selector); |
| 350 | |
| 351 Element createInvocationMirrorElement = | |
| 352 findHelper(const SourceString('createInvocationMirror')); | |
| 353 enqueuer.resolution.addToWorkList(createInvocationMirrorElement); | |
| 354 enqueuer.codegen.addToWorkList(createInvocationMirrorElement); | |
| 355 } | 345 } |
| 356 | 346 |
| 357 void enableIsolateSupport(LibraryElement element) { | 347 void enableIsolateSupport(LibraryElement element) { |
| 358 // TODO(ahe): Move this method to Enqueuer. | 348 // TODO(ahe): Move this method to Enqueuer. |
| 359 isolateLibrary = element.patch; | 349 isolateLibrary = element.patch; |
| 360 enqueuer.resolution.addToWorkList(isolateLibrary.find(START_ROOT_ISOLATE)); | 350 enqueuer.resolution.addToWorkList(isolateLibrary.find(START_ROOT_ISOLATE)); |
| 361 enqueuer.resolution.addToWorkList( | 351 enqueuer.resolution.addToWorkList( |
| 362 isolateLibrary.find(const SourceString('_currentIsolate'))); | 352 isolateLibrary.find(const SourceString('_currentIsolate'))); |
| 363 enqueuer.resolution.addToWorkList( | 353 enqueuer.resolution.addToWorkList( |
| 364 isolateLibrary.find(const SourceString('_callInIsolate'))); | 354 isolateLibrary.find(const SourceString('_callInIsolate'))); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 } | 386 } |
| 397 objectClass = lookupSpecialClass(const SourceString('Object')); | 387 objectClass = lookupSpecialClass(const SourceString('Object')); |
| 398 boolClass = lookupSpecialClass(const SourceString('bool')); | 388 boolClass = lookupSpecialClass(const SourceString('bool')); |
| 399 numClass = lookupSpecialClass(const SourceString('num')); | 389 numClass = lookupSpecialClass(const SourceString('num')); |
| 400 intClass = lookupSpecialClass(const SourceString('int')); | 390 intClass = lookupSpecialClass(const SourceString('int')); |
| 401 doubleClass = lookupSpecialClass(const SourceString('double')); | 391 doubleClass = lookupSpecialClass(const SourceString('double')); |
| 402 stringClass = lookupSpecialClass(const SourceString('String')); | 392 stringClass = lookupSpecialClass(const SourceString('String')); |
| 403 functionClass = lookupSpecialClass(const SourceString('Function')); | 393 functionClass = lookupSpecialClass(const SourceString('Function')); |
| 404 listClass = lookupSpecialClass(const SourceString('List')); | 394 listClass = lookupSpecialClass(const SourceString('List')); |
| 405 mapClass = lookupSpecialClass(const SourceString('Map')); | 395 mapClass = lookupSpecialClass(const SourceString('Map')); |
| 406 jsInvocationMirrorClass = | |
| 407 lookupSpecialClass(const SourceString('JSInvocationMirror')); | |
| 408 closureClass = lookupSpecialClass(const SourceString('Closure')); | 396 closureClass = lookupSpecialClass(const SourceString('Closure')); |
| 409 dynamicClass = lookupSpecialClass(const SourceString('Dynamic_')); | 397 dynamicClass = lookupSpecialClass(const SourceString('Dynamic_')); |
| 410 nullClass = lookupSpecialClass(const SourceString('Null')); | 398 nullClass = lookupSpecialClass(const SourceString('Null')); |
| 411 types = new Types(this, dynamicClass); | 399 types = new Types(this, dynamicClass); |
| 412 if (!coreLibValid) { | 400 if (!coreLibValid) { |
| 413 cancel('core library does not contain required classes'); | 401 cancel('core library does not contain required classes'); |
| 414 } | 402 } |
| 415 } | 403 } |
| 416 | 404 |
| 417 void scanBuiltinLibraries() { | 405 void scanBuiltinLibraries() { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 430 addForeignFunctions(interceptorsLibrary); | 418 addForeignFunctions(interceptorsLibrary); |
| 431 | 419 |
| 432 assertMethod = jsHelperLibrary.find(const SourceString('assertHelper')); | 420 assertMethod = jsHelperLibrary.find(const SourceString('assertHelper')); |
| 433 identicalFunction = coreLibrary.find(const SourceString('identical')); | 421 identicalFunction = coreLibrary.find(const SourceString('identical')); |
| 434 | 422 |
| 435 initializeSpecialClasses(); | 423 initializeSpecialClasses(); |
| 436 | 424 |
| 437 functionClass.ensureResolved(this); | 425 functionClass.ensureResolved(this); |
| 438 functionApplyMethod = | 426 functionApplyMethod = |
| 439 functionClass.lookupLocalMember(const SourceString('apply')); | 427 functionClass.lookupLocalMember(const SourceString('apply')); |
| 440 jsInvocationMirrorClass.ensureResolved(this); | |
| 441 invokeOnMethod = jsInvocationMirrorClass.lookupLocalMember( | |
| 442 const SourceString('invokeOn')); | |
| 443 } | 428 } |
| 444 | 429 |
| 445 void loadCoreImplLibrary() { | 430 void loadCoreImplLibrary() { |
| 446 Uri coreImplUri = new Uri.fromComponents(scheme: 'dart', path: 'coreimpl'); | 431 Uri coreImplUri = new Uri.fromComponents(scheme: 'dart', path: 'coreimpl'); |
| 447 coreImplLibrary = libraryLoader.loadLibrary(coreImplUri, null, coreImplUri); | 432 coreImplLibrary = libraryLoader.loadLibrary(coreImplUri, null, coreImplUri); |
| 448 } | 433 } |
| 449 | 434 |
| 450 void importHelperLibrary(LibraryElement library) { | 435 void importHelperLibrary(LibraryElement library) { |
| 451 if (jsHelperLibrary != null) { | 436 if (jsHelperLibrary != null) { |
| 452 libraryLoader.importLibrary(library, jsHelperLibrary, null); | 437 libraryLoader.importLibrary(library, jsHelperLibrary, null); |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 // TODO(johnniwinther): Use [spannable] and [message] to provide better | 890 // TODO(johnniwinther): Use [spannable] and [message] to provide better |
| 906 // information on assertion errors. | 891 // information on assertion errors. |
| 907 if (condition is Function){ | 892 if (condition is Function){ |
| 908 condition = condition(); | 893 condition = condition(); |
| 909 } | 894 } |
| 910 if (spannable == null || !condition) { | 895 if (spannable == null || !condition) { |
| 911 throw new SpannableAssertionFailure(spannable, message); | 896 throw new SpannableAssertionFailure(spannable, message); |
| 912 } | 897 } |
| 913 return true; | 898 return true; |
| 914 } | 899 } |
| OLD | NEW |