| 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 }; | 158 }; |
| 159 | 159 |
| 160 | 160 |
| 161 class AwaitNode : public AstNode { | 161 class AwaitNode : public AstNode { |
| 162 public: | 162 public: |
| 163 AwaitNode(intptr_t token_pos, | 163 AwaitNode(intptr_t token_pos, |
| 164 AstNode* expr, | 164 AstNode* expr, |
| 165 LocalVariable* saved_try_ctx, | 165 LocalVariable* saved_try_ctx, |
| 166 LocalVariable* async_saved_try_ctx, | 166 LocalVariable* async_saved_try_ctx, |
| 167 LocalVariable* outer_saved_try_ctx, | 167 LocalVariable* outer_saved_try_ctx, |
| 168 LocalVariable* outer_async_saved_try_ctx) | 168 LocalVariable* outer_async_saved_try_ctx, |
| 169 LocalScope* scope) |
| 169 : AstNode(token_pos), | 170 : AstNode(token_pos), |
| 170 expr_(expr), | 171 expr_(expr), |
| 171 saved_try_ctx_(saved_try_ctx), | 172 saved_try_ctx_(saved_try_ctx), |
| 172 async_saved_try_ctx_(async_saved_try_ctx), | 173 async_saved_try_ctx_(async_saved_try_ctx), |
| 173 outer_saved_try_ctx_(outer_saved_try_ctx), | 174 outer_saved_try_ctx_(outer_saved_try_ctx), |
| 174 outer_async_saved_try_ctx_(outer_async_saved_try_ctx) { } | 175 outer_async_saved_try_ctx_(outer_async_saved_try_ctx), |
| 176 scope_(scope) { } |
| 175 | 177 |
| 176 void VisitChildren(AstNodeVisitor* visitor) const { | 178 void VisitChildren(AstNodeVisitor* visitor) const { |
| 177 expr_->Visit(visitor); | 179 expr_->Visit(visitor); |
| 178 } | 180 } |
| 179 | 181 |
| 180 AstNode* expr() const { return expr_; } | 182 AstNode* expr() const { return expr_; } |
| 181 LocalVariable* saved_try_ctx() const { return saved_try_ctx_; } | 183 LocalVariable* saved_try_ctx() const { return saved_try_ctx_; } |
| 182 LocalVariable* async_saved_try_ctx() const { return async_saved_try_ctx_; } | 184 LocalVariable* async_saved_try_ctx() const { return async_saved_try_ctx_; } |
| 183 LocalVariable* outer_saved_try_ctx() const { return outer_saved_try_ctx_; } | 185 LocalVariable* outer_saved_try_ctx() const { return outer_saved_try_ctx_; } |
| 184 LocalVariable* outer_async_saved_try_ctx() const { | 186 LocalVariable* outer_async_saved_try_ctx() const { |
| 185 return outer_async_saved_try_ctx_; | 187 return outer_async_saved_try_ctx_; |
| 186 } | 188 } |
| 189 LocalScope* scope() const { return scope_; } |
| 187 | 190 |
| 188 DECLARE_COMMON_NODE_FUNCTIONS(AwaitNode); | 191 DECLARE_COMMON_NODE_FUNCTIONS(AwaitNode); |
| 189 | 192 |
| 190 private: | 193 private: |
| 191 AstNode* expr_; | 194 AstNode* expr_; |
| 192 LocalVariable* saved_try_ctx_; | 195 LocalVariable* saved_try_ctx_; |
| 193 LocalVariable* async_saved_try_ctx_; | 196 LocalVariable* async_saved_try_ctx_; |
| 194 LocalVariable* outer_saved_try_ctx_; | 197 LocalVariable* outer_saved_try_ctx_; |
| 195 LocalVariable* outer_async_saved_try_ctx_; | 198 LocalVariable* outer_async_saved_try_ctx_; |
| 199 LocalScope* scope_; |
| 196 | 200 |
| 197 DISALLOW_COPY_AND_ASSIGN(AwaitNode); | 201 DISALLOW_COPY_AND_ASSIGN(AwaitNode); |
| 198 }; | 202 }; |
| 199 | 203 |
| 200 | 204 |
| 201 // AwaitMarker nodes are used to generate markers that the FlowGraphBuilder | 205 // AwaitMarker nodes are used to generate markers that the FlowGraphBuilder |
| 202 // relies on. A marker indicates that a new await state needs to be | 206 // relies on. A marker indicates that a new await state needs to be |
| 203 // added to a function preamble. This type also triggers storing of the | 207 // added to a function preamble. This type also triggers storing of the |
| 204 // current context. | 208 // current context. |
| 205 // | 209 // |
| 206 // It is expected (ASSERT) that an AwaitMarker is followed by | 210 // It is expected (ASSERT) that an AwaitMarker is followed by |
| 207 // a return node of kind kContinuationTarget. That is: | 211 // a return node of kind kContinuationTarget. That is: |
| 208 // <AwaitMarker> -> <other nodes> -> <kContinuationTarget> -> <other nodes> -> | 212 // <AwaitMarker> -> <other nodes> -> <kContinuationTarget> -> <other nodes> -> |
| 209 // <AwaitMarker> -> ... | 213 // <AwaitMarker> -> ... |
| 210 class AwaitMarkerNode : public AstNode { | 214 class AwaitMarkerNode : public AstNode { |
| 211 public: | 215 public: |
| 212 AwaitMarkerNode() : AstNode(Scanner::kNoSourcePos) { } | 216 AwaitMarkerNode(LocalScope* async_scope, LocalScope* await_scope) |
| 217 : AstNode(Scanner::kNoSourcePos), |
| 218 async_scope_(async_scope), |
| 219 await_scope_(await_scope) { |
| 220 ASSERT(async_scope != NULL); |
| 221 ASSERT(await_scope != NULL); |
| 222 await_scope->CaptureLocalVariables(async_scope); |
| 223 } |
| 213 | 224 |
| 214 void VisitChildren(AstNodeVisitor* visitor) const { } | 225 void VisitChildren(AstNodeVisitor* visitor) const { } |
| 215 | 226 |
| 216 LocalScope* scope() const { return scope_; } | 227 LocalScope* async_scope() const { return async_scope_; } |
| 217 void set_scope(LocalScope* scope) { scope_ = scope; } | 228 LocalScope* await_scope() const { return await_scope_; } |
| 218 | 229 |
| 219 DECLARE_COMMON_NODE_FUNCTIONS(AwaitMarkerNode); | 230 DECLARE_COMMON_NODE_FUNCTIONS(AwaitMarkerNode); |
| 220 | 231 |
| 221 private: | 232 private: |
| 222 LocalScope* scope_; | 233 LocalScope* async_scope_; |
| 234 LocalScope* await_scope_; |
| 223 | 235 |
| 224 DISALLOW_COPY_AND_ASSIGN(AwaitMarkerNode); | 236 DISALLOW_COPY_AND_ASSIGN(AwaitMarkerNode); |
| 225 }; | 237 }; |
| 226 | 238 |
| 227 | 239 |
| 228 class SequenceNode : public AstNode { | 240 class SequenceNode : public AstNode { |
| 229 public: | 241 public: |
| 230 SequenceNode(intptr_t token_pos, LocalScope* scope) | 242 SequenceNode(intptr_t token_pos, LocalScope* scope) |
| 231 : AstNode(token_pos), | 243 : AstNode(token_pos), |
| 232 scope_(scope), | 244 scope_(scope), |
| (...skipping 1783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2016 const intptr_t try_index_; | 2028 const intptr_t try_index_; |
| 2017 | 2029 |
| 2018 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); | 2030 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); |
| 2019 }; | 2031 }; |
| 2020 | 2032 |
| 2021 } // namespace dart | 2033 } // namespace dart |
| 2022 | 2034 |
| 2023 #undef DECLARE_COMMON_NODE_FUNCTIONS | 2035 #undef DECLARE_COMMON_NODE_FUNCTIONS |
| 2024 | 2036 |
| 2025 #endif // VM_AST_H_ | 2037 #endif // VM_AST_H_ |
| OLD | NEW |