Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(426)

Side by Side Diff: src/ast.h

Issue 1272673003: [es6] Re-implement rest parameters via desugaring. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase + fix brokenness Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 V(CallRuntime) \ 82 V(CallRuntime) \
83 V(UnaryOperation) \ 83 V(UnaryOperation) \
84 V(CountOperation) \ 84 V(CountOperation) \
85 V(BinaryOperation) \ 85 V(BinaryOperation) \
86 V(CompareOperation) \ 86 V(CompareOperation) \
87 V(Spread) \ 87 V(Spread) \
88 V(ThisFunction) \ 88 V(ThisFunction) \
89 V(SuperPropertyReference) \ 89 V(SuperPropertyReference) \
90 V(SuperCallReference) \ 90 V(SuperCallReference) \
91 V(CaseClause) \ 91 V(CaseClause) \
92 V(EmptyParentheses) 92 V(EmptyParentheses) \
93 V(RestParameter)
93 94
94 #define AST_NODE_LIST(V) \ 95 #define AST_NODE_LIST(V) \
95 DECLARATION_NODE_LIST(V) \ 96 DECLARATION_NODE_LIST(V) \
96 STATEMENT_NODE_LIST(V) \ 97 STATEMENT_NODE_LIST(V) \
97 EXPRESSION_NODE_LIST(V) 98 EXPRESSION_NODE_LIST(V)
98 99
99 // Forward declarations 100 // Forward declarations
100 class AstNodeFactory; 101 class AstNodeFactory;
101 class AstVisitor; 102 class AstVisitor;
102 class Declaration; 103 class Declaration;
(...skipping 1620 matching lines...) Expand 10 before | Expand all | Expand 10 after
1723 const AstRawString* raw_name_; // if !is_resolved_ 1724 const AstRawString* raw_name_; // if !is_resolved_
1724 Variable* var_; // if is_resolved_ 1725 Variable* var_; // if is_resolved_
1725 }; 1726 };
1726 // Position is stored in the AstNode superclass, but VariableProxy needs to 1727 // Position is stored in the AstNode superclass, but VariableProxy needs to
1727 // know its end position too (for error messages). It cannot be inferred from 1728 // know its end position too (for error messages). It cannot be inferred from
1728 // the variable name length because it can contain escapes. 1729 // the variable name length because it can contain escapes.
1729 int end_position_; 1730 int end_position_;
1730 }; 1731 };
1731 1732
1732 1733
1734 class RestParameter final : public Expression {
1735 public:
1736 DECLARE_NODE_TYPE(RestParameter)
1737
1738 VariableProxy* parameter() const { return parameter_; }
1739 int literal_index() const { return literal_index_; }
1740
1741 int end_position() const { return parameter_->end_position(); }
1742
1743 protected:
1744 RestParameter(Zone* zone, VariableProxy* parameter, int literal_index,
1745 int position)
1746 : Expression(zone, position),
1747 parameter_(parameter),
1748 literal_index_(literal_index) {}
1749
1750 VariableProxy* parameter_;
1751 int literal_index_;
1752
1753 friend class AstLiteralReindexer;
1754 };
1755
1756
1733 // Left-hand side can only be a property, a global or a (parameter or local) 1757 // Left-hand side can only be a property, a global or a (parameter or local)
1734 // slot. 1758 // slot.
1735 enum LhsKind { 1759 enum LhsKind {
1736 VARIABLE, 1760 VARIABLE,
1737 NAMED_PROPERTY, 1761 NAMED_PROPERTY,
1738 KEYED_PROPERTY, 1762 KEYED_PROPERTY,
1739 NAMED_SUPER_PROPERTY, 1763 NAMED_SUPER_PROPERTY,
1740 KEYED_SUPER_PROPERTY 1764 KEYED_SUPER_PROPERTY
1741 }; 1765 };
1742 1766
(...skipping 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after
3492 3516
3493 VariableProxy* NewVariableProxy(const AstRawString* name, 3517 VariableProxy* NewVariableProxy(const AstRawString* name,
3494 Variable::Kind variable_kind, 3518 Variable::Kind variable_kind,
3495 int start_position = RelocInfo::kNoPosition, 3519 int start_position = RelocInfo::kNoPosition,
3496 int end_position = RelocInfo::kNoPosition) { 3520 int end_position = RelocInfo::kNoPosition) {
3497 DCHECK_NOT_NULL(name); 3521 DCHECK_NOT_NULL(name);
3498 return new (zone_) 3522 return new (zone_)
3499 VariableProxy(zone_, name, variable_kind, start_position, end_position); 3523 VariableProxy(zone_, name, variable_kind, start_position, end_position);
3500 } 3524 }
3501 3525
3526 RestParameter* NewRestParameter(VariableProxy* parameter, int literal_index,
3527 int position) {
3528 DCHECK_NOT_NULL(parameter);
3529 DCHECK(literal_index >= 0);
3530 DCHECK(position >= 0);
3531
3532 return new (zone_) RestParameter(zone_, parameter, literal_index, position);
3533 }
3534
3502 Property* NewProperty(Expression* obj, Expression* key, int pos) { 3535 Property* NewProperty(Expression* obj, Expression* key, int pos) {
3503 return new (zone_) Property(zone_, obj, key, pos); 3536 return new (zone_) Property(zone_, obj, key, pos);
3504 } 3537 }
3505 3538
3506 Call* NewCall(Expression* expression, 3539 Call* NewCall(Expression* expression,
3507 ZoneList<Expression*>* arguments, 3540 ZoneList<Expression*>* arguments,
3508 int pos) { 3541 int pos) {
3509 return new (zone_) Call(zone_, expression, arguments, pos); 3542 return new (zone_) Call(zone_, expression, arguments, pos);
3510 } 3543 }
3511 3544
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
3654 3687
3655 private: 3688 private:
3656 Zone* zone_; 3689 Zone* zone_;
3657 AstValueFactory* ast_value_factory_; 3690 AstValueFactory* ast_value_factory_;
3658 }; 3691 };
3659 3692
3660 3693
3661 } } // namespace v8::internal 3694 } } // namespace v8::internal
3662 3695
3663 #endif // V8_AST_H_ 3696 #endif // V8_AST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698