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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/elements/modelx.dart

Issue 90713003: Dart2js option to dump info about compilation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 elements.modelx; 5 library elements.modelx;
6 6
7 import 'elements.dart'; 7 import 'elements.dart';
8 import '../../compiler.dart' as api; 8 import '../../compiler.dart' as api;
9 import '../tree/tree.dart'; 9 import '../tree/tree.dart';
10 import '../util/util.dart'; 10 import '../util/util.dart';
(...skipping 13 matching lines...) Expand all
24 Constant, 24 Constant,
25 Compiler, 25 Compiler,
26 isPrivateName; 26 isPrivateName;
27 27
28 import '../dart_types.dart'; 28 import '../dart_types.dart';
29 29
30 import '../scanner/scannerlib.dart' show Token, EOF_TOKEN; 30 import '../scanner/scannerlib.dart' show Token, EOF_TOKEN;
31 31
32 import '../ordered_typeset.dart' show OrderedTypeSet; 32 import '../ordered_typeset.dart' show OrderedTypeSet;
33 33
34 class ElementX implements Element { 34 import 'visitor.dart' show ElementVisitor;
35
36 abstract class ElementX implements Element {
35 static int elementHashCode = 0; 37 static int elementHashCode = 0;
36 38
37 final String name; 39 final String name;
38 final ElementKind kind; 40 final ElementKind kind;
39 final Element enclosingElement; 41 final Element enclosingElement;
40 final int hashCode = ++elementHashCode; 42 final int hashCode = ++elementHashCode;
41 Link<MetadataAnnotation> metadata = const Link<MetadataAnnotation>(); 43 Link<MetadataAnnotation> metadata = const Link<MetadataAnnotation>();
42 44
43 ElementX(this.name, this.kind, this.enclosingElement) { 45 ElementX(this.name, this.kind, this.enclosingElement) {
44 assert(isErroneous() || getImplementationLibrary() != null); 46 assert(isErroneous() || getImplementationLibrary() != null);
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 351
350 get redirectionTarget => this; 352 get redirectionTarget => this;
351 353
352 getLibrary() => enclosingElement.getLibrary(); 354 getLibrary() => enclosingElement.getLibrary();
353 355
354 computeTargetType(InterfaceType newType) => unsupported(); 356 computeTargetType(InterfaceType newType) => unsupported();
355 357
356 String get message => '${messageKind.message(messageArguments)}'; 358 String get message => '${messageKind.message(messageArguments)}';
357 359
358 String toString() => '<$name: $message>'; 360 String toString() => '<$name: $message>';
361
362 accept(ElementVisitor visitor) => visitor.visitErroneousElementX(this);
359 } 363 }
360 364
361 /// A message attached to a [WarnOnUseElementX]. 365 /// A message attached to a [WarnOnUseElementX].
362 class WrappedMessage { 366 class WrappedMessage {
363 /// The message position. If [:null:] the position of the reference to the 367 /// The message position. If [:null:] the position of the reference to the
364 /// [WarnOnUseElementX] is used. 368 /// [WarnOnUseElementX] is used.
365 final Spannable spannable; 369 final Spannable spannable;
366 370
367 /** 371 /**
368 * The message to report on resolving a wrapped element. 372 * The message to report on resolving a wrapped element.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 Spannable spannable = info.spannable; 413 Spannable spannable = info.spannable;
410 if (spannable == null) spannable = usageSpannable; 414 if (spannable == null) spannable = usageSpannable;
411 listener.reportInfo( 415 listener.reportInfo(
412 spannable, info.messageKind, info.messageArguments); 416 spannable, info.messageKind, info.messageArguments);
413 } 417 }
414 if (unwrapped.isWarnOnUse()) { 418 if (unwrapped.isWarnOnUse()) {
415 unwrapped = unwrapped.unwrap(listener, usageSpannable); 419 unwrapped = unwrapped.unwrap(listener, usageSpannable);
416 } 420 }
417 return unwrapped; 421 return unwrapped;
418 } 422 }
423
424 accept(ElementVisitor visitor) => visitor.visitWarnOnUseElementX(this);
419 } 425 }
420 426
421 /** 427 /**
422 * An ambiguous element represents multiple elements accessible by the same name . 428 * An ambiguous element represents multiple elements accessible by the same name .
423 * 429 *
424 * Ambiguous elements are created during handling of import/export scopes. If an 430 * Ambiguous elements are created during handling of import/export scopes. If an
425 * ambiguous element is encountered during resolution a warning/error should be 431 * ambiguous element is encountered during resolution a warning/error should be
426 * reported. 432 * reported.
427 */ 433 */
428 class AmbiguousElementX extends ElementX implements AmbiguousElement { 434 class AmbiguousElementX extends ElementX implements AmbiguousElement {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 listener.reportInfo(element, code, arguments); 482 listener.reportInfo(element, code, arguments);
477 Link<Import> importers = importer.importers.getImports(element); 483 Link<Import> importers = importer.importers.getImports(element);
478 listener.withCurrentElement(importer, () { 484 listener.withCurrentElement(importer, () {
479 for (; !importers.isEmpty; importers = importers.tail) { 485 for (; !importers.isEmpty; importers = importers.tail) {
480 listener.reportInfo( 486 listener.reportInfo(
481 importers.head, MessageKind.IMPORTED_HERE, arguments); 487 importers.head, MessageKind.IMPORTED_HERE, arguments);
482 } 488 }
483 }); 489 });
484 } 490 }
485 } 491 }
492
493 accept(ElementVisitor visitor) => visitor.visitAmbiguousElementX(this);
486 } 494 }
487 495
488 class ScopeX { 496 class ScopeX {
489 final Map<String, Element> contents = new Map<String, Element>(); 497 final Map<String, Element> contents = new Map<String, Element>();
490 498
491 bool get isEmpty => contents.isEmpty; 499 bool get isEmpty => contents.isEmpty;
492 Iterable<Element> get values => contents.values; 500 Iterable<Element> get values => contents.values;
493 501
494 Element lookup(String name) { 502 Element lookup(String name) {
495 return contents[name]; 503 return contents[name];
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 } 638 }
631 } 639 }
632 } 640 }
633 641
634 bool get hasMembers => !localMembers.isEmpty; 642 bool get hasMembers => !localMembers.isEmpty;
635 643
636 int compareTo(CompilationUnitElement other) { 644 int compareTo(CompilationUnitElement other) {
637 if (this == other) return 0; 645 if (this == other) return 0;
638 return '${script.uri}'.compareTo('${other.script.uri}'); 646 return '${script.uri}'.compareTo('${other.script.uri}');
639 } 647 }
648
649 accept(ElementVisitor visitor) => visitor.visitCompilationUnitElement(this);
640 } 650 }
641 651
642 class Importers { 652 class Importers {
643 Map<Element, Link<Import>> importers = new Map<Element, Link<Import>>(); 653 Map<Element, Link<Import>> importers = new Map<Element, Link<Import>>();
644 654
645 Link<Import> getImports(Element element) { 655 Link<Import> getImports(Element element) {
646 Link<Import> imports = importers[element]; 656 Link<Import> imports = importers[element];
647 return imports != null ? imports : const Link<Import>(); 657 return imports != null ? imports : const Link<Import>();
648 } 658 }
649 659
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 return 'origin library(${getLibraryOrScriptName()})'; 997 return 'origin library(${getLibraryOrScriptName()})';
988 } else { 998 } else {
989 return 'library(${getLibraryOrScriptName()})'; 999 return 'library(${getLibraryOrScriptName()})';
990 } 1000 }
991 } 1001 }
992 1002
993 int compareTo(LibraryElement other) { 1003 int compareTo(LibraryElement other) {
994 if (this == other) return 0; 1004 if (this == other) return 0;
995 return getLibraryOrScriptName().compareTo(other.getLibraryOrScriptName()); 1005 return getLibraryOrScriptName().compareTo(other.getLibraryOrScriptName());
996 } 1006 }
1007
1008 accept(ElementVisitor visitor) => visitor.visitLibraryElementX(this);
997 } 1009 }
998 1010
999 class PrefixElementX extends ElementX implements PrefixElement { 1011 class PrefixElementX extends ElementX implements PrefixElement {
1000 Token firstPosition; 1012 Token firstPosition;
1001 1013
1002 final ImportScope importScope = new ImportScope(); 1014 final ImportScope importScope = new ImportScope();
1003 1015
1004 PrefixElementX(String prefix, Element enclosing, this.firstPosition) 1016 PrefixElementX(String prefix, Element enclosing, this.firstPosition)
1005 : super(prefix, ElementKind.PREFIX, enclosing); 1017 : super(prefix, ElementKind.PREFIX, enclosing);
1006 1018
1007 Element lookupLocalMember(String memberName) => importScope[memberName]; 1019 Element lookupLocalMember(String memberName) => importScope[memberName];
1008 1020
1009 DartType computeType(Compiler compiler) => compiler.types.dynamicType; 1021 DartType computeType(Compiler compiler) => compiler.types.dynamicType;
1010 1022
1011 Token position() => firstPosition; 1023 Token position() => firstPosition;
1012 1024
1013 void addImport(Element element, Import import, DiagnosticListener listener) { 1025 void addImport(Element element, Import import, DiagnosticListener listener) {
1014 importScope.addImport(this, element, import, listener); 1026 importScope.addImport(this, element, import, listener);
1015 } 1027 }
1028
1029 accept(ElementVisitor visitor) => visitor.visitPrefixElementX(this);
1016 } 1030 }
1017 1031
1018 class TypedefElementX extends ElementX implements TypedefElement { 1032 class TypedefElementX extends ElementX implements TypedefElement {
1019 Typedef cachedNode; 1033 Typedef cachedNode;
1020 1034
1021 /** 1035 /**
1022 * The type of this typedef in which the type arguments are the type 1036 * The type of this typedef in which the type arguments are the type
1023 * variables. 1037 * variables.
1024 * 1038 *
1025 * This resembles the [ClassElement.thisType] though a typedef has no notion 1039 * This resembles the [ClassElement.thisType] though a typedef has no notion
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 Scope buildScope() { 1103 Scope buildScope() {
1090 return new TypeDeclarationScope(enclosingElement.buildScope(), this); 1104 return new TypeDeclarationScope(enclosingElement.buildScope(), this);
1091 } 1105 }
1092 1106
1093 void checkCyclicReference(Compiler compiler) { 1107 void checkCyclicReference(Compiler compiler) {
1094 if (hasBeenCheckedForCycles) return; 1108 if (hasBeenCheckedForCycles) return;
1095 var visitor = new TypedefCyclicVisitor(compiler, this); 1109 var visitor = new TypedefCyclicVisitor(compiler, this);
1096 computeType(compiler).accept(visitor, null); 1110 computeType(compiler).accept(visitor, null);
1097 hasBeenCheckedForCycles = true; 1111 hasBeenCheckedForCycles = true;
1098 } 1112 }
1113
1114 accept(ElementVisitor visitor) => visitor.visitTypedefElementX(this);
1099 } 1115 }
1100 1116
1101 class VariableElementX extends ElementX implements VariableElement { 1117 class VariableElementX extends ElementX implements VariableElement {
1102 final VariableListElement variables; 1118 final VariableListElement variables;
1103 Expression cachedNode; // The send or the identifier in the variables list. 1119 Expression cachedNode; // The send or the identifier in the variables list.
1104 1120
1105 Modifiers get modifiers => variables.modifiers; 1121 Modifiers get modifiers => variables.modifiers;
1106 1122
1107 VariableElementX(String name, 1123 VariableElementX(String name,
1108 VariableListElement variables, 1124 VariableListElement variables,
1109 ElementKind kind, 1125 ElementKind kind,
1110 this.cachedNode) 1126 this.cachedNode)
1111 : this.variables = variables, 1127 : this.variables = variables,
1112 super(name, kind, variables.enclosingElement); 1128 super(name, kind, variables.enclosingElement);
1113 1129
1130 VariableElementX.synthetic(String name,
1131 ElementKind kind,
1132 Element enclosing) :
1133 variables = null,
1134 super(name, kind, enclosing);
1135
1114 Node parseNode(DiagnosticListener listener) { 1136 Node parseNode(DiagnosticListener listener) {
1115 if (cachedNode != null) return cachedNode; 1137 if (cachedNode != null) return cachedNode;
1116 VariableDefinitions definitions = variables.parseNode(listener); 1138 VariableDefinitions definitions = variables.parseNode(listener);
1117 for (Link<Node> link = definitions.definitions.nodes; 1139 for (Link<Node> link = definitions.definitions.nodes;
1118 !link.isEmpty; link = link.tail) { 1140 !link.isEmpty; link = link.tail) {
1119 Expression initializedIdentifier = link.head; 1141 Expression initializedIdentifier = link.head;
1120 Identifier identifier = initializedIdentifier.asIdentifier(); 1142 Identifier identifier = initializedIdentifier.asIdentifier();
1121 if (identifier == null) { 1143 if (identifier == null) {
1122 identifier = initializedIdentifier.asSendSet().selector.asIdentifier(); 1144 identifier = initializedIdentifier.asSendSet().selector.asIdentifier();
1123 } 1145 }
1124 if (identical(name, identifier.source)) { 1146 if (identical(name, identifier.source)) {
1125 cachedNode = initializedIdentifier; 1147 cachedNode = initializedIdentifier;
1126 return cachedNode; 1148 return cachedNode;
1127 } 1149 }
1128 } 1150 }
1129 listener.cancel('internal error: could not find $name', node: variables); 1151 listener.cancel('internal error: could not find $name', node: variables);
1130 } 1152 }
1131 1153
1132 DartType computeType(Compiler compiler) { 1154 DartType computeType(Compiler compiler) {
1133 return variables.computeType(compiler); 1155 return variables.computeType(compiler);
1134 } 1156 }
1135 1157
1136 DartType get type => variables.type;
1137
1138 bool isInstanceMember() => variables.isInstanceMember(); 1158 bool isInstanceMember() => variables.isInstanceMember();
1139 1159
1140 // Note: cachedNode.getBeginToken() will not be correct in all 1160 // Note: cachedNode.getBeginToken() will not be correct in all
1141 // cases, for example, for function typed parameters. 1161 // cases, for example, for function typed parameters.
1142 Token position() => findMyName(variables.position()); 1162 Token position() => findMyName(variables.position());
1163
1164 accept(ElementVisitor visitor) => visitor.visitVariableElementX(this);
1143 } 1165 }
1144 1166
1145 /** 1167 /**
1146 * Parameters in constructors that directly initialize fields. For example: 1168 * Parameters in constructors that directly initialize fields. For example:
1147 * [:A(this.field):]. 1169 * [:A(this.field):].
1148 */ 1170 */
1149 class FieldParameterElementX extends VariableElementX 1171 class FieldParameterElementX extends VariableElementX
1150 implements FieldParameterElement { 1172 implements FieldParameterElement {
1151 VariableElement fieldElement; 1173 VariableElement fieldElement;
1152 1174
1153 FieldParameterElementX(String name, 1175 FieldParameterElementX(String name,
1154 this.fieldElement, 1176 this.fieldElement,
1155 VariableListElement variables, 1177 VariableListElement variables,
1156 Node node) 1178 Node node)
1157 : super(name, variables, ElementKind.FIELD_PARAMETER, node); 1179 : super(name, variables, ElementKind.FIELD_PARAMETER, node);
1158 1180
1159 DartType computeType(Compiler compiler) { 1181 DartType computeType(Compiler compiler) {
1160 VariableDefinitions definitions = variables.parseNode(compiler); 1182 VariableDefinitions definitions = variables.parseNode(compiler);
1161 if (definitions.type == null) { 1183 if (definitions.type == null) {
1162 return fieldElement.computeType(compiler); 1184 return fieldElement.computeType(compiler);
1163 } 1185 }
1164 return super.computeType(compiler); 1186 return super.computeType(compiler);
1165 } 1187 }
1188
1189 accept(ElementVisitor visitor) => visitor.visitFieldParameterElementX(this);
1166 } 1190 }
1167 1191
1168 // This element represents a list of variable or field declaration. 1192 // This element represents a list of variable or field declaration.
1169 // It contains the node, and the type. A [VariableElement] always 1193 // It contains the node, and the type. A [VariableElement] always
1170 // references its [VariableListElement]. It forwards its 1194 // references its [VariableListElement]. It forwards its
1171 // [computeType] and [parseNode] methods to this element. 1195 // [computeType] and [parseNode] methods to this element.
1172 class VariableListElementX extends ElementX implements VariableListElement { 1196 class VariableListElementX extends ElementX implements VariableListElement {
1173 VariableDefinitions cachedNode; 1197 VariableDefinitions cachedNode;
1174 DartType type; 1198 DartType type;
1175 final Modifiers modifiers; 1199 final Modifiers modifiers;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 }); 1248 });
1225 assert(type != null); 1249 assert(type != null);
1226 return type; 1250 return type;
1227 } 1251 }
1228 1252
1229 Token position() => cachedNode.getBeginToken(); 1253 Token position() => cachedNode.getBeginToken();
1230 1254
1231 bool isInstanceMember() { 1255 bool isInstanceMember() {
1232 return isMember() && !modifiers.isStatic(); 1256 return isMember() && !modifiers.isStatic();
1233 } 1257 }
1258
1259 accept(ElementVisitor visitor) => visitor.visitVariableListElementX(this);
1234 } 1260 }
1235 1261
1236 class AbstractFieldElementX extends ElementX implements AbstractFieldElement { 1262 class AbstractFieldElementX extends ElementX implements AbstractFieldElement {
1237 FunctionElement getter; 1263 FunctionElement getter;
1238 FunctionElement setter; 1264 FunctionElement setter;
1239 1265
1240 AbstractFieldElementX(String name, Element enclosing) 1266 AbstractFieldElementX(String name, Element enclosing)
1241 : super(name, ElementKind.ABSTRACT_FIELD, enclosing); 1267 : super(name, ElementKind.ABSTRACT_FIELD, enclosing);
1242 1268
1243 DartType computeType(Compiler compiler) { 1269 DartType computeType(Compiler compiler) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 } else { 1301 } else {
1276 return new Modifiers.withFlags( 1302 return new Modifiers.withFlags(
1277 setter.modifiers.nodes, 1303 setter.modifiers.nodes,
1278 setter.modifiers.flags | Modifiers.FLAG_ABSTRACT); 1304 setter.modifiers.flags | Modifiers.FLAG_ABSTRACT);
1279 } 1305 }
1280 } 1306 }
1281 1307
1282 bool isInstanceMember() { 1308 bool isInstanceMember() {
1283 return isMember() && !modifiers.isStatic(); 1309 return isMember() && !modifiers.isStatic();
1284 } 1310 }
1311
1312 accept(ElementVisitor visitor) => visitor.visitAbstractFieldElementX(this);
1285 } 1313 }
1286 1314
1287 // TODO(johnniwinther): [FunctionSignature] should be merged with 1315 // TODO(johnniwinther): [FunctionSignature] should be merged with
1288 // [FunctionType]. 1316 // [FunctionType].
1289 class FunctionSignatureX implements FunctionSignature { 1317 class FunctionSignatureX implements FunctionSignature {
1290 final Link<Element> requiredParameters; 1318 final Link<Element> requiredParameters;
1291 final Link<Element> optionalParameters; 1319 final Link<Element> optionalParameters;
1292 final DartType returnType; 1320 final DartType returnType;
1293 final int requiredParameterCount; 1321 final int requiredParameterCount;
1294 final int optionalParameterCount; 1322 final int optionalParameterCount;
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 } else { 1570 } else {
1543 return super.toString(); 1571 return super.toString();
1544 } 1572 }
1545 } 1573 }
1546 1574
1547 bool get isAbstract { 1575 bool get isAbstract {
1548 return !modifiers.isExternal() && 1576 return !modifiers.isExternal() &&
1549 (isFunction() || isAccessor()) && 1577 (isFunction() || isAccessor()) &&
1550 _hasNoBody; 1578 _hasNoBody;
1551 } 1579 }
1580
1581 accept(ElementVisitor visitor) => visitor.visitFunctionElementX(this);
1552 } 1582 }
1553 1583
1554 class ConstructorBodyElementX extends FunctionElementX 1584 class ConstructorBodyElementX extends FunctionElementX
1555 implements ConstructorBodyElement { 1585 implements ConstructorBodyElement {
1556 FunctionElement constructor; 1586 FunctionElement constructor;
1557 1587
1558 ConstructorBodyElementX(FunctionElement constructor) 1588 ConstructorBodyElementX(FunctionElement constructor)
1559 : this.constructor = constructor, 1589 : this.constructor = constructor,
1560 super(constructor.name, 1590 super(constructor.name,
1561 ElementKind.GENERATIVE_CONSTRUCTOR_BODY, 1591 ElementKind.GENERATIVE_CONSTRUCTOR_BODY,
1562 Modifiers.EMPTY, 1592 Modifiers.EMPTY,
1563 constructor.enclosingElement, false) { 1593 constructor.enclosingElement, false) {
1564 functionSignature = constructor.functionSignature; 1594 functionSignature = constructor.functionSignature;
1565 } 1595 }
1566 1596
1567 bool isInstanceMember() => true; 1597 bool isInstanceMember() => true;
1568 1598
1569 FunctionType computeType(Compiler compiler) { 1599 FunctionType computeType(Compiler compiler) {
1570 compiler.internalErrorOnElement(this, '$this.computeType.'); 1600 compiler.internalErrorOnElement(this, '$this.computeType.');
1571 } 1601 }
1572 1602
1573 Node parseNode(DiagnosticListener listener) { 1603 Node parseNode(DiagnosticListener listener) {
1574 if (cachedNode != null) return cachedNode; 1604 if (cachedNode != null) return cachedNode;
1575 cachedNode = constructor.parseNode(listener); 1605 cachedNode = constructor.parseNode(listener);
1576 assert(cachedNode != null); 1606 assert(cachedNode != null);
1577 return cachedNode; 1607 return cachedNode;
1578 } 1608 }
1579 1609
1580 Token position() => constructor.position(); 1610 Token position() => constructor.position();
1611
1612 accept(ElementVisitor visitor) => visitor.visitConstructorBodyElementX(this);
1581 } 1613 }
1582 1614
1583 /** 1615 /**
1584 * A constructor that is not defined in the source code but rather implied by 1616 * A constructor that is not defined in the source code but rather implied by
1585 * the language semantics. 1617 * the language semantics.
1586 * 1618 *
1587 * This class is used to represent default constructors and forwarding 1619 * This class is used to represent default constructors and forwarding
1588 * constructors for mixin applications. 1620 * constructors for mixin applications.
1589 */ 1621 */
1590 class SynthesizedConstructorElementX extends FunctionElementX { 1622 class SynthesizedConstructorElementX extends FunctionElementX {
(...skipping 28 matching lines...) Expand all
1619 if (superMember.isErroneous()) { 1651 if (superMember.isErroneous()) {
1620 return functionSignature = compiler.objectClass.localLookup('') 1652 return functionSignature = compiler.objectClass.localLookup('')
1621 .computeSignature(compiler); 1653 .computeSignature(compiler);
1622 } 1654 }
1623 return functionSignature = superMember.computeSignature(compiler); 1655 return functionSignature = superMember.computeSignature(compiler);
1624 } 1656 }
1625 1657
1626 get declaration => this; 1658 get declaration => this;
1627 get implementation => this; 1659 get implementation => this;
1628 get defaultImplementation => this; 1660 get defaultImplementation => this;
1661
1662 accept(ElementVisitor visitor) {
1663 visitor.visitSynthesizedConstructorElementX(this);
1664 }
1629 } 1665 }
1630 1666
1631 class VoidElementX extends ElementX { 1667 class VoidElementX extends ElementX {
1632 VoidElementX(Element enclosing) : super('void', ElementKind.VOID, enclosing); 1668 VoidElementX(Element enclosing) : super('void', ElementKind.VOID, enclosing);
1633 DartType computeType(compiler) => compiler.types.voidType; 1669 DartType computeType(compiler) => compiler.types.voidType;
1634 Node parseNode(_) { 1670 Node parseNode(_) {
1635 throw 'internal error: parseNode on void'; 1671 throw 'internal error: parseNode on void';
1636 } 1672 }
1637 bool impliesType() => true; 1673 bool impliesType() => true;
1674
1675 accept(ElementVisitor visitor) => visitor.visitVoidElementX(this);
1638 } 1676 }
1639 1677
1640 class TypeDeclarationElementX { 1678 class TypeDeclarationElementX {
1641 /** 1679 /**
1642 * Creates the type variables, their type and corresponding element, for the 1680 * Creates the type variables, their type and corresponding element, for the
1643 * type variables declared in [parameter] on [element]. The bounds of the type 1681 * type variables declared in [parameter] on [element]. The bounds of the type
1644 * variables are not set until [element] has been resolved. 1682 * variables are not set until [element] has been resolved.
1645 */ 1683 */
1646 static Link<DartType> createTypeVariables(TypeDeclarationElement element, 1684 static Link<DartType> createTypeVariables(TypeDeclarationElement element,
1647 NodeList parameters) { 1685 NodeList parameters) {
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
2253 assert(!hasConstructor); 2291 assert(!hasConstructor);
2254 addConstructor(constructor); 2292 addConstructor(constructor);
2255 } 2293 }
2256 2294
2257 Link<DartType> computeTypeParameters(Compiler compiler) { 2295 Link<DartType> computeTypeParameters(Compiler compiler) {
2258 NamedMixinApplication named = node.asNamedMixinApplication(); 2296 NamedMixinApplication named = node.asNamedMixinApplication();
2259 if (named == null) return const Link<DartType>(); 2297 if (named == null) return const Link<DartType>();
2260 return TypeDeclarationElementX.createTypeVariables( 2298 return TypeDeclarationElementX.createTypeVariables(
2261 this, named.typeParameters); 2299 this, named.typeParameters);
2262 } 2300 }
2301
2302 accept(ElementVisitor visitor) => visitor.visitMixinApplicationElement(this);
2263 } 2303 }
2264 2304
2265 class LabelElementX extends ElementX implements LabelElement { 2305 class LabelElementX extends ElementX implements LabelElement {
2266 2306
2267 // We store the original label here so it can be returned by [parseNode]. 2307 // We store the original label here so it can be returned by [parseNode].
2268 final Label label; 2308 final Label label;
2269 final String labelName; 2309 final String labelName;
2270 final TargetElement target; 2310 final TargetElement target;
2271 bool isBreakTarget = false; 2311 bool isBreakTarget = false;
2272 bool isContinueTarget = false; 2312 bool isContinueTarget = false;
(...skipping 16 matching lines...) Expand all
2289 void setContinueTarget() { 2329 void setContinueTarget() {
2290 isContinueTarget = true; 2330 isContinueTarget = true;
2291 target.isContinueTarget = true; 2331 target.isContinueTarget = true;
2292 } 2332 }
2293 2333
2294 bool get isTarget => isBreakTarget || isContinueTarget; 2334 bool get isTarget => isBreakTarget || isContinueTarget;
2295 Node parseNode(DiagnosticListener l) => label; 2335 Node parseNode(DiagnosticListener l) => label;
2296 2336
2297 Token position() => label.getBeginToken(); 2337 Token position() => label.getBeginToken();
2298 String toString() => "${labelName}:"; 2338 String toString() => "${labelName}:";
2339
2340 accept(ElementVisitor visitor) => visitor.visitLabelElementX(this);
2299 } 2341 }
2300 2342
2301 // Represents a reference to a statement or switch-case, either by label or the 2343 // Represents a reference to a statement or switch-case, either by label or the
2302 // default target of a break or continue. 2344 // default target of a break or continue.
2303 class TargetElementX extends ElementX implements TargetElement { 2345 class TargetElementX extends ElementX implements TargetElement {
2304 final Node statement; 2346 final Node statement;
2305 final int nestingLevel; 2347 final int nestingLevel;
2306 Link<LabelElement> labels = const Link<LabelElement>(); 2348 Link<LabelElement> labels = const Link<LabelElement>();
2307 bool isBreakTarget = false; 2349 bool isBreakTarget = false;
2308 bool isContinueTarget = false; 2350 bool isContinueTarget = false;
2309 2351
2310 TargetElementX(this.statement, this.nestingLevel, Element enclosingElement) 2352 TargetElementX(this.statement, this.nestingLevel, Element enclosingElement)
2311 : super("target", ElementKind.STATEMENT, enclosingElement); 2353 : super("target", ElementKind.STATEMENT, enclosingElement);
2312 bool get isTarget => isBreakTarget || isContinueTarget; 2354 bool get isTarget => isBreakTarget || isContinueTarget;
2313 2355
2314 LabelElement addLabel(Label label, String labelName) { 2356 LabelElement addLabel(Label label, String labelName) {
2315 LabelElement result = new LabelElementX(label, labelName, this, 2357 LabelElement result = new LabelElementX(label, labelName, this,
2316 enclosingElement); 2358 enclosingElement);
2317 labels = labels.prepend(result); 2359 labels = labels.prepend(result);
2318 return result; 2360 return result;
2319 } 2361 }
2320 2362
2321 Node parseNode(DiagnosticListener l) => statement; 2363 Node parseNode(DiagnosticListener l) => statement;
2322 2364
2323 bool get isSwitch => statement is SwitchStatement; 2365 bool get isSwitch => statement is SwitchStatement;
2324 2366
2325 Token position() => statement.getBeginToken(); 2367 Token position() => statement.getBeginToken();
2326 String toString() => statement.toString(); 2368 String toString() => statement.toString();
2369
2370 accept(ElementVisitor visitor) => visitor.visitTargetElementX(this);
2327 } 2371 }
2328 2372
2329 class TypeVariableElementX extends ElementX implements TypeVariableElement { 2373 class TypeVariableElementX extends ElementX implements TypeVariableElement {
2330 final Node cachedNode; 2374 final Node cachedNode;
2331 TypeVariableType type; 2375 TypeVariableType type;
2332 DartType bound; 2376 DartType bound;
2333 2377
2334 TypeVariableElementX(name, Element enclosing, this.cachedNode, 2378 TypeVariableElementX(name, Element enclosing, this.cachedNode,
2335 [this.type, this.bound]) 2379 [this.type, this.bound])
2336 : super(name, ElementKind.TYPE_VARIABLE, enclosing); 2380 : super(name, ElementKind.TYPE_VARIABLE, enclosing);
2337 2381
2338 TypeVariableType computeType(compiler) => type; 2382 TypeVariableType computeType(compiler) => type;
2339 2383
2340 Node parseNode(compiler) => cachedNode; 2384 Node parseNode(compiler) => cachedNode;
2341 2385
2342 String toString() => "${enclosingElement.toString()}.${name}"; 2386 String toString() => "${enclosingElement.toString()}.${name}";
2343 2387
2344 Token position() => cachedNode.getBeginToken(); 2388 Token position() => cachedNode.getBeginToken();
2389
2390 accept(ElementVisitor visitor) => visitor.visitTypeVariableElementX(this);
2345 } 2391 }
2346 2392
2347 /** 2393 /**
2348 * A single metadata annotation. 2394 * A single metadata annotation.
2349 * 2395 *
2350 * For example, consider: 2396 * For example, consider:
2351 * 2397 *
2352 * class Data { 2398 * class Data {
2353 * const Data(); 2399 * const Data();
2354 * } 2400 * }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2386 2432
2387 MetadataAnnotation ensureResolved(Compiler compiler) { 2433 MetadataAnnotation ensureResolved(Compiler compiler) {
2388 if (resolutionState == STATE_NOT_STARTED) { 2434 if (resolutionState == STATE_NOT_STARTED) {
2389 compiler.resolver.resolveMetadataAnnotation(this); 2435 compiler.resolver.resolveMetadataAnnotation(this);
2390 } 2436 }
2391 return this; 2437 return this;
2392 } 2438 }
2393 2439
2394 String toString() => 'MetadataAnnotation($value, $resolutionState)'; 2440 String toString() => 'MetadataAnnotation($value, $resolutionState)';
2395 } 2441 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698