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

Unified Diff: runtime/vm/ast.h

Issue 8294013: Merge the 3 different closure nodes into a single node. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 years, 2 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 | runtime/vm/ast_printer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/ast.h
===================================================================
--- runtime/vm/ast.h (revision 473)
+++ runtime/vm/ast.h (working copy)
@@ -38,8 +38,6 @@
V(ArgumentListNode, "args") \
V(ArrayNode, "array") \
V(ClosureNode, "closure") \
- V(ImplicitInstanceClosureNode, "implicit instance closure") \
- V(ImplicitStaticClosureNode, "implicit static closure") \
V(InstanceCallNode, "instance call") \
V(StaticCallNode, "static call") \
V(ClosureCallNode, "closure call") \
@@ -363,75 +361,38 @@
class ClosureNode : public AstNode {
public:
- ClosureNode(intptr_t token_index, const Function& function, LocalScope* scope)
- : AstNode(token_index), function_(function), scope_(scope) {
+ ClosureNode(intptr_t token_index,
+ const Function& function,
+ AstNode* receiver, // Receiver is for implicit instance closures.
+ LocalScope* scope) // Scope is for non implicit closures only.
+ : AstNode(token_index),
+ function_(function),
+ receiver_(receiver),
+ scope_(scope) {
ASSERT(function.IsZoneHandle());
- ASSERT(function.IsNonImplicitClosureFunction());
- ASSERT(scope_ != NULL);
+ ASSERT((scope_ != NULL) || !function.IsNonImplicitClosureFunction());
+ ASSERT((receiver_ != NULL) ||
+ !function.IsImplicitInstanceClosureFunction());
siva 2011/10/17 19:03:39 I am wondering if this would be more readable as:
regis 2011/10/17 20:19:28 Done.
}
const Function& function() const { return function_; }
+ AstNode* receiver() const { return receiver_; }
LocalScope* scope() const { return scope_; }
- virtual void VisitChildren(AstNodeVisitor* visitor) const { }
-
- DECLARE_COMMON_NODE_FUNCTIONS(ClosureNode);
-
- private:
- const Function& function_;
- LocalScope* scope_;
-
- DISALLOW_IMPLICIT_CONSTRUCTORS(ClosureNode);
-};
-
-
-class ImplicitStaticClosureNode : public AstNode {
- public:
- ImplicitStaticClosureNode(intptr_t token_index, const Function& function)
- : AstNode(token_index), function_(function) {
- ASSERT(function.IsZoneHandle());
- ASSERT(function.IsImplicitStaticClosureFunction());
- }
-
- const Function& function() const { return function_; }
-
- virtual void VisitChildren(AstNodeVisitor* visitor) const { }
-
- DECLARE_COMMON_NODE_FUNCTIONS(ImplicitStaticClosureNode);
-
- private:
- const Function& function_;
-
- DISALLOW_IMPLICIT_CONSTRUCTORS(ImplicitStaticClosureNode);
-};
-
-
-class ImplicitInstanceClosureNode : public AstNode {
- public:
- ImplicitInstanceClosureNode(intptr_t token_index,
- const Function& function,
- AstNode* receiver)
- : AstNode(token_index), function_(function), receiver_(receiver) {
- ASSERT(function.IsZoneHandle());
- ASSERT(function.IsImplicitInstanceClosureFunction());
- }
-
- const Function& function() const { return function_; }
- AstNode* receiver() const { return receiver_; }
-
virtual void VisitChildren(AstNodeVisitor* visitor) const {
if (receiver() != NULL) {
receiver()->Visit(visitor);
}
}
- DECLARE_COMMON_NODE_FUNCTIONS(ImplicitInstanceClosureNode);
+ DECLARE_COMMON_NODE_FUNCTIONS(ClosureNode);
private:
const Function& function_;
AstNode* receiver_;
+ LocalScope* scope_;
- DISALLOW_IMPLICIT_CONSTRUCTORS(ImplicitInstanceClosureNode);
+ DISALLOW_IMPLICIT_CONSTRUCTORS(ClosureNode);
};
« no previous file with comments | « no previous file | runtime/vm/ast_printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698