| OLD | NEW |
| 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 '../constants/expressions.dart'; | 8 import '../constants/expressions.dart'; |
| 9 import '../helpers/helpers.dart'; // Included for debug helpers. | 9 import '../helpers/helpers.dart'; // Included for debug helpers. |
| 10 import '../tree/tree.dart'; | 10 import '../tree/tree.dart'; |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 computeEffectiveTargetType(InterfaceType newType) => unsupported(); | 319 computeEffectiveTargetType(InterfaceType newType) => unsupported(); |
| 320 | 320 |
| 321 get definingConstructor => null; | 321 get definingConstructor => null; |
| 322 | 322 |
| 323 FunctionElement asFunctionElement() => this; | 323 FunctionElement asFunctionElement() => this; |
| 324 | 324 |
| 325 String get message => '${messageKind.message(messageArguments)}'; | 325 String get message => '${messageKind.message(messageArguments)}'; |
| 326 | 326 |
| 327 String toString() => '<$name: $message>'; | 327 String toString() => '<$name: $message>'; |
| 328 | 328 |
| 329 accept(ElementVisitor visitor) => visitor.visitErroneousElement(this); | 329 accept(ElementVisitor visitor, arg) { |
| 330 return visitor.visitErroneousElement(this, arg); |
| 331 } |
| 330 } | 332 } |
| 331 | 333 |
| 332 /// A constructor that was synthesized to recover from a compile-time error. | 334 /// A constructor that was synthesized to recover from a compile-time error. |
| 333 class ErroneousConstructorElementX extends ErroneousElementX | 335 class ErroneousConstructorElementX extends ErroneousElementX |
| 334 with PatchMixin<FunctionElement>, AnalyzableElementX | 336 with PatchMixin<FunctionElement>, AnalyzableElementX |
| 335 implements ConstructorElementX { | 337 implements ConstructorElementX { |
| 336 // TODO(ahe): Instead of subclassing [ErroneousElementX], this class should | 338 // TODO(ahe): Instead of subclassing [ErroneousElementX], this class should |
| 337 // be more like [ErroneousFieldElementX]. In particular, its kind should be | 339 // be more like [ErroneousFieldElementX]. In particular, its kind should be |
| 338 // [ElementKind.GENERATIVE_CONSTRUCTOR], and it shouldn't throw as much. | 340 // [ElementKind.GENERATIVE_CONSTRUCTOR], and it shouldn't throw as much. |
| 339 | 341 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 if (spannable == null) spannable = usageSpannable; | 470 if (spannable == null) spannable = usageSpannable; |
| 469 listener.reportInfo( | 471 listener.reportInfo( |
| 470 spannable, info.messageKind, info.messageArguments); | 472 spannable, info.messageKind, info.messageArguments); |
| 471 } | 473 } |
| 472 if (unwrapped.isWarnOnUse) { | 474 if (unwrapped.isWarnOnUse) { |
| 473 unwrapped = unwrapped.unwrap(listener, usageSpannable); | 475 unwrapped = unwrapped.unwrap(listener, usageSpannable); |
| 474 } | 476 } |
| 475 return unwrapped; | 477 return unwrapped; |
| 476 } | 478 } |
| 477 | 479 |
| 478 accept(ElementVisitor visitor) => visitor.visitWarnOnUseElement(this); | 480 accept(ElementVisitor visitor, arg) { |
| 481 return visitor.visitWarnOnUseElement(this, arg); |
| 482 } |
| 479 } | 483 } |
| 480 | 484 |
| 481 abstract class AmbiguousElementX extends ElementX implements AmbiguousElement { | 485 abstract class AmbiguousElementX extends ElementX implements AmbiguousElement { |
| 482 /** | 486 /** |
| 483 * The message to report on resolving this element. | 487 * The message to report on resolving this element. |
| 484 */ | 488 */ |
| 485 final MessageKind messageKind; | 489 final MessageKind messageKind; |
| 486 | 490 |
| 487 /** | 491 /** |
| 488 * The message arguments to report on resolving this element. | 492 * The message arguments to report on resolving this element. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 510 var set = new Setlet(); | 514 var set = new Setlet(); |
| 511 while (element.isAmbiguous) { | 515 while (element.isAmbiguous) { |
| 512 AmbiguousElement ambiguous = element; | 516 AmbiguousElement ambiguous = element; |
| 513 set.add(ambiguous.newElement); | 517 set.add(ambiguous.newElement); |
| 514 element = ambiguous.existingElement; | 518 element = ambiguous.existingElement; |
| 515 } | 519 } |
| 516 set.add(element); | 520 set.add(element); |
| 517 return set; | 521 return set; |
| 518 } | 522 } |
| 519 | 523 |
| 520 accept(ElementVisitor visitor) => visitor.visitAmbiguousElement(this); | 524 accept(ElementVisitor visitor, arg) { |
| 525 return visitor.visitAmbiguousElement(this, arg); |
| 526 } |
| 521 | 527 |
| 522 bool get isTopLevel => false; | 528 bool get isTopLevel => false; |
| 523 | 529 |
| 524 DynamicType get type => const DynamicType(); | 530 DynamicType get type => const DynamicType(); |
| 525 } | 531 } |
| 526 | 532 |
| 527 /// Element synthesized to diagnose an ambiguous import. | 533 /// Element synthesized to diagnose an ambiguous import. |
| 528 class AmbiguousImportX extends AmbiguousElementX { | 534 class AmbiguousImportX extends AmbiguousElementX { |
| 529 AmbiguousImportX( | 535 AmbiguousImportX( |
| 530 MessageKind messageKind, | 536 MessageKind messageKind, |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 | 724 |
| 719 bool get hasMembers => !localMembers.isEmpty; | 725 bool get hasMembers => !localMembers.isEmpty; |
| 720 | 726 |
| 721 int compareTo(CompilationUnitElement other) { | 727 int compareTo(CompilationUnitElement other) { |
| 722 if (this == other) return 0; | 728 if (this == other) return 0; |
| 723 return '${script.readableUri}'.compareTo('${other.script.readableUri}'); | 729 return '${script.readableUri}'.compareTo('${other.script.readableUri}'); |
| 724 } | 730 } |
| 725 | 731 |
| 726 Element get analyzableElement => library; | 732 Element get analyzableElement => library; |
| 727 | 733 |
| 728 accept(ElementVisitor visitor) => visitor.visitCompilationUnitElement(this); | 734 accept(ElementVisitor visitor, arg) { |
| 735 return visitor.visitCompilationUnitElement(this, arg); |
| 736 } |
| 729 } | 737 } |
| 730 | 738 |
| 731 class Importers { | 739 class Importers { |
| 732 Map<Element, Link<Import>> importers = new Map<Element, Link<Import>>(); | 740 Map<Element, Link<Import>> importers = new Map<Element, Link<Import>>(); |
| 733 | 741 |
| 734 Link<Import> getImports(Element element) { | 742 Link<Import> getImports(Element element) { |
| 735 Link<Import> imports = importers[element]; | 743 Link<Import> imports = importers[element]; |
| 736 return imports != null ? imports : const Link<Import>(); | 744 return imports != null ? imports : const Link<Import>(); |
| 737 } | 745 } |
| 738 | 746 |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1097 } else { | 1105 } else { |
| 1098 return 'library(${canonicalUri})'; | 1106 return 'library(${canonicalUri})'; |
| 1099 } | 1107 } |
| 1100 } | 1108 } |
| 1101 | 1109 |
| 1102 int compareTo(LibraryElement other) { | 1110 int compareTo(LibraryElement other) { |
| 1103 if (this == other) return 0; | 1111 if (this == other) return 0; |
| 1104 return getLibraryOrScriptName().compareTo(other.getLibraryOrScriptName()); | 1112 return getLibraryOrScriptName().compareTo(other.getLibraryOrScriptName()); |
| 1105 } | 1113 } |
| 1106 | 1114 |
| 1107 accept(ElementVisitor visitor) => visitor.visitLibraryElement(this); | 1115 accept(ElementVisitor visitor, arg) { |
| 1116 return visitor.visitLibraryElement(this, arg); |
| 1117 } |
| 1108 | 1118 |
| 1109 // TODO(johnniwinther): Remove these when issue 18630 is fixed. | 1119 // TODO(johnniwinther): Remove these when issue 18630 is fixed. |
| 1110 LibraryElementX get patch => super.patch; | 1120 LibraryElementX get patch => super.patch; |
| 1111 LibraryElementX get origin => super.origin; | 1121 LibraryElementX get origin => super.origin; |
| 1112 } | 1122 } |
| 1113 | 1123 |
| 1114 class PrefixElementX extends ElementX implements PrefixElement { | 1124 class PrefixElementX extends ElementX implements PrefixElement { |
| 1115 Token firstPosition; | 1125 Token firstPosition; |
| 1116 | 1126 |
| 1117 final ImportScope importScope = new ImportScope(); | 1127 final ImportScope importScope = new ImportScope(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1130 Element lookupLocalMember(String memberName) => importScope[memberName]; | 1140 Element lookupLocalMember(String memberName) => importScope[memberName]; |
| 1131 | 1141 |
| 1132 DartType computeType(Compiler compiler) => const DynamicType(); | 1142 DartType computeType(Compiler compiler) => const DynamicType(); |
| 1133 | 1143 |
| 1134 Token get position => firstPosition; | 1144 Token get position => firstPosition; |
| 1135 | 1145 |
| 1136 void addImport(Element element, Import import, DiagnosticListener listener) { | 1146 void addImport(Element element, Import import, DiagnosticListener listener) { |
| 1137 importScope.addImport(this, element, import, listener); | 1147 importScope.addImport(this, element, import, listener); |
| 1138 } | 1148 } |
| 1139 | 1149 |
| 1140 accept(ElementVisitor visitor) => visitor.visitPrefixElement(this); | 1150 accept(ElementVisitor visitor, arg) { |
| 1151 return visitor.visitPrefixElement(this, arg); |
| 1152 } |
| 1141 | 1153 |
| 1142 void markAsDeferred(Import deferredImport) { | 1154 void markAsDeferred(Import deferredImport) { |
| 1143 _deferredImport = deferredImport; | 1155 _deferredImport = deferredImport; |
| 1144 } | 1156 } |
| 1145 } | 1157 } |
| 1146 | 1158 |
| 1147 class TypedefElementX extends ElementX | 1159 class TypedefElementX extends ElementX |
| 1148 with AstElementMixin, | 1160 with AstElementMixin, |
| 1149 AnalyzableElementX, | 1161 AnalyzableElementX, |
| 1150 TypeDeclarationElementX<TypedefType> | 1162 TypeDeclarationElementX<TypedefType> |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 return new TypeDeclarationScope(enclosingElement.buildScope(), this); | 1216 return new TypeDeclarationScope(enclosingElement.buildScope(), this); |
| 1205 } | 1217 } |
| 1206 | 1218 |
| 1207 void checkCyclicReference(Compiler compiler) { | 1219 void checkCyclicReference(Compiler compiler) { |
| 1208 if (hasBeenCheckedForCycles) return; | 1220 if (hasBeenCheckedForCycles) return; |
| 1209 var visitor = new TypedefCyclicVisitor(compiler, this); | 1221 var visitor = new TypedefCyclicVisitor(compiler, this); |
| 1210 computeType(compiler).accept(visitor, null); | 1222 computeType(compiler).accept(visitor, null); |
| 1211 hasBeenCheckedForCycles = true; | 1223 hasBeenCheckedForCycles = true; |
| 1212 } | 1224 } |
| 1213 | 1225 |
| 1214 accept(ElementVisitor visitor) => visitor.visitTypedefElement(this); | 1226 accept(ElementVisitor visitor, arg) { |
| 1227 return visitor.visitTypedefElement(this, arg); |
| 1228 } |
| 1215 | 1229 |
| 1216 // A typedef cannot be patched therefore defines itself. | 1230 // A typedef cannot be patched therefore defines itself. |
| 1217 AstElement get definingElement => this; | 1231 AstElement get definingElement => this; |
| 1218 } | 1232 } |
| 1219 | 1233 |
| 1220 // This class holds common information for a list of variable or field | 1234 // This class holds common information for a list of variable or field |
| 1221 // declarations. It contains the node, and the type. A [VariableElementX] | 1235 // declarations. It contains the node, and the type. A [VariableElementX] |
| 1222 // forwards its [computeType] and [parseNode] methods to this class. | 1236 // forwards its [computeType] and [parseNode] methods to this class. |
| 1223 class VariableList implements DeclarationSite { | 1237 class VariableList implements DeclarationSite { |
| 1224 VariableDefinitions definitions; | 1238 VariableDefinitions definitions; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1341 message: "Type has not been computed for $this.")); | 1355 message: "Type has not been computed for $this.")); |
| 1342 return variables.type; | 1356 return variables.type; |
| 1343 } | 1357 } |
| 1344 | 1358 |
| 1345 bool get isInstanceMember => isClassMember && !isStatic; | 1359 bool get isInstanceMember => isClassMember && !isStatic; |
| 1346 | 1360 |
| 1347 // Note: cachedNode.beginToken will not be correct in all | 1361 // Note: cachedNode.beginToken will not be correct in all |
| 1348 // cases, for example, for function typed parameters. | 1362 // cases, for example, for function typed parameters. |
| 1349 Token get position => token; | 1363 Token get position => token; |
| 1350 | 1364 |
| 1351 accept(ElementVisitor visitor) => visitor.visitVariableElement(this); | 1365 accept(ElementVisitor visitor, arg) { |
| 1366 return visitor.visitVariableElement(this, arg); |
| 1367 } |
| 1352 | 1368 |
| 1353 DeclarationSite get declarationSite => variables; | 1369 DeclarationSite get declarationSite => variables; |
| 1354 } | 1370 } |
| 1355 | 1371 |
| 1356 class LocalVariableElementX extends VariableElementX | 1372 class LocalVariableElementX extends VariableElementX |
| 1357 implements LocalVariableElement { | 1373 implements LocalVariableElement { |
| 1358 LocalVariableElementX(String name, | 1374 LocalVariableElementX(String name, |
| 1359 ExecutableElement enclosingElement, | 1375 ExecutableElement enclosingElement, |
| 1360 VariableList variables, | 1376 VariableList variables, |
| 1361 Token token) | 1377 Token token) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1373 class FieldElementX extends VariableElementX | 1389 class FieldElementX extends VariableElementX |
| 1374 with AnalyzableElementX implements FieldElement { | 1390 with AnalyzableElementX implements FieldElement { |
| 1375 List<FunctionElement> nestedClosures = new List<FunctionElement>(); | 1391 List<FunctionElement> nestedClosures = new List<FunctionElement>(); |
| 1376 | 1392 |
| 1377 FieldElementX(Identifier name, | 1393 FieldElementX(Identifier name, |
| 1378 Element enclosingElement, | 1394 Element enclosingElement, |
| 1379 VariableList variables) | 1395 VariableList variables) |
| 1380 : super(name.source, ElementKind.FIELD, enclosingElement, | 1396 : super(name.source, ElementKind.FIELD, enclosingElement, |
| 1381 variables, name.token); | 1397 variables, name.token); |
| 1382 | 1398 |
| 1383 accept(ElementVisitor visitor) => visitor.visitFieldElement(this); | 1399 accept(ElementVisitor visitor, arg) { |
| 1400 return visitor.visitFieldElement(this, arg); |
| 1401 } |
| 1384 | 1402 |
| 1385 MemberElement get memberContext => this; | 1403 MemberElement get memberContext => this; |
| 1386 | 1404 |
| 1387 void reuseElement() { | 1405 void reuseElement() { |
| 1388 super.reuseElement(); | 1406 super.reuseElement(); |
| 1389 nestedClosures.clear(); | 1407 nestedClosures.clear(); |
| 1390 } | 1408 } |
| 1391 | 1409 |
| 1392 FieldElementX copyWithEnclosing(Element enclosingElement) { | 1410 FieldElementX copyWithEnclosing(Element enclosingElement) { |
| 1393 return new FieldElementX( | 1411 return new FieldElementX( |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 | 1462 |
| 1445 get nestedClosures { | 1463 get nestedClosures { |
| 1446 throw new UnsupportedError("nestedClosures"); | 1464 throw new UnsupportedError("nestedClosures"); |
| 1447 } | 1465 } |
| 1448 | 1466 |
| 1449 set nestedClosures(_) { | 1467 set nestedClosures(_) { |
| 1450 throw new UnsupportedError("nestedClosures="); | 1468 throw new UnsupportedError("nestedClosures="); |
| 1451 } | 1469 } |
| 1452 | 1470 |
| 1453 // TODO(ahe): Should this throw or do nothing? | 1471 // TODO(ahe): Should this throw or do nothing? |
| 1454 accept(ElementVisitor visitor) => visitor.visitFieldElement(this); | 1472 accept(ElementVisitor visitor, arg) { |
| 1473 return visitor.visitFieldElement(this, arg); |
| 1474 } |
| 1455 | 1475 |
| 1456 // TODO(ahe): Should return the context of the error site? | 1476 // TODO(ahe): Should return the context of the error site? |
| 1457 MemberElement get memberContext => this; | 1477 MemberElement get memberContext => this; |
| 1458 | 1478 |
| 1459 // TODO(ahe): Should return the definingElement of the error site? | 1479 // TODO(ahe): Should return the definingElement of the error site? |
| 1460 AstElement get definingElement => this; | 1480 AstElement get definingElement => this; |
| 1461 | 1481 |
| 1462 void reuseElement() { | 1482 void reuseElement() { |
| 1463 throw new UnsupportedError("reuseElement"); | 1483 throw new UnsupportedError("reuseElement"); |
| 1464 } | 1484 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1517 message: "Parameter signature has not been set for $this.")); | 1537 message: "Parameter signature has not been set for $this.")); |
| 1518 return functionSignatureCache; | 1538 return functionSignatureCache; |
| 1519 } | 1539 } |
| 1520 | 1540 |
| 1521 bool get hasNode => true; | 1541 bool get hasNode => true; |
| 1522 | 1542 |
| 1523 VariableDefinitions get node => definitions; | 1543 VariableDefinitions get node => definitions; |
| 1524 | 1544 |
| 1525 FunctionType get functionType => type; | 1545 FunctionType get functionType => type; |
| 1526 | 1546 |
| 1527 accept(ElementVisitor visitor) => visitor.visitFormalElement(this); | 1547 accept(ElementVisitor visitor, arg) { |
| 1548 return visitor.visitFormalElement(this, arg); |
| 1549 } |
| 1528 | 1550 |
| 1529 // A parameter is defined by the declaration element. | 1551 // A parameter is defined by the declaration element. |
| 1530 AstElement get definingElement => declaration; | 1552 AstElement get definingElement => declaration; |
| 1531 } | 1553 } |
| 1532 | 1554 |
| 1533 /// [Element] for a formal parameter. | 1555 /// [Element] for a formal parameter. |
| 1534 /// | 1556 /// |
| 1535 /// A [ParameterElementX] can be patched. A parameter of an external method is | 1557 /// A [ParameterElementX] can be patched. A parameter of an external method is |
| 1536 /// patched with the corresponding parameter of the patch method. This is done | 1558 /// patched with the corresponding parameter of the patch method. This is done |
| 1537 /// to ensure that default values on parameters are computed once (on the | 1559 /// to ensure that default values on parameters are computed once (on the |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1550 {this.isOptional: false, | 1572 {this.isOptional: false, |
| 1551 this.isNamed: false}) | 1573 this.isNamed: false}) |
| 1552 : super(elementKind, functionDeclaration, definitions, identifier); | 1574 : super(elementKind, functionDeclaration, definitions, identifier); |
| 1553 | 1575 |
| 1554 FunctionElement get functionDeclaration => enclosingElement; | 1576 FunctionElement get functionDeclaration => enclosingElement; |
| 1555 | 1577 |
| 1556 ExecutableElement get executableContext => enclosingElement; | 1578 ExecutableElement get executableContext => enclosingElement; |
| 1557 | 1579 |
| 1558 MemberElement get memberContext => executableContext.memberContext; | 1580 MemberElement get memberContext => executableContext.memberContext; |
| 1559 | 1581 |
| 1560 accept(ElementVisitor visitor) => visitor.visitParameterElement(this); | 1582 accept(ElementVisitor visitor, arg) { |
| 1583 return visitor.visitParameterElement(this, arg); |
| 1584 } |
| 1561 | 1585 |
| 1562 bool get isLocal => true; | 1586 bool get isLocal => true; |
| 1563 } | 1587 } |
| 1564 | 1588 |
| 1565 class LocalParameterElementX extends ParameterElementX | 1589 class LocalParameterElementX extends ParameterElementX |
| 1566 implements LocalParameterElement { | 1590 implements LocalParameterElement { |
| 1567 | 1591 |
| 1568 | 1592 |
| 1569 LocalParameterElementX(FunctionElement functionDeclaration, | 1593 LocalParameterElementX(FunctionElement functionDeclaration, |
| 1570 VariableDefinitions definitions, | 1594 VariableDefinitions definitions, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1587 VariableDefinitions variables, | 1611 VariableDefinitions variables, |
| 1588 Identifier identifier, | 1612 Identifier identifier, |
| 1589 Expression initializer, | 1613 Expression initializer, |
| 1590 this.fieldElement, | 1614 this.fieldElement, |
| 1591 {bool isOptional: false, | 1615 {bool isOptional: false, |
| 1592 bool isNamed: false}) | 1616 bool isNamed: false}) |
| 1593 : super(ElementKind.INITIALIZING_FORMAL, constructorDeclaration, | 1617 : super(ElementKind.INITIALIZING_FORMAL, constructorDeclaration, |
| 1594 variables, identifier, initializer, | 1618 variables, identifier, initializer, |
| 1595 isOptional: isOptional, isNamed: isNamed); | 1619 isOptional: isOptional, isNamed: isNamed); |
| 1596 | 1620 |
| 1597 accept(ElementVisitor visitor) => visitor.visitFieldParameterElement(this); | 1621 accept(ElementVisitor visitor, arg) { |
| 1622 return visitor.visitFieldParameterElement(this, arg); |
| 1623 } |
| 1598 | 1624 |
| 1599 MemberElement get memberContext => enclosingElement; | 1625 MemberElement get memberContext => enclosingElement; |
| 1600 | 1626 |
| 1601 bool get isLocal => false; | 1627 bool get isLocal => false; |
| 1602 } | 1628 } |
| 1603 | 1629 |
| 1604 class ErroneousInitializingFormalElementX extends ParameterElementX | 1630 class ErroneousInitializingFormalElementX extends ParameterElementX |
| 1605 implements InitializingFormalElementX { | 1631 implements InitializingFormalElementX { |
| 1606 final ErroneousFieldElementX fieldElement; | 1632 final ErroneousFieldElementX fieldElement; |
| 1607 | 1633 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1668 return new Modifiers.withFlags( | 1694 return new Modifiers.withFlags( |
| 1669 setter.modifiers.nodes, | 1695 setter.modifiers.nodes, |
| 1670 setter.modifiers.flags | Modifiers.FLAG_ABSTRACT); | 1696 setter.modifiers.flags | Modifiers.FLAG_ABSTRACT); |
| 1671 } | 1697 } |
| 1672 } | 1698 } |
| 1673 | 1699 |
| 1674 bool get isInstanceMember { | 1700 bool get isInstanceMember { |
| 1675 return isClassMember && !isStatic; | 1701 return isClassMember && !isStatic; |
| 1676 } | 1702 } |
| 1677 | 1703 |
| 1678 accept(ElementVisitor visitor) => visitor.visitAbstractFieldElement(this); | 1704 accept(ElementVisitor visitor, arg) { |
| 1705 return visitor.visitAbstractFieldElement(this, arg); |
| 1706 } |
| 1679 | 1707 |
| 1680 bool get isAbstract { | 1708 bool get isAbstract { |
| 1681 return getter != null && getter.isAbstract | 1709 return getter != null && getter.isAbstract |
| 1682 || setter != null && setter.isAbstract; | 1710 || setter != null && setter.isAbstract; |
| 1683 } | 1711 } |
| 1684 } | 1712 } |
| 1685 | 1713 |
| 1686 // TODO(johnniwinther): [FunctionSignature] should be merged with | 1714 // TODO(johnniwinther): [FunctionSignature] should be merged with |
| 1687 // [FunctionType]. | 1715 // [FunctionType]. |
| 1688 // TODO(karlklose): all these lists should have element type [FormalElement]. | 1716 // TODO(karlklose): all these lists should have element type [FormalElement]. |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1856 return super.toString(); | 1884 return super.toString(); |
| 1857 } | 1885 } |
| 1858 } | 1886 } |
| 1859 | 1887 |
| 1860 bool get isAbstract { | 1888 bool get isAbstract { |
| 1861 return !modifiers.isExternal && | 1889 return !modifiers.isExternal && |
| 1862 (isFunction || isAccessor) && | 1890 (isFunction || isAccessor) && |
| 1863 _hasNoBody; | 1891 _hasNoBody; |
| 1864 } | 1892 } |
| 1865 | 1893 |
| 1866 accept(ElementVisitor visitor) => visitor.visitFunctionElement(this); | 1894 accept(ElementVisitor visitor, arg) { |
| 1895 return visitor.visitFunctionElement(this, arg); |
| 1896 } |
| 1867 | 1897 |
| 1868 // A function is defined by the implementation element. | 1898 // A function is defined by the implementation element. |
| 1869 AstElement get definingElement => implementation; | 1899 AstElement get definingElement => implementation; |
| 1870 } | 1900 } |
| 1871 | 1901 |
| 1872 abstract class FunctionElementX extends BaseFunctionElementX | 1902 abstract class FunctionElementX extends BaseFunctionElementX |
| 1873 with AnalyzableElementX implements MethodElement { | 1903 with AnalyzableElementX implements MethodElement { |
| 1874 FunctionElementX(String name, | 1904 FunctionElementX(String name, |
| 1875 ElementKind kind, | 1905 ElementKind kind, |
| 1876 Modifiers modifiers, | 1906 Modifiers modifiers, |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2031 compiler.internalError(this, '$this.computeType.'); | 2061 compiler.internalError(this, '$this.computeType.'); |
| 2032 return null; | 2062 return null; |
| 2033 } | 2063 } |
| 2034 | 2064 |
| 2035 Token get position => constructor.position; | 2065 Token get position => constructor.position; |
| 2036 | 2066 |
| 2037 Element get outermostEnclosingMemberOrTopLevel => constructor; | 2067 Element get outermostEnclosingMemberOrTopLevel => constructor; |
| 2038 | 2068 |
| 2039 Element get analyzableElement => constructor.analyzableElement; | 2069 Element get analyzableElement => constructor.analyzableElement; |
| 2040 | 2070 |
| 2041 accept(ElementVisitor visitor) => visitor.visitConstructorBodyElement(this); | 2071 accept(ElementVisitor visitor, arg) { |
| 2072 return visitor.visitConstructorBodyElement(this, arg); |
| 2073 } |
| 2042 | 2074 |
| 2043 MemberElement get memberContext => constructor; | 2075 MemberElement get memberContext => constructor; |
| 2044 } | 2076 } |
| 2045 | 2077 |
| 2046 /** | 2078 /** |
| 2047 * A constructor that is not defined in the source code but rather implied by | 2079 * A constructor that is not defined in the source code but rather implied by |
| 2048 * the language semantics. | 2080 * the language semantics. |
| 2049 * | 2081 * |
| 2050 * This class is used to represent default constructors and forwarding | 2082 * This class is used to represent default constructors and forwarding |
| 2051 * constructors for mixin applications. | 2083 * constructors for mixin applications. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2085 if (definingConstructor.isErroneous) { | 2117 if (definingConstructor.isErroneous) { |
| 2086 return functionSignatureCache = | 2118 return functionSignatureCache = |
| 2087 compiler.objectClass.localLookup('').computeSignature(compiler); | 2119 compiler.objectClass.localLookup('').computeSignature(compiler); |
| 2088 } | 2120 } |
| 2089 // TODO(johnniwinther): Ensure that the function signature (and with it the | 2121 // TODO(johnniwinther): Ensure that the function signature (and with it the |
| 2090 // function type) substitutes type variables correctly. | 2122 // function type) substitutes type variables correctly. |
| 2091 return functionSignatureCache = | 2123 return functionSignatureCache = |
| 2092 definingConstructor.computeSignature(compiler); | 2124 definingConstructor.computeSignature(compiler); |
| 2093 } | 2125 } |
| 2094 | 2126 |
| 2095 accept(ElementVisitor visitor) { | 2127 accept(ElementVisitor visitor, arg) { |
| 2096 return visitor.visitFunctionElement(this); | 2128 return visitor.visitFunctionElement(this, arg); |
| 2097 } | 2129 } |
| 2098 } | 2130 } |
| 2099 | 2131 |
| 2100 abstract class TypeDeclarationElementX<T extends GenericType> | 2132 abstract class TypeDeclarationElementX<T extends GenericType> |
| 2101 implements TypeDeclarationElement { | 2133 implements TypeDeclarationElement { |
| 2102 /** | 2134 /** |
| 2103 * The `this type` for this type declaration. | 2135 * The `this type` for this type declaration. |
| 2104 * | 2136 * |
| 2105 * The type of [:this:] is the generic type based on this element in which | 2137 * The type of [:this:] is the generic type based on this element in which |
| 2106 * the type arguments are the declared type variables. For instance, | 2138 * the type arguments are the declared type variables. For instance, |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2690 @override | 2722 @override |
| 2691 Token get position => node.name.token; | 2723 Token get position => node.name.token; |
| 2692 | 2724 |
| 2693 @override | 2725 @override |
| 2694 bool get isEnumClass => true; | 2726 bool get isEnumClass => true; |
| 2695 | 2727 |
| 2696 @override | 2728 @override |
| 2697 Node parseNode(Compiler compiler) => node; | 2729 Node parseNode(Compiler compiler) => node; |
| 2698 | 2730 |
| 2699 @override | 2731 @override |
| 2700 accept(ElementVisitor visitor) => visitor.visitEnumClassElement(this); | 2732 accept(ElementVisitor visitor, arg) { |
| 2733 return visitor.visitEnumClassElement(this, arg); |
| 2734 } |
| 2701 | 2735 |
| 2702 List<DartType> computeTypeParameters(Compiler compiler) => const <DartType>[]; | 2736 List<DartType> computeTypeParameters(Compiler compiler) => const <DartType>[]; |
| 2703 | 2737 |
| 2704 List<FieldElement> get enumValues { | 2738 List<FieldElement> get enumValues { |
| 2705 assert(invariant(this, _enumValues != null, | 2739 assert(invariant(this, _enumValues != null, |
| 2706 message: "enumValues has not been computed for $this.")); | 2740 message: "enumValues has not been computed for $this.")); |
| 2707 return _enumValues; | 2741 return _enumValues; |
| 2708 } | 2742 } |
| 2709 | 2743 |
| 2710 void set enumValues(List<FieldElement> values) { | 2744 void set enumValues(List<FieldElement> values) { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2850 List<DartType> computeTypeParameters(Compiler compiler) { | 2884 List<DartType> computeTypeParameters(Compiler compiler) { |
| 2851 NamedMixinApplication named = node.asNamedMixinApplication(); | 2885 NamedMixinApplication named = node.asNamedMixinApplication(); |
| 2852 if (named == null) { | 2886 if (named == null) { |
| 2853 throw new SpannableAssertionFailure(node, | 2887 throw new SpannableAssertionFailure(node, |
| 2854 "Type variables on unnamed mixin applications must be set on " | 2888 "Type variables on unnamed mixin applications must be set on " |
| 2855 "creation."); | 2889 "creation."); |
| 2856 } | 2890 } |
| 2857 return createTypeVariables(named.typeParameters); | 2891 return createTypeVariables(named.typeParameters); |
| 2858 } | 2892 } |
| 2859 | 2893 |
| 2860 accept(ElementVisitor visitor) => visitor.visitMixinApplicationElement(this); | 2894 accept(ElementVisitor visitor, arg) { |
| 2895 return visitor.visitMixinApplicationElement(this, arg); |
| 2896 } |
| 2861 } | 2897 } |
| 2862 | 2898 |
| 2863 class LabelDefinitionX implements LabelDefinition { | 2899 class LabelDefinitionX implements LabelDefinition { |
| 2864 final Label label; | 2900 final Label label; |
| 2865 final String labelName; | 2901 final String labelName; |
| 2866 final JumpTarget target; | 2902 final JumpTarget target; |
| 2867 bool isBreakTarget = false; | 2903 bool isBreakTarget = false; |
| 2868 bool isContinueTarget = false; | 2904 bool isContinueTarget = false; |
| 2869 | 2905 |
| 2870 LabelDefinitionX(Label label, String labelName, this.target) | 2906 LabelDefinitionX(Label label, String labelName, this.target) |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2939 message: "Bound has not been set on $this.")); | 2975 message: "Bound has not been set on $this.")); |
| 2940 return boundCache; | 2976 return boundCache; |
| 2941 } | 2977 } |
| 2942 | 2978 |
| 2943 bool get hasNode => true; | 2979 bool get hasNode => true; |
| 2944 | 2980 |
| 2945 Node parseNode(compiler) => node; | 2981 Node parseNode(compiler) => node; |
| 2946 | 2982 |
| 2947 Token get position => node.getBeginToken(); | 2983 Token get position => node.getBeginToken(); |
| 2948 | 2984 |
| 2949 accept(ElementVisitor visitor) => visitor.visitTypeVariableElement(this); | 2985 accept(ElementVisitor visitor, arg) { |
| 2986 return visitor.visitTypeVariableElement(this, arg); |
| 2987 } |
| 2950 | 2988 |
| 2951 // A type variable cannot be patched therefore defines itself. | 2989 // A type variable cannot be patched therefore defines itself. |
| 2952 AstElement get definingElement => this; | 2990 AstElement get definingElement => this; |
| 2953 } | 2991 } |
| 2954 | 2992 |
| 2955 /** | 2993 /** |
| 2956 * A single metadata annotation. | 2994 * A single metadata annotation. |
| 2957 * | 2995 * |
| 2958 * For example, consider: | 2996 * For example, consider: |
| 2959 * | 2997 * |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3070 AstElement get definingElement; | 3108 AstElement get definingElement; |
| 3071 | 3109 |
| 3072 bool get hasResolvedAst => definingElement.hasTreeElements; | 3110 bool get hasResolvedAst => definingElement.hasTreeElements; |
| 3073 | 3111 |
| 3074 ResolvedAst get resolvedAst { | 3112 ResolvedAst get resolvedAst { |
| 3075 return new ResolvedAst(declaration, | 3113 return new ResolvedAst(declaration, |
| 3076 definingElement.node, definingElement.treeElements); | 3114 definingElement.node, definingElement.treeElements); |
| 3077 } | 3115 } |
| 3078 | 3116 |
| 3079 } | 3117 } |
| OLD | NEW |