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

Side by Side Diff: pkg/analyzer/lib/src/generated/element.dart

Issue 1050203002: Begin making copies of AST nodes for constants during resolution. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments and switch to using mixins. Created 5 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.element; 8 library engine.element;
9 9
10 import 'dart:collection'; 10 import 'dart:collection';
(...skipping 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 safelyVisitChildren(_functions, visitor); 1486 safelyVisitChildren(_functions, visitor);
1487 safelyVisitChildren(_typeAliases, visitor); 1487 safelyVisitChildren(_typeAliases, visitor);
1488 safelyVisitChildren(_types, visitor); 1488 safelyVisitChildren(_types, visitor);
1489 safelyVisitChildren(_variables, visitor); 1489 safelyVisitChildren(_variables, visitor);
1490 } 1490 }
1491 } 1491 }
1492 1492
1493 /** 1493 /**
1494 * A [FieldElement] for a 'const' field that has an initializer. 1494 * A [FieldElement] for a 'const' field that has an initializer.
1495 */ 1495 */
1496 class ConstFieldElementImpl extends FieldElementImpl { 1496 class ConstFieldElementImpl extends FieldElementImpl with ConstVariableElement {
1497 /** 1497 /**
1498 * The result of evaluating this variable's initializer. 1498 * The result of evaluating this variable's initializer.
1499 */ 1499 */
1500 EvaluationResultImpl _result; 1500 EvaluationResultImpl _result;
1501 1501
1502 /** 1502 /**
1503 * Initialize a newly created field element to have the given [name]. 1503 * Initialize a newly created field element to have the given [name].
1504 */ 1504 */
1505 ConstFieldElementImpl.con1(Identifier name) : super.forNode(name); 1505 ConstFieldElementImpl.con1(Identifier name) : super.forNode(name);
1506 1506
1507 /** 1507 /**
1508 * Initialize a newly created synthetic field element to have the given 1508 * Initialize a newly created synthetic field element to have the given
1509 * [name] and [offset]. 1509 * [name] and [offset].
1510 */ 1510 */
1511 ConstFieldElementImpl.con2(String name, int offset) : super(name, offset); 1511 ConstFieldElementImpl.con2(String name, int offset) : super(name, offset);
1512 1512
1513 @override 1513 @override
1514 EvaluationResultImpl get evaluationResult => _result; 1514 EvaluationResultImpl get evaluationResult => _result;
1515 1515
1516 @override 1516 @override
1517 void set evaluationResult(EvaluationResultImpl result) { 1517 void set evaluationResult(EvaluationResultImpl result) {
1518 this._result = result; 1518 this._result = result;
1519 } 1519 }
1520 } 1520 }
1521 1521
1522 /** 1522 /**
1523 * A [LocalVariableElement] for a local 'const' variable that has an 1523 * A [LocalVariableElement] for a local 'const' variable that has an
1524 * initializer. 1524 * initializer.
1525 */ 1525 */
1526 class ConstLocalVariableElementImpl extends LocalVariableElementImpl { 1526 class ConstLocalVariableElementImpl extends LocalVariableElementImpl
1527 with ConstVariableElement {
1527 /** 1528 /**
1528 * The result of evaluating this variable's initializer. 1529 * The result of evaluating this variable's initializer.
1529 */ 1530 */
1530 EvaluationResultImpl _result; 1531 EvaluationResultImpl _result;
1531 1532
1532 /** 1533 /**
1534 * Initialize a newly created local variable element to have the given [name]
1535 * and [offset].
1536 */
1537 ConstLocalVariableElementImpl(String name, int offset) : super(name, offset);
1538
1539 /**
1533 * Initialize a newly created local variable element to have the given [name]. 1540 * Initialize a newly created local variable element to have the given [name].
1534 */ 1541 */
1535 ConstLocalVariableElementImpl(Identifier name) : super.forNode(name); 1542 ConstLocalVariableElementImpl.forNode(Identifier name) : super.forNode(name);
1536 1543
1537 @override 1544 @override
1538 EvaluationResultImpl get evaluationResult => _result; 1545 EvaluationResultImpl get evaluationResult => _result;
1539 1546
1540 @override 1547 @override
1541 void set evaluationResult(EvaluationResultImpl result) { 1548 void set evaluationResult(EvaluationResultImpl result) {
1542 this._result = result; 1549 this._result = result;
1543 } 1550 }
1544 } 1551 }
1545 1552
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1622 */ 1629 */
1623 int periodOffset; 1630 int periodOffset;
1624 1631
1625 /** 1632 /**
1626 * Return the offset of the character immediately following the last character 1633 * Return the offset of the character immediately following the last character
1627 * of this constructor's name, or `null` if not named. 1634 * of this constructor's name, or `null` if not named.
1628 */ 1635 */
1629 int nameEnd; 1636 int nameEnd;
1630 1637
1631 /** 1638 /**
1639 * True if this constructor has been found by constant evaluation to be free
1640 * of redirect cycles, and is thus safe to evaluate.
1641 */
1642 bool isCycleFree = false;
1643
1644 /**
1632 * Initialize a newly created constructor element to have the given [name] and 1645 * Initialize a newly created constructor element to have the given [name] and
1633 * [offset]. 1646 * [offset].
1634 */ 1647 */
1635 ConstructorElementImpl(String name, int offset) : super(name, offset); 1648 ConstructorElementImpl(String name, int offset) : super(name, offset);
1636 1649
1637 /** 1650 /**
1638 * Initialize a newly created constructor element to have the given [name]. 1651 * Initialize a newly created constructor element to have the given [name].
1639 */ 1652 */
1640 ConstructorElementImpl.forNode(Identifier name) : super.forNode(name); 1653 ConstructorElementImpl.forNode(Identifier name) : super.forNode(name);
1641 1654
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1819 // instance. It would use more memory but speed up some operations. 1832 // instance. It would use more memory but speed up some operations.
1820 // We need to see how often the type is being re-computed. 1833 // We need to see how often the type is being re-computed.
1821 return new ConstructorMember(constructor, definingType); 1834 return new ConstructorMember(constructor, definingType);
1822 } 1835 }
1823 } 1836 }
1824 1837
1825 /** 1838 /**
1826 * A [TopLevelVariableElement] for a top-level 'const' variable that has an 1839 * A [TopLevelVariableElement] for a top-level 'const' variable that has an
1827 * initializer. 1840 * initializer.
1828 */ 1841 */
1829 class ConstTopLevelVariableElementImpl extends TopLevelVariableElementImpl { 1842 class ConstTopLevelVariableElementImpl extends TopLevelVariableElementImpl
1843 with ConstVariableElement {
1830 /** 1844 /**
1831 * The result of evaluating this variable's initializer. 1845 * The result of evaluating this variable's initializer.
1832 */ 1846 */
1833 EvaluationResultImpl _result; 1847 EvaluationResultImpl _result;
1834 1848
1835 /** 1849 /**
1836 * Initialize a newly created top-level variable element to have the given 1850 * Initialize a newly created top-level variable element to have the given
1837 * [name]. 1851 * [name].
1838 */ 1852 */
1839 ConstTopLevelVariableElementImpl(Identifier name) : super.forNode(name); 1853 ConstTopLevelVariableElementImpl(Identifier name) : super.forNode(name);
1840 1854
1841 @override 1855 @override
1842 EvaluationResultImpl get evaluationResult => _result; 1856 EvaluationResultImpl get evaluationResult => _result;
1843 1857
1844 @override 1858 @override
1845 void set evaluationResult(EvaluationResultImpl result) { 1859 void set evaluationResult(EvaluationResultImpl result) {
1846 this._result = result; 1860 this._result = result;
1847 } 1861 }
1848 } 1862 }
1849 1863
1850 /** 1864 /**
1865 * Mixin used by elements that represent constant variables and have
1866 * initializers.
1867 *
1868 * Note that in correct Dart code, all constant variables must have
1869 * initializers. However, analyzer also needs to handle incorrect Dart code,
1870 * in which case there might be some constant variables that lack initializers.
1871 * This interface is only used for constant variables that have initializers.
1872 *
1873 * This class is not intended to be part of the public API for analyzer.
1874 */
1875 abstract class ConstVariableElement implements PotentiallyConstVariableElement {
1876 /**
1877 * If this element represents a constant variable, and it has an initializer,
1878 * a copy of the initializer for the constant. Otherwise `null`.
1879 *
1880 * Note that in correct Dart code, all constant variables must have
1881 * initializers. However, analyzer also needs to handle incorrect Dart code,
1882 * in which case there might be some constant variables that lack
1883 * initializers.
1884 */
1885 Expression constantInitializer;
1886 }
1887
1888 /**
1851 * The type associated with elements in the element model. 1889 * The type associated with elements in the element model.
1852 */ 1890 */
1853 abstract class DartType { 1891 abstract class DartType {
1854 /** 1892 /**
1855 * Return the name of this type as it should appear when presented to users in 1893 * Return the name of this type as it should appear when presented to users in
1856 * contexts such as error messages. 1894 * contexts such as error messages.
1857 */ 1895 */
1858 String get displayName; 1896 String get displayName;
1859 1897
1860 /** 1898 /**
(...skipping 1864 matching lines...) Expand 10 before | Expand all | Expand 10 after
3725 * so parsing and resolving will be performed. 3763 * so parsing and resolving will be performed.
3726 */ 3764 */
3727 @override 3765 @override
3728 AstNode get node; 3766 AstNode get node;
3729 } 3767 }
3730 3768
3731 /** 3769 /**
3732 * A concrete implementation of a [FieldElement]. 3770 * A concrete implementation of a [FieldElement].
3733 */ 3771 */
3734 class FieldElementImpl extends PropertyInducingElementImpl 3772 class FieldElementImpl extends PropertyInducingElementImpl
3735 implements FieldElement { 3773 with PotentiallyConstVariableElement implements FieldElement {
3736 /** 3774 /**
3737 * An empty list of field elements. 3775 * An empty list of field elements.
3738 */ 3776 */
3739 static const List<FieldElement> EMPTY_ARRAY = const <FieldElement>[]; 3777 static const List<FieldElement> EMPTY_ARRAY = const <FieldElement>[];
3740 3778
3741 /** 3779 /**
3742 * Initialize a newly created synthetic field element to have the given [name] 3780 * Initialize a newly created synthetic field element to have the given [name]
3743 * at the given [offset]. 3781 * at the given [offset].
3744 */ 3782 */
3745 FieldElementImpl(String name, int offset) : super(name, offset); 3783 FieldElementImpl(String name, int offset) : super(name, offset);
(...skipping 3582 matching lines...) Expand 10 before | Expand all | Expand 10 after
7328 7366
7329 /** 7367 /**
7330 * A local variable. 7368 * A local variable.
7331 */ 7369 */
7332 abstract class LocalVariableElement implements LocalElement, VariableElement {} 7370 abstract class LocalVariableElement implements LocalElement, VariableElement {}
7333 7371
7334 /** 7372 /**
7335 * A concrete implementation of a [LocalVariableElement]. 7373 * A concrete implementation of a [LocalVariableElement].
7336 */ 7374 */
7337 class LocalVariableElementImpl extends VariableElementImpl 7375 class LocalVariableElementImpl extends VariableElementImpl
7338 implements LocalVariableElement { 7376 with PotentiallyConstVariableElement implements LocalVariableElement {
7339 /** 7377 /**
7340 * An empty list of field elements. 7378 * An empty list of field elements.
7341 */ 7379 */
7342 static const List<LocalVariableElement> EMPTY_ARRAY = 7380 static const List<LocalVariableElement> EMPTY_ARRAY =
7343 const <LocalVariableElement>[]; 7381 const <LocalVariableElement>[];
7344 7382
7345 /** 7383 /**
7346 * The offset to the beginning of the visible range for this element. 7384 * The offset to the beginning of the visible range for this element.
7347 */ 7385 */
7348 int _visibleRangeOffset = 0; 7386 int _visibleRangeOffset = 0;
(...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after
8520 // We need to see how often the type is being re-computed. 8558 // We need to see how often the type is being re-computed.
8521 if (isFieldFormal) { 8559 if (isFieldFormal) {
8522 return new FieldFormalParameterMember( 8560 return new FieldFormalParameterMember(
8523 parameter as FieldFormalParameterElement, definingType); 8561 parameter as FieldFormalParameterElement, definingType);
8524 } 8562 }
8525 return new ParameterMember(parameter, definingType); 8563 return new ParameterMember(parameter, definingType);
8526 } 8564 }
8527 } 8565 }
8528 8566
8529 /** 8567 /**
8568 * Interface used by elements that might represent constant variables.
8569 *
8570 * This class may be used as a mixin in the case where [constInitializer] is
8571 * known to return null.
8572 *
8573 * This class is not intended to be part of the public API for analyzer.
8574 */
8575 abstract class PotentiallyConstVariableElement {
8576 /**
8577 * If this element represents a constant variable, and it has an initializer,
8578 * a copy of the initializer for the constant. Otherwise `null`.
8579 *
8580 * Note that in correct Dart code, all constant variables must have
8581 * initializers. However, analyzer also needs to handle incorrect Dart code,
8582 * in which case there might be some constant variables that lack
8583 * initializers.
8584 */
8585 Expression get constantInitializer => null;
8586 }
8587
8588 /**
8530 * A prefix used to import one or more libraries into another library. 8589 * A prefix used to import one or more libraries into another library.
8531 */ 8590 */
8532 abstract class PrefixElement implements Element { 8591 abstract class PrefixElement implements Element {
8533 /** 8592 /**
8534 * Return the library into which other libraries are imported using this 8593 * Return the library into which other libraries are imported using this
8535 * prefix. 8594 * prefix.
8536 */ 8595 */
8537 @override 8596 @override
8538 LibraryElement get enclosingElement; 8597 LibraryElement get enclosingElement;
8539 8598
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
9300 9359
9301 /** 9360 /**
9302 * A top-level variable. 9361 * A top-level variable.
9303 */ 9362 */
9304 abstract class TopLevelVariableElement implements PropertyInducingElement {} 9363 abstract class TopLevelVariableElement implements PropertyInducingElement {}
9305 9364
9306 /** 9365 /**
9307 * A concrete implementation of a [TopLevelVariableElement]. 9366 * A concrete implementation of a [TopLevelVariableElement].
9308 */ 9367 */
9309 class TopLevelVariableElementImpl extends PropertyInducingElementImpl 9368 class TopLevelVariableElementImpl extends PropertyInducingElementImpl
9310 implements TopLevelVariableElement { 9369 with PotentiallyConstVariableElement implements TopLevelVariableElement {
9311 /** 9370 /**
9312 * An empty list of top-level variable elements. 9371 * An empty list of top-level variable elements.
9313 */ 9372 */
9314 static const List<TopLevelVariableElement> EMPTY_ARRAY = 9373 static const List<TopLevelVariableElement> EMPTY_ARRAY =
9315 const <TopLevelVariableElement>[]; 9374 const <TopLevelVariableElement>[];
9316 9375
9317 /** 9376 /**
9318 * Initialize a newly created synthetic top-level variable element to have the 9377 * Initialize a newly created synthetic top-level variable element to have the
9319 * given [name] and [offset]. 9378 * given [name] and [offset].
9320 */ 9379 */
(...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after
10453 // void <: void (by reflexivity) 10512 // void <: void (by reflexivity)
10454 // bottom <: void (as bottom is a subtype of all types). 10513 // bottom <: void (as bottom is a subtype of all types).
10455 // void <: dynamic (as dynamic is a supertype of all types) 10514 // void <: dynamic (as dynamic is a supertype of all types)
10456 return identical(type, this) || type.isDynamic; 10515 return identical(type, this) || type.isDynamic;
10457 } 10516 }
10458 10517
10459 @override 10518 @override
10460 VoidTypeImpl substitute2( 10519 VoidTypeImpl substitute2(
10461 List<DartType> argumentTypes, List<DartType> parameterTypes) => this; 10520 List<DartType> argumentTypes, List<DartType> parameterTypes) => this;
10462 } 10521 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698