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

Side by Side Diff: src/ast.h

Issue 1290013002: [es6] Make assignment to new.target an early ReferenceError (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add a few more tests Created 5 years, 4 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
« no previous file with comments | « no previous file | src/parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1621 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 Handle<FixedArray> constant_elements_; 1632 Handle<FixedArray> constant_elements_;
1633 ZoneList<Expression*>* values_; 1633 ZoneList<Expression*>* values_;
1634 int first_spread_index_; 1634 int first_spread_index_;
1635 }; 1635 };
1636 1636
1637 1637
1638 class VariableProxy final : public Expression { 1638 class VariableProxy final : public Expression {
1639 public: 1639 public:
1640 DECLARE_NODE_TYPE(VariableProxy) 1640 DECLARE_NODE_TYPE(VariableProxy)
1641 1641
1642 bool IsValidReferenceExpression() const override { return !is_this(); } 1642 bool IsValidReferenceExpression() const override {
1643 return !is_this() && !is_new_target();
1644 }
1643 1645
1644 bool IsArguments() const { return is_resolved() && var()->is_arguments(); } 1646 bool IsArguments() const { return is_resolved() && var()->is_arguments(); }
1645 1647
1646 Handle<String> name() const { return raw_name()->string(); } 1648 Handle<String> name() const { return raw_name()->string(); }
1647 const AstRawString* raw_name() const { 1649 const AstRawString* raw_name() const {
1648 return is_resolved() ? var_->raw_name() : raw_name_; 1650 return is_resolved() ? var_->raw_name() : raw_name_;
1649 } 1651 }
1650 1652
1651 Variable* var() const { 1653 Variable* var() const {
1652 DCHECK(is_resolved()); 1654 DCHECK(is_resolved());
(...skipping 10 matching lines...) Expand all
1663 bool is_assigned() const { return IsAssignedField::decode(bit_field_); } 1665 bool is_assigned() const { return IsAssignedField::decode(bit_field_); }
1664 void set_is_assigned() { 1666 void set_is_assigned() {
1665 bit_field_ = IsAssignedField::update(bit_field_, true); 1667 bit_field_ = IsAssignedField::update(bit_field_, true);
1666 } 1668 }
1667 1669
1668 bool is_resolved() const { return IsResolvedField::decode(bit_field_); } 1670 bool is_resolved() const { return IsResolvedField::decode(bit_field_); }
1669 void set_is_resolved() { 1671 void set_is_resolved() {
1670 bit_field_ = IsResolvedField::update(bit_field_, true); 1672 bit_field_ = IsResolvedField::update(bit_field_, true);
1671 } 1673 }
1672 1674
1675 bool is_new_target() const { return IsNewTargetField::decode(bit_field_); }
1676 void set_is_new_target() {
1677 bit_field_ = IsNewTargetField::update(bit_field_, true);
1678 }
1679
1673 int end_position() const { return end_position_; } 1680 int end_position() const { return end_position_; }
1674 1681
1675 // Bind this proxy to the variable var. 1682 // Bind this proxy to the variable var.
1676 void BindTo(Variable* var); 1683 void BindTo(Variable* var);
1677 1684
1678 bool UsesVariableFeedbackSlot() const { 1685 bool UsesVariableFeedbackSlot() const {
1679 return var()->IsUnallocated() || var()->IsLookupSlot(); 1686 return var()->IsUnallocated() || var()->IsLookupSlot();
1680 } 1687 }
1681 1688
1682 virtual FeedbackVectorRequirements ComputeFeedbackRequirements( 1689 virtual FeedbackVectorRequirements ComputeFeedbackRequirements(
(...skipping 15 matching lines...) Expand all
1698 1705
1699 VariableProxy(Zone* zone, const AstRawString* name, 1706 VariableProxy(Zone* zone, const AstRawString* name,
1700 Variable::Kind variable_kind, int start_position, 1707 Variable::Kind variable_kind, int start_position,
1701 int end_position); 1708 int end_position);
1702 static int parent_num_ids() { return Expression::num_ids(); } 1709 static int parent_num_ids() { return Expression::num_ids(); }
1703 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 1710 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1704 1711
1705 class IsThisField : public BitField8<bool, 0, 1> {}; 1712 class IsThisField : public BitField8<bool, 0, 1> {};
1706 class IsAssignedField : public BitField8<bool, 1, 1> {}; 1713 class IsAssignedField : public BitField8<bool, 1, 1> {};
1707 class IsResolvedField : public BitField8<bool, 2, 1> {}; 1714 class IsResolvedField : public BitField8<bool, 2, 1> {};
1715 class IsNewTargetField : public BitField8<bool, 3, 1> {};
1708 1716
1709 // Start with 16-bit (or smaller) field, which should get packed together 1717 // Start with 16-bit (or smaller) field, which should get packed together
1710 // with Expression's trailing 16-bit field. 1718 // with Expression's trailing 16-bit field.
1711 uint8_t bit_field_; 1719 uint8_t bit_field_;
1712 FeedbackVectorICSlot variable_feedback_slot_; 1720 FeedbackVectorICSlot variable_feedback_slot_;
1713 union { 1721 union {
1714 const AstRawString* raw_name_; // if !is_resolved_ 1722 const AstRawString* raw_name_; // if !is_resolved_
1715 Variable* var_; // if is_resolved_ 1723 Variable* var_; // if is_resolved_
1716 }; 1724 };
1717 // Position is stored in the AstNode superclass, but VariableProxy needs to 1725 // Position is stored in the AstNode superclass, but VariableProxy needs to
(...skipping 1909 matching lines...) Expand 10 before | Expand all | Expand 10 after
3627 3635
3628 private: 3636 private:
3629 Zone* zone_; 3637 Zone* zone_;
3630 AstValueFactory* ast_value_factory_; 3638 AstValueFactory* ast_value_factory_;
3631 }; 3639 };
3632 3640
3633 3641
3634 } } // namespace v8::internal 3642 } } // namespace v8::internal
3635 3643
3636 #endif // V8_AST_H_ 3644 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698