OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_AST_AST_H_ | 5 #ifndef V8_AST_AST_H_ |
6 #define V8_AST_AST_H_ | 6 #define V8_AST_AST_H_ |
7 | 7 |
8 #include "src/ast/ast-types.h" | 8 #include "src/ast/ast-types.h" |
9 #include "src/ast/ast-value-factory.h" | 9 #include "src/ast/ast-value-factory.h" |
10 #include "src/ast/modules.h" | 10 #include "src/ast/modules.h" |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 | 890 |
891 BreakStatement(BreakableStatement* target, int pos) | 891 BreakStatement(BreakableStatement* target, int pos) |
892 : JumpStatement(pos, kBreakStatement), target_(target) {} | 892 : JumpStatement(pos, kBreakStatement), target_(target) {} |
893 | 893 |
894 BreakableStatement* target_; | 894 BreakableStatement* target_; |
895 }; | 895 }; |
896 | 896 |
897 | 897 |
898 class ReturnStatement final : public JumpStatement { | 898 class ReturnStatement final : public JumpStatement { |
899 public: | 899 public: |
| 900 enum Type { kNormal, kAsyncReturn }; |
900 Expression* expression() const { return expression_; } | 901 Expression* expression() const { return expression_; } |
901 | 902 |
902 void set_expression(Expression* e) { expression_ = e; } | 903 void set_expression(Expression* e) { expression_ = e; } |
| 904 Type type() const { return TypeField::decode(bit_field_); } |
| 905 bool is_async_return() const { return type() == kAsyncReturn; } |
903 | 906 |
904 private: | 907 private: |
905 friend class AstNodeFactory; | 908 friend class AstNodeFactory; |
906 | 909 |
907 ReturnStatement(Expression* expression, int pos) | 910 ReturnStatement(Expression* expression, Type type, int pos) |
908 : JumpStatement(pos, kReturnStatement), expression_(expression) {} | 911 : JumpStatement(pos, kReturnStatement), expression_(expression) { |
| 912 bit_field_ |= TypeField::encode(type); |
| 913 } |
909 | 914 |
910 Expression* expression_; | 915 Expression* expression_; |
| 916 |
| 917 class TypeField |
| 918 : public BitField<Type, JumpStatement::kNextBitFieldIndex, 2> {}; |
911 }; | 919 }; |
912 | 920 |
913 | 921 |
914 class WithStatement final : public Statement { | 922 class WithStatement final : public Statement { |
915 public: | 923 public: |
916 Scope* scope() { return scope_; } | 924 Scope* scope() { return scope_; } |
917 Expression* expression() const { return expression_; } | 925 Expression* expression() const { return expression_; } |
918 void set_expression(Expression* e) { expression_ = e; } | 926 void set_expression(Expression* e) { expression_ = e; } |
919 Statement* statement() const { return statement_; } | 927 Statement* statement() const { return statement_; } |
920 void set_statement(Statement* s) { statement_ = s; } | 928 void set_statement(Statement* s) { statement_ = s; } |
(...skipping 2282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3203 | 3211 |
3204 ContinueStatement* NewContinueStatement(IterationStatement* target, int pos) { | 3212 ContinueStatement* NewContinueStatement(IterationStatement* target, int pos) { |
3205 return new (zone_) ContinueStatement(target, pos); | 3213 return new (zone_) ContinueStatement(target, pos); |
3206 } | 3214 } |
3207 | 3215 |
3208 BreakStatement* NewBreakStatement(BreakableStatement* target, int pos) { | 3216 BreakStatement* NewBreakStatement(BreakableStatement* target, int pos) { |
3209 return new (zone_) BreakStatement(target, pos); | 3217 return new (zone_) BreakStatement(target, pos); |
3210 } | 3218 } |
3211 | 3219 |
3212 ReturnStatement* NewReturnStatement(Expression* expression, int pos) { | 3220 ReturnStatement* NewReturnStatement(Expression* expression, int pos) { |
3213 return new (zone_) ReturnStatement(expression, pos); | 3221 return new (zone_) |
| 3222 ReturnStatement(expression, ReturnStatement::kNormal, pos); |
| 3223 } |
| 3224 |
| 3225 ReturnStatement* NewAsyncReturnStatement(Expression* expression, int pos) { |
| 3226 return new (zone_) |
| 3227 ReturnStatement(expression, ReturnStatement::kAsyncReturn, pos); |
3214 } | 3228 } |
3215 | 3229 |
3216 WithStatement* NewWithStatement(Scope* scope, | 3230 WithStatement* NewWithStatement(Scope* scope, |
3217 Expression* expression, | 3231 Expression* expression, |
3218 Statement* statement, | 3232 Statement* statement, |
3219 int pos) { | 3233 int pos) { |
3220 return new (zone_) WithStatement(scope, expression, statement, pos); | 3234 return new (zone_) WithStatement(scope, expression, statement, pos); |
3221 } | 3235 } |
3222 | 3236 |
3223 IfStatement* NewIfStatement(Expression* condition, | 3237 IfStatement* NewIfStatement(Expression* condition, |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3629 : NULL; \ | 3643 : NULL; \ |
3630 } | 3644 } |
3631 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3645 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3632 #undef DECLARE_NODE_FUNCTIONS | 3646 #undef DECLARE_NODE_FUNCTIONS |
3633 | 3647 |
3634 | 3648 |
3635 } // namespace internal | 3649 } // namespace internal |
3636 } // namespace v8 | 3650 } // namespace v8 |
3637 | 3651 |
3638 #endif // V8_AST_AST_H_ | 3652 #endif // V8_AST_AST_H_ |
OLD | NEW |