Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 ClassElement dynamicClass; | 125 ClassElement dynamicClass; |
| 126 ClassElement boolClass; | 126 ClassElement boolClass; |
| 127 ClassElement numClass; | 127 ClassElement numClass; |
| 128 ClassElement intClass; | 128 ClassElement intClass; |
| 129 ClassElement doubleClass; | 129 ClassElement doubleClass; |
| 130 ClassElement stringClass; | 130 ClassElement stringClass; |
| 131 ClassElement functionClass; | 131 ClassElement functionClass; |
| 132 ClassElement nullClass; | 132 ClassElement nullClass; |
| 133 ClassElement listClass; | 133 ClassElement listClass; |
| 134 ClassElement mapClass; | 134 ClassElement mapClass; |
| 135 ClassElement jsInvocationMirrorClass; | |
| 135 Element assertMethod; | 136 Element assertMethod; |
| 136 Element identicalFunction; | 137 Element identicalFunction; |
| 137 Element functionApplyMethod; | 138 Element functionApplyMethod; |
| 139 Element invokeOnMethod; | |
| 138 | 140 |
| 139 Element get currentElement => _currentElement; | 141 Element get currentElement => _currentElement; |
| 140 withCurrentElement(Element element, f()) { | 142 withCurrentElement(Element element, f()) { |
| 141 Element old = currentElement; | 143 Element old = currentElement; |
| 142 _currentElement = element; | 144 _currentElement = element; |
| 143 try { | 145 try { |
| 144 return f(); | 146 return f(); |
| 145 } on CompilerCancelledException catch (ex) { | 147 } on CompilerCancelledException catch (ex) { |
| 146 throw; | 148 throw; |
| 147 } on StackOverflowError catch (ex) { | 149 } on StackOverflowError catch (ex) { |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 168 LibraryLoader libraryLoader; | 170 LibraryLoader libraryLoader; |
| 169 TreeValidatorTask validator; | 171 TreeValidatorTask validator; |
| 170 ResolverTask resolver; | 172 ResolverTask resolver; |
| 171 closureMapping.ClosureTask closureToClassMapper; | 173 closureMapping.ClosureTask closureToClassMapper; |
| 172 TypeCheckerTask checker; | 174 TypeCheckerTask checker; |
| 173 ti.TypesTask typesTask; | 175 ti.TypesTask typesTask; |
| 174 Backend backend; | 176 Backend backend; |
| 175 ConstantHandler constantHandler; | 177 ConstantHandler constantHandler; |
| 176 EnqueueTask enqueuer; | 178 EnqueueTask enqueuer; |
| 177 | 179 |
| 178 static const SourceString MAIN = const SourceString('main'); | 180 static const SourceString MAIN = const SourceString('main'); |
|
ahe
2012/10/29 12:14:05
How about adding a TODO that these should be selec
| |
| 179 static const SourceString CALL_OPERATOR_NAME = const SourceString('call'); | 181 static const SourceString CALL_OPERATOR_NAME = const SourceString('call'); |
| 180 static const SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod'); | 182 static const SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod'); |
| 183 static const int NO_SUCH_METHOD_ARG_COUNT = 1; | |
| 184 static const SourceString INVOKE_ON = const SourceString('invokeOn'); | |
| 181 static const SourceString RUNTIME_TYPE = const SourceString('runtimeType'); | 185 static const SourceString RUNTIME_TYPE = const SourceString('runtimeType'); |
| 182 static const SourceString START_ROOT_ISOLATE = | 186 static const SourceString START_ROOT_ISOLATE = |
| 183 const SourceString('startRootIsolate'); | 187 const SourceString('startRootIsolate'); |
| 184 bool enabledNoSuchMethod = false; | 188 bool enabledNoSuchMethod = false; |
| 185 bool enabledRuntimeType = false; | 189 bool enabledRuntimeType = false; |
| 186 bool enabledFunctionApply = false; | 190 bool enabledFunctionApply = false; |
| 191 bool enabledInvokeOn = false; | |
| 187 | 192 |
| 188 Stopwatch progress; | 193 Stopwatch progress; |
| 189 | 194 |
| 190 static const int PHASE_SCANNING = 0; | 195 static const int PHASE_SCANNING = 0; |
| 191 static const int PHASE_RESOLVING = 1; | 196 static const int PHASE_RESOLVING = 1; |
| 192 static const int PHASE_COMPILING = 2; | 197 static const int PHASE_COMPILING = 2; |
| 193 int phase; | 198 int phase; |
| 194 | 199 |
| 195 bool compilationFailed = false; | 200 bool compilationFailed = false; |
| 196 | 201 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 318 // TODO(ahe): Move this method to Enqueuer. | 323 // TODO(ahe): Move this method to Enqueuer. |
| 319 if (enabledNoSuchMethod) return; | 324 if (enabledNoSuchMethod) return; |
| 320 if (identical(element.getEnclosingClass(), objectClass)) { | 325 if (identical(element.getEnclosingClass(), objectClass)) { |
| 321 enqueuer.resolution.registerDynamicInvocationOf(element); | 326 enqueuer.resolution.registerDynamicInvocationOf(element); |
| 322 return; | 327 return; |
| 323 } | 328 } |
| 324 enabledNoSuchMethod = true; | 329 enabledNoSuchMethod = true; |
| 325 Selector selector = new Selector.noSuchMethod(); | 330 Selector selector = new Selector.noSuchMethod(); |
| 326 enqueuer.resolution.registerInvocation(NO_SUCH_METHOD, selector); | 331 enqueuer.resolution.registerInvocation(NO_SUCH_METHOD, selector); |
| 327 enqueuer.codegen.registerInvocation(NO_SUCH_METHOD, selector); | 332 enqueuer.codegen.registerInvocation(NO_SUCH_METHOD, selector); |
| 333 | |
| 334 Element createInvocationMirrorElement = | |
| 335 findHelper(const SourceString('createInvocationMirror')); | |
|
ahe
2012/10/29 12:14:05
This looks specific to the JS backend.
| |
| 336 enqueuer.resolution.addToWorkList(createInvocationMirrorElement); | |
| 337 enqueuer.codegen.addToWorkList(createInvocationMirrorElement); | |
|
ahe
2012/10/29 12:14:05
This should only be added if it is really needed.
| |
| 328 } | 338 } |
| 329 | 339 |
| 330 void enableIsolateSupport(LibraryElement element) { | 340 void enableIsolateSupport(LibraryElement element) { |
| 331 // TODO(ahe): Move this method to Enqueuer. | 341 // TODO(ahe): Move this method to Enqueuer. |
| 332 isolateLibrary = element.patch; | 342 isolateLibrary = element.patch; |
| 333 enqueuer.resolution.addToWorkList(isolateLibrary.find(START_ROOT_ISOLATE)); | 343 enqueuer.resolution.addToWorkList(isolateLibrary.find(START_ROOT_ISOLATE)); |
| 334 enqueuer.resolution.addToWorkList( | 344 enqueuer.resolution.addToWorkList( |
| 335 isolateLibrary.find(const SourceString('_currentIsolate'))); | 345 isolateLibrary.find(const SourceString('_currentIsolate'))); |
| 336 enqueuer.resolution.addToWorkList( | 346 enqueuer.resolution.addToWorkList( |
| 337 isolateLibrary.find(const SourceString('_callInIsolate'))); | 347 isolateLibrary.find(const SourceString('_callInIsolate'))); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 369 } | 379 } |
| 370 objectClass = lookupSpecialClass(const SourceString('Object')); | 380 objectClass = lookupSpecialClass(const SourceString('Object')); |
| 371 boolClass = lookupSpecialClass(const SourceString('bool')); | 381 boolClass = lookupSpecialClass(const SourceString('bool')); |
| 372 numClass = lookupSpecialClass(const SourceString('num')); | 382 numClass = lookupSpecialClass(const SourceString('num')); |
| 373 intClass = lookupSpecialClass(const SourceString('int')); | 383 intClass = lookupSpecialClass(const SourceString('int')); |
| 374 doubleClass = lookupSpecialClass(const SourceString('double')); | 384 doubleClass = lookupSpecialClass(const SourceString('double')); |
| 375 stringClass = lookupSpecialClass(const SourceString('String')); | 385 stringClass = lookupSpecialClass(const SourceString('String')); |
| 376 functionClass = lookupSpecialClass(const SourceString('Function')); | 386 functionClass = lookupSpecialClass(const SourceString('Function')); |
| 377 listClass = lookupSpecialClass(const SourceString('List')); | 387 listClass = lookupSpecialClass(const SourceString('List')); |
| 378 mapClass = lookupSpecialClass(const SourceString('Map')); | 388 mapClass = lookupSpecialClass(const SourceString('Map')); |
| 389 jsInvocationMirrorClass = | |
| 390 lookupSpecialClass(const SourceString('JSInvocationMirror')); | |
|
ahe
2012/10/29 12:14:05
This looks specific to the JS backend.
| |
| 379 closureClass = lookupSpecialClass(const SourceString('Closure')); | 391 closureClass = lookupSpecialClass(const SourceString('Closure')); |
| 380 dynamicClass = lookupSpecialClass(const SourceString('Dynamic_')); | 392 dynamicClass = lookupSpecialClass(const SourceString('Dynamic_')); |
| 381 nullClass = lookupSpecialClass(const SourceString('Null')); | 393 nullClass = lookupSpecialClass(const SourceString('Null')); |
| 382 types = new Types(this, dynamicClass); | 394 types = new Types(this, dynamicClass); |
| 383 if (!coreLibValid) { | 395 if (!coreLibValid) { |
| 384 cancel('core library does not contain required classes'); | 396 cancel('core library does not contain required classes'); |
| 385 } | 397 } |
| 386 } | 398 } |
| 387 | 399 |
| 388 void scanBuiltinLibraries() { | 400 void scanBuiltinLibraries() { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 401 addForeignFunctions(interceptorsLibrary); | 413 addForeignFunctions(interceptorsLibrary); |
| 402 | 414 |
| 403 assertMethod = jsHelperLibrary.find(const SourceString('assertHelper')); | 415 assertMethod = jsHelperLibrary.find(const SourceString('assertHelper')); |
| 404 identicalFunction = coreLibrary.find(const SourceString('identical')); | 416 identicalFunction = coreLibrary.find(const SourceString('identical')); |
| 405 | 417 |
| 406 initializeSpecialClasses(); | 418 initializeSpecialClasses(); |
| 407 | 419 |
| 408 functionClass.ensureResolved(this); | 420 functionClass.ensureResolved(this); |
| 409 functionApplyMethod = | 421 functionApplyMethod = |
| 410 functionClass.lookupLocalMember(const SourceString('apply')); | 422 functionClass.lookupLocalMember(const SourceString('apply')); |
| 423 jsInvocationMirrorClass.ensureResolved(this); | |
| 424 invokeOnMethod = jsInvocationMirrorClass.lookupLocalMember( | |
| 425 const SourceString('invokeOn')); | |
|
ahe
2012/10/29 12:14:05
This looks specific to the JS backend.
| |
| 411 } | 426 } |
| 412 | 427 |
| 413 void loadCoreImplLibrary() { | 428 void loadCoreImplLibrary() { |
| 414 Uri coreImplUri = new Uri.fromComponents(scheme: 'dart', path: 'coreimpl'); | 429 Uri coreImplUri = new Uri.fromComponents(scheme: 'dart', path: 'coreimpl'); |
| 415 coreImplLibrary = libraryLoader.loadLibrary(coreImplUri, null, coreImplUri); | 430 coreImplLibrary = libraryLoader.loadLibrary(coreImplUri, null, coreImplUri); |
| 416 } | 431 } |
| 417 | 432 |
| 418 void importHelperLibrary(LibraryElement library) { | 433 void importHelperLibrary(LibraryElement library) { |
| 419 if (jsHelperLibrary != null) { | 434 if (jsHelperLibrary != null) { |
| 420 libraryLoader.importLibrary(library, jsHelperLibrary, null); | 435 libraryLoader.importLibrary(library, jsHelperLibrary, null); |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 862 // TODO(johnniwinther): Use [spannable] and [message] to provide better | 877 // TODO(johnniwinther): Use [spannable] and [message] to provide better |
| 863 // information on assertion errors. | 878 // information on assertion errors. |
| 864 if (condition is Function){ | 879 if (condition is Function){ |
| 865 condition = condition(); | 880 condition = condition(); |
| 866 } | 881 } |
| 867 if (!condition && message != null) { | 882 if (!condition && message != null) { |
| 868 print('assertion failed: $message'); | 883 print('assertion failed: $message'); |
| 869 } | 884 } |
| 870 return spannable != null && condition; | 885 return spannable != null && condition; |
| 871 } | 886 } |
| OLD | NEW |