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

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, 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 | dart/frog/gen.dart » ('j') | dart/frog/gen.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/frog/analyze.dart
===================================================================
--- dart/frog/analyze.dart (revision 3892)
+++ dart/frog/analyze.dart (working copy)
@@ -25,6 +25,7 @@
* enclosing type to advise future code generation and analysis.
*/
bool hasTypeParams = false;
+ bool visitingInitializers = false;
MethodAnalyzer(this.method, this.body);
@@ -46,7 +47,20 @@
_frame = new CallFrame(this, method, thisValue, args, context);
_bindArguments(_frame.args);
- body.visit(this);
+
+ final declaredInitializers = method.definition.dynamic.initializers;
kasperl 2012/02/03 15:39:20 Add a comment here that explains how this is dealt
ngeoffray 2012/02/06 11:50:31 Done.
+ var initializerCall = null;
+ if (declaredInitializers != null) {
+ visitingInitializers = true;
+ for (var init in declaredInitializers) {
+ if (init is CallExpression) {
kasperl 2012/02/03 15:39:20 How bad would it be to add an optional parameter t
ngeoffray 2012/02/06 11:50:31 Done.
+ init.visit(this);;
kasperl 2012/02/03 15:39:20 ;; -> ;
ngeoffray 2012/02/06 11:50:31 Done.
+ }
+ }
+ visitingInitializers = false;
+ }
+
+ if (body != null) body.visit(this);
}
/* Checks whether or not a particular TypeReference Node includes references
@@ -394,6 +408,27 @@
return _frame._makeValue(world.functionType, node);
}
+ analyzeThisOrSuperConstructorCall(CallExpression node,
kasperl 2012/02/03 15:39:20 analyzeInitializerConstructorCall instead? In this
ngeoffray 2012/02/06 11:50:31 Done.
+ Expression receiver,
+ String name) {
+ var type = _frame.method.declaringType;
+ if (receiver is SuperExpression) {
+ type = type.parent;
+ }
+ var member = type.getConstructor(name);
+ if (member !== null) {
+ return member.invoke(_frame, node, _frame.makeThisValue(node),
+ _visitArgs(node.arguments));
+ } else {
+ world.warning('cannot find "$name"', node.span);
kasperl 2012/02/03 15:39:20 How does this look if name is the empty string? Ma
ngeoffray 2012/02/06 11:50:31 Done.
+ return _frame._makeValue(world.varType, node);
+ }
+ }
+
+ bool isThisOrSuper(Expression node) {
+ return node is ThisExpression || node is SuperExpression;
+ }
+
Value visitCallExpression(CallExpression node) {
var target;
var position = node.target;
@@ -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 analyzeThisOrSuperConstructorCall(node, dot.self, name);
+ } else {
+ position = dot.name;
+ }
+ } else if (isThisOrSuper(node.target) && visitingInitializers) {
+ return analyzeThisOrSuperConstructorCall(node, node.target, '');
} 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') | dart/frog/gen.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698