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 2316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2327 public: | 2327 public: |
2328 DECLARE_NODE_TYPE(Assignment) | 2328 DECLARE_NODE_TYPE(Assignment) |
2329 | 2329 |
2330 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } | 2330 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } |
2331 | 2331 |
2332 Token::Value binary_op() const; | 2332 Token::Value binary_op() const; |
2333 | 2333 |
2334 Token::Value op() const { return TokenField::decode(bit_field_); } | 2334 Token::Value op() const { return TokenField::decode(bit_field_); } |
2335 Expression* target() const { return target_; } | 2335 Expression* target() const { return target_; } |
2336 Expression* value() const { return value_; } | 2336 Expression* value() const { return value_; } |
2337 Expression* destructuring_assignment() const { | |
2338 return destructuring_assignment_; | |
2339 } | |
2337 BinaryOperation* binary_operation() const { return binary_operation_; } | 2340 BinaryOperation* binary_operation() const { return binary_operation_; } |
2338 | 2341 |
2339 // This check relies on the definition order of token in token.h. | 2342 // This check relies on the definition order of token in token.h. |
2340 bool is_compound() const { return op() > Token::ASSIGN; } | 2343 bool is_compound() const { return op() > Token::ASSIGN; } |
2341 | 2344 |
2342 static int num_ids() { return parent_num_ids() + 2; } | 2345 static int num_ids() { return parent_num_ids() + 2; } |
2343 BailoutId AssignmentId() const { return BailoutId(local_id(0)); } | 2346 BailoutId AssignmentId() const { return BailoutId(local_id(0)); } |
2344 | 2347 |
2345 // Type feedback information. | 2348 // Type feedback information. |
2346 TypeFeedbackId AssignmentFeedbackId() { return TypeFeedbackId(local_id(1)); } | 2349 TypeFeedbackId AssignmentFeedbackId() { return TypeFeedbackId(local_id(1)); } |
(...skipping 13 matching lines...) Expand all Loading... | |
2360 } | 2363 } |
2361 void set_is_uninitialized(bool b) { | 2364 void set_is_uninitialized(bool b) { |
2362 bit_field_ = IsUninitializedField::update(bit_field_, b); | 2365 bit_field_ = IsUninitializedField::update(bit_field_, b); |
2363 } | 2366 } |
2364 void set_key_type(IcCheckType key_type) { | 2367 void set_key_type(IcCheckType key_type) { |
2365 bit_field_ = KeyTypeField::update(bit_field_, key_type); | 2368 bit_field_ = KeyTypeField::update(bit_field_, key_type); |
2366 } | 2369 } |
2367 void set_store_mode(KeyedAccessStoreMode mode) { | 2370 void set_store_mode(KeyedAccessStoreMode mode) { |
2368 bit_field_ = StoreModeField::update(bit_field_, mode); | 2371 bit_field_ = StoreModeField::update(bit_field_, mode); |
2369 } | 2372 } |
2373 bool is_destructuring_assignment() const { | |
2374 return DestructuringAssignmentField::decode(bit_field_); | |
2375 } | |
2376 void set_is_destructuring_assignment() { | |
2377 bit_field_ |= DestructuringAssignmentField::encode(true); | |
2378 } | |
2379 Expression* destructuring_assignment() { return destructuring_assignment_; } | |
adamk
2015/11/25 21:05:28
Looks like this is a non-const dup of the above ac
caitp (gmail)
2015/11/25 21:41:51
Acknowledged.
| |
2380 | |
2381 void set_destructuring_assignment(Expression* expression) { | |
2382 destructuring_assignment_ = expression; | |
2383 } | |
2370 | 2384 |
2371 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 2385 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
2372 FeedbackVectorSlotCache* cache) override; | 2386 FeedbackVectorSlotCache* cache) override; |
2373 FeedbackVectorSlot AssignmentSlot() const { return slot_; } | 2387 FeedbackVectorSlot AssignmentSlot() const { return slot_; } |
2374 | 2388 |
2375 protected: | 2389 protected: |
2376 Assignment(Zone* zone, Token::Value op, Expression* target, Expression* value, | 2390 Assignment(Zone* zone, Token::Value op, Expression* target, Expression* value, |
2377 int pos); | 2391 int pos); |
2378 static int parent_num_ids() { return Expression::num_ids(); } | 2392 static int parent_num_ids() { return Expression::num_ids(); } |
2379 | 2393 |
2380 private: | 2394 private: |
2381 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2395 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
2382 | 2396 |
2383 class IsUninitializedField : public BitField16<bool, 0, 1> {}; | 2397 class IsUninitializedField : public BitField16<bool, 0, 1> {}; |
2384 class KeyTypeField : public BitField16<IcCheckType, 1, 1> {}; | 2398 class KeyTypeField : public BitField16<IcCheckType, 1, 1> {}; |
2385 class StoreModeField : public BitField16<KeyedAccessStoreMode, 2, 3> {}; | 2399 class StoreModeField : public BitField16<KeyedAccessStoreMode, 2, 3> {}; |
2386 class TokenField : public BitField16<Token::Value, 5, 8> {}; | 2400 class TokenField : public BitField16<Token::Value, 5, 8> {}; |
2401 class DestructuringAssignmentField | |
2402 : public BitField16<bool, TokenField::kNext, 1> {}; | |
adamk
2015/11/25 21:05:28
Can you use kNext for the above lines while you're
caitp (gmail)
2015/11/25 21:41:51
Acknowledged.
| |
2387 | 2403 |
2388 // Starts with 16-bit field, which should get packed together with | 2404 // Starts with 16-bit field, which should get packed together with |
2389 // Expression's trailing 16-bit field. | 2405 // Expression's trailing 16-bit field. |
2390 uint16_t bit_field_; | 2406 uint16_t bit_field_; |
2391 Expression* target_; | 2407 Expression* target_; |
2392 Expression* value_; | 2408 Expression* value_; |
2409 Expression* destructuring_assignment_; | |
2393 BinaryOperation* binary_operation_; | 2410 BinaryOperation* binary_operation_; |
2394 SmallMapList receiver_types_; | 2411 SmallMapList receiver_types_; |
2395 FeedbackVectorSlot slot_; | 2412 FeedbackVectorSlot slot_; |
2396 }; | 2413 }; |
2397 | 2414 |
2398 | 2415 |
2399 class Yield final : public Expression { | 2416 class Yield final : public Expression { |
2400 public: | 2417 public: |
2401 DECLARE_NODE_TYPE(Yield) | 2418 DECLARE_NODE_TYPE(Yield) |
2402 | 2419 |
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3189 virtual void VisitStatements(ZoneList<Statement*>* statements); | 3206 virtual void VisitStatements(ZoneList<Statement*>* statements); |
3190 virtual void VisitExpressions(ZoneList<Expression*>* expressions); | 3207 virtual void VisitExpressions(ZoneList<Expression*>* expressions); |
3191 | 3208 |
3192 // Individual AST nodes. | 3209 // Individual AST nodes. |
3193 #define DEF_VISIT(type) \ | 3210 #define DEF_VISIT(type) \ |
3194 virtual void Visit##type(type* node) = 0; | 3211 virtual void Visit##type(type* node) = 0; |
3195 AST_NODE_LIST(DEF_VISIT) | 3212 AST_NODE_LIST(DEF_VISIT) |
3196 #undef DEF_VISIT | 3213 #undef DEF_VISIT |
3197 }; | 3214 }; |
3198 | 3215 |
3216 // Pattern used in some AST visitors | |
3217 #define RETURN_IF_VISIT_NODE(node) \ | |
3218 do { \ | |
3219 AstNode* tmp = node; \ | |
3220 if (tmp != nullptr) { \ | |
3221 Visit(tmp); \ | |
3222 return; \ | |
3223 } \ | |
3224 } while (false) | |
3199 | 3225 |
3200 #define DEFINE_AST_VISITOR_SUBCLASS_MEMBERS() \ | 3226 #define DEFINE_AST_VISITOR_SUBCLASS_MEMBERS() \ |
3201 public: \ | 3227 public: \ |
3202 void Visit(AstNode* node) final { \ | 3228 void Visit(AstNode* node) final { \ |
3203 if (!CheckStackOverflow()) node->Accept(this); \ | 3229 if (!CheckStackOverflow()) node->Accept(this); \ |
3204 } \ | 3230 } \ |
3205 \ | 3231 \ |
3206 void SetStackOverflow() { stack_overflow_ = true; } \ | 3232 void SetStackOverflow() { stack_overflow_ = true; } \ |
3207 void ClearStackOverflow() { stack_overflow_ = false; } \ | 3233 void ClearStackOverflow() { stack_overflow_ = false; } \ |
3208 bool HasStackOverflow() const { return stack_overflow_; } \ | 3234 bool HasStackOverflow() const { return stack_overflow_; } \ |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3670 // the parser-level zone. | 3696 // the parser-level zone. |
3671 Zone* parser_zone_; | 3697 Zone* parser_zone_; |
3672 AstValueFactory* ast_value_factory_; | 3698 AstValueFactory* ast_value_factory_; |
3673 }; | 3699 }; |
3674 | 3700 |
3675 | 3701 |
3676 } // namespace internal | 3702 } // namespace internal |
3677 } // namespace v8 | 3703 } // namespace v8 |
3678 | 3704 |
3679 #endif // V8_AST_H_ | 3705 #endif // V8_AST_H_ |
OLD | NEW |