Index: lib/compiler/implementation/elements/elements.dart |
diff --git a/lib/compiler/implementation/elements/elements.dart b/lib/compiler/implementation/elements/elements.dart |
index 0c51eb972192aff1e0381c3e793d202e4091d69a..6736b57ef0d87732f74056afb838ea413bb7c20b 100644 |
--- a/lib/compiler/implementation/elements/elements.dart |
+++ b/lib/compiler/implementation/elements/elements.dart |
@@ -102,7 +102,6 @@ class Element implements Hashable { |
final SourceString name; |
final ElementKind kind; |
final Element enclosingElement; |
- Script scriptOverride = null; |
Link<Node> metadata = const EmptyLink<Node>(); |
Modifiers get modifiers() => null; |
@@ -176,11 +175,6 @@ class Element implements Hashable { |
// the same hash code. Replace this with a simple id in the element? |
int hashCode() => name.hashCode(); |
- Script getScript() { |
- if (scriptOverride !== null) return scriptOverride; |
- return getCompilationUnit().script; |
- } |
- |
CompilationUnitElement getCompilationUnit() { |
Element element = this; |
while (element !== null && !element.isCompilationUnit()) { |
@@ -236,10 +230,6 @@ class Element implements Hashable { |
bool isNative() => _isNative; |
FunctionElement asFunctionElement() => null; |
- |
- Element cloneTo(Element enclosing, DiagnosticListener listener) { |
- listener.cancel("Unimplemented cloneTo", element: this); |
- } |
} |
class ContainerElement extends Element { |
@@ -406,22 +396,23 @@ class LibraryElement extends CompilationUnitElement { |
class PrefixElement extends Element { |
Map<SourceString, Element> imported; |
Token firstPosition; |
+ final CompilationUnitElement patchSource; |
- PrefixElement(SourceString prefix, Element enclosing, this.firstPosition) |
- : imported = new Map<SourceString, Element>(), |
- super(prefix, ElementKind.PREFIX, enclosing); |
+ PrefixElement(SourceString prefix, Element enclosing, this.firstPosition, |
+ [this.patchSource]) |
+ : imported = new Map<SourceString, Element>(), |
+ super(prefix, ElementKind.PREFIX, enclosing); |
+ |
+ CompilationUnitElement getCompilationUnit() { |
+ if (patchSource !== null) return patchSource; |
+ return super.getCompilationUnit(); |
+ } |
lookupLocalMember(SourceString memberName) => imported[memberName]; |
Type computeType(Compiler compiler) => compiler.types.dynamicType; |
Token position() => firstPosition; |
- |
- PrefixElement cloneTo(Element enclosing, DiagnosticListener listener) { |
- PrefixElement result = new PrefixElement(name, enclosing, firstPosition); |
- result.scriptOverride = getScript(); |
- return result; |
- } |
} |
class TypedefElement extends Element { |
@@ -437,12 +428,6 @@ class TypedefElement extends Element { |
this, compiler.resolveTypedef(this)); |
return cachedType; |
} |
- |
- TypedefElement cloneTo(Element enclosing, DiagnosticListener listener) { |
- TypedefElement result = new TypedefElement(name, enclosing); |
- result.scriptOverride = getScript(); |
- return result; |
- } |
} |
class VariableElement extends Element { |
@@ -489,15 +474,6 @@ class VariableElement extends Element { |
// Note: cachedNode.getBeginToken() will not be correct in all |
// cases, for example, for function typed parameters. |
Token position() => findMyName(variables.position()); |
- |
- VariableElement cloneTo(Element enclosing, DiagnosticListener listener) { |
- VariableListElement clonedVariables = |
- variables.cloneTo(enclosing, listener); |
- VariableElement result = new VariableElement( |
- name, clonedVariables, kind, enclosing, cachedNode); |
- result.scriptOverride = getScript(); |
- return result; |
- } |
} |
/** |
@@ -513,16 +489,6 @@ class FieldParameterElement extends VariableElement { |
Element enclosing, |
Node node) |
: super(name, variables, ElementKind.FIELD_PARAMETER, enclosing, node); |
- |
- FieldParameterElement cloneTo(Element enclosing, |
- DiagnosticListener listener) { |
- FieldParameterElement result = |
- new FieldParameterElement(name, fieldElement, |
- variables.cloneTo(enclosing, listener), |
- enclosing, cachedNode); |
- result.scriptOverride = getScript(); |
- return result; |
- } |
} |
// This element represents a list of variable or field declaration. |
@@ -557,17 +523,6 @@ class VariableListElement extends Element { |
} |
Token position() => cachedNode.getBeginToken(); |
- |
- VariableListElement cloneTo(Element enclosing, DiagnosticListener listener) { |
- VariableListElement result; |
- if (cachedNode !== null) { |
- result = new VariableListElement(cachedNode, kind, enclosing); |
- } else { |
- result = new VariableListElement(kind, modifiers, enclosing); |
- } |
- result.scriptOverride = getScript(); |
- return result; |
- } |
} |
class ForeignElement extends Element { |
@@ -581,12 +536,6 @@ class ForeignElement extends Element { |
parseNode(DiagnosticListener listener) { |
throw "internal error: ForeignElement has no node"; |
} |
- |
- ForeignElement cloneTo(Element enclosing, DiagnosticListener listener) { |
- ForeignElement result = new ForeignElement(name, kind, enclosing); |
- result.scriptOverride = getScript(); |
- return result; |
- } |
} |
class AbstractFieldElement extends Element { |
@@ -631,11 +580,6 @@ class AbstractFieldElement extends Element { |
setter.modifiers.flags | Modifiers.FLAG_ABSTRACT); |
} |
} |
- |
- AbstractFieldElement cloneTo(Element enclosing, DiagnosticListener listener) { |
- listener.cancel("Cannot clone synthetic AbstractFieldElement", |
- element: this); |
- } |
} |
class FunctionSignature { |
@@ -718,9 +662,9 @@ class FunctionElement extends Element { |
defaultImplementation = this; |
} |
- Script getScript() { |
- if (patch !== null) return patch.getScript(); |
- return super.getScript(); |
+ CompilationUnitElement getCompilationUnit() { |
+ if (patch !== null) return patch.getCompilationUnit(); |
+ return super.getCompilationUnit(); |
} |
bool get isPatched() => patch !== null; |
@@ -788,18 +732,8 @@ class FunctionElement extends Element { |
Token position() => cachedNode.getBeginToken(); |
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; |
- result.scriptOverride = getScript(); |
- return result; |
- } |
} |
- |
class ConstructorBodyElement extends FunctionElement { |
FunctionElement constructor; |
@@ -826,14 +760,6 @@ class ConstructorBodyElement extends FunctionElement { |
} |
Token position() => constructor.position(); |
- |
- ConstructorBodyElement cloneTo(Element enclosing, |
- DiagnosticListener listener) { |
- ConstructorBodyElement result = |
- new ConstructorBodyElement(constructor.cloneTo(enclosing, listener)); |
- result.scriptOverride = getScript(); |
- return result; |
- } |
} |
class SynthesizedConstructorElement extends FunctionElement { |
@@ -842,11 +768,6 @@ class SynthesizedConstructorElement extends FunctionElement { |
null, enclosing); |
Token position() => enclosingElement.position(); |
- |
- SynthesizedConstructorElement cloneTo(Element enclosing, |
- DiagnosticListener listener) { |
- return new SynthesizedConstructorElement(enclosing); |
- } |
} |
class VoidElement extends Element { |
@@ -869,7 +790,6 @@ class ClassElement extends ContainerElement { |
Map<SourceString, Element> constructors; |
Link<Type> interfaces = const EmptyLink<Type>(); |
LinkedHashMap<SourceString, TypeVariableElement> typeParameters; |
- SourceString nativeName; |
bool isResolved = false; |
bool isBeingResolved = false; |
// backendMembers are members that have been added by the backend to simplify |
@@ -877,6 +797,7 @@ class ClassElement extends ContainerElement { |
Link<Element> backendMembers = const EmptyLink<Element>(); |
Link<Type> allSupertypes; |
+ ClassElement patch = null; |
ClassElement(SourceString name, CompilationUnitElement enclosing, this.id) |
: localMembers = new Map<SourceString, Element>(), |
@@ -1047,40 +968,8 @@ class ClassElement extends ContainerElement { |
bool isInterface() => false; |
bool isNative() => nativeName != null; |
+ SourceString nativeName; |
int hashCode() => id; |
- |
- void cloneMembersTo(Element target, DiagnosticListener listener) { |
- target.type = type; |
- target.supertype = supertype; |
- target.defaultClass = defaultClass; |
- target.interfaces = interfaces; |
- target.typeParameters = |
- new LinkedHashMap<SourceString, TypeVariableElement>(); |
- typeParameters.forEach((SourceString name, TypeVariableElement type) { |
- target.typeParameters[name] = type.cloneTo(target, listener); |
- }); |
- target.nativeName = nativeName; |
- target.isResolved = isResolved; |
- target.isBeingResolved = isBeingResolved; |
- target.allSupertypes = allSupertypes; |
- if (!backendMembers.isEmpty()) { |
- listener.cancel("Cloning backend-modified class.", element: this); |
- } |
- |
- Link<Element> elementList = this.members; |
- while (!elementList.isEmpty()) { |
- target.addMember(elementList.head.cloneTo(target, listener), listener); |
- elementList = elementList.tail; |
- } |
- } |
- |
- ClassElement cloneTo(Element enclosing, DiagnosticListener listener) { |
- // TODO(lrn): Is copying id acceptable? |
- ClassElement result = new ClassElement(name, enclosing, id); |
- cloneMembersTo(result, listener); |
- result.scriptOverride = getScript(); |
- return result; |
- } |
} |
class Elements { |
@@ -1201,6 +1090,7 @@ class Elements { |
} |
} |
+ |
class LabelElement extends Element { |
// We store the original label here so it can be returned by [parseNode]. |
final Label label; |
@@ -1267,11 +1157,4 @@ class TypeVariableElement extends Element { |
Type computeType(compiler) => type; |
Node parseNode(compiler) => node; |
toString() => "${enclosingElement.toString()}.${name.slowToString()}"; |
- |
- TypeVariableElement cloneTo(Element enclosing, DiagnosticListener listener) { |
- TypeVariableElement result = |
- new TypeVariableElement(name, enclosing, node, type, bound); |
- result.scriptOverride = getScript(); |
- return result; |
- } |
} |