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

Unified Diff: runtime/vm/ast.h

Issue 460763002: Fix returning from async functions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: add scope via sequencenode add method Created 6 years, 4 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/flow_graph_builder.cc » ('j') | runtime/vm/flow_graph_builder.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/ast.h
diff --git a/runtime/vm/ast.h b/runtime/vm/ast.h
index 03d65a06f3561c9161e330c1ec2dadd0a08eb75a..88f5a51dbdeb90dec8b8cb82d658f4a9099e55b6 100644
--- a/runtime/vm/ast.h
+++ b/runtime/vm/ast.h
@@ -146,6 +146,102 @@ class AstNode : public ZoneAllocated {
};
+class LiteralNode : public AstNode {
+ public:
+ LiteralNode(intptr_t token_pos, const Instance& literal)
+ : AstNode(token_pos), literal_(literal) {
+ ASSERT(literal_.IsNotTemporaryScopedHandle());
+ ASSERT(literal_.IsSmi() || literal_.IsOld());
+#if defined(DEBUG)
+ if (literal_.IsString()) {
+ ASSERT(String::Cast(literal_).IsSymbol());
+ }
+#endif // defined(DEBUG)
+ ASSERT(literal_.IsNull() ||
+ Class::Handle(literal_.clazz()).is_finalized() ||
+ Class::Handle(literal_.clazz()).is_prefinalized());
+ }
+
+ const Instance& literal() const { return literal_; }
+
+ virtual bool IsPotentiallyConst() const;
+ virtual const Instance* EvalConstExpr() const {
+ return &literal();
+ }
+
+ virtual void VisitChildren(AstNodeVisitor* visitor) const { }
+
+ virtual AstNode* ApplyUnaryOp(Token::Kind unary_op_kind);
+
+ DECLARE_COMMON_NODE_FUNCTIONS(LiteralNode);
+
+ private:
+ const Instance& literal_;
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(LiteralNode);
+};
+
+
+class ReturnNode : public AstNode {
+ public:
+ // Return from a void function returns the null object.
+ explicit ReturnNode(intptr_t token_pos)
+ : AstNode(token_pos),
+ value_(new LiteralNode(token_pos, Instance::ZoneHandle())),
+ inlined_finally_list_(),
+ saved_return_value_var_(NULL),
+ scope_(NULL) { }
+ // Return from a non-void function.
+ ReturnNode(intptr_t token_pos,
+ AstNode* value)
+ : AstNode(token_pos),
+ value_(value),
+ inlined_finally_list_(),
+ saved_return_value_var_(NULL),
+ scope_(NULL) {
+ ASSERT(value_ != NULL);
+ }
+
+ AstNode* value() const { return value_; }
+
+ intptr_t inlined_finally_list_length() const {
+ return inlined_finally_list_.length();
+ }
+ InlinedFinallyNode* InlinedFinallyNodeAt(intptr_t index) const {
+ return inlined_finally_list_[index];
+ }
+ void AddInlinedFinallyNode(InlinedFinallyNode* finally_node) {
+ inlined_finally_list_.Add(finally_node);
+ }
+
+ LocalVariable* saved_return_value_var() const {
+ return saved_return_value_var_;
+ }
+ void set_saved_return_value_var(LocalVariable* var) {
+ saved_return_value_var_ = var;
+ }
+
+ virtual void VisitChildren(AstNodeVisitor* visitor) const {
+ if (value() != NULL) {
+ value()->Visit(visitor);
+ }
+ }
+
+ void set_scope(LocalScope* scope) { scope_ = scope; }
+ LocalScope* scope() const { return scope_; }
+
+ DECLARE_COMMON_NODE_FUNCTIONS(ReturnNode);
+
+ private:
+ AstNode* value_;
+ GrowableArray<InlinedFinallyNode*> inlined_finally_list_;
+ LocalVariable* saved_return_value_var_;
+ LocalScope* scope_;
+
+ DISALLOW_COPY_AND_ASSIGN(ReturnNode);
+};
+
+
class SequenceNode : public AstNode {
public:
SequenceNode(intptr_t token_pos, LocalScope* scope)
@@ -162,7 +258,12 @@ class SequenceNode : public AstNode {
void VisitChildren(AstNodeVisitor* visitor) const;
- void Add(AstNode* node) { nodes_.Add(node); }
+ void Add(AstNode* node) {
hausner 2014/08/12 20:51:26 This should now maybe go into the .cc file. Then y
Michael Lippautz (Google) 2014/08/12 21:13:57 Done.
+ if (node->IsReturnNode()) {
+ node->AsReturnNode()->set_scope(scope());
+ }
+ nodes_.Add(node);
+ }
intptr_t length() const { return nodes_.length(); }
AstNode* NodeAt(intptr_t index) const { return nodes_[index]; }
void ReplaceNodeAt(intptr_t index, AstNode* value) { nodes_[index] = value; }
@@ -329,42 +430,6 @@ class StringInterpolateNode : public AstNode {
};
-class LiteralNode : public AstNode {
- public:
- LiteralNode(intptr_t token_pos, const Instance& literal)
- : AstNode(token_pos), literal_(literal) {
- ASSERT(literal_.IsNotTemporaryScopedHandle());
- ASSERT(literal_.IsSmi() || literal_.IsOld());
-#if defined(DEBUG)
- if (literal_.IsString()) {
- ASSERT(String::Cast(literal_).IsSymbol());
- }
-#endif // defined(DEBUG)
- ASSERT(literal_.IsNull() ||
- Class::Handle(literal_.clazz()).is_finalized() ||
- Class::Handle(literal_.clazz()).is_prefinalized());
- }
-
- const Instance& literal() const { return literal_; }
-
- virtual bool IsPotentiallyConst() const;
- virtual const Instance* EvalConstExpr() const {
- return &literal();
- }
-
- virtual void VisitChildren(AstNodeVisitor* visitor) const { }
-
- virtual AstNode* ApplyUnaryOp(Token::Kind unary_op_kind);
-
- DECLARE_COMMON_NODE_FUNCTIONS(LiteralNode);
-
- private:
- const Instance& literal_;
-
- DISALLOW_IMPLICIT_CONSTRUCTORS(LiteralNode);
-};
-
-
class TypeNode : public AstNode {
public:
TypeNode(intptr_t token_pos, const AbstractType& type)
@@ -515,60 +580,6 @@ class PrimaryNode : public AstNode {
};
-class ReturnNode : public AstNode {
- public:
- // Return from a void function returns the null object.
- explicit ReturnNode(intptr_t token_pos)
- : AstNode(token_pos),
- value_(new LiteralNode(token_pos, Instance::ZoneHandle())),
- inlined_finally_list_(),
- saved_return_value_var_(NULL) { }
- // Return from a non-void function.
- ReturnNode(intptr_t token_pos,
- AstNode* value)
- : AstNode(token_pos),
- value_(value),
- inlined_finally_list_(),
- saved_return_value_var_(NULL) {
- ASSERT(value_ != NULL);
- }
-
- AstNode* value() const { return value_; }
-
- intptr_t inlined_finally_list_length() const {
- return inlined_finally_list_.length();
- }
- InlinedFinallyNode* InlinedFinallyNodeAt(intptr_t index) const {
- return inlined_finally_list_[index];
- }
- void AddInlinedFinallyNode(InlinedFinallyNode* finally_node) {
- inlined_finally_list_.Add(finally_node);
- }
-
- LocalVariable* saved_return_value_var() const {
- return saved_return_value_var_;
- }
- void set_saved_return_value_var(LocalVariable* var) {
- saved_return_value_var_ = var;
- }
-
- virtual void VisitChildren(AstNodeVisitor* visitor) const {
- if (value() != NULL) {
- value()->Visit(visitor);
- }
- }
-
- DECLARE_COMMON_NODE_FUNCTIONS(ReturnNode);
-
- private:
- AstNode* value_;
- GrowableArray<InlinedFinallyNode*> inlined_finally_list_;
- LocalVariable* saved_return_value_var_;
-
- DISALLOW_COPY_AND_ASSIGN(ReturnNode);
-};
-
-
class ComparisonNode : public AstNode {
public:
ComparisonNode(intptr_t token_pos,
« no previous file with comments | « no previous file | runtime/vm/flow_graph_builder.cc » ('j') | runtime/vm/flow_graph_builder.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698