Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_AST_H_ | 5 #ifndef VM_AST_H_ |
| 6 #define VM_AST_H_ | 6 #define VM_AST_H_ |
| 7 | 7 |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
| 10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 V(PrimaryNode, "primary") \ | 48 V(PrimaryNode, "primary") \ |
| 49 V(LoadLocalNode, "load local") \ | 49 V(LoadLocalNode, "load local") \ |
| 50 V(StoreLocalNode, "store local") \ | 50 V(StoreLocalNode, "store local") \ |
| 51 V(LoadInstanceFieldNode, "load field") \ | 51 V(LoadInstanceFieldNode, "load field") \ |
| 52 V(StoreInstanceFieldNode, "store field") \ | 52 V(StoreInstanceFieldNode, "store field") \ |
| 53 V(LoadStaticFieldNode, "load static field") \ | 53 V(LoadStaticFieldNode, "load static field") \ |
| 54 V(StoreStaticFieldNode, "store static field") \ | 54 V(StoreStaticFieldNode, "store static field") \ |
| 55 V(LoadIndexedNode, "load indexed") \ | 55 V(LoadIndexedNode, "load indexed") \ |
| 56 V(StoreIndexedNode, "store indexed") \ | 56 V(StoreIndexedNode, "store indexed") \ |
| 57 V(SequenceNode, "seq") \ | 57 V(SequenceNode, "seq") \ |
| 58 V(CommaNode, "comma") \ | |
| 58 V(CatchClauseNode, "catch clause block") \ | 59 V(CatchClauseNode, "catch clause block") \ |
| 59 V(TryCatchNode, "try catch block") \ | 60 V(TryCatchNode, "try catch block") \ |
| 60 V(ThrowNode, "throw") \ | 61 V(ThrowNode, "throw") \ |
| 61 V(InlinedFinallyNode, "inlined finally") \ | 62 V(InlinedFinallyNode, "inlined finally") \ |
| 62 | 63 |
| 63 | 64 |
| 64 #define DEFINE_FORWARD_DECLARATION(type, name) class type; | 65 #define DEFINE_FORWARD_DECLARATION(type, name) class type; |
| 65 NODE_LIST(DEFINE_FORWARD_DECLARATION) | 66 NODE_LIST(DEFINE_FORWARD_DECLARATION) |
| 66 #undef DEFINE_FORWARD_DECLARATION | 67 #undef DEFINE_FORWARD_DECLARATION |
| 67 | 68 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 | 174 |
| 174 private: | 175 private: |
| 175 LocalScope* scope_; | 176 LocalScope* scope_; |
| 176 GrowableArray<AstNode*> nodes_; | 177 GrowableArray<AstNode*> nodes_; |
| 177 SourceLabel* label_; | 178 SourceLabel* label_; |
| 178 | 179 |
| 179 DISALLOW_COPY_AND_ASSIGN(SequenceNode); | 180 DISALLOW_COPY_AND_ASSIGN(SequenceNode); |
| 180 }; | 181 }; |
| 181 | 182 |
| 182 | 183 |
| 184 // Comma node represents a pair of expressions evaluated in sequence | |
| 185 // and return the value of the second expression. | |
| 186 class CommaNode : public AstNode { | |
| 187 public: | |
| 188 CommaNode(intptr_t token_pos, | |
|
Kevin Millikin (Google)
2013/05/28 09:13:26
As discussed offline, I think that this node shoul
Florian Schneider
2013/05/28 09:22:35
Agree. I'll do that in a separate CL.
| |
| 189 AstNode* first, | |
| 190 AstNode* second) | |
| 191 : AstNode(token_pos), | |
| 192 first_(first), | |
| 193 second_(second) { } | |
| 194 | |
| 195 AstNode* first() const { return first_; } | |
| 196 AstNode* second() const { return second_; } | |
| 197 | |
| 198 void VisitChildren(AstNodeVisitor* visitor) const { | |
| 199 first_->Visit(visitor); | |
| 200 second_->Visit(visitor); | |
| 201 } | |
| 202 | |
| 203 DECLARE_COMMON_NODE_FUNCTIONS(CommaNode); | |
| 204 | |
| 205 private: | |
| 206 AstNode* first_; | |
| 207 AstNode* second_; | |
| 208 | |
| 209 DISALLOW_COPY_AND_ASSIGN(CommaNode); | |
| 210 }; | |
| 211 | |
| 212 | |
| 183 class CloneContextNode : public AstNode { | 213 class CloneContextNode : public AstNode { |
| 184 public: | 214 public: |
| 185 explicit CloneContextNode(intptr_t token_pos) | 215 explicit CloneContextNode(intptr_t token_pos) |
| 186 : AstNode(token_pos) { | 216 : AstNode(token_pos) { |
| 187 } | 217 } |
| 188 | 218 |
| 189 virtual void VisitChildren(AstNodeVisitor* visitor) const { } | 219 virtual void VisitChildren(AstNodeVisitor* visitor) const { } |
| 190 | 220 |
| 191 DECLARE_COMMON_NODE_FUNCTIONS(CloneContextNode); | 221 DECLARE_COMMON_NODE_FUNCTIONS(CloneContextNode); |
| 192 | 222 |
| (...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 955 Token::Kind kind_; | 985 Token::Kind kind_; |
| 956 SourceLabel* label_; | 986 SourceLabel* label_; |
| 957 GrowableArray<InlinedFinallyNode*> inlined_finally_list_; | 987 GrowableArray<InlinedFinallyNode*> inlined_finally_list_; |
| 958 DISALLOW_IMPLICIT_CONSTRUCTORS(JumpNode); | 988 DISALLOW_IMPLICIT_CONSTRUCTORS(JumpNode); |
| 959 }; | 989 }; |
| 960 | 990 |
| 961 | 991 |
| 962 class LoadLocalNode : public AstNode { | 992 class LoadLocalNode : public AstNode { |
| 963 public: | 993 public: |
| 964 LoadLocalNode(intptr_t token_pos, const LocalVariable* local) | 994 LoadLocalNode(intptr_t token_pos, const LocalVariable* local) |
| 965 : AstNode(token_pos), local_(*local), pseudo_(NULL) { | 995 : AstNode(token_pos), local_(*local) { |
| 966 ASSERT(local != NULL); | |
| 967 } | |
| 968 | |
| 969 // A local variable load can optionally be a pair of an arbitrary 'pseudo' | |
| 970 // AST node followed by the load. The pseudo node is evaluated for its | |
| 971 // side-effects and the value of the expression is the value of the local | |
| 972 // load after evaluating the pseudo node. Pseudo nodes are used, e.g., in | |
| 973 // the desugaring of postincrement and cascade expressions. | |
| 974 LoadLocalNode(intptr_t token_pos, const LocalVariable* local, AstNode* pseudo) | |
| 975 : AstNode(token_pos), local_(*local), pseudo_(pseudo) { | |
| 976 ASSERT(local != NULL); | 996 ASSERT(local != NULL); |
| 977 } | 997 } |
| 978 | 998 |
| 979 const LocalVariable& local() const { return local_; } | 999 const LocalVariable& local() const { return local_; } |
| 980 AstNode* pseudo() const { return pseudo_; } // Can be NULL. | |
| 981 bool HasPseudo() const { return pseudo_ != NULL; } | |
| 982 | 1000 |
| 983 virtual void VisitChildren(AstNodeVisitor* visitor) const { | 1001 virtual void VisitChildren(AstNodeVisitor* visitor) const { } |
| 984 if (HasPseudo()) { | |
| 985 pseudo()->Visit(visitor); | |
| 986 } | |
| 987 } | |
| 988 | 1002 |
| 989 virtual const Instance* EvalConstExpr() const; | 1003 virtual const Instance* EvalConstExpr() const; |
| 990 virtual AstNode* MakeAssignmentNode(AstNode* rhs); | 1004 virtual AstNode* MakeAssignmentNode(AstNode* rhs); |
| 991 | 1005 |
| 992 DECLARE_COMMON_NODE_FUNCTIONS(LoadLocalNode); | 1006 DECLARE_COMMON_NODE_FUNCTIONS(LoadLocalNode); |
| 993 | 1007 |
| 994 private: | 1008 private: |
| 995 const LocalVariable& local_; | 1009 const LocalVariable& local_; |
| 996 AstNode* pseudo_; | |
| 997 | 1010 |
| 998 DISALLOW_IMPLICIT_CONSTRUCTORS(LoadLocalNode); | 1011 DISALLOW_IMPLICIT_CONSTRUCTORS(LoadLocalNode); |
| 999 }; | 1012 }; |
| 1000 | 1013 |
| 1001 | 1014 |
| 1002 class StoreLocalNode : public AstNode { | 1015 class StoreLocalNode : public AstNode { |
| 1003 public: | 1016 public: |
| 1004 StoreLocalNode(intptr_t token_pos, const LocalVariable* local, AstNode* value) | 1017 StoreLocalNode(intptr_t token_pos, const LocalVariable* local, AstNode* value) |
| 1005 : AstNode(token_pos), local_(*local), value_(value) { | 1018 : AstNode(token_pos), local_(*local), value_(value) { |
| 1006 ASSERT(local != NULL); | 1019 ASSERT(local != NULL); |
| (...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1731 const LocalVariable& context_var_; | 1744 const LocalVariable& context_var_; |
| 1732 | 1745 |
| 1733 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); | 1746 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); |
| 1734 }; | 1747 }; |
| 1735 | 1748 |
| 1736 } // namespace dart | 1749 } // namespace dart |
| 1737 | 1750 |
| 1738 #undef DECLARE_COMMON_NODE_FUNCTIONS | 1751 #undef DECLARE_COMMON_NODE_FUNCTIONS |
| 1739 | 1752 |
| 1740 #endif // VM_AST_H_ | 1753 #endif // VM_AST_H_ |
| OLD | NEW |