| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library engine; | 5 library engine; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:math' as math; | 9 import 'dart:math' as math; |
| 10 | 10 |
| (...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1163 void set analysisOptions(AnalysisOptions options) { | 1163 void set analysisOptions(AnalysisOptions options) { |
| 1164 bool needsRecompute = this._options.analyzeFunctionBodiesPredicate != | 1164 bool needsRecompute = this._options.analyzeFunctionBodiesPredicate != |
| 1165 options.analyzeFunctionBodiesPredicate || | 1165 options.analyzeFunctionBodiesPredicate || |
| 1166 this._options.generateImplicitErrors != | 1166 this._options.generateImplicitErrors != |
| 1167 options.generateImplicitErrors || | 1167 options.generateImplicitErrors || |
| 1168 this._options.generateSdkErrors != options.generateSdkErrors || | 1168 this._options.generateSdkErrors != options.generateSdkErrors || |
| 1169 this._options.dart2jsHint != options.dart2jsHint || | 1169 this._options.dart2jsHint != options.dart2jsHint || |
| 1170 (this._options.hint && !options.hint) || | 1170 (this._options.hint && !options.hint) || |
| 1171 this._options.preserveComments != options.preserveComments || | 1171 this._options.preserveComments != options.preserveComments || |
| 1172 this._options.strongMode != options.strongMode || | 1172 this._options.strongMode != options.strongMode || |
| 1173 this._options.enableAssertMessage != options.enableAssertMessage || |
| 1173 this._options.enableStrictCallChecks != | 1174 this._options.enableStrictCallChecks != |
| 1174 options.enableStrictCallChecks || | 1175 options.enableStrictCallChecks || |
| 1175 this._options.enableSuperMixins != options.enableSuperMixins; | 1176 this._options.enableSuperMixins != options.enableSuperMixins; |
| 1176 int cacheSize = options.cacheSize; | 1177 int cacheSize = options.cacheSize; |
| 1177 if (this._options.cacheSize != cacheSize) { | 1178 if (this._options.cacheSize != cacheSize) { |
| 1178 this._options.cacheSize = cacheSize; | 1179 this._options.cacheSize = cacheSize; |
| 1179 //cache.setMaxCacheSize(cacheSize); | 1180 //cache.setMaxCacheSize(cacheSize); |
| 1180 _privatePartition.maxCacheSize = cacheSize; | 1181 _privatePartition.maxCacheSize = cacheSize; |
| 1181 // | 1182 // |
| 1182 // Cap the size of the priority list to being less than the cache size. | 1183 // Cap the size of the priority list to being less than the cache size. |
| 1183 // Failure to do so can result in an infinite loop in | 1184 // Failure to do so can result in an infinite loop in |
| 1184 // performAnalysisTask() because re-caching one AST structure | 1185 // performAnalysisTask() because re-caching one AST structure |
| 1185 // can cause another priority source's AST structure to be flushed. | 1186 // can cause another priority source's AST structure to be flushed. |
| 1186 // | 1187 // |
| 1187 // TODO(brianwilkerson) Remove this constraint when the new task model is | 1188 // TODO(brianwilkerson) Remove this constraint when the new task model is |
| 1188 // implemented. | 1189 // implemented. |
| 1189 // | 1190 // |
| 1190 int maxPriorityOrderSize = cacheSize - _PRIORITY_ORDER_SIZE_DELTA; | 1191 int maxPriorityOrderSize = cacheSize - _PRIORITY_ORDER_SIZE_DELTA; |
| 1191 if (_priorityOrder.length > maxPriorityOrderSize) { | 1192 if (_priorityOrder.length > maxPriorityOrderSize) { |
| 1192 _priorityOrder = _priorityOrder.sublist(0, maxPriorityOrderSize); | 1193 _priorityOrder = _priorityOrder.sublist(0, maxPriorityOrderSize); |
| 1193 } | 1194 } |
| 1194 } | 1195 } |
| 1195 this._options.analyzeFunctionBodiesPredicate = | 1196 this._options.analyzeFunctionBodiesPredicate = |
| 1196 options.analyzeFunctionBodiesPredicate; | 1197 options.analyzeFunctionBodiesPredicate; |
| 1197 this._options.generateImplicitErrors = options.generateImplicitErrors; | 1198 this._options.generateImplicitErrors = options.generateImplicitErrors; |
| 1198 this._options.generateSdkErrors = options.generateSdkErrors; | 1199 this._options.generateSdkErrors = options.generateSdkErrors; |
| 1199 this._options.dart2jsHint = options.dart2jsHint; | 1200 this._options.dart2jsHint = options.dart2jsHint; |
| 1201 this._options.enableAssertMessage = options.enableAssertMessage; |
| 1200 this._options.enableStrictCallChecks = options.enableStrictCallChecks; | 1202 this._options.enableStrictCallChecks = options.enableStrictCallChecks; |
| 1201 this._options.enableSuperMixins = options.enableSuperMixins; | 1203 this._options.enableSuperMixins = options.enableSuperMixins; |
| 1202 this._options.hint = options.hint; | 1204 this._options.hint = options.hint; |
| 1203 this._options.incremental = options.incremental; | 1205 this._options.incremental = options.incremental; |
| 1204 this._options.incrementalApi = options.incrementalApi; | 1206 this._options.incrementalApi = options.incrementalApi; |
| 1205 this._options.incrementalValidation = options.incrementalValidation; | 1207 this._options.incrementalValidation = options.incrementalValidation; |
| 1206 this._options.lint = options.lint; | 1208 this._options.lint = options.lint; |
| 1207 this._options.preserveComments = options.preserveComments; | 1209 this._options.preserveComments = options.preserveComments; |
| 1208 this._options.strongMode = options.strongMode; | 1210 this._options.strongMode = options.strongMode; |
| 1209 _generateImplicitErrors = options.generateImplicitErrors; | 1211 _generateImplicitErrors = options.generateImplicitErrors; |
| (...skipping 5045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6255 * kept in the cache. | 6257 * kept in the cache. |
| 6256 */ | 6258 */ |
| 6257 int get cacheSize; | 6259 int get cacheSize; |
| 6258 | 6260 |
| 6259 /** | 6261 /** |
| 6260 * Return `true` if analysis is to generate dart2js related hint results. | 6262 * Return `true` if analysis is to generate dart2js related hint results. |
| 6261 */ | 6263 */ |
| 6262 bool get dart2jsHint; | 6264 bool get dart2jsHint; |
| 6263 | 6265 |
| 6264 /** | 6266 /** |
| 6267 * Return `true` to enable custom assert messages (DEP 37). |
| 6268 */ |
| 6269 bool get enableAssertMessage; |
| 6270 |
| 6271 /** |
| 6265 * Return `true` if analysis is to include the new async support. | 6272 * Return `true` if analysis is to include the new async support. |
| 6266 */ | 6273 */ |
| 6267 @deprecated // Always true | 6274 @deprecated // Always true |
| 6268 bool get enableAsync; | 6275 bool get enableAsync; |
| 6269 | 6276 |
| 6270 /** | 6277 /** |
| 6271 * Return `true` if analysis is to include the new deferred loading support. | 6278 * Return `true` if analysis is to include the new deferred loading support. |
| 6272 */ | 6279 */ |
| 6273 @deprecated // Always true | 6280 @deprecated // Always true |
| 6274 bool get enableDeferredLoading; | 6281 bool get enableDeferredLoading; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6388 */ | 6395 */ |
| 6389 int cacheSize = DEFAULT_CACHE_SIZE; | 6396 int cacheSize = DEFAULT_CACHE_SIZE; |
| 6390 | 6397 |
| 6391 /** | 6398 /** |
| 6392 * A flag indicating whether analysis is to generate dart2js related hint | 6399 * A flag indicating whether analysis is to generate dart2js related hint |
| 6393 * results. | 6400 * results. |
| 6394 */ | 6401 */ |
| 6395 bool dart2jsHint = false; | 6402 bool dart2jsHint = false; |
| 6396 | 6403 |
| 6397 /** | 6404 /** |
| 6405 * A flag indicating whether custom assert messages are to be supported (DEP |
| 6406 * 37). |
| 6407 */ |
| 6408 bool enableAssertMessage = false; |
| 6409 |
| 6410 /** |
| 6398 * A flag indicating whether generic methods are to be supported (DEP 22). | 6411 * A flag indicating whether generic methods are to be supported (DEP 22). |
| 6399 */ | 6412 */ |
| 6400 bool enableGenericMethods = false; | 6413 bool enableGenericMethods = false; |
| 6401 | 6414 |
| 6402 /** | 6415 /** |
| 6403 * A flag indicating whether analysis is to strictly follow the specification | 6416 * A flag indicating whether analysis is to strictly follow the specification |
| 6404 * when generating warnings on "call" methods (fixes dartbug.com/21938). | 6417 * when generating warnings on "call" methods (fixes dartbug.com/21938). |
| 6405 */ | 6418 */ |
| 6406 bool enableStrictCallChecks = false; | 6419 bool enableStrictCallChecks = false; |
| 6407 | 6420 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6469 | 6482 |
| 6470 /** | 6483 /** |
| 6471 * Initialize a newly created set of analysis options to have the same values | 6484 * Initialize a newly created set of analysis options to have the same values |
| 6472 * as those in the given set of analysis [options]. | 6485 * as those in the given set of analysis [options]. |
| 6473 */ | 6486 */ |
| 6474 @deprecated // Use new AnalysisOptionsImpl.from(options) | 6487 @deprecated // Use new AnalysisOptionsImpl.from(options) |
| 6475 AnalysisOptionsImpl.con1(AnalysisOptions options) { | 6488 AnalysisOptionsImpl.con1(AnalysisOptions options) { |
| 6476 analyzeFunctionBodiesPredicate = options.analyzeFunctionBodiesPredicate; | 6489 analyzeFunctionBodiesPredicate = options.analyzeFunctionBodiesPredicate; |
| 6477 cacheSize = options.cacheSize; | 6490 cacheSize = options.cacheSize; |
| 6478 dart2jsHint = options.dart2jsHint; | 6491 dart2jsHint = options.dart2jsHint; |
| 6492 enableAssertMessage = options.enableAssertMessage; |
| 6479 enableStrictCallChecks = options.enableStrictCallChecks; | 6493 enableStrictCallChecks = options.enableStrictCallChecks; |
| 6480 enableGenericMethods = options.enableGenericMethods; | 6494 enableGenericMethods = options.enableGenericMethods; |
| 6481 enableSuperMixins = options.enableSuperMixins; | 6495 enableSuperMixins = options.enableSuperMixins; |
| 6482 generateImplicitErrors = options.generateImplicitErrors; | 6496 generateImplicitErrors = options.generateImplicitErrors; |
| 6483 generateSdkErrors = options.generateSdkErrors; | 6497 generateSdkErrors = options.generateSdkErrors; |
| 6484 hint = options.hint; | 6498 hint = options.hint; |
| 6485 incremental = options.incremental; | 6499 incremental = options.incremental; |
| 6486 incrementalApi = options.incrementalApi; | 6500 incrementalApi = options.incrementalApi; |
| 6487 incrementalValidation = options.incrementalValidation; | 6501 incrementalValidation = options.incrementalValidation; |
| 6488 lint = options.lint; | 6502 lint = options.lint; |
| 6489 preserveComments = options.preserveComments; | 6503 preserveComments = options.preserveComments; |
| 6490 strongMode = options.strongMode; | 6504 strongMode = options.strongMode; |
| 6491 } | 6505 } |
| 6492 | 6506 |
| 6493 /** | 6507 /** |
| 6494 * Initialize a newly created set of analysis options to have the same values | 6508 * Initialize a newly created set of analysis options to have the same values |
| 6495 * as those in the given set of analysis [options]. | 6509 * as those in the given set of analysis [options]. |
| 6496 */ | 6510 */ |
| 6497 AnalysisOptionsImpl.from(AnalysisOptions options) { | 6511 AnalysisOptionsImpl.from(AnalysisOptions options) { |
| 6498 analyzeFunctionBodiesPredicate = options.analyzeFunctionBodiesPredicate; | 6512 analyzeFunctionBodiesPredicate = options.analyzeFunctionBodiesPredicate; |
| 6499 cacheSize = options.cacheSize; | 6513 cacheSize = options.cacheSize; |
| 6500 dart2jsHint = options.dart2jsHint; | 6514 dart2jsHint = options.dart2jsHint; |
| 6515 enableAssertMessage = options.enableAssertMessage; |
| 6501 enableStrictCallChecks = options.enableStrictCallChecks; | 6516 enableStrictCallChecks = options.enableStrictCallChecks; |
| 6502 enableGenericMethods = options.enableGenericMethods; | 6517 enableGenericMethods = options.enableGenericMethods; |
| 6503 enableSuperMixins = options.enableSuperMixins; | 6518 enableSuperMixins = options.enableSuperMixins; |
| 6504 generateImplicitErrors = options.generateImplicitErrors; | 6519 generateImplicitErrors = options.generateImplicitErrors; |
| 6505 generateSdkErrors = options.generateSdkErrors; | 6520 generateSdkErrors = options.generateSdkErrors; |
| 6506 hint = options.hint; | 6521 hint = options.hint; |
| 6507 incremental = options.incremental; | 6522 incremental = options.incremental; |
| 6508 incrementalApi = options.incrementalApi; | 6523 incrementalApi = options.incrementalApi; |
| 6509 incrementalValidation = options.incrementalValidation; | 6524 incrementalValidation = options.incrementalValidation; |
| 6510 lint = options.lint; | 6525 lint = options.lint; |
| (...skipping 2051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8562 // ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter,
libraryElement, typeProvider); | 8577 // ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter,
libraryElement, typeProvider); |
| 8563 // _unit.accept(constantVerifier); | 8578 // _unit.accept(constantVerifier); |
| 8564 // | 8579 // |
| 8565 // Use the ErrorVerifier to compute the rest of the errors. | 8580 // Use the ErrorVerifier to compute the rest of the errors. |
| 8566 // | 8581 // |
| 8567 ErrorVerifier errorVerifier = new ErrorVerifier( | 8582 ErrorVerifier errorVerifier = new ErrorVerifier( |
| 8568 errorReporter, | 8583 errorReporter, |
| 8569 libraryElement, | 8584 libraryElement, |
| 8570 typeProvider, | 8585 typeProvider, |
| 8571 new InheritanceManager(libraryElement), | 8586 new InheritanceManager(libraryElement), |
| 8572 context.analysisOptions.enableSuperMixins); | 8587 context.analysisOptions.enableSuperMixins, |
| 8588 context.analysisOptions.enableAssertMessage); |
| 8573 _unit.accept(errorVerifier); | 8589 _unit.accept(errorVerifier); |
| 8574 _errors = errorListener.getErrorsForSource(source); | 8590 _errors = errorListener.getErrorsForSource(source); |
| 8575 }); | 8591 }); |
| 8576 } | 8592 } |
| 8577 | 8593 |
| 8578 /** | 8594 /** |
| 8579 * Check each directive in the given compilation unit to see if the referenced
source exists and | 8595 * Check each directive in the given compilation unit to see if the referenced
source exists and |
| 8580 * report an error if it does not. | 8596 * report an error if it does not. |
| 8581 * | 8597 * |
| 8582 * @param context the context in which the library exists | 8598 * @param context the context in which the library exists |
| (...skipping 2459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11042 // | 11058 // |
| 11043 // Perform additional error checking. | 11059 // Perform additional error checking. |
| 11044 // | 11060 // |
| 11045 PerformanceStatistics.errors.makeCurrentWhile(() { | 11061 PerformanceStatistics.errors.makeCurrentWhile(() { |
| 11046 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); | 11062 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); |
| 11047 ErrorVerifier errorVerifier = new ErrorVerifier( | 11063 ErrorVerifier errorVerifier = new ErrorVerifier( |
| 11048 errorReporter, | 11064 errorReporter, |
| 11049 _libraryElement, | 11065 _libraryElement, |
| 11050 typeProvider, | 11066 typeProvider, |
| 11051 inheritanceManager, | 11067 inheritanceManager, |
| 11052 context.analysisOptions.enableSuperMixins); | 11068 context.analysisOptions.enableSuperMixins, |
| 11069 context.analysisOptions.enableAssertMessage); |
| 11053 unit.accept(errorVerifier); | 11070 unit.accept(errorVerifier); |
| 11054 // TODO(paulberry): as a temporary workaround for issue 21572, | 11071 // TODO(paulberry): as a temporary workaround for issue 21572, |
| 11055 // ConstantVerifier is being run right after ConstantValueComputer, so we | 11072 // ConstantVerifier is being run right after ConstantValueComputer, so we |
| 11056 // don't need to run it here. Once issue 21572 is fixed, re-enable the | 11073 // don't need to run it here. Once issue 21572 is fixed, re-enable the |
| 11057 // call to ConstantVerifier. | 11074 // call to ConstantVerifier. |
| 11058 // ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter,
_libraryElement, typeProvider); | 11075 // ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter,
_libraryElement, typeProvider); |
| 11059 // unit.accept(constantVerifier); | 11076 // unit.accept(constantVerifier); |
| 11060 }); | 11077 }); |
| 11061 // | 11078 // |
| 11062 // Capture the results. | 11079 // Capture the results. |
| (...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12136 PendingFuture pendingFuture = | 12153 PendingFuture pendingFuture = |
| 12137 new PendingFuture<T>(_context, source, computeValue); | 12154 new PendingFuture<T>(_context, source, computeValue); |
| 12138 if (!pendingFuture.evaluate(sourceEntry)) { | 12155 if (!pendingFuture.evaluate(sourceEntry)) { |
| 12139 _context._pendingFutureSources | 12156 _context._pendingFutureSources |
| 12140 .putIfAbsent(source, () => <PendingFuture>[]) | 12157 .putIfAbsent(source, () => <PendingFuture>[]) |
| 12141 .add(pendingFuture); | 12158 .add(pendingFuture); |
| 12142 } | 12159 } |
| 12143 return pendingFuture.future; | 12160 return pendingFuture.future; |
| 12144 } | 12161 } |
| 12145 } | 12162 } |
| OLD | NEW |