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