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_H_ | 5 #ifndef V8_AST_H_ |
6 #define V8_AST_H_ | 6 #define V8_AST_H_ |
7 | 7 |
8 #include "src/assembler.h" | 8 #include "src/assembler.h" |
9 #include "src/ast-value-factory.h" | 9 #include "src/ast-value-factory.h" |
10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
663 Block* body_; | 663 Block* body_; |
664 }; | 664 }; |
665 | 665 |
666 | 666 |
667 class IterationStatement : public BreakableStatement { | 667 class IterationStatement : public BreakableStatement { |
668 public: | 668 public: |
669 // Type testing & conversion. | 669 // Type testing & conversion. |
670 IterationStatement* AsIterationStatement() final { return this; } | 670 IterationStatement* AsIterationStatement() final { return this; } |
671 | 671 |
672 Statement* body() const { return body_; } | 672 Statement* body() const { return body_; } |
673 void set_body(Statement* s) { body_ = s; } | |
673 | 674 |
674 static int num_ids() { return parent_num_ids() + 1; } | 675 static int num_ids() { return parent_num_ids() + 1; } |
675 BailoutId OsrEntryId() const { return BailoutId(local_id(0)); } | 676 BailoutId OsrEntryId() const { return BailoutId(local_id(0)); } |
676 virtual BailoutId ContinueId() const = 0; | 677 virtual BailoutId ContinueId() const = 0; |
677 virtual BailoutId StackCheckId() const = 0; | 678 virtual BailoutId StackCheckId() const = 0; |
678 | 679 |
679 // Code generation | 680 // Code generation |
680 Label* continue_target() { return &continue_target_; } | 681 Label* continue_target() { return &continue_target_; } |
681 | 682 |
682 protected: | 683 protected: |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1021 }; | 1022 }; |
1022 | 1023 |
1023 | 1024 |
1024 class WithStatement final : public Statement { | 1025 class WithStatement final : public Statement { |
1025 public: | 1026 public: |
1026 DECLARE_NODE_TYPE(WithStatement) | 1027 DECLARE_NODE_TYPE(WithStatement) |
1027 | 1028 |
1028 Scope* scope() { return scope_; } | 1029 Scope* scope() { return scope_; } |
1029 Expression* expression() const { return expression_; } | 1030 Expression* expression() const { return expression_; } |
1030 Statement* statement() const { return statement_; } | 1031 Statement* statement() const { return statement_; } |
1032 void set_statement(Statement* s) { statement_ = s; } | |
1031 | 1033 |
1032 void set_base_id(int id) { base_id_ = id; } | 1034 void set_base_id(int id) { base_id_ = id; } |
1033 static int num_ids() { return parent_num_ids() + 1; } | 1035 static int num_ids() { return parent_num_ids() + 1; } |
1034 BailoutId EntryId() const { return BailoutId(local_id(0)); } | 1036 BailoutId EntryId() const { return BailoutId(local_id(0)); } |
1035 | 1037 |
1036 protected: | 1038 protected: |
1037 WithStatement(Zone* zone, Scope* scope, Expression* expression, | 1039 WithStatement(Zone* zone, Scope* scope, Expression* expression, |
1038 Statement* statement, int pos) | 1040 Statement* statement, int pos) |
1039 : Statement(zone, pos), | 1041 : Statement(zone, pos), |
1040 scope_(scope), | 1042 scope_(scope), |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1125 public: | 1127 public: |
1126 DECLARE_NODE_TYPE(IfStatement) | 1128 DECLARE_NODE_TYPE(IfStatement) |
1127 | 1129 |
1128 bool HasThenStatement() const { return !then_statement()->IsEmpty(); } | 1130 bool HasThenStatement() const { return !then_statement()->IsEmpty(); } |
1129 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } | 1131 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } |
1130 | 1132 |
1131 Expression* condition() const { return condition_; } | 1133 Expression* condition() const { return condition_; } |
1132 Statement* then_statement() const { return then_statement_; } | 1134 Statement* then_statement() const { return then_statement_; } |
1133 Statement* else_statement() const { return else_statement_; } | 1135 Statement* else_statement() const { return else_statement_; } |
1134 | 1136 |
1137 void set_then_statement(Statement* s) { then_statement_ = s; } | |
rossberg
2015/09/28 11:42:15
Can you add assertions DCHECK(s != nullptr) to all
| |
1138 void set_else_statement(Statement* s) { else_statement_ = s; } | |
1139 | |
1135 bool IsJump() const override { | 1140 bool IsJump() const override { |
1136 return HasThenStatement() && then_statement()->IsJump() | 1141 return HasThenStatement() && then_statement()->IsJump() |
1137 && HasElseStatement() && else_statement()->IsJump(); | 1142 && HasElseStatement() && else_statement()->IsJump(); |
1138 } | 1143 } |
1139 | 1144 |
1140 void set_base_id(int id) { base_id_ = id; } | 1145 void set_base_id(int id) { base_id_ = id; } |
1141 static int num_ids() { return parent_num_ids() + 3; } | 1146 static int num_ids() { return parent_num_ids() + 3; } |
1142 BailoutId IfId() const { return BailoutId(local_id(0)); } | 1147 BailoutId IfId() const { return BailoutId(local_id(0)); } |
1143 BailoutId ThenId() const { return BailoutId(local_id(1)); } | 1148 BailoutId ThenId() const { return BailoutId(local_id(1)); } |
1144 BailoutId ElseId() const { return BailoutId(local_id(2)); } | 1149 BailoutId ElseId() const { return BailoutId(local_id(2)); } |
(...skipping 19 matching lines...) Expand all Loading... | |
1164 Expression* condition_; | 1169 Expression* condition_; |
1165 Statement* then_statement_; | 1170 Statement* then_statement_; |
1166 Statement* else_statement_; | 1171 Statement* else_statement_; |
1167 int base_id_; | 1172 int base_id_; |
1168 }; | 1173 }; |
1169 | 1174 |
1170 | 1175 |
1171 class TryStatement : public Statement { | 1176 class TryStatement : public Statement { |
1172 public: | 1177 public: |
1173 Block* try_block() const { return try_block_; } | 1178 Block* try_block() const { return try_block_; } |
1179 void set_try_block(Block* b) { try_block_ = b; } | |
1174 | 1180 |
1175 void set_base_id(int id) { base_id_ = id; } | 1181 void set_base_id(int id) { base_id_ = id; } |
1176 static int num_ids() { return parent_num_ids() + 1; } | 1182 static int num_ids() { return parent_num_ids() + 1; } |
1177 BailoutId HandlerId() const { return BailoutId(local_id(0)); } | 1183 BailoutId HandlerId() const { return BailoutId(local_id(0)); } |
1178 | 1184 |
1179 protected: | 1185 protected: |
1180 TryStatement(Zone* zone, Block* try_block, int pos) | 1186 TryStatement(Zone* zone, Block* try_block, int pos) |
1181 : Statement(zone, pos), | 1187 : Statement(zone, pos), |
1182 try_block_(try_block), | 1188 try_block_(try_block), |
1183 base_id_(BailoutId::None().ToInt()) {} | 1189 base_id_(BailoutId::None().ToInt()) {} |
(...skipping 12 matching lines...) Expand all Loading... | |
1196 }; | 1202 }; |
1197 | 1203 |
1198 | 1204 |
1199 class TryCatchStatement final : public TryStatement { | 1205 class TryCatchStatement final : public TryStatement { |
1200 public: | 1206 public: |
1201 DECLARE_NODE_TYPE(TryCatchStatement) | 1207 DECLARE_NODE_TYPE(TryCatchStatement) |
1202 | 1208 |
1203 Scope* scope() { return scope_; } | 1209 Scope* scope() { return scope_; } |
1204 Variable* variable() { return variable_; } | 1210 Variable* variable() { return variable_; } |
1205 Block* catch_block() const { return catch_block_; } | 1211 Block* catch_block() const { return catch_block_; } |
1212 void set_catch_block(Block* b) { catch_block_ = b; } | |
1206 | 1213 |
1207 protected: | 1214 protected: |
1208 TryCatchStatement(Zone* zone, Block* try_block, Scope* scope, | 1215 TryCatchStatement(Zone* zone, Block* try_block, Scope* scope, |
1209 Variable* variable, Block* catch_block, int pos) | 1216 Variable* variable, Block* catch_block, int pos) |
1210 : TryStatement(zone, try_block, pos), | 1217 : TryStatement(zone, try_block, pos), |
1211 scope_(scope), | 1218 scope_(scope), |
1212 variable_(variable), | 1219 variable_(variable), |
1213 catch_block_(catch_block) {} | 1220 catch_block_(catch_block) {} |
1214 | 1221 |
1215 private: | 1222 private: |
1216 Scope* scope_; | 1223 Scope* scope_; |
1217 Variable* variable_; | 1224 Variable* variable_; |
1218 Block* catch_block_; | 1225 Block* catch_block_; |
1219 }; | 1226 }; |
1220 | 1227 |
1221 | 1228 |
1222 class TryFinallyStatement final : public TryStatement { | 1229 class TryFinallyStatement final : public TryStatement { |
1223 public: | 1230 public: |
1224 DECLARE_NODE_TYPE(TryFinallyStatement) | 1231 DECLARE_NODE_TYPE(TryFinallyStatement) |
1225 | 1232 |
1226 Block* finally_block() const { return finally_block_; } | 1233 Block* finally_block() const { return finally_block_; } |
1234 void set_finally_block(Block* b) { finally_block_ = b; } | |
1227 | 1235 |
1228 protected: | 1236 protected: |
1229 TryFinallyStatement(Zone* zone, Block* try_block, Block* finally_block, | 1237 TryFinallyStatement(Zone* zone, Block* try_block, Block* finally_block, |
1230 int pos) | 1238 int pos) |
1231 : TryStatement(zone, try_block, pos), finally_block_(finally_block) {} | 1239 : TryStatement(zone, try_block, pos), finally_block_(finally_block) {} |
1232 | 1240 |
1233 private: | 1241 private: |
1234 Block* finally_block_; | 1242 Block* finally_block_; |
1235 }; | 1243 }; |
1236 | 1244 |
(...skipping 2492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3729 // ZoneObjects which need to persist until scope analysis must be allocated in | 3737 // ZoneObjects which need to persist until scope analysis must be allocated in |
3730 // the parser-level zone. | 3738 // the parser-level zone. |
3731 Zone* parser_zone_; | 3739 Zone* parser_zone_; |
3732 AstValueFactory* ast_value_factory_; | 3740 AstValueFactory* ast_value_factory_; |
3733 }; | 3741 }; |
3734 | 3742 |
3735 | 3743 |
3736 } } // namespace v8::internal | 3744 } } // namespace v8::internal |
3737 | 3745 |
3738 #endif // V8_AST_H_ | 3746 #endif // V8_AST_H_ |
OLD | NEW |