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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 // TODO(ahe): Move this method to Enqueuer. | 336 // TODO(ahe): Move this method to Enqueuer. |
342 if (enabledNoSuchMethod) return; | 337 if (enabledNoSuchMethod) return; |
343 if (identical(element.getEnclosingClass(), objectClass)) { | 338 if (identical(element.getEnclosingClass(), objectClass)) { |
344 enqueuer.resolution.registerDynamicInvocationOf(element); | 339 enqueuer.resolution.registerDynamicInvocationOf(element); |
345 return; | 340 return; |
346 } | 341 } |
347 enabledNoSuchMethod = true; | 342 enabledNoSuchMethod = true; |
348 Selector selector = new Selector.noSuchMethod(); | 343 Selector selector = new Selector.noSuchMethod(); |
349 enqueuer.resolution.registerInvocation(NO_SUCH_METHOD, selector); | 344 enqueuer.resolution.registerInvocation(NO_SUCH_METHOD, selector); |
350 enqueuer.codegen.registerInvocation(NO_SUCH_METHOD, selector); | 345 enqueuer.codegen.registerInvocation(NO_SUCH_METHOD, selector); |
351 | |
352 Element createInvocationMirrorElement = | |
353 findHelper(const SourceString('createInvocationMirror')); | |
354 enqueuer.resolution.addToWorkList(createInvocationMirrorElement); | |
355 enqueuer.codegen.addToWorkList(createInvocationMirrorElement); | |
356 } | 346 } |
357 | 347 |
358 void enableIsolateSupport(LibraryElement element) { | 348 void enableIsolateSupport(LibraryElement element) { |
359 // TODO(ahe): Move this method to Enqueuer. | 349 // TODO(ahe): Move this method to Enqueuer. |
360 isolateLibrary = element.patch; | 350 isolateLibrary = element.patch; |
361 enqueuer.resolution.addToWorkList(isolateLibrary.find(START_ROOT_ISOLATE)); | 351 enqueuer.resolution.addToWorkList(isolateLibrary.find(START_ROOT_ISOLATE)); |
362 enqueuer.resolution.addToWorkList( | 352 enqueuer.resolution.addToWorkList( |
363 isolateLibrary.find(const SourceString('_currentIsolate'))); | 353 isolateLibrary.find(const SourceString('_currentIsolate'))); |
364 enqueuer.resolution.addToWorkList( | 354 enqueuer.resolution.addToWorkList( |
365 isolateLibrary.find(const SourceString('_callInIsolate'))); | 355 isolateLibrary.find(const SourceString('_callInIsolate'))); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 } | 387 } |
398 objectClass = lookupSpecialClass(const SourceString('Object')); | 388 objectClass = lookupSpecialClass(const SourceString('Object')); |
399 boolClass = lookupSpecialClass(const SourceString('bool')); | 389 boolClass = lookupSpecialClass(const SourceString('bool')); |
400 numClass = lookupSpecialClass(const SourceString('num')); | 390 numClass = lookupSpecialClass(const SourceString('num')); |
401 intClass = lookupSpecialClass(const SourceString('int')); | 391 intClass = lookupSpecialClass(const SourceString('int')); |
402 doubleClass = lookupSpecialClass(const SourceString('double')); | 392 doubleClass = lookupSpecialClass(const SourceString('double')); |
403 stringClass = lookupSpecialClass(const SourceString('String')); | 393 stringClass = lookupSpecialClass(const SourceString('String')); |
404 functionClass = lookupSpecialClass(const SourceString('Function')); | 394 functionClass = lookupSpecialClass(const SourceString('Function')); |
405 listClass = lookupSpecialClass(const SourceString('List')); | 395 listClass = lookupSpecialClass(const SourceString('List')); |
406 mapClass = lookupSpecialClass(const SourceString('Map')); | 396 mapClass = lookupSpecialClass(const SourceString('Map')); |
407 jsInvocationMirrorClass = | |
408 lookupSpecialClass(const SourceString('JSInvocationMirror')); | |
409 closureClass = lookupSpecialClass(const SourceString('Closure')); | 397 closureClass = lookupSpecialClass(const SourceString('Closure')); |
410 dynamicClass = lookupSpecialClass(const SourceString('Dynamic_')); | 398 dynamicClass = lookupSpecialClass(const SourceString('Dynamic_')); |
411 nullClass = lookupSpecialClass(const SourceString('Null')); | 399 nullClass = lookupSpecialClass(const SourceString('Null')); |
412 types = new Types(this, dynamicClass); | 400 types = new Types(this, dynamicClass); |
413 if (!coreLibValid) { | 401 if (!coreLibValid) { |
414 cancel('core library does not contain required classes'); | 402 cancel('core library does not contain required classes'); |
415 } | 403 } |
416 } | 404 } |
417 | 405 |
418 void scanBuiltinLibraries() { | 406 void scanBuiltinLibraries() { |
(...skipping 12 matching lines...) Expand all Loading... |
431 addForeignFunctions(interceptorsLibrary); | 419 addForeignFunctions(interceptorsLibrary); |
432 | 420 |
433 assertMethod = jsHelperLibrary.find(const SourceString('assertHelper')); | 421 assertMethod = jsHelperLibrary.find(const SourceString('assertHelper')); |
434 identicalFunction = coreLibrary.find(const SourceString('identical')); | 422 identicalFunction = coreLibrary.find(const SourceString('identical')); |
435 | 423 |
436 initializeSpecialClasses(); | 424 initializeSpecialClasses(); |
437 | 425 |
438 functionClass.ensureResolved(this); | 426 functionClass.ensureResolved(this); |
439 functionApplyMethod = | 427 functionApplyMethod = |
440 functionClass.lookupLocalMember(const SourceString('apply')); | 428 functionClass.lookupLocalMember(const SourceString('apply')); |
441 jsInvocationMirrorClass.ensureResolved(this); | |
442 invokeOnMethod = jsInvocationMirrorClass.lookupLocalMember( | |
443 const SourceString('invokeOn')); | |
444 } | 429 } |
445 | 430 |
446 void loadCoreImplLibrary() { | 431 void loadCoreImplLibrary() { |
447 Uri coreImplUri = new Uri.fromComponents(scheme: 'dart', path: 'coreimpl'); | 432 Uri coreImplUri = new Uri.fromComponents(scheme: 'dart', path: 'coreimpl'); |
448 coreImplLibrary = libraryLoader.loadLibrary(coreImplUri, null, coreImplUri); | 433 coreImplLibrary = libraryLoader.loadLibrary(coreImplUri, null, coreImplUri); |
449 } | 434 } |
450 | 435 |
451 void importHelperLibrary(LibraryElement library) { | 436 void importHelperLibrary(LibraryElement library) { |
452 if (jsHelperLibrary != null) { | 437 if (jsHelperLibrary != null) { |
453 libraryLoader.importLibrary(library, jsHelperLibrary, null); | 438 libraryLoader.importLibrary(library, jsHelperLibrary, null); |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 // TODO(johnniwinther): Use [spannable] and [message] to provide better | 891 // TODO(johnniwinther): Use [spannable] and [message] to provide better |
907 // information on assertion errors. | 892 // information on assertion errors. |
908 if (condition is Function){ | 893 if (condition is Function){ |
909 condition = condition(); | 894 condition = condition(); |
910 } | 895 } |
911 if (spannable == null || !condition) { | 896 if (spannable == null || !condition) { |
912 throw new SpannableAssertionFailure(spannable, message); | 897 throw new SpannableAssertionFailure(spannable, message); |
913 } | 898 } |
914 return true; | 899 return true; |
915 } | 900 } |
OLD | NEW |