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

Unified Diff: lib/compiler/implementation/elements/elements.dart

Issue 10917285: Stub implementation of patch invariants for the patch refactoring. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Leftovers from rebase. Created 8 years, 3 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
Index: lib/compiler/implementation/elements/elements.dart
diff --git a/lib/compiler/implementation/elements/elements.dart b/lib/compiler/implementation/elements/elements.dart
index 72e3a9abfe799df7f460665595cecc8af2774902..7f2fc1c5b9736b6348aa15666c401287461d2225 100644
--- a/lib/compiler/implementation/elements/elements.dart
+++ b/lib/compiler/implementation/elements/elements.dart
@@ -171,6 +171,19 @@ class Element implements Hashable {
/** See [ErroneousElement] for documentation. */
bool isErroneous() => false;
+ //----------------------------------------------------------------------------
ahe 2012/09/18 11:25:54 What does this comment apply to? I think this is d
Johnni Winther 2012/09/20 08:12:23 Done.
+ // Patch related getters. See [:patch_parser.dart:] for a description of the
+ // terminology.
+ //----------------------------------------------------------------------------
+ bool get isPatched => false;
+ bool get isPatch => false;
+
+ bool get isImplementation => implementation === this;
+ bool get isDeclaration => declaration === this;
+
+ Element get implementation => this;
+ Element get declaration => this;
+
// TODO(johnniwinther): This breaks for libraries (for which enclosing
// elements are null) and is invalid for top level variable declarations for
// which the enclosing element is a VariableDeclarations and not a compilation
@@ -229,6 +242,8 @@ class Element implements Hashable {
return element;
}
+ LibraryElement getImplementationLibrary() => getLibrary();
+
ClassElement getEnclosingClass() {
for (Element e = this; e !== null; e = e.enclosingElement) {
if (e.isClass()) return e;
@@ -294,8 +309,6 @@ class Element implements Hashable {
Element cloneTo(Element enclosing, DiagnosticListener listener) {
listener.cancel("Unimplemented cloneTo", element: this);
}
-
- bool get isPatched => false;
}
/**
@@ -345,8 +358,10 @@ class ErroneousFunctionElement extends ErroneousElement
get cachedNode => unsupported();
get functionSignature => unsupported();
get patch => unsupported();
+ get origin => unsupported();
get defaultImplementation => unsupported();
bool get isPatched => unsupported();
+ bool get isPatch => unsupported();
setPatch(patch) => unsupported();
computeSignature(compiler) => unsupported();
requiredParameterCount(compiler) => unsupported();
@@ -980,20 +995,18 @@ class FunctionElement extends Element {
FunctionType computeType(Compiler compiler) {
if (type != null) return type;
- type = compiler.computeFunctionType(this, computeSignature(compiler));
+ type = compiler.computeFunctionType(declaration,
ngeoffray 2012/09/17 12:46:24 Why this change?
Johnni Winther 2012/09/20 08:12:23 To enforce the invariant that DartType.element is
+ computeSignature(compiler));
return type;
}
Node parseNode(DiagnosticListener listener) {
- if (cachedNode !== null) return cachedNode;
if (patch === null) {
- if (modifiers.isExternal()) {
+ if (modifiers != null && modifiers.isExternal()) {
listener.cancel("Compiling external function with no implementation.",
element: this);
}
- return null;
}
- cachedNode = patch.parseNode(listener);
return cachedNode;
}
@@ -1001,25 +1014,27 @@ class FunctionElement extends Element {
FunctionElement asFunctionElement() => this;
- FunctionElement cloneTo(Element enclosing, DiagnosticListener listener) {
- FunctionElement result = new FunctionElement.tooMuchOverloading(
- name, cachedNode, kind, modifiers, enclosing, functionSignature);
- result.defaultImplementation = defaultImplementation;
- result.type = type;
- return result;
+ String toString() {
+ if (isPatch) {
+ return 'patch ${super.toString()}';
+ } else if (isPatched) {
+ return 'origin ${super.toString()}';
+ } else {
+ return super.toString();
+ }
}
Scope buildScope() {
- Scope result = new MethodScope(enclosingElement.buildScope(), this);
+ Scope result =
+ new MethodScope(enclosingElement.buildScope(), this);
if (enclosingElement.isClass()) {
- ClassScope clsScope = result.parent;
+ Scope clsScope = result.parent;
clsScope.inStaticContext = !isInstanceMember() && !isConstructor();
}
return result;
}
}
-
class ConstructorBodyElement extends FunctionElement {
FunctionElement constructor;
@@ -1155,6 +1170,8 @@ class ClassElement extends ScopeContainerElement
bool get isPatched => patch != null;
+ bool get isObject => supertype === null;
ngeoffray 2012/09/17 12:46:24 This is fragile: the class may not have been resol
Johnni Winther 2012/09/20 08:12:23 Changed to a less fragile method call.
+
Link<DartType> get typeVariables => type.arguments;
ClassElement ensureResolved(Compiler compiler) {

Powered by Google App Engine
This is Rietveld 408576698