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

Side by Side Diff: pkg/compiler/lib/src/js_backend/lookup_map_analysis.dart

Issue 2751983002: Pending renames and cleanups after commits (Closed)
Patch Set: Created 3 years, 9 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
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 /// Analysis to determine how to generate code for `LookupMap`s. 5 /// Analysis to determine how to generate code for `LookupMap`s.
6 library compiler.src.js_backend.lookup_map_analysis; 6 library compiler.src.js_backend.lookup_map_analysis;
7 7
8 import 'package:pub_semver/pub_semver.dart'; 8 import 'package:pub_semver/pub_semver.dart';
9 9
10 import '../common.dart'; 10 import '../common.dart';
(...skipping 19 matching lines...) Expand all
30 import 'backend_helpers.dart'; 30 import 'backend_helpers.dart';
31 31
32 /// Lookup map handling for resolution. 32 /// Lookup map handling for resolution.
33 /// 33 ///
34 /// This analysis checks for the import of `package:lookup_map/lookup_map.dart`, 34 /// This analysis checks for the import of `package:lookup_map/lookup_map.dart`,
35 /// and if found, read the `_version` variable from it. 35 /// and if found, read the `_version` variable from it.
36 /// 36 ///
37 /// In [LookupMapAnalysis] the value of `_version` is checked to ensure that it 37 /// In [LookupMapAnalysis] the value of `_version` is checked to ensure that it
38 /// is valid to perform the optimization of `LookupMap`. The actual optimization 38 /// is valid to perform the optimization of `LookupMap`. The actual optimization
39 /// is performed by [LookupMapAnalysis]. 39 /// is performed by [LookupMapAnalysis].
40 class LookupMapLibraryAccess { 40 class LookupMapResolutionAnalysis {
41 static final Uri PACKAGE_LOOKUP_MAP = 41 static final Uri PACKAGE_LOOKUP_MAP =
42 new Uri(scheme: 'package', path: 'lookup_map/lookup_map.dart'); 42 new Uri(scheme: 'package', path: 'lookup_map/lookup_map.dart');
43 43
44 /// Reference the diagnostic reporting system for logging and reporting issues 44 /// Reference the diagnostic reporting system for logging and reporting issues
45 /// to the end-user. 45 /// to the end-user.
46 final DiagnosticReporter _reporter; 46 final DiagnosticReporter _reporter;
47 47
48 final ElementEnvironment _elementEnvironment; 48 final ElementEnvironment _elementEnvironment;
49 49
50 /// The resolved [FieldEntity] associated with the top-level `_version`. 50 /// The resolved [FieldEntity] associated with the top-level `_version`.
51 FieldEntity lookupMapVersionVariable; 51 FieldEntity lookupMapVersionVariable;
52 52
53 /// The resolved [LibraryEntity] associated with 53 /// The resolved [LibraryEntity] associated with
54 /// `package:lookup_map/lookup_map.dart`. 54 /// `package:lookup_map/lookup_map.dart`.
55 LibraryEntity lookupMapLibrary; 55 LibraryEntity lookupMapLibrary;
56 56
57 final StagedWorldImpactBuilder _impactBuilder = 57 final StagedWorldImpactBuilder _impactBuilder =
58 new StagedWorldImpactBuilder(); 58 new StagedWorldImpactBuilder();
59 59
60 LookupMapLibraryAccess(this._reporter, this._elementEnvironment); 60 LookupMapResolutionAnalysis(this._reporter, this._elementEnvironment);
61 61
62 /// Compute the [WorldImpact] for the constants registered since last flush. 62 /// Compute the [WorldImpact] for the constants registered since last flush.
63 WorldImpact flush() { 63 WorldImpact flush() {
64 return _impactBuilder.flush(); 64 return _impactBuilder.flush();
65 } 65 }
66 66
67 /// Initializes this analysis by providing the resolved library. This is 67 /// Initializes this analysis by providing the resolved library. This is
68 /// invoked during resolution when the `lookup_map` library is discovered. 68 /// invoked during resolution when the `lookup_map` library is discovered.
69 void init(LibraryEntity library) { 69 void init(LibraryEntity library) {
70 lookupMapLibrary = library; 70 lookupMapLibrary = library;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 const LookupMapAnalysis._(); 124 const LookupMapAnalysis._();
125 125
126 factory LookupMapAnalysis( 126 factory LookupMapAnalysis(
127 DiagnosticReporter reporter, 127 DiagnosticReporter reporter,
128 ConstantSystem constantSystem, 128 ConstantSystem constantSystem,
129 ConstantEnvironment constants, 129 ConstantEnvironment constants,
130 ElementEnvironment elementEnvironment, 130 ElementEnvironment elementEnvironment,
131 CommonElements commonElements, 131 CommonElements commonElements,
132 BackendHelpers helpers, 132 BackendHelpers helpers,
133 BackendClasses backendClasses, 133 BackendClasses backendClasses,
134 LookupMapLibraryAccess analysis) { 134 LookupMapResolutionAnalysis analysis) {
135 /// Checks if the version of lookup_map is valid, and if so, enable this 135 /// Checks if the version of lookup_map is valid, and if so, enable this
136 /// analysis during codegen. 136 /// analysis during codegen.
137 FieldElement lookupMapVersionVariable = analysis.lookupMapVersionVariable; 137 FieldElement lookupMapVersionVariable = analysis.lookupMapVersionVariable;
138 if (lookupMapVersionVariable == null) return const LookupMapAnalysis._(); 138 if (lookupMapVersionVariable == null) return const LookupMapAnalysis._();
139 139
140 // At this point, the lookupMapVersionVariable should be resolved and it's 140 // At this point, the lookupMapVersionVariable should be resolved and it's
141 // constant value should be available. 141 // constant value should be available.
142 StringConstantValue value = 142 StringConstantValue value =
143 constants.getConstantValue(lookupMapVersionVariable.constant); 143 constants.getConstantValue(lookupMapVersionVariable.constant);
144 if (value == null) { 144 if (value == null) {
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 original.fields[analysis._valueField] = keyValuePairs[1]; 510 original.fields[analysis._valueField] = keyValuePairs[1];
511 } 511 }
512 } else { 512 } else {
513 original.fields[analysis._entriesField] = 513 original.fields[analysis._entriesField] =
514 new ListConstantValue(listType, keyValuePairs); 514 new ListConstantValue(listType, keyValuePairs);
515 } 515 }
516 } 516 }
517 } 517 }
518 518
519 final _validLookupMapVersionConstraint = new VersionConstraint.parse('^0.0.1'); 519 final _validLookupMapVersionConstraint = new VersionConstraint.parse('^0.0.1');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698