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

Side by Side Diff: pkg/compiler/lib/src/elements/common.dart

Issue 1927963002: Support compilation of Hello World (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fixes Created 4 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
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 /// Mixins that implement convenience methods on [Element] subclasses. 5 /// Mixins that implement convenience methods on [Element] subclasses.
6 6
7 library elements.common; 7 library elements.common;
8 8
9 import '../common/names.dart' show Names, Uris; 9 import '../common/names.dart' show Names, Uris;
10 import '../core_types.dart' show CoreClasses; 10 import '../core_types.dart' show CoreClasses;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // TODO(johnniwinther): Clean up this method: This method does not return 144 // TODO(johnniwinther): Clean up this method: This method does not return
145 // the outermost for elements in closure classses, but some call-sites rely 145 // the outermost for elements in closure classses, but some call-sites rely
146 // on that behavior. 146 // on that behavior.
147 for (Element e = this; e != null; e = e.enclosingElement) { 147 for (Element e = this; e != null; e = e.enclosingElement) {
148 if (e.isClassMember || e.isTopLevel) { 148 if (e.isClassMember || e.isTopLevel) {
149 return e; 149 return e;
150 } 150 }
151 } 151 }
152 return null; 152 return null;
153 } 153 }
154
155 Element get enclosingClassOrCompilationUnit {
156 for (Element e = this; e != null; e = e.enclosingElement) {
157 if (e.isClass || e.isCompilationUnit) return e;
158 }
159 return null;
160 }
154 } 161 }
155 162
156 abstract class LibraryElementCommon implements LibraryElement { 163 abstract class LibraryElementCommon implements LibraryElement {
157 @override 164 @override
158 bool get isDartCore => canonicalUri == Uris.dart_core; 165 bool get isDartCore => canonicalUri == Uris.dart_core;
159 166
160 @override 167 @override
161 bool get isPlatformLibrary => canonicalUri.scheme == 'dart'; 168 bool get isPlatformLibrary => canonicalUri.scheme == 'dart';
162 169
163 @override 170 @override
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 465
459 FunctionType get callType { 466 FunctionType get callType {
460 MemberSignature member = lookupInterfaceMember(Names.call); 467 MemberSignature member = lookupInterfaceMember(Names.call);
461 return member != null && member.isMethod ? member.type : null; 468 return member != null && member.isMethod ? member.type : null;
462 } 469 }
463 470
464 @override 471 @override
465 bool get isNamedMixinApplication { 472 bool get isNamedMixinApplication {
466 return isMixinApplication && !isUnnamedMixinApplication; 473 return isMixinApplication && !isUnnamedMixinApplication;
467 } 474 }
475
476 // backendMembers are members that have been added by the backend to simplify
477 // compilation. They don't have any user-side counter-part.
478 Link<Element> backendMembers = const Link<Element>();
479
480 bool get hasBackendMembers => !backendMembers.isEmpty;
481
482 void addBackendMember(Element member) {
483 // TODO(ngeoffray): Deprecate this method.
484 assert(member.isGenerativeConstructorBody);
485 backendMembers = backendMembers.prepend(member);
486 }
487
488 void reverseBackendMembers() {
489 backendMembers = backendMembers.reverse();
490 }
491
492 /// Lookup a synthetic element created by the backend.
493 Element lookupBackendMember(String memberName) {
494 for (Element element in backendMembers) {
495 if (element.name == memberName) {
496 return element;
497 }
498 }
499 return null;
500 }
501
502 void forEachBackendMember(void f(Element member)) {
503 backendMembers.forEach(f);
504 }
468 } 505 }
469 506
470 abstract class FunctionSignatureCommon implements FunctionSignature { 507 abstract class FunctionSignatureCommon implements FunctionSignature {
471 void forEachRequiredParameter(void function(Element parameter)) { 508 void forEachRequiredParameter(void function(Element parameter)) {
472 requiredParameters.forEach(function); 509 requiredParameters.forEach(function);
473 } 510 }
474 511
475 void forEachOptionalParameter(void function(Element parameter)) { 512 void forEachOptionalParameter(void function(Element parameter)) {
476 optionalParameters.forEach(function); 513 optionalParameters.forEach(function);
477 } 514 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 587
551 @override 588 @override
552 void forEachLocalMember(void f(Element member)) { 589 void forEachLocalMember(void f(Element member)) {
553 constructors.forEach(f); 590 constructors.forEach(f);
554 if (mixin != null) 591 if (mixin != null)
555 mixin.forEachLocalMember((Element mixedInElement) { 592 mixin.forEachLocalMember((Element mixedInElement) {
556 if (mixedInElement.isInstanceMember) f(mixedInElement); 593 if (mixedInElement.isInstanceMember) f(mixedInElement);
557 }); 594 });
558 } 595 }
559 } 596 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/diagnostics/messages.dart ('k') | pkg/compiler/lib/src/elements/elements.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698