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

Unified Diff: dart/frog/leg/elements/elements.dart

Issue 9283031: Build script tags. (Closed) Base URL: ssh://aaricia.aar/home/ahe/Dart/all/dart.googlecode.com.git@script
Patch Set: Created 8 years, 11 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: dart/frog/leg/elements/elements.dart
diff --git a/dart/frog/leg/elements/elements.dart b/dart/frog/leg/elements/elements.dart
index 72fd376866d0b19decfb39bc815b5f247b635a3b..d4f91d9b081c277eea8d048a9027418bff5b82ab 100644
--- a/dart/frog/leg/elements/elements.dart
+++ b/dart/frog/leg/elements/elements.dart
@@ -50,7 +50,6 @@ class Element implements Hashable {
final Element enclosingElement;
Modifiers get modifiers() => null;
-
Node parseNode(Canceler canceler, Logger logger) {
canceler.cancel("Internal Error: Element.parseNode");
}
@@ -87,13 +86,38 @@ class Element implements Hashable {
toString() => '$kind($name)';
}
-class CompilationUnitElement extends Element {
+class EnclosingElement extends Element {
ngeoffray 2012/01/25 09:04:59 EnclosingElement -> ContainerElement? Because oth
ahe 2012/01/25 09:18:53 I was planning on making the other elements subcla
ahe 2012/01/25 09:28:53 Done.
+ EnclosingElement(name, kind, enclosingElement) :
+ super(name, kind, enclosingElement);
+
+ abstract void addMember(Element element, Canceler canceler);
+}
+
+class CompilationUnitElement extends EnclosingElement {
final Script script;
+ Link<Element> topLevelElements = const EmptyLink<Element>();
+ Link<ScriptTag> tags = const EmptyLink<ScriptTag>();
+ final Map<SourceString, Element> scope;
+
CompilationUnitElement(Script script, Element enclosing)
: super(new SourceString(script.name),
ElementKind.COMPILATION_UNIT,
enclosing),
- this.script = script;
+ this.script = script,
+ this.scope = new Map<SourceString, Element>();
+
+ void addMember(Element element, Canceler canceler) {
+ topLevelElements = topLevelElements.prepend(element);
+ Element existing = scope.putIfAbsent(element.name, ()=>element);
ngeoffray 2012/01/25 09:04:59 spaces around => ?
+ if (existing !== element) {
ngeoffray 2012/01/25 09:04:59 Is this the right place to do it? Do we want a per
ahe 2012/01/25 09:18:53 You're right, there is not much value in reporting
ahe 2012/01/25 09:28:53 Done.
+ canceler.cancel('duplicate definition', token: element.position());
+ canceler.cancel('existing definition', token: existing.position());
+ }
+ }
+
+ void addTag(ScriptTag tag) {
+ tags = tags.prepend(tag);
+ }
}
class VariableElement extends Element {
@@ -329,7 +353,7 @@ class SynthesizedConstructorElement extends FunctionElement {
Token position() => null;
}
-class ClassElement extends Element {
+class ClassElement extends EnclosingElement {
Type type;
Type supertype;
Link<Element> members = const EmptyLink<Element>();
@@ -347,7 +371,7 @@ class ClassElement extends Element {
constructors = new Map<SourceString, Element>(),
super(name, ElementKind.CLASS, enclosing);
- void addMember(Element element) {
+ void addMember(Element element, Canceler canceler) {
members = members.prepend(element);
if (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR ||
element.modifiers.isFactory()) {

Powered by Google App Engine
This is Rietveld 408576698