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

Unified Diff: frog/leg/resolver.dart

Issue 9166010: Implement super calls. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. 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
« no previous file with comments | « no previous file | frog/leg/ssa/builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/leg/resolver.dart
diff --git a/frog/leg/resolver.dart b/frog/leg/resolver.dart
index 6a8342687b8c928376d1e8912624278d79582889..1b3c75b2cda41d7790ca11f8215caf4beeb6916e 100644
--- a/frog/leg/resolver.dart
+++ b/frog/leg/resolver.dart
@@ -142,6 +142,7 @@ class ResolverVisitor extends AbstractVisitor/*<Element>*/ {
final Element enclosingElement;
bool inInstanceContext;
Scope context;
+ ClassElement currentClass;
ResolverVisitor(Compiler compiler, Element element)
: this.compiler = compiler,
@@ -151,14 +152,16 @@ class ResolverVisitor extends AbstractVisitor/*<Element>*/ {
|| element.isGenerativeConstructor(),
this.context = element.isMember()
? new ClassScope(element.enclosingElement, compiler.universe)
- : new TopScope(compiler.universe);
+ : new TopScope(compiler.universe),
+ this.currentClass = element.isMember() ? element.enclosingElement : null;
ResolverVisitor.from(ResolverVisitor other)
: compiler = other.compiler,
mapping = other.mapping,
enclosingElement = other.enclosingElement,
inInstanceContext = other.inInstanceContext,
- context = other.context;
+ context = other.context,
+ currentClass = other.currentClass;
error(Node node, MessageKind kind, [arguments = const []]) {
ResolutionError error = new ResolutionError(kind, arguments);
@@ -198,6 +201,9 @@ class ResolverVisitor extends AbstractVisitor/*<Element>*/ {
if (node.isThis()) {
if (!inInstanceContext) error(node, MessageKind.NO_THIS_IN_STATIC);
return null;
+ } else if (node.isSuper()) {
+ if (!inInstanceContext) error(node, MessageKind.NO_SUPER_IN_STATIC);
+ return null;
} else {
Element element = lookup(node, node.source);
if (element == null) {
@@ -357,7 +363,17 @@ class FullResolverVisitor extends ResolverVisitor {
if (isLogicalOperator(selector)) return null;
Element target = null;
- if (node.isOperator) {
+ if (node.isSuperCall) {
+ if (currentClass !== null) {
+ ClassElement superElement = currentClass.superClass;
ahe 2012/01/11 13:55:58 It is called "superclass", but an element should n
+ if (superElement !== null) {
+ target = superElement.lookupLocalMember(name);
+ }
+ if (target == null) {
+ error(node, MessageKind.METHOD_NOT_FOUND, [superElement.name, name]);
+ }
+ }
+ } else if (node.isOperator) {
return null;
} else if (node.receiver === null) {
target = lookup(node, name);
@@ -370,9 +386,9 @@ class FullResolverVisitor extends ResolverVisitor {
ClassElement receiverClass = receiver;
target = receiverClass.resolve(compiler).lookupLocalMember(name);
if (target == null) {
- error(node, MessageKind.METHOD_NOT_FOUND, [receiver, name]);
+ error(node, MessageKind.METHOD_NOT_FOUND, [receiver.name, name]);
} else if (target.isInstanceMember()) {
- error(node, MessageKind.MEMBER_NOT_STATIC, [receiver, name]);
+ error(node, MessageKind.MEMBER_NOT_STATIC, [receiver.name, name]);
}
}
return target;
@@ -580,6 +596,18 @@ class ClassResolverVisitor extends AbstractVisitor/* <Type> */ {
compiler.ensure(element !== null);
compiler.ensure(!element.isResolved);
element.supertype = visit(node.superclass);
+ if (element.name != Types.OBJECT && element.supertype === null) {
+ ClassElement objectElement = context.lookup(Types.OBJECT);
+ if (objectElement !== null && !objectElement.isResolved) {
+ compiler.resolver.toResolve.add(objectElement);
+ } else if (objectElement === null){
+ compiler.reportError(node,
+ new ResolutionError(MessageKind.CANNOT_RESOLVE_TYPE,
+ [Types.OBJECT]));
+ }
+ element.supertype = new SimpleType(Types.OBJECT,
+ objectElement);
+ }
for (Link<Node> link = node.interfaces.nodes;
!link.isEmpty();
link = link.tail) {
« no previous file with comments | « no previous file | frog/leg/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698