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

Side by Side Diff: pkg/compiler/lib/src/resolution/resolution.dart

Issue 2595493002: Merge CoreTypes and CoreClasses into CommonElements. (Closed)
Patch Set: Updated cf. comment Created 4 years 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) 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 library dart2js.resolution; 5 library dart2js.resolution;
6 6
7 import 'dart:collection' show Queue; 7 import 'dart:collection' show Queue;
8 8
9 import '../common.dart'; 9 import '../common.dart';
10 import '../common/names.dart' show Identifiers; 10 import '../common/names.dart' show Identifiers;
11 import '../common/resolution.dart' 11 import '../common/resolution.dart'
12 show ParsingContext, Resolution, ResolutionImpact, Target; 12 show ParsingContext, Resolution, ResolutionImpact, Target;
13 import '../common/tasks.dart' show CompilerTask, Measurer; 13 import '../common/tasks.dart' show CompilerTask, Measurer;
14 import '../compile_time_constants.dart' show ConstantCompiler; 14 import '../compile_time_constants.dart' show ConstantCompiler;
15 import '../constants/expressions.dart' 15 import '../constants/expressions.dart'
16 show 16 show
17 ConstantExpression, 17 ConstantExpression,
18 ConstantExpressionKind, 18 ConstantExpressionKind,
19 ConstructedConstantExpression, 19 ConstructedConstantExpression,
20 ErroneousConstantExpression; 20 ErroneousConstantExpression;
21 import '../constants/values.dart' show ConstantValue; 21 import '../constants/values.dart' show ConstantValue;
22 import '../core_types.dart' show CoreClasses, CoreTypes, CommonElements; 22 import '../core_types.dart' show CommonElements;
23 import '../dart_types.dart'; 23 import '../dart_types.dart';
24 import '../elements/elements.dart'; 24 import '../elements/elements.dart';
25 import '../elements/modelx.dart' 25 import '../elements/modelx.dart'
26 show 26 show
27 BaseClassElementX, 27 BaseClassElementX,
28 BaseFunctionElementX, 28 BaseFunctionElementX,
29 ConstructorElementX, 29 ConstructorElementX,
30 FieldElementX, 30 FieldElementX,
31 FunctionElementX, 31 FunctionElementX,
32 GetterElementX, 32 GetterElementX,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 final ConstantCompiler constantCompiler; 65 final ConstantCompiler constantCompiler;
66 final Resolution resolution; 66 final Resolution resolution;
67 67
68 ResolverTask(this.resolution, this.constantCompiler, Measurer measurer) 68 ResolverTask(this.resolution, this.constantCompiler, Measurer measurer)
69 : super(measurer); 69 : super(measurer);
70 70
71 String get name => 'Resolver'; 71 String get name => 'Resolver';
72 72
73 DiagnosticReporter get reporter => resolution.reporter; 73 DiagnosticReporter get reporter => resolution.reporter;
74 Target get target => resolution.target; 74 Target get target => resolution.target;
75 CoreTypes get coreTypes => resolution.coreTypes;
76 CoreClasses get coreClasses => resolution.coreClasses;
77 CommonElements get commonElements => resolution.commonElements; 75 CommonElements get commonElements => resolution.commonElements;
78 ParsingContext get parsingContext => resolution.parsingContext; 76 ParsingContext get parsingContext => resolution.parsingContext;
79 CompilerOptions get options => resolution.options; 77 CompilerOptions get options => resolution.options;
80 ResolutionEnqueuer get enqueuer => resolution.enqueuer; 78 ResolutionEnqueuer get enqueuer => resolution.enqueuer;
81 OpenWorld get world => enqueuer.universe; 79 OpenWorld get world => enqueuer.universe;
82 80
83 ResolutionImpact resolve(Element element) { 81 ResolutionImpact resolve(Element element) {
84 return measure(() { 82 return measure(() {
85 if (Elements.isMalformed(element)) { 83 if (Elements.isMalformed(element)) {
86 // TODO(johnniwinther): Add a predicate for this. 84 // TODO(johnniwinther): Add a predicate for this.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 return; 137 return;
140 } 138 }
141 seen.add(redirection); 139 seen.add(redirection);
142 redirection = resolver.visitor.resolveConstructorRedirection(redirection); 140 redirection = resolver.visitor.resolveConstructorRedirection(redirection);
143 } 141 }
144 } 142 }
145 143
146 static void processAsyncMarker(Resolution resolution, 144 static void processAsyncMarker(Resolution resolution,
147 BaseFunctionElementX element, ResolutionRegistry registry) { 145 BaseFunctionElementX element, ResolutionRegistry registry) {
148 DiagnosticReporter reporter = resolution.reporter; 146 DiagnosticReporter reporter = resolution.reporter;
149 CoreClasses coreClasses = resolution.coreClasses; 147 CommonElements commonElements = resolution.commonElements;
150 FunctionExpression functionExpression = element.node; 148 FunctionExpression functionExpression = element.node;
151 AsyncModifier asyncModifier = functionExpression.asyncModifier; 149 AsyncModifier asyncModifier = functionExpression.asyncModifier;
152 if (asyncModifier != null) { 150 if (asyncModifier != null) {
153 if (!resolution.target.supportsAsyncAwait) { 151 if (!resolution.target.supportsAsyncAwait) {
154 reporter.reportErrorMessage(functionExpression.asyncModifier, 152 reporter.reportErrorMessage(functionExpression.asyncModifier,
155 MessageKind.ASYNC_AWAIT_NOT_SUPPORTED); 153 MessageKind.ASYNC_AWAIT_NOT_SUPPORTED);
156 } else { 154 } else {
157 if (asyncModifier.isAsynchronous) { 155 if (asyncModifier.isAsynchronous) {
158 element.asyncMarker = asyncModifier.isYielding 156 element.asyncMarker = asyncModifier.isYielding
159 ? AsyncMarker.ASYNC_STAR 157 ? AsyncMarker.ASYNC_STAR
(...skipping 22 matching lines...) Expand all
182 element.asyncMarker.isYielding) { 180 element.asyncMarker.isYielding) {
183 reporter.reportErrorMessage( 181 reporter.reportErrorMessage(
184 asyncModifier, 182 asyncModifier,
185 MessageKind.YIELDING_MODIFIER_ON_ARROW_BODY, 183 MessageKind.YIELDING_MODIFIER_ON_ARROW_BODY,
186 {'modifier': element.asyncMarker}); 184 {'modifier': element.asyncMarker});
187 } 185 }
188 } 186 }
189 switch (element.asyncMarker) { 187 switch (element.asyncMarker) {
190 case AsyncMarker.ASYNC: 188 case AsyncMarker.ASYNC:
191 registry.registerFeature(Feature.ASYNC); 189 registry.registerFeature(Feature.ASYNC);
192 coreClasses.futureClass.ensureResolved(resolution); 190 commonElements.futureClass.ensureResolved(resolution);
193 break; 191 break;
194 case AsyncMarker.ASYNC_STAR: 192 case AsyncMarker.ASYNC_STAR:
195 registry.registerFeature(Feature.ASYNC_STAR); 193 registry.registerFeature(Feature.ASYNC_STAR);
196 coreClasses.streamClass.ensureResolved(resolution); 194 commonElements.streamClass.ensureResolved(resolution);
197 break; 195 break;
198 case AsyncMarker.SYNC_STAR: 196 case AsyncMarker.SYNC_STAR:
199 registry.registerFeature(Feature.SYNC_STAR); 197 registry.registerFeature(Feature.SYNC_STAR);
200 coreClasses.iterableClass.ensureResolved(resolution); 198 commonElements.iterableClass.ensureResolved(resolution);
201 break; 199 break;
202 } 200 }
203 } 201 }
204 } 202 }
205 } 203 }
206 204
207 bool _isNativeClassOrExtendsNativeClass(ClassElement classElement) { 205 bool _isNativeClassOrExtendsNativeClass(ClassElement classElement) {
208 assert(classElement != null); 206 assert(classElement != null);
209 while (classElement != null) { 207 while (classElement != null) {
210 if (target.isNative(classElement)) return true; 208 if (target.isNative(classElement)) return true;
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 * called by [resolveClass] and [ClassSupertypeResolver]. 530 * called by [resolveClass] and [ClassSupertypeResolver].
533 */ 531 */
534 void loadSupertypes(BaseClassElementX cls, Spannable from) { 532 void loadSupertypes(BaseClassElementX cls, Spannable from) {
535 measure(() { 533 measure(() {
536 if (cls.supertypeLoadState == STATE_DONE) return; 534 if (cls.supertypeLoadState == STATE_DONE) return;
537 if (cls.supertypeLoadState == STATE_STARTED) { 535 if (cls.supertypeLoadState == STATE_STARTED) {
538 reporter.reportErrorMessage( 536 reporter.reportErrorMessage(
539 from, MessageKind.CYCLIC_CLASS_HIERARCHY, {'className': cls.name}); 537 from, MessageKind.CYCLIC_CLASS_HIERARCHY, {'className': cls.name});
540 cls.supertypeLoadState = STATE_DONE; 538 cls.supertypeLoadState = STATE_DONE;
541 cls.hasIncompleteHierarchy = true; 539 cls.hasIncompleteHierarchy = true;
542 cls.allSupertypesAndSelf = coreClasses.objectClass.allSupertypesAndSelf 540 cls.allSupertypesAndSelf = commonElements
541 .objectClass.allSupertypesAndSelf
543 .extendClass(cls.computeType(resolution)); 542 .extendClass(cls.computeType(resolution));
544 cls.supertype = cls.allSupertypes.head; 543 cls.supertype = cls.allSupertypes.head;
545 assert(invariant(from, cls.supertype != null, 544 assert(invariant(from, cls.supertype != null,
546 message: 'Missing supertype on cyclic class $cls.')); 545 message: 'Missing supertype on cyclic class $cls.'));
547 cls.interfaces = const Link<DartType>(); 546 cls.interfaces = const Link<DartType>();
548 return; 547 return;
549 } 548 }
550 cls.supertypeLoadState = STATE_STARTED; 549 cls.supertypeLoadState = STATE_STARTED;
551 reporter.withCurrentElement(cls, () { 550 reporter.withCurrentElement(cls, () {
552 // TODO(ahe): Cache the node in cls. 551 // TODO(ahe): Cache the node in cls.
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 TreeElements get treeElements { 1134 TreeElements get treeElements {
1136 assert(invariant(this, _treeElements != null, 1135 assert(invariant(this, _treeElements != null,
1137 message: "TreeElements have not been computed for $this.")); 1136 message: "TreeElements have not been computed for $this."));
1138 return _treeElements; 1137 return _treeElements;
1139 } 1138 }
1140 1139
1141 void reuseElement() { 1140 void reuseElement() {
1142 _treeElements = null; 1141 _treeElements = null;
1143 } 1142 }
1144 } 1143 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/members.dart ('k') | pkg/compiler/lib/src/resolution/signatures.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698