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

Unified Diff: dart/frog/analyze.dart

Issue 9325029: Fix for issue 1480: analyze a method even if it does not have a body, and do not try to evaluate ... (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 8 years, 10 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 | dart/frog/gen.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/frog/analyze.dart
===================================================================
--- dart/frog/analyze.dart (revision 3935)
+++ dart/frog/analyze.dart (working copy)
@@ -46,7 +46,18 @@
_frame = new CallFrame(this, method, thisValue, args, context);
_bindArguments(_frame.args);
- body.visit(this);
+
+ // Visit the super or this call in a constructor, if any.
+ final declaredInitializers = method.definition.dynamic.initializers;
+ if (declaredInitializers != null) {
+ for (var init in declaredInitializers) {
+ if (init is CallExpression) {
+ visitCallExpression(init, true);
+ }
+ }
+ }
+
+ if (body != null) body.visit(this);
}
/* Checks whether or not a particular TypeReference Node includes references
@@ -394,7 +405,31 @@
return _frame._makeValue(world.functionType, node);
}
- Value visitCallExpression(CallExpression node) {
+ analyzeInitializerConstructorCall(CallExpression node,
+ Expression receiver,
+ String name) {
+ var type = _frame.method.declaringType;
+ if (receiver is SuperExpression) {
+ type = type.parent;
+ }
+ var member = type.getConstructor(name == null ? '' : name);
+ if (member !== null) {
+ return member.invoke(_frame, node, _frame.makeThisValue(node),
+ _visitArgs(node.arguments));
+ } else {
+ String constructorName = name == null ? '' : '.$name';
+ world.warning('cannot find constructor "${type.name}$constructorName"',
+ node.span);
+ return _frame._makeValue(world.varType, node);
+ }
+ }
+
+ bool isThisOrSuper(Expression node) {
+ return node is ThisExpression || node is SuperExpression;
+ }
+
+ Value visitCallExpression(CallExpression node,
+ [bool visitingInitializers = false]) {
var target;
var position = node.target;
var name = ':call';
@@ -402,7 +437,13 @@
DotExpression dot = node.target;
target = dot.self.visit(this);
name = dot.name.name;
- position = dot.name;
+ if (isThisOrSuper(dot.self) && visitingInitializers) {
+ return analyzeInitializerConstructorCall(node, dot.self, name);
+ } else {
+ position = dot.name;
+ }
+ } else if (isThisOrSuper(node.target) && visitingInitializers) {
+ return analyzeInitializerConstructorCall(node, node.target, null);
} else if (node.target is VarExpression) {
VarExpression varExpr = node.target;
name = varExpr.name.name;
« no previous file with comments | « no previous file | dart/frog/gen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698