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

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

Issue 8769012: Start resolving classes and default constructors. (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 | « frog/leg/compiler.dart ('k') | frog/leg/resolver.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/leg/elements/elements.dart
===================================================================
--- frog/leg/elements/elements.dart (revision 2023)
+++ frog/leg/elements/elements.dart (working copy)
@@ -29,6 +29,7 @@
static final ElementKind FUNCTION = const ElementKind('function');
static final ElementKind CLASS = const ElementKind('class');
static final ElementKind FOREIGN = const ElementKind('foreign');
+ static final ElementKind CONSTRUCTOR = const ElementKind('constructor');
toString() => id;
}
@@ -39,6 +40,8 @@
final Element enclosingElement;
abstract Node parseNode(Canceler canceler, Logger logger);
abstract Type computeType(Compiler compiler, Types types);
+ bool isClassMember() =>
+ enclosingElement !== null && enclosingElement.kind == ElementKind.CLASS;
const Element(this.name, this.kind, this.enclosingElement);
@@ -95,10 +98,14 @@
FunctionExpression node;
Type type;
- // TODO(ngeoffray): set the enclosingElement.
- FunctionElement(SourceString name) : super(name, ElementKind.FUNCTION, null);
- FunctionElement.node(FunctionExpression node, Element enclosing)
- : super(node.name.dynamic.source, ElementKind.FUNCTION, enclosing),
+ FunctionElement(SourceString name,
+ ElementKind kind,
+ Element enclosing)
+ : super(name, kind, enclosing);
+ FunctionElement.node(FunctionExpression node,
+ ElementKind kind,
+ Element enclosing)
+ : super(node.name.asIdentifier().source, kind, enclosing),
this.node = node;
FunctionType computeType(Compiler compiler, types) {
@@ -120,11 +127,34 @@
Node parseNode(Canceler canceler, Logger logger) => node;
}
+class SynthesizedConstructorElement extends FunctionElement {
+ SynthesizedConstructorElement(Element enclosing)
+ : super(const SourceString(''), ElementKind.CONSTRUCTOR, enclosing) {
+ parameters = const EmptyLink<Element>();
+ }
+
+ FunctionType computeType(Compiler compiler, types) {
+ if (type != null) return type;
+ type = new FunctionType(types.voidType, const EmptyLink<Type>());
+ return type;
+ }
+
+ Node parseNode(Canceler canceler, Logger logger) {
+ if (node != null) return node;
+ node = new FunctionExpression(
+ new Identifier.synthetic(''),
+ new NodeList.empty(),
+ new Block(new NodeList.empty()));
+ return node;
+ }
+}
+
class ClassElement extends Element {
Type type;
Type supertype;
Link<Type> interfaces = const EmptyLink<Type>();
bool isResolved = false;
+ ClassNode node;
ClassElement(SourceString name) : super(name, ElementKind.CLASS, null);
@@ -140,4 +170,9 @@
compiler.resolveType(this);
isResolved = true;
}
+
+ // TODO(ngeoffray): Implement these.
+ Element lookupLocalElement(SourceString name) => null;
+ bool canHaveDefaultConstructor() => true;
+ void addConstructor(Element element) {}
}
« no previous file with comments | « frog/leg/compiler.dart ('k') | frog/leg/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698