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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 V(CallRuntime) \ | 83 V(CallRuntime) \ |
84 V(UnaryOperation) \ | 84 V(UnaryOperation) \ |
85 V(CountOperation) \ | 85 V(CountOperation) \ |
86 V(BinaryOperation) \ | 86 V(BinaryOperation) \ |
87 V(CompareOperation) \ | 87 V(CompareOperation) \ |
88 V(Spread) \ | 88 V(Spread) \ |
89 V(ThisFunction) \ | 89 V(ThisFunction) \ |
90 V(SuperPropertyReference) \ | 90 V(SuperPropertyReference) \ |
91 V(SuperCallReference) \ | 91 V(SuperCallReference) \ |
92 V(CaseClause) \ | 92 V(CaseClause) \ |
93 V(EmptyParentheses) | 93 V(EmptyParentheses) \ |
94 V(DoExpression) | |
94 | 95 |
95 #define AST_NODE_LIST(V) \ | 96 #define AST_NODE_LIST(V) \ |
96 DECLARATION_NODE_LIST(V) \ | 97 DECLARATION_NODE_LIST(V) \ |
97 STATEMENT_NODE_LIST(V) \ | 98 STATEMENT_NODE_LIST(V) \ |
98 EXPRESSION_NODE_LIST(V) | 99 EXPRESSION_NODE_LIST(V) |
99 | 100 |
100 // Forward declarations | 101 // Forward declarations |
101 class AstNodeFactory; | 102 class AstNodeFactory; |
102 class AstVisitor; | 103 class AstVisitor; |
103 class Declaration; | 104 class Declaration; |
(...skipping 2579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2683 NativeFunctionLiteral(Zone* zone, const AstRawString* name, | 2684 NativeFunctionLiteral(Zone* zone, const AstRawString* name, |
2684 v8::Extension* extension, int pos) | 2685 v8::Extension* extension, int pos) |
2685 : Expression(zone, pos), name_(name), extension_(extension) {} | 2686 : Expression(zone, pos), name_(name), extension_(extension) {} |
2686 | 2687 |
2687 private: | 2688 private: |
2688 const AstRawString* name_; | 2689 const AstRawString* name_; |
2689 v8::Extension* extension_; | 2690 v8::Extension* extension_; |
2690 }; | 2691 }; |
2691 | 2692 |
2692 | 2693 |
2694 class DoExpression final : public Expression { | |
2695 public: | |
2696 DECLARE_NODE_TYPE(DoExpression) | |
2697 | |
2698 Scope* scope() { return scope_; } | |
rossberg
2015/10/12 13:52:39
Why not just have a DoExpression carry a Block, in
caitp (gmail)
2015/10/12 18:22:59
Done
| |
2699 ZoneList<Statement*>* statements() { return statements_; } | |
2700 | |
2701 static int num_ids() { return parent_num_ids() + 1; } | |
2702 BailoutId EntryId() const { return BailoutId(local_id(0)); } | |
2703 BailoutId ExitId() const { return BailoutId(local_id(1)); } | |
2704 BailoutId DeclsId() const { return BailoutId(local_id(2)); } | |
2705 | |
2706 VariableProxy* result() { return result_; } | |
2707 | |
2708 protected: | |
2709 DoExpression(Zone* zone, Scope* scope, ZoneList<Statement*>* statements, | |
2710 VariableProxy* result, int pos) | |
2711 : Expression(zone, pos), | |
2712 scope_(scope), | |
2713 statements_(statements), | |
2714 result_(result) { | |
2715 DCHECK_NOT_NULL(scope_); | |
2716 DCHECK_NOT_NULL(statements_); | |
2717 DCHECK_NOT_NULL(result_); | |
2718 } | |
2719 static int parent_num_ids() { return Expression::num_ids(); } | |
2720 | |
2721 private: | |
2722 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
2723 | |
2724 Scope* scope_; | |
2725 ZoneList<Statement*>* statements_; | |
2726 VariableProxy* result_; | |
2727 }; | |
2728 | |
2729 | |
2693 class ThisFunction final : public Expression { | 2730 class ThisFunction final : public Expression { |
2694 public: | 2731 public: |
2695 DECLARE_NODE_TYPE(ThisFunction) | 2732 DECLARE_NODE_TYPE(ThisFunction) |
2696 | 2733 |
2697 protected: | 2734 protected: |
2698 ThisFunction(Zone* zone, int pos) : Expression(zone, pos) {} | 2735 ThisFunction(Zone* zone, int pos) : Expression(zone, pos) {} |
2699 }; | 2736 }; |
2700 | 2737 |
2701 | 2738 |
2702 class SuperPropertyReference final : public Expression { | 2739 class SuperPropertyReference final : public Expression { |
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3551 properties, start_position, end_position); | 3588 properties, start_position, end_position); |
3552 } | 3589 } |
3553 | 3590 |
3554 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name, | 3591 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name, |
3555 v8::Extension* extension, | 3592 v8::Extension* extension, |
3556 int pos) { | 3593 int pos) { |
3557 return new (parser_zone_) | 3594 return new (parser_zone_) |
3558 NativeFunctionLiteral(parser_zone_, name, extension, pos); | 3595 NativeFunctionLiteral(parser_zone_, name, extension, pos); |
3559 } | 3596 } |
3560 | 3597 |
3598 DoExpression* NewDoExpression(Scope* scope, ZoneList<Statement*>* statements, | |
3599 int pos, int end_pos) { | |
3600 Variable* result_var = | |
3601 NewTemporaryVar(scope, ast_value_factory()->dot_result_string()); | |
3602 VariableProxy* result = NewVariableProxy(result_var, end_pos, end_pos); | |
3603 return new (parser_zone_) | |
3604 DoExpression(parser_zone_, scope, statements, result, pos); | |
3605 } | |
3606 | |
3561 ThisFunction* NewThisFunction(int pos) { | 3607 ThisFunction* NewThisFunction(int pos) { |
3562 return new (local_zone_) ThisFunction(local_zone_, pos); | 3608 return new (local_zone_) ThisFunction(local_zone_, pos); |
3563 } | 3609 } |
3564 | 3610 |
3565 SuperPropertyReference* NewSuperPropertyReference(VariableProxy* this_var, | 3611 SuperPropertyReference* NewSuperPropertyReference(VariableProxy* this_var, |
3566 Expression* home_object, | 3612 Expression* home_object, |
3567 int pos) { | 3613 int pos) { |
3568 return new (parser_zone_) | 3614 return new (parser_zone_) |
3569 SuperPropertyReference(parser_zone_, this_var, home_object, pos); | 3615 SuperPropertyReference(parser_zone_, this_var, home_object, pos); |
3570 } | 3616 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3603 private: | 3649 private: |
3604 // This zone may be deallocated upon returning from parsing a function body | 3650 // This zone may be deallocated upon returning from parsing a function body |
3605 // which we can guarantee is not going to be compiled or have its AST | 3651 // which we can guarantee is not going to be compiled or have its AST |
3606 // inspected. | 3652 // inspected. |
3607 // See ParseFunctionLiteral in parser.cc for preconditions. | 3653 // See ParseFunctionLiteral in parser.cc for preconditions. |
3608 Zone* local_zone_; | 3654 Zone* local_zone_; |
3609 // ZoneObjects which need to persist until scope analysis must be allocated in | 3655 // ZoneObjects which need to persist until scope analysis must be allocated in |
3610 // the parser-level zone. | 3656 // the parser-level zone. |
3611 Zone* parser_zone_; | 3657 Zone* parser_zone_; |
3612 AstValueFactory* ast_value_factory_; | 3658 AstValueFactory* ast_value_factory_; |
3659 | |
3660 Variable* NewTemporaryVar(Scope* scope, const AstRawString* name); | |
3613 }; | 3661 }; |
3614 | 3662 |
3615 | 3663 |
3616 } // namespace internal | 3664 } // namespace internal |
3617 } // namespace v8 | 3665 } // namespace v8 |
3618 | 3666 |
3619 #endif // V8_AST_H_ | 3667 #endif // V8_AST_H_ |
OLD | NEW |