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/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/assembler.h" | 10 #include "src/assembler.h" |
(...skipping 1581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1592 Handle<FixedArray> constant_elements_; | 1592 Handle<FixedArray> constant_elements_; |
1593 ZoneList<Expression*>* values_; | 1593 ZoneList<Expression*>* values_; |
1594 }; | 1594 }; |
1595 | 1595 |
1596 | 1596 |
1597 class VariableProxy FINAL : public Expression { | 1597 class VariableProxy FINAL : public Expression { |
1598 public: | 1598 public: |
1599 DECLARE_NODE_TYPE(VariableProxy) | 1599 DECLARE_NODE_TYPE(VariableProxy) |
1600 | 1600 |
1601 bool IsValidReferenceExpression() const OVERRIDE { | 1601 bool IsValidReferenceExpression() const OVERRIDE { |
1602 return !is_resolved() || var()->IsValidReference(); | 1602 return !is_this() && !is_new_target(); |
1603 } | 1603 } |
1604 | 1604 |
1605 bool IsArguments() const { return is_resolved() && var()->is_arguments(); } | 1605 bool IsArguments() const { return is_resolved() && var()->is_arguments(); } |
1606 | 1606 |
1607 Handle<String> name() const { return raw_name()->string(); } | 1607 Handle<String> name() const { return raw_name()->string(); } |
1608 const AstRawString* raw_name() const { | 1608 const AstRawString* raw_name() const { |
1609 return is_resolved() ? var_->raw_name() : raw_name_; | 1609 return is_resolved() ? var_->raw_name() : raw_name_; |
1610 } | 1610 } |
1611 | 1611 |
1612 Variable* var() const { | 1612 Variable* var() const { |
1613 DCHECK(is_resolved()); | 1613 DCHECK(is_resolved()); |
1614 return var_; | 1614 return var_; |
1615 } | 1615 } |
1616 void set_var(Variable* v) { | 1616 void set_var(Variable* v) { |
1617 DCHECK(!is_resolved()); | 1617 DCHECK(!is_resolved()); |
1618 DCHECK_NOT_NULL(v); | 1618 DCHECK_NOT_NULL(v); |
1619 var_ = v; | 1619 var_ = v; |
1620 } | 1620 } |
1621 | 1621 |
1622 bool is_this() const { return IsThisField::decode(bit_field_); } | 1622 bool is_this() const { return IsThisField::decode(bit_field_); } |
1623 | 1623 |
| 1624 bool is_new_target() const { return IsNewTargetField::decode(bit_field_); } |
| 1625 |
1624 bool is_assigned() const { return IsAssignedField::decode(bit_field_); } | 1626 bool is_assigned() const { return IsAssignedField::decode(bit_field_); } |
1625 void set_is_assigned() { | 1627 void set_is_assigned() { |
1626 bit_field_ = IsAssignedField::update(bit_field_, true); | 1628 bit_field_ = IsAssignedField::update(bit_field_, true); |
1627 } | 1629 } |
1628 | 1630 |
1629 bool is_resolved() const { return IsResolvedField::decode(bit_field_); } | 1631 bool is_resolved() const { return IsResolvedField::decode(bit_field_); } |
1630 void set_is_resolved() { | 1632 void set_is_resolved() { |
1631 bit_field_ = IsResolvedField::update(bit_field_, true); | 1633 bit_field_ = IsResolvedField::update(bit_field_, true); |
1632 } | 1634 } |
1633 | 1635 |
(...skipping 14 matching lines...) Expand all Loading... |
1648 } | 1650 } |
1649 Code::Kind FeedbackICSlotKind(int index) OVERRIDE { return Code::LOAD_IC; } | 1651 Code::Kind FeedbackICSlotKind(int index) OVERRIDE { return Code::LOAD_IC; } |
1650 FeedbackVectorICSlot VariableFeedbackSlot() { | 1652 FeedbackVectorICSlot VariableFeedbackSlot() { |
1651 DCHECK(!UsesVariableFeedbackSlot() || !variable_feedback_slot_.IsInvalid()); | 1653 DCHECK(!UsesVariableFeedbackSlot() || !variable_feedback_slot_.IsInvalid()); |
1652 return variable_feedback_slot_; | 1654 return variable_feedback_slot_; |
1653 } | 1655 } |
1654 | 1656 |
1655 protected: | 1657 protected: |
1656 VariableProxy(Zone* zone, Variable* var, int position); | 1658 VariableProxy(Zone* zone, Variable* var, int position); |
1657 | 1659 |
1658 VariableProxy(Zone* zone, const AstRawString* name, bool is_this, | 1660 VariableProxy(Zone* zone, const AstRawString* name, |
1659 int position); | 1661 Variable::Kind variable_kind, int position); |
1660 | 1662 |
1661 class IsThisField : public BitField8<bool, 0, 1> {}; | 1663 class IsThisField : public BitField8<bool, 0, 1> {}; |
1662 class IsAssignedField : public BitField8<bool, 1, 1> {}; | 1664 class IsAssignedField : public BitField8<bool, 1, 1> {}; |
1663 class IsResolvedField : public BitField8<bool, 2, 1> {}; | 1665 class IsResolvedField : public BitField8<bool, 2, 1> {}; |
| 1666 class IsNewTargetField : public BitField8<bool, 3, 1> {}; |
1664 | 1667 |
1665 // Start with 16-bit (or smaller) field, which should get packed together | 1668 // Start with 16-bit (or smaller) field, which should get packed together |
1666 // with Expression's trailing 16-bit field. | 1669 // with Expression's trailing 16-bit field. |
1667 uint8_t bit_field_; | 1670 uint8_t bit_field_; |
1668 FeedbackVectorICSlot variable_feedback_slot_; | 1671 FeedbackVectorICSlot variable_feedback_slot_; |
1669 union { | 1672 union { |
1670 const AstRawString* raw_name_; // if !is_resolved_ | 1673 const AstRawString* raw_name_; // if !is_resolved_ |
1671 Variable* var_; // if is_resolved_ | 1674 Variable* var_; // if is_resolved_ |
1672 }; | 1675 }; |
1673 }; | 1676 }; |
(...skipping 1677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3351 int pos) { | 3354 int pos) { |
3352 return new (zone_) ArrayLiteral(zone_, values, literal_index, pos); | 3355 return new (zone_) ArrayLiteral(zone_, values, literal_index, pos); |
3353 } | 3356 } |
3354 | 3357 |
3355 VariableProxy* NewVariableProxy(Variable* var, | 3358 VariableProxy* NewVariableProxy(Variable* var, |
3356 int pos = RelocInfo::kNoPosition) { | 3359 int pos = RelocInfo::kNoPosition) { |
3357 return new (zone_) VariableProxy(zone_, var, pos); | 3360 return new (zone_) VariableProxy(zone_, var, pos); |
3358 } | 3361 } |
3359 | 3362 |
3360 VariableProxy* NewVariableProxy(const AstRawString* name, | 3363 VariableProxy* NewVariableProxy(const AstRawString* name, |
3361 bool is_this, | 3364 Variable::Kind variable_kind, |
3362 int position = RelocInfo::kNoPosition) { | 3365 int position = RelocInfo::kNoPosition) { |
3363 return new (zone_) VariableProxy(zone_, name, is_this, position); | 3366 return new (zone_) VariableProxy(zone_, name, variable_kind, position); |
3364 } | 3367 } |
3365 | 3368 |
3366 Property* NewProperty(Expression* obj, Expression* key, int pos) { | 3369 Property* NewProperty(Expression* obj, Expression* key, int pos) { |
3367 return new (zone_) Property(zone_, obj, key, pos); | 3370 return new (zone_) Property(zone_, obj, key, pos); |
3368 } | 3371 } |
3369 | 3372 |
3370 Call* NewCall(Expression* expression, | 3373 Call* NewCall(Expression* expression, |
3371 ZoneList<Expression*>* arguments, | 3374 ZoneList<Expression*>* arguments, |
3372 int pos) { | 3375 int pos) { |
3373 return new (zone_) Call(zone_, expression, arguments, pos); | 3376 return new (zone_) Call(zone_, expression, arguments, pos); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3490 | 3493 |
3491 private: | 3494 private: |
3492 Zone* zone_; | 3495 Zone* zone_; |
3493 AstValueFactory* ast_value_factory_; | 3496 AstValueFactory* ast_value_factory_; |
3494 }; | 3497 }; |
3495 | 3498 |
3496 | 3499 |
3497 } } // namespace v8::internal | 3500 } } // namespace v8::internal |
3498 | 3501 |
3499 #endif // V8_AST_H_ | 3502 #endif // V8_AST_H_ |
OLD | NEW |