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

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

Issue 1421003004: Add CoreClasses (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comment. Created 5 years, 1 month 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/compiler/lib/src/resolution/members.dart ('k') | pkg/compiler/lib/src/ssa/builder.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) 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 10 import '../common/names.dart' show
11 Identifiers; 11 Identifiers;
12 import '../common/resolution.dart' show 12 import '../common/resolution.dart' show
13 Parsing, 13 Parsing,
14 Resolution, 14 Resolution,
15 ResolutionImpact; 15 ResolutionImpact;
16 import '../common/tasks.dart' show 16 import '../common/tasks.dart' show
17 CompilerTask, 17 CompilerTask,
18 DeferredAction; 18 DeferredAction;
19 import '../compiler.dart' show 19 import '../compiler.dart' show
20 Compiler; 20 Compiler;
21 import '../compile_time_constants.dart' show 21 import '../compile_time_constants.dart' show
22 ConstantCompiler; 22 ConstantCompiler;
23 import '../constants/values.dart' show 23 import '../constants/values.dart' show
24 ConstantValue; 24 ConstantValue;
25 import '../core_types.dart' show 25 import '../core_types.dart' show
26 CoreClasses,
26 CoreTypes; 27 CoreTypes;
27 import '../dart_types.dart'; 28 import '../dart_types.dart';
28 import '../elements/elements.dart'; 29 import '../elements/elements.dart';
29 import '../elements/modelx.dart' show 30 import '../elements/modelx.dart' show
30 BaseClassElementX, 31 BaseClassElementX,
31 BaseFunctionElementX, 32 BaseFunctionElementX,
32 ConstructorElementX, 33 ConstructorElementX,
33 FieldElementX, 34 FieldElementX,
34 FunctionElementX, 35 FunctionElementX,
35 GetterElementX, 36 GetterElementX,
(...skipping 29 matching lines...) Expand all
65 final ConstantCompiler constantCompiler; 66 final ConstantCompiler constantCompiler;
66 67
67 ResolverTask(Compiler compiler, this.constantCompiler) : super(compiler); 68 ResolverTask(Compiler compiler, this.constantCompiler) : super(compiler);
68 69
69 String get name => 'Resolver'; 70 String get name => 'Resolver';
70 71
71 Resolution get resolution => compiler.resolution; 72 Resolution get resolution => compiler.resolution;
72 73
73 Parsing get parsing => compiler.parsing; 74 Parsing get parsing => compiler.parsing;
74 75
76 CoreClasses get coreClasses => compiler.coreClasses;
77
75 CoreTypes get coreTypes => compiler.coreTypes; 78 CoreTypes get coreTypes => compiler.coreTypes;
76 79
77 ResolutionImpact resolve(Element element) { 80 ResolutionImpact resolve(Element element) {
78 return measure(() { 81 return measure(() {
79 if (Elements.isMalformed(element)) { 82 if (Elements.isMalformed(element)) {
80 // TODO(johnniwinther): Add a predicate for this. 83 // TODO(johnniwinther): Add a predicate for this.
81 assert(invariant(element, element is! ErroneousElement, 84 assert(invariant(element, element is! ErroneousElement,
82 message: "Element $element expected to have parse errors.")); 85 message: "Element $element expected to have parse errors."));
83 _ensureTreeElements(element); 86 _ensureTreeElements(element);
84 return const ResolutionImpact(); 87 return const ResolutionImpact();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 seen.add(redirection); 137 seen.add(redirection);
135 redirection = resolver.visitor.resolveConstructorRedirection(redirection); 138 redirection = resolver.visitor.resolveConstructorRedirection(redirection);
136 } 139 }
137 } 140 }
138 141
139 static void processAsyncMarker(Compiler compiler, 142 static void processAsyncMarker(Compiler compiler,
140 BaseFunctionElementX element, 143 BaseFunctionElementX element,
141 ResolutionRegistry registry) { 144 ResolutionRegistry registry) {
142 DiagnosticReporter reporter = compiler.reporter; 145 DiagnosticReporter reporter = compiler.reporter;
143 Resolution resolution = compiler.resolution; 146 Resolution resolution = compiler.resolution;
147 CoreClasses coreClasses = compiler.coreClasses;
144 FunctionExpression functionExpression = element.node; 148 FunctionExpression functionExpression = element.node;
145 AsyncModifier asyncModifier = functionExpression.asyncModifier; 149 AsyncModifier asyncModifier = functionExpression.asyncModifier;
146 if (asyncModifier != null) { 150 if (asyncModifier != null) {
147 151
148 if (asyncModifier.isAsynchronous) { 152 if (asyncModifier.isAsynchronous) {
149 element.asyncMarker = asyncModifier.isYielding 153 element.asyncMarker = asyncModifier.isYielding
150 ? AsyncMarker.ASYNC_STAR : AsyncMarker.ASYNC; 154 ? AsyncMarker.ASYNC_STAR : AsyncMarker.ASYNC;
151 } else { 155 } else {
152 element.asyncMarker = AsyncMarker.SYNC_STAR; 156 element.asyncMarker = AsyncMarker.SYNC_STAR;
153 } 157 }
(...skipping 19 matching lines...) Expand all
173 element.asyncMarker.isYielding) { 177 element.asyncMarker.isYielding) {
174 reporter.reportErrorMessage( 178 reporter.reportErrorMessage(
175 asyncModifier, 179 asyncModifier,
176 MessageKind.YIELDING_MODIFIER_ON_ARROW_BODY, 180 MessageKind.YIELDING_MODIFIER_ON_ARROW_BODY,
177 {'modifier': element.asyncMarker}); 181 {'modifier': element.asyncMarker});
178 } 182 }
179 } 183 }
180 registry.registerAsyncMarker(element); 184 registry.registerAsyncMarker(element);
181 switch (element.asyncMarker) { 185 switch (element.asyncMarker) {
182 case AsyncMarker.ASYNC: 186 case AsyncMarker.ASYNC:
183 compiler.futureClass.ensureResolved(resolution); 187 coreClasses.futureClass.ensureResolved(resolution);
184 break; 188 break;
185 case AsyncMarker.ASYNC_STAR: 189 case AsyncMarker.ASYNC_STAR:
186 compiler.streamClass.ensureResolved(resolution); 190 coreClasses.streamClass.ensureResolved(resolution);
187 break; 191 break;
188 case AsyncMarker.SYNC_STAR: 192 case AsyncMarker.SYNC_STAR:
189 compiler.iterableClass.ensureResolved(resolution); 193 coreClasses.iterableClass.ensureResolved(resolution);
190 break; 194 break;
191 } 195 }
192 } 196 }
193 } 197 }
194 198
195 bool _isNativeClassOrExtendsNativeClass(ClassElement classElement) { 199 bool _isNativeClassOrExtendsNativeClass(ClassElement classElement) {
196 assert(classElement != null); 200 assert(classElement != null);
197 while (classElement != null) { 201 while (classElement != null) {
198 if (compiler.backend.isNative(classElement)) return true; 202 if (compiler.backend.isNative(classElement)) return true;
199 classElement = classElement.superclass; 203 classElement = classElement.superclass;
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 reporter.withCurrentElement(cls, () => measure(() { 493 reporter.withCurrentElement(cls, () => measure(() {
490 if (cls.supertypeLoadState == STATE_DONE) return; 494 if (cls.supertypeLoadState == STATE_DONE) return;
491 if (cls.supertypeLoadState == STATE_STARTED) { 495 if (cls.supertypeLoadState == STATE_STARTED) {
492 reporter.reportErrorMessage( 496 reporter.reportErrorMessage(
493 from, 497 from,
494 MessageKind.CYCLIC_CLASS_HIERARCHY, 498 MessageKind.CYCLIC_CLASS_HIERARCHY,
495 {'className': cls.name}); 499 {'className': cls.name});
496 cls.supertypeLoadState = STATE_DONE; 500 cls.supertypeLoadState = STATE_DONE;
497 cls.hasIncompleteHierarchy = true; 501 cls.hasIncompleteHierarchy = true;
498 cls.allSupertypesAndSelf = 502 cls.allSupertypesAndSelf =
499 compiler.objectClass.allSupertypesAndSelf.extendClass( 503 coreClasses.objectClass.allSupertypesAndSelf.extendClass(
500 cls.computeType(resolution)); 504 cls.computeType(resolution));
501 cls.supertype = cls.allSupertypes.head; 505 cls.supertype = cls.allSupertypes.head;
502 assert(invariant(from, cls.supertype != null, 506 assert(invariant(from, cls.supertype != null,
503 message: 'Missing supertype on cyclic class $cls.')); 507 message: 'Missing supertype on cyclic class $cls.'));
504 cls.interfaces = const Link<DartType>(); 508 cls.interfaces = const Link<DartType>();
505 return; 509 return;
506 } 510 }
507 cls.supertypeLoadState = STATE_STARTED; 511 cls.supertypeLoadState = STATE_STARTED;
508 reporter.withCurrentElement(cls, () { 512 reporter.withCurrentElement(cls, () {
509 // TODO(ahe): Cache the node in cls. 513 // TODO(ahe): Cache the node in cls.
(...skipping 24 matching lines...) Expand all
534 resolveTypeDeclaration()) { 538 resolveTypeDeclaration()) {
535 return reporter.withCurrentElement(element, () { 539 return reporter.withCurrentElement(element, () {
536 return measure(() { 540 return measure(() {
537 TypeDeclarationElement previousResolvedTypeDeclaration = 541 TypeDeclarationElement previousResolvedTypeDeclaration =
538 currentlyResolvedTypeDeclaration; 542 currentlyResolvedTypeDeclaration;
539 currentlyResolvedTypeDeclaration = element; 543 currentlyResolvedTypeDeclaration = element;
540 var result = resolveTypeDeclaration(); 544 var result = resolveTypeDeclaration();
541 if (previousResolvedTypeDeclaration == null) { 545 if (previousResolvedTypeDeclaration == null) {
542 do { 546 do {
543 while (!pendingClassesToBeResolved.isEmpty) { 547 while (!pendingClassesToBeResolved.isEmpty) {
544 pendingClassesToBeResolved.removeFirst().ensureResolved(resolution ); 548 pendingClassesToBeResolved.removeFirst()
549 .ensureResolved(resolution);
545 } 550 }
546 while (!pendingClassesToBePostProcessed.isEmpty) { 551 while (!pendingClassesToBePostProcessed.isEmpty) {
547 _postProcessClassElement( 552 _postProcessClassElement(
548 pendingClassesToBePostProcessed.removeFirst()); 553 pendingClassesToBePostProcessed.removeFirst());
549 } 554 }
550 } while (!pendingClassesToBeResolved.isEmpty); 555 } while (!pendingClassesToBeResolved.isEmpty);
551 assert(pendingClassesToBeResolved.isEmpty); 556 assert(pendingClassesToBeResolved.isEmpty);
552 assert(pendingClassesToBePostProcessed.isEmpty); 557 assert(pendingClassesToBePostProcessed.isEmpty);
553 } 558 }
554 currentlyResolvedTypeDeclaration = previousResolvedTypeDeclaration; 559 currentlyResolvedTypeDeclaration = previousResolvedTypeDeclaration;
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 TreeElements get treeElements { 1083 TreeElements get treeElements {
1079 assert(invariant(this, _treeElements !=null, 1084 assert(invariant(this, _treeElements !=null,
1080 message: "TreeElements have not been computed for $this.")); 1085 message: "TreeElements have not been computed for $this."));
1081 return _treeElements; 1086 return _treeElements;
1082 } 1087 }
1083 1088
1084 void reuseElement() { 1089 void reuseElement() {
1085 _treeElements = null; 1090 _treeElements = null;
1086 } 1091 }
1087 } 1092 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/members.dart ('k') | pkg/compiler/lib/src/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698