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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 | 484 |
484 private: | 485 private: |
485 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 486 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
486 | 487 |
487 ZoneList<Statement*> statements_; | 488 ZoneList<Statement*> statements_; |
488 bool ignore_completion_value_; | 489 bool ignore_completion_value_; |
489 Scope* scope_; | 490 Scope* scope_; |
490 }; | 491 }; |
491 | 492 |
492 | 493 |
| 494 class DoExpression final : public Expression { |
| 495 public: |
| 496 DECLARE_NODE_TYPE(DoExpression) |
| 497 |
| 498 Block* block() { return block_; } |
| 499 VariableProxy* result() { return result_; } |
| 500 |
| 501 protected: |
| 502 DoExpression(Zone* zone, Block* block, VariableProxy* result, int pos) |
| 503 : Expression(zone, pos), block_(block), result_(result) { |
| 504 DCHECK_NOT_NULL(block_); |
| 505 DCHECK_NOT_NULL(result_); |
| 506 } |
| 507 static int parent_num_ids() { return Expression::num_ids(); } |
| 508 |
| 509 private: |
| 510 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 511 |
| 512 Block* block_; |
| 513 VariableProxy* result_; |
| 514 }; |
| 515 |
| 516 |
493 class Declaration : public AstNode { | 517 class Declaration : public AstNode { |
494 public: | 518 public: |
495 VariableProxy* proxy() const { return proxy_; } | 519 VariableProxy* proxy() const { return proxy_; } |
496 VariableMode mode() const { return mode_; } | 520 VariableMode mode() const { return mode_; } |
497 Scope* scope() const { return scope_; } | 521 Scope* scope() const { return scope_; } |
498 virtual InitializationFlag initialization() const = 0; | 522 virtual InitializationFlag initialization() const = 0; |
499 virtual bool IsInlineable() const; | 523 virtual bool IsInlineable() const; |
500 | 524 |
501 protected: | 525 protected: |
502 Declaration(Zone* zone, VariableProxy* proxy, VariableMode mode, Scope* scope, | 526 Declaration(Zone* zone, VariableProxy* proxy, VariableMode mode, Scope* scope, |
(...skipping 3048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3551 properties, start_position, end_position); | 3575 properties, start_position, end_position); |
3552 } | 3576 } |
3553 | 3577 |
3554 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name, | 3578 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name, |
3555 v8::Extension* extension, | 3579 v8::Extension* extension, |
3556 int pos) { | 3580 int pos) { |
3557 return new (parser_zone_) | 3581 return new (parser_zone_) |
3558 NativeFunctionLiteral(parser_zone_, name, extension, pos); | 3582 NativeFunctionLiteral(parser_zone_, name, extension, pos); |
3559 } | 3583 } |
3560 | 3584 |
| 3585 DoExpression* NewDoExpression(Block* block, Variable* result_var, int pos) { |
| 3586 VariableProxy* result = NewVariableProxy(result_var, pos); |
| 3587 return new (parser_zone_) DoExpression(parser_zone_, block, result, pos); |
| 3588 } |
| 3589 |
3561 ThisFunction* NewThisFunction(int pos) { | 3590 ThisFunction* NewThisFunction(int pos) { |
3562 return new (local_zone_) ThisFunction(local_zone_, pos); | 3591 return new (local_zone_) ThisFunction(local_zone_, pos); |
3563 } | 3592 } |
3564 | 3593 |
3565 SuperPropertyReference* NewSuperPropertyReference(VariableProxy* this_var, | 3594 SuperPropertyReference* NewSuperPropertyReference(VariableProxy* this_var, |
3566 Expression* home_object, | 3595 Expression* home_object, |
3567 int pos) { | 3596 int pos) { |
3568 return new (parser_zone_) | 3597 return new (parser_zone_) |
3569 SuperPropertyReference(parser_zone_, this_var, home_object, pos); | 3598 SuperPropertyReference(parser_zone_, this_var, home_object, pos); |
3570 } | 3599 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3610 // the parser-level zone. | 3639 // the parser-level zone. |
3611 Zone* parser_zone_; | 3640 Zone* parser_zone_; |
3612 AstValueFactory* ast_value_factory_; | 3641 AstValueFactory* ast_value_factory_; |
3613 }; | 3642 }; |
3614 | 3643 |
3615 | 3644 |
3616 } // namespace internal | 3645 } // namespace internal |
3617 } // namespace v8 | 3646 } // namespace v8 |
3618 | 3647 |
3619 #endif // V8_AST_H_ | 3648 #endif // V8_AST_H_ |
OLD | NEW |