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

Side by Side Diff: pkg/analyzer/lib/src/summary/summary_sdk.dart

Issue 1684773002: Use spec.sum SDK summary and CONSTANT_EXPRESSION_RESOLVED. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « pkg/analyzer/lib/src/generated/sdk_io.dart ('k') | no next file » | 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.summary.summary_sdk; 5 library analyzer.src.summary.summary_sdk;
6 6
7 import 'package:analyzer/dart/element/element.dart'; 7 import 'package:analyzer/dart/element/element.dart';
8 import 'package:analyzer/dart/element/type.dart'; 8 import 'package:analyzer/dart/element/type.dart';
9 import 'package:analyzer/src/context/cache.dart' show CacheEntry; 9 import 'package:analyzer/src/context/cache.dart' show CacheEntry;
10 import 'package:analyzer/src/context/context.dart'; 10 import 'package:analyzer/src/context/context.dart';
11 import 'package:analyzer/src/dart/element/type.dart'; 11 import 'package:analyzer/src/dart/element/type.dart';
12 import 'package:analyzer/src/generated/constant.dart'; 12 import 'package:analyzer/src/generated/constant.dart';
13 import 'package:analyzer/src/generated/engine.dart'; 13 import 'package:analyzer/src/generated/engine.dart';
14 import 'package:analyzer/src/generated/resolver.dart'; 14 import 'package:analyzer/src/generated/resolver.dart';
15 import 'package:analyzer/src/generated/source.dart' 15 import 'package:analyzer/src/generated/source.dart'
16 show DartUriResolver, Source, SourceFactory, SourceKind; 16 show DartUriResolver, Source, SourceFactory, SourceKind;
17 import 'package:analyzer/src/summary/idl.dart'; 17 import 'package:analyzer/src/summary/idl.dart';
18 import 'package:analyzer/src/summary/resynthesize.dart'; 18 import 'package:analyzer/src/summary/resynthesize.dart';
19 import 'package:analyzer/src/task/dart.dart' 19 import 'package:analyzer/src/task/dart.dart';
20 show
21 CONSTANT_VALUE,
22 LIBRARY_ELEMENT1,
23 LIBRARY_ELEMENT2,
24 LIBRARY_ELEMENT3,
25 LIBRARY_ELEMENT4,
26 LIBRARY_ELEMENT5,
27 LIBRARY_ELEMENT6,
28 LIBRARY_ELEMENT7,
29 LIBRARY_ELEMENT8,
30 READY_LIBRARY_ELEMENT2,
31 READY_LIBRARY_ELEMENT5,
32 READY_LIBRARY_ELEMENT6,
33 TYPE_PROVIDER;
34 import 'package:analyzer/task/dart.dart'; 20 import 'package:analyzer/task/dart.dart';
35 import 'package:analyzer/task/model.dart' 21 import 'package:analyzer/task/model.dart'
36 show AnalysisTarget, ResultDescriptor, TargetedResult; 22 show AnalysisTarget, ResultDescriptor, TargetedResult;
37 23
38 class SdkSummaryResultProvider implements SummaryResultProvider { 24 class SdkSummaryResultProvider implements SummaryResultProvider {
39 final InternalAnalysisContext context; 25 final InternalAnalysisContext context;
40 final SdkBundle bundle; 26 final SdkBundle bundle;
41 final SummaryTypeProvider typeProvider = new SummaryTypeProvider(); 27 final SummaryTypeProvider typeProvider = new SummaryTypeProvider();
42 28
43 @override 29 @override
44 SummaryResynthesizer resynthesizer; 30 SummaryResynthesizer resynthesizer;
45 31
46 SdkSummaryResultProvider(this.context, this.bundle) { 32 SdkSummaryResultProvider(this.context, this.bundle) {
47 resynthesizer = new SdkSummaryResynthesizer( 33 resynthesizer = new SdkSummaryResynthesizer(
48 context, typeProvider, context.sourceFactory, bundle); 34 context, typeProvider, context.sourceFactory, bundle);
49 _buildCoreLibrary(); 35 _buildCoreLibrary();
50 _buildAsyncLibrary(); 36 _buildAsyncLibrary();
51 resynthesizer.finalizeCoreAsyncLibraries(); 37 resynthesizer.finalizeCoreAsyncLibraries();
52 context.typeProvider = typeProvider; 38 context.typeProvider = typeProvider;
53 } 39 }
54 40
55 @override 41 @override
56 bool compute(CacheEntry entry, ResultDescriptor result) { 42 bool compute(CacheEntry entry, ResultDescriptor result) {
57 if (result == TYPE_PROVIDER) { 43 if (result == TYPE_PROVIDER) {
58 // print('SummarySdkAnalysisContext: $result');
59 entry.setValue(result, typeProvider, TargetedResult.EMPTY_LIST); 44 entry.setValue(result, typeProvider, TargetedResult.EMPTY_LIST);
60 return true; 45 return true;
61 } 46 }
62 AnalysisTarget target = entry.target; 47 AnalysisTarget target = entry.target;
63 // TODO(scheglov) we don't actually update "evaluationResult" yet 48 // Only SDK sources after this point.
64 if (result == CONSTANT_VALUE) { 49 if (target.source == null || !target.source.isInSystemLibrary) {
65 if (target.source != null && target.source.isInSystemLibrary) { 50 return false;
66 entry.setValue(result, target, TargetedResult.EMPTY_LIST);
67 return true;
68 }
69 } 51 }
70 if (target is Source && target.isInSystemLibrary) { 52 print('SummarySdkAnalysisContext: $result of $target');
Paul Berry 2016/02/09 21:23:19 Debugging code - please delete.
71 // print('SummarySdkAnalysisContext: $result of $target'); 53 // Constant expressions are always resolved in summaries.
54 if (result == CONSTANT_EXPRESSION_RESOLVED &&
55 target is ConstantEvaluationTarget) {
56 entry.setValue(result, true, TargetedResult.EMPTY_LIST);
57 return true;
58 }
59 if (target is Source) {
72 if (result == LIBRARY_ELEMENT1 || 60 if (result == LIBRARY_ELEMENT1 ||
73 result == LIBRARY_ELEMENT2 || 61 result == LIBRARY_ELEMENT2 ||
74 result == LIBRARY_ELEMENT3 || 62 result == LIBRARY_ELEMENT3 ||
75 result == LIBRARY_ELEMENT4 || 63 result == LIBRARY_ELEMENT4 ||
76 result == LIBRARY_ELEMENT5 || 64 result == LIBRARY_ELEMENT5 ||
77 result == LIBRARY_ELEMENT6 || 65 result == LIBRARY_ELEMENT6 ||
78 result == LIBRARY_ELEMENT7 || 66 result == LIBRARY_ELEMENT7 ||
79 result == LIBRARY_ELEMENT8 || 67 result == LIBRARY_ELEMENT8 ||
80 result == LIBRARY_ELEMENT) { 68 result == LIBRARY_ELEMENT) {
81 // TODO(scheglov) try to find a way to avoid listing every result 69 // TODO(scheglov) try to find a way to avoid listing every result
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 * throw a [StateError] if there is no class with the given name. 391 * throw a [StateError] if there is no class with the given name.
404 */ 392 */
405 InterfaceType _getType(LibraryElement library, String name) { 393 InterfaceType _getType(LibraryElement library, String name) {
406 Element element = library.getType(name); 394 Element element = library.getType(name);
407 if (element == null) { 395 if (element == null) {
408 throw new StateError("No definition of type $name"); 396 throw new StateError("No definition of type $name");
409 } 397 }
410 return (element as ClassElement).type; 398 return (element as ClassElement).type;
411 } 399 }
412 } 400 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/sdk_io.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698