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

Unified Diff: pkg/analyzer/lib/src/dart/element/element.dart

Issue 2032663002: Start making constructor elements lazy. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/resynthesize.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/element/element.dart
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index b504fdbb1c5724da6e9352c55fe41ed8cd64995d..97d87084aa9b1f661f65718dc1232490059a9a3f 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -1876,6 +1876,11 @@ class ConstLocalVariableElementImpl extends LocalVariableElementImpl
class ConstructorElementImpl extends ExecutableElementImpl
implements ConstructorElement {
/**
+ * Set of slots corresponding to const constructors that are part of cycles.
+ */
+ final Set<int> _constCycles;
+
+ /**
* The constructor to which this constructor is redirecting.
*/
ConstructorElement redirectedConstructor;
@@ -1889,36 +1894,40 @@ class ConstructorElementImpl extends ExecutableElementImpl
/**
* The offset of the `.` before this constructor name or `null` if not named.
*/
- int periodOffset;
+ int _periodOffset;
/**
* Return the offset of the character immediately following the last character
* of this constructor's name, or `null` if not named.
*/
- int nameEnd;
+ int _nameEnd;
/**
* True if this constructor has been found by constant evaluation to be free
* of redirect cycles, and is thus safe to evaluate.
*/
- bool isCycleFree = false;
+ bool _isCycleFree = false;
/**
* Initialize a newly created constructor element to have the given [name] and
* [offset].
*/
- ConstructorElementImpl(String name, int offset) : super(name, offset);
+ ConstructorElementImpl(String name, int offset)
+ : _constCycles = null,
+ super(name, offset);
/**
* Initialize a newly created constructor element to have the given [name].
*/
- ConstructorElementImpl.forNode(Identifier name) : super.forNode(name);
+ ConstructorElementImpl.forNode(Identifier name)
+ : _constCycles = null,
+ super.forNode(name);
/**
* Initialize using the given serialized information.
*/
- ConstructorElementImpl.forSerialized(
- UnlinkedExecutable serializedExecutable, ClassElementImpl enclosingClass)
+ ConstructorElementImpl.forSerialized(UnlinkedExecutable serializedExecutable,
+ this._constCycles, ClassElementImpl enclosingClass)
: super.forSerialized(serializedExecutable, enclosingClass);
/**
@@ -1952,6 +1961,19 @@ class ConstructorElementImpl extends ExecutableElementImpl
return hasModifier(Modifier.CONST);
}
+ bool get isCycleFree {
+ if (serializedExecutable != null) {
+ return serializedExecutable.isConst &&
+ !_constCycles.contains(serializedExecutable.constCycleSlot);
+ }
+ return _isCycleFree;
+ }
+
+ void set isCycleFree(bool isCycleFree) {
+ assert(serializedExecutable == null);
+ _isCycleFree = isCycleFree;
+ }
+
@override
bool get isDefaultConstructor {
// unnamed
@@ -1984,6 +2006,37 @@ class ConstructorElementImpl extends ExecutableElementImpl
ElementKind get kind => ElementKind.CONSTRUCTOR;
@override
+ int get nameEnd {
+ if (serializedExecutable != null) {
+ if (serializedExecutable.name.isNotEmpty) {
+ return serializedExecutable.nameEnd;
+ } else {
+ return serializedExecutable.nameOffset + enclosingElement.name.length;
+ }
+ }
+ return _nameEnd;
+ }
+
+ void set nameEnd(int nameEnd) {
+ assert(serializedExecutable == null);
+ _nameEnd = nameEnd;
+ }
+
+ int get periodOffset {
+ if (serializedExecutable != null) {
+ if (serializedExecutable.name.isNotEmpty) {
+ return serializedExecutable.periodOffset;
+ }
+ }
+ return _periodOffset;
+ }
+
+ void set periodOffset(int periodOffset) {
+ assert(serializedExecutable == null);
+ _periodOffset = periodOffset;
+ }
+
+ @override
DartType get returnType => enclosingElement.type;
@override
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/resynthesize.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698