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

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

Issue 8924001: First implementation of top-level fields without initializers. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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 | frog/leg/resolver.dart » ('j') | frog/leg/scanner/listener.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/leg/elements/elements.dart
===================================================================
--- frog/leg/elements/elements.dart (revision 2339)
+++ frog/leg/elements/elements.dart (working copy)
@@ -30,6 +30,9 @@
static final ElementKind CLASS = const ElementKind('class');
static final ElementKind FOREIGN = const ElementKind('foreign');
static final ElementKind CONSTRUCTOR = const ElementKind('constructor');
+ static final ElementKind FIELD = const ElementKind('field');
+ static final ElementKind VARIABLE_LIST = const ElementKind('variable_list');
+ static final ElementKind FIELD_LIST = const ElementKind('field_list');
static final ElementKind CONSTRUCTOR_BODY =
const ElementKind('constructor_body');
@@ -58,21 +61,47 @@
}
class VariableElement extends Element {
- final Node node;
- final TypeAnnotation typeAnnotation;
+ final VariableListElement variables;
+
+ VariableElement(SourceString name, VariableListElement this.variables,
+ ElementKind kind, [Element enclosing = null])
+ : super(name, kind, enclosing);
+
+ Node parseNode(Canceler canceler, Logger logger) {
+ return variables.parseNode(canceler, logger);
+ }
+
+ Type computeType(Compiler compiler, types) {
+ return variables.computeType(compiler, types);
+ }
+
+ Type get type() => variables.type;
+}
+
+// This element represents a list of variable or field declaration.
+// It contains the node, and the type. A [VariableElement] always
+// references its [VariableListElement]. It forwards its
+// [computeType] and [parseNode] methods to this element.
+class VariableListElement extends Element {
+ VariableDefinitions node;
Type type;
- VariableElement(Node this.node, TypeAnnotation this.typeAnnotation,
- ElementKind kind, SourceString name, Element enclosingElement)
- : super(name, kind, enclosingElement);
+ VariableListElement(ElementKind kind, [Element enclosing = null])
+ : super(null, kind, enclosing);
+ VariableListElement.node(VariableDefinitions node,
+ ElementKind kind,
+ [Element enclosing = null])
+ : super(null, kind, enclosing),
+ this.node = node;
+
Node parseNode(Canceler canceler, Logger logger) {
karlklose 2011/12/12 17:02:09 Node -> VariableDefinitions.
ngeoffray 2011/12/12 17:18:04 Done.
return node;
}
- Type computeType(Compiler compiler, Types types) {
- if (type !== null) return type;
- type = getType(typeAnnotation, compiler, types);
+ Type computeType(Compiler compiler, types) {
+ if (type != null) return type;
+ type = getType(parseNode(compiler, compiler).type, compiler, types);
return type;
}
}
@@ -80,7 +109,7 @@
class ForeignElement extends Element {
ForeignElement(SourceString name) : super(name, ElementKind.FOREIGN, null);
- Type computeType(Compiler compiler, Types types) {
+ Type computeType(Compiler compiler, types) {
return types.dynamicType;
}
}
@@ -195,7 +224,7 @@
ClassNode node;
// backendMembers are members that have been added by the backend to simplify
// compilation. They don't have any user-side counter-part.
- Link<Element> backendMembers = const EmptyLink<Element>();
+ Link<Element> backendMembers = const EmptyLink<Element>();
SynthesizedConstructorElement synthesizedConstructor;
ClassElement(SourceString name) : super(name, ElementKind.CLASS, null);
« no previous file with comments | « no previous file | frog/leg/resolver.dart » ('j') | frog/leg/scanner/listener.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698