Chromium Code Reviews| 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..02a056cd37042364922e267d25a4eecdb8be0633 100644 |
| --- a/lib/compiler/implementation/elements/elements.dart |
| +++ b/lib/compiler/implementation/elements/elements.dart |
| @@ -107,7 +107,7 @@ class ElementKind { |
| toString() => id; |
| } |
| -class Element implements Hashable { |
| +class Element implements Hashable, Spanable { |
|
ahe
2012/09/20 11:12:07
It's "spanned" and "spanning", so shouldn't it be
Johnni Winther
2012/09/21 09:18:25
Probably :)
|
| final SourceString name; |
| final ElementKind kind; |
| final Element enclosingElement; |
| @@ -171,6 +171,60 @@ class Element implements Hashable { |
| /** See [ErroneousElement] for documentation. */ |
| bool isErroneous() => false; |
| + //---------------------------------------------------------------------------- |
|
ahe
2012/09/20 11:12:07
Can you remove this comment now?
Johnni Winther
2012/09/21 09:18:25
Done.
|
| + // Patch related getters. See [:patch_parser.dart:] for a description of the |
| + // terminology. |
| + //---------------------------------------------------------------------------- |
| + |
| + /** |
| + * Is [:true:] iff this element has a corresponding patch. |
|
ahe
2012/09/20 11:12:07
Don't use "iff" or "if and only if" in documentati
Johnni Winther
2012/09/21 09:18:25
Done.
|
| + * |
| + * If [:true:] this element has a non-null [patch] field. |
| + * |
| + * See [:patch_parser.dart:] for a description of the terminology. |
| + */ |
| + bool get isPatched => false; |
| + |
| + /** |
| + * Is [:true:] iff this element is a patch. |
| + * |
| + * If [:true:] this element has a non-null [origin] field. |
| + * |
| + * See [:patch_parser.dart:] for a description of the terminology. |
| + */ |
| + bool get isPatch => false; |
| + |
| + |
| + /** |
| + * Is [:true:] iff this element defines the implementation for the entity of |
| + * this element. |
| + * |
| + * See [:patch_parser.dart:] for a description of the terminology. |
| + */ |
| + bool get isImplementation => implementation === this; |
| + |
| + /** |
| + * Is [:true:] iff this element introduces the entity of this element. |
| + * |
| + * See [:patch_parser.dart:] for a description of the terminology. |
| + */ |
| + bool get isDeclaration => declaration === this; |
| + |
| + /** |
| + * Returns the element which defines the implementation for the entity of this |
| + * element. |
| + * |
| + * See [:patch_parser.dart:] for a description of the terminology. |
| + */ |
| + Element get implementation => this; |
| + |
| + /** |
| + * Returns the element which introduces the entity of this element. |
| + * |
| + * See [:patch_parser.dart:] for a description of the terminology. |
| + */ |
| + 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 +283,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 +350,6 @@ class Element implements Hashable { |
| Element cloneTo(Element enclosing, DiagnosticListener listener) { |
| listener.cancel("Unimplemented cloneTo", element: this); |
| } |
| - |
| - bool get isPatched => false; |
| } |
| /** |
| @@ -345,8 +399,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 +1036,18 @@ class FunctionElement extends Element { |
| FunctionType computeType(Compiler compiler) { |
| if (type != null) return type; |
| - type = compiler.computeFunctionType(this, computeSignature(compiler)); |
| + type = compiler.computeFunctionType(declaration, |
| + computeSignature(compiler)); |
| return type; |
| } |
| Node parseNode(DiagnosticListener listener) { |
|
ahe
2012/09/20 11:12:07
I think this method is fishy. It concerns me great
Johnni Winther
2012/09/21 09:18:25
Bad merge. These should not have been removed unti
|
| - 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 +1055,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 +1211,12 @@ class ClassElement extends ScopeContainerElement |
| bool get isPatched => patch != null; |
| + /** |
| + * Return [:true:] if this element is the [:Object:] class for the [compiler]. |
|
ahe
2012/09/20 11:12:07
This is not using "iff" and is perfectly clear.
|
| + */ |
| + bool isObject(Compiler compiler) => |
| + declaration === compiler.objectClass; |
| + |
| Link<DartType> get typeVariables => type.arguments; |
| ClassElement ensureResolved(Compiler compiler) { |