Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(911)

Side by Side Diff: pkg/analyzer/lib/src/context/cache.dart

Issue 1132103002: Remove memento. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/context/context.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 analyzer.src.context.cache; 5 library analyzer.src.context.cache;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/src/generated/engine.dart' 9 import 'package:analyzer/src/generated/engine.dart'
10 show AnalysisEngine, CacheState, InternalAnalysisContext, RetentionPriority; 10 show AnalysisEngine, CacheState, InternalAnalysisContext, RetentionPriority;
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 /** 252 /**
253 * Fix the state of the [exception] to match the current state of the entry. 253 * Fix the state of the [exception] to match the current state of the entry.
254 */ 254 */
255 void fixExceptionState() { 255 void fixExceptionState() {
256 if (!hasErrorState()) { 256 if (!hasErrorState()) {
257 _exception = null; 257 _exception = null;
258 } 258 }
259 } 259 }
260 260
261 /** 261 /**
262 * Return the memento of the result represented by the given [descriptor].
263 */
264 Object getMemento(ResultDescriptor descriptor) {
265 ResultData data = _resultMap[descriptor];
266 if (data == null) {
267 return null;
268 }
269 return data.memento;
270 }
271
272 /**
273 * Return the state of the result represented by the given [descriptor]. 262 * Return the state of the result represented by the given [descriptor].
274 */ 263 */
275 CacheState getState(ResultDescriptor descriptor) { 264 CacheState getState(ResultDescriptor descriptor) {
276 ResultData data = _resultMap[descriptor]; 265 ResultData data = _resultMap[descriptor];
277 if (data == null) { 266 if (data == null) {
278 return CacheState.INVALID; 267 return CacheState.INVALID;
279 } 268 }
280 return data.state; 269 return data.state;
281 } 270 }
282 271
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 // If the state is in-process, we can leave the current value in the 362 // If the state is in-process, we can leave the current value in the
374 // cache for any 'get' methods to access. 363 // cache for any 'get' methods to access.
375 // 364 //
376 data.value = descriptor.defaultValue; 365 data.value = descriptor.defaultValue;
377 } 366 }
378 } 367 }
379 } 368 }
380 369
381 /** 370 /**
382 * Set the value of the result represented by the given [descriptor] to the 371 * Set the value of the result represented by the given [descriptor] to the
383 * given [value]. The optional [memento] may help to recompute [value] more 372 * given [value].
384 * efficiently after invalidation.
385 */ 373 */
386 /*<V>*/ void setValue(ResultDescriptor /*<V>*/ descriptor, dynamic /*V*/ 374 /*<V>*/ void setValue(ResultDescriptor /*<V>*/ descriptor, dynamic /*V*/
387 value, List<TargetedResult> dependedOn, Object memento) { 375 value, List<TargetedResult> dependedOn) {
388 _validateStateChange(descriptor, CacheState.VALID); 376 _validateStateChange(descriptor, CacheState.VALID);
389 TargetedResult thisResult = new TargetedResult(target, descriptor); 377 TargetedResult thisResult = new TargetedResult(target, descriptor);
390 if (_partition != null) { 378 if (_partition != null) {
391 _partition.resultStored(thisResult, value); 379 _partition.resultStored(thisResult, value);
392 } 380 }
393 _invalidate(descriptor, null); 381 _invalidate(descriptor, null);
394 ResultData data = _getResultData(descriptor); 382 ResultData data = _getResultData(descriptor);
395 _setDependedOnResults(data, thisResult, dependedOn); 383 _setDependedOnResults(data, thisResult, dependedOn);
396 data.state = CacheState.VALID; 384 data.state = CacheState.VALID;
397 data.value = value == null ? descriptor.defaultValue : value; 385 data.value = value == null ? descriptor.defaultValue : value;
398 data.memento = memento;
399 } 386 }
400 387
401 @override 388 @override
402 String toString() { 389 String toString() {
403 StringBuffer buffer = new StringBuffer(); 390 StringBuffer buffer = new StringBuffer();
404 _writeOn(buffer); 391 _writeOn(buffer);
405 return buffer.toString(); 392 return buffer.toString();
406 } 393 }
407 394
408 /** 395 /**
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 */ 768 */
782 CacheState state; 769 CacheState state;
783 770
784 /** 771 /**
785 * The value being cached, or the default value for the result if there is no 772 * The value being cached, or the default value for the result if there is no
786 * value (for example, when the [state] is [CacheState.INVALID]). 773 * value (for example, when the [state] is [CacheState.INVALID]).
787 */ 774 */
788 Object value; 775 Object value;
789 776
790 /** 777 /**
791 * The optional data that is remembered with [value] and, when [value] is
792 * invalidated, may help to recompute it more efficiently.
793 */
794 Object memento;
795
796 /**
797 * A list of the results on which this result depends. 778 * A list of the results on which this result depends.
798 */ 779 */
799 List<TargetedResult> dependedOnResults = <TargetedResult>[]; 780 List<TargetedResult> dependedOnResults = <TargetedResult>[];
800 781
801 /** 782 /**
802 * A list of the results that depend on this result. 783 * A list of the results that depend on this result.
803 */ 784 */
804 List<TargetedResult> dependentResults = <TargetedResult>[]; 785 List<TargetedResult> dependentResults = <TargetedResult>[];
805 786
806 /** 787 /**
807 * Initialize a newly created result holder to represent the value of data 788 * Initialize a newly created result holder to represent the value of data
808 * described by the given [descriptor]. 789 * described by the given [descriptor].
809 */ 790 */
810 ResultData(this.descriptor) { 791 ResultData(this.descriptor) {
811 state = CacheState.INVALID; 792 state = CacheState.INVALID;
812 value = descriptor.defaultValue; 793 value = descriptor.defaultValue;
813 } 794 }
814 795
815 /** 796 /**
816 * Flush this value. 797 * Flush this value.
817 */ 798 */
818 void flush() { 799 void flush() {
819 state = CacheState.FLUSHED; 800 state = CacheState.FLUSHED;
820 value = descriptor.defaultValue; 801 value = descriptor.defaultValue;
821 memento = null;
822 } 802 }
823 } 803 }
824 804
825 /** 805 /**
826 * A cache partition that contains all of the targets in the SDK. 806 * A cache partition that contains all of the targets in the SDK.
827 */ 807 */
828 class SdkCachePartition extends CachePartition { 808 class SdkCachePartition extends CachePartition {
829 /** 809 /**
830 * Initialize a newly created cache partition, belonging to the given 810 * Initialize a newly created cache partition, belonging to the given
831 * [context]. 811 * [context].
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 class UniversalCachePartition extends CachePartition { 868 class UniversalCachePartition extends CachePartition {
889 /** 869 /**
890 * Initialize a newly created cache partition, belonging to the given 870 * Initialize a newly created cache partition, belonging to the given
891 * [context]. 871 * [context].
892 */ 872 */
893 UniversalCachePartition(InternalAnalysisContext context) : super(context); 873 UniversalCachePartition(InternalAnalysisContext context) : super(context);
894 874
895 @override 875 @override
896 bool isResponsibleFor(AnalysisTarget target) => true; 876 bool isResponsibleFor(AnalysisTarget target) => true;
897 } 877 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/context/context.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698