Chromium Code Reviews| 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/assembler.h" | 8 #include "src/assembler.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 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1175 | 1175 |
| 1176 | 1176 |
| 1177 class TryCatchStatement final : public TryStatement { | 1177 class TryCatchStatement final : public TryStatement { |
| 1178 public: | 1178 public: |
| 1179 DECLARE_NODE_TYPE(TryCatchStatement) | 1179 DECLARE_NODE_TYPE(TryCatchStatement) |
| 1180 | 1180 |
| 1181 Scope* scope() { return scope_; } | 1181 Scope* scope() { return scope_; } |
| 1182 Variable* variable() { return variable_; } | 1182 Variable* variable() { return variable_; } |
| 1183 Block* catch_block() const { return catch_block_; } | 1183 Block* catch_block() const { return catch_block_; } |
| 1184 void set_catch_block(Block* b) { catch_block_ = b; } | 1184 void set_catch_block(Block* b) { catch_block_ = b; } |
| 1185 bool clear_pending_message() { return clear_pending_message_; } | |
| 1185 | 1186 |
| 1186 protected: | 1187 protected: |
| 1187 TryCatchStatement(Zone* zone, Block* try_block, Scope* scope, | 1188 TryCatchStatement(Zone* zone, Block* try_block, Scope* scope, |
| 1188 Variable* variable, Block* catch_block, int pos) | 1189 Variable* variable, Block* catch_block, |
| 1190 bool clear_pending_message, int pos) | |
| 1189 : TryStatement(zone, try_block, pos), | 1191 : TryStatement(zone, try_block, pos), |
| 1190 scope_(scope), | 1192 scope_(scope), |
| 1191 variable_(variable), | 1193 variable_(variable), |
| 1192 catch_block_(catch_block) {} | 1194 catch_block_(catch_block), |
| 1195 clear_pending_message_(clear_pending_message) {} | |
| 1193 | 1196 |
| 1194 private: | 1197 private: |
| 1195 Scope* scope_; | 1198 Scope* scope_; |
| 1196 Variable* variable_; | 1199 Variable* variable_; |
| 1197 Block* catch_block_; | 1200 Block* catch_block_; |
| 1201 bool clear_pending_message_; | |
| 1198 }; | 1202 }; |
| 1199 | 1203 |
| 1200 | 1204 |
| 1201 class TryFinallyStatement final : public TryStatement { | 1205 class TryFinallyStatement final : public TryStatement { |
| 1202 public: | 1206 public: |
| 1203 DECLARE_NODE_TYPE(TryFinallyStatement) | 1207 DECLARE_NODE_TYPE(TryFinallyStatement) |
| 1204 | 1208 |
| 1205 Block* finally_block() const { return finally_block_; } | 1209 Block* finally_block() const { return finally_block_; } |
| 1206 void set_finally_block(Block* b) { finally_block_ = b; } | 1210 void set_finally_block(Block* b) { finally_block_ = b; } |
| 1207 | 1211 |
| (...skipping 1916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3124 } | 3128 } |
| 3125 | 3129 |
| 3126 IfStatement* NewIfStatement(Expression* condition, | 3130 IfStatement* NewIfStatement(Expression* condition, |
| 3127 Statement* then_statement, | 3131 Statement* then_statement, |
| 3128 Statement* else_statement, | 3132 Statement* else_statement, |
| 3129 int pos) { | 3133 int pos) { |
| 3130 return new (local_zone_) IfStatement(local_zone_, condition, then_statement, | 3134 return new (local_zone_) IfStatement(local_zone_, condition, then_statement, |
| 3131 else_statement, pos); | 3135 else_statement, pos); |
| 3132 } | 3136 } |
| 3133 | 3137 |
| 3138 // The clear_pending_message flag indicates whether or not to clear the | |
| 3139 // isolate's pending exception message before executing the catch_block. In | |
| 3140 // the normal use case, this flag is always on because the message object | |
| 3141 // is not needed anymore when entering the catch block and should not be kept | |
| 3142 // alive. | |
| 3143 // The use case where the flag is off is when the catch block is guaranteed to | |
| 3144 // rethrow the caught exception (using %ReThrow), which reuses the pending | |
| 3145 // message instead of generating a new one. | |
| 3146 // (When the catch block doesn't rethrow but is guaranteed to perform an | |
| 3147 // ordinary throw, not clearing the old message is safe but not very useful.) | |
| 3134 TryCatchStatement* NewTryCatchStatement(Block* try_block, Scope* scope, | 3148 TryCatchStatement* NewTryCatchStatement(Block* try_block, Scope* scope, |
| 3135 Variable* variable, | 3149 Variable* variable, |
| 3136 Block* catch_block, int pos) { | 3150 Block* catch_block, |
| 3137 return new (local_zone_) TryCatchStatement(local_zone_, try_block, scope, | 3151 bool clear_pending_message, int pos) { |
|
Yang
2016/03/30 12:12:49
I'd prefer having an enum so the callsite clearly
| |
| 3138 variable, catch_block, pos); | 3152 return new (local_zone_) |
| 3153 TryCatchStatement(local_zone_, try_block, scope, variable, catch_block, | |
| 3154 clear_pending_message, pos); | |
| 3139 } | 3155 } |
| 3140 | 3156 |
| 3141 TryFinallyStatement* NewTryFinallyStatement(Block* try_block, | 3157 TryFinallyStatement* NewTryFinallyStatement(Block* try_block, |
| 3142 Block* finally_block, int pos) { | 3158 Block* finally_block, int pos) { |
| 3143 return new (local_zone_) | 3159 return new (local_zone_) |
| 3144 TryFinallyStatement(local_zone_, try_block, finally_block, pos); | 3160 TryFinallyStatement(local_zone_, try_block, finally_block, pos); |
| 3145 } | 3161 } |
| 3146 | 3162 |
| 3147 DebuggerStatement* NewDebuggerStatement(int pos) { | 3163 DebuggerStatement* NewDebuggerStatement(int pos) { |
| 3148 return new (local_zone_) DebuggerStatement(local_zone_, pos); | 3164 return new (local_zone_) DebuggerStatement(local_zone_, pos); |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3514 : NULL; \ | 3530 : NULL; \ |
| 3515 } | 3531 } |
| 3516 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3532 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
| 3517 #undef DECLARE_NODE_FUNCTIONS | 3533 #undef DECLARE_NODE_FUNCTIONS |
| 3518 | 3534 |
| 3519 | 3535 |
| 3520 } // namespace internal | 3536 } // namespace internal |
| 3521 } // namespace v8 | 3537 } // namespace v8 |
| 3522 | 3538 |
| 3523 #endif // V8_AST_AST_H_ | 3539 #endif // V8_AST_AST_H_ |
| OLD | NEW |