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 boolClass; | 124 ClassElement boolClass; |
125 ClassElement numClass; | 125 ClassElement numClass; |
126 ClassElement intClass; | 126 ClassElement intClass; |
127 ClassElement doubleClass; | 127 ClassElement doubleClass; |
128 ClassElement stringClass; | 128 ClassElement stringClass; |
129 ClassElement functionClass; | 129 ClassElement functionClass; |
130 ClassElement nullClass; | 130 ClassElement nullClass; |
131 ClassElement listClass; | 131 ClassElement listClass; |
132 Element assertMethod; | 132 Element assertMethod; |
133 Element identicalFunction; | 133 Element identicalFunction; |
| 134 Element functionApplyMethod; |
134 | 135 |
135 Element get currentElement => _currentElement; | 136 Element get currentElement => _currentElement; |
136 withCurrentElement(Element element, f()) { | 137 withCurrentElement(Element element, f()) { |
137 Element old = currentElement; | 138 Element old = currentElement; |
138 _currentElement = element; | 139 _currentElement = element; |
139 try { | 140 try { |
140 return f(); | 141 return f(); |
141 } on CompilerCancelledException catch (ex) { | 142 } on CompilerCancelledException catch (ex) { |
142 throw; | 143 throw; |
143 } on StackOverflowException catch (ex) { | 144 } on StackOverflowException catch (ex) { |
(...skipping 27 matching lines...) Expand all Loading... |
171 EnqueueTask enqueuer; | 172 EnqueueTask enqueuer; |
172 | 173 |
173 static const SourceString MAIN = const SourceString('main'); | 174 static const SourceString MAIN = const SourceString('main'); |
174 static const SourceString CALL_OPERATOR_NAME = const SourceString('call'); | 175 static const SourceString CALL_OPERATOR_NAME = const SourceString('call'); |
175 static const SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod'); | 176 static const SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod'); |
176 static const SourceString RUNTIME_TYPE = const SourceString('runtimeType'); | 177 static const SourceString RUNTIME_TYPE = const SourceString('runtimeType'); |
177 static const SourceString START_ROOT_ISOLATE = | 178 static const SourceString START_ROOT_ISOLATE = |
178 const SourceString('startRootIsolate'); | 179 const SourceString('startRootIsolate'); |
179 bool enabledNoSuchMethod = false; | 180 bool enabledNoSuchMethod = false; |
180 bool enabledRuntimeType = false; | 181 bool enabledRuntimeType = false; |
| 182 bool enabledFunctionApply = false; |
181 | 183 |
182 Stopwatch progress; | 184 Stopwatch progress; |
183 | 185 |
184 static const int PHASE_SCANNING = 0; | 186 static const int PHASE_SCANNING = 0; |
185 static const int PHASE_RESOLVING = 1; | 187 static const int PHASE_RESOLVING = 1; |
186 static const int PHASE_COMPILING = 2; | 188 static const int PHASE_COMPILING = 2; |
187 int phase; | 189 int phase; |
188 | 190 |
189 bool compilationFailed = false; | 191 bool compilationFailed = false; |
190 | 192 |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 importHelperLibrary(coreImplLibrary); | 379 importHelperLibrary(coreImplLibrary); |
378 importHelperLibrary(interceptorsLibrary); | 380 importHelperLibrary(interceptorsLibrary); |
379 | 381 |
380 addForeignFunctions(jsHelperLibrary); | 382 addForeignFunctions(jsHelperLibrary); |
381 addForeignFunctions(interceptorsLibrary); | 383 addForeignFunctions(interceptorsLibrary); |
382 | 384 |
383 assertMethod = jsHelperLibrary.find(const SourceString('assert')); | 385 assertMethod = jsHelperLibrary.find(const SourceString('assert')); |
384 identicalFunction = coreLibrary.find(const SourceString('identical')); | 386 identicalFunction = coreLibrary.find(const SourceString('identical')); |
385 | 387 |
386 initializeSpecialClasses(); | 388 initializeSpecialClasses(); |
| 389 |
| 390 functionClass.ensureResolved(this); |
| 391 functionApplyMethod = |
| 392 functionClass.lookupLocalMember(const SourceString('apply')); |
387 } | 393 } |
388 | 394 |
389 void loadCoreImplLibrary() { | 395 void loadCoreImplLibrary() { |
390 Uri coreImplUri = new Uri.fromComponents(scheme: 'dart', path: 'coreimpl'); | 396 Uri coreImplUri = new Uri.fromComponents(scheme: 'dart', path: 'coreimpl'); |
391 coreImplLibrary = scanner.loadLibrary(coreImplUri, null, coreImplUri); | 397 coreImplLibrary = scanner.loadLibrary(coreImplUri, null, coreImplUri); |
392 } | 398 } |
393 | 399 |
394 void importHelperLibrary(LibraryElement library) { | 400 void importHelperLibrary(LibraryElement library) { |
395 if (jsHelperLibrary !== null) { | 401 if (jsHelperLibrary !== null) { |
396 scanner.importLibrary(library, jsHelperLibrary, null); | 402 scanner.importLibrary(library, jsHelperLibrary, null); |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 * information in the generated error message. | 856 * information in the generated error message. |
851 */ | 857 */ |
852 bool invariant(Spannable spannable, var condition, {String message: null}) { | 858 bool invariant(Spannable spannable, var condition, {String message: null}) { |
853 // TODO(johnniwinther): Use [spannable] and [message] to provide better | 859 // TODO(johnniwinther): Use [spannable] and [message] to provide better |
854 // information on assertion errors. | 860 // information on assertion errors. |
855 if (condition is Function){ | 861 if (condition is Function){ |
856 condition = condition(); | 862 condition = condition(); |
857 } | 863 } |
858 return spannable != null && condition; | 864 return spannable != null && condition; |
859 } | 865 } |
OLD | NEW |