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_AST_H_ | 5 #ifndef V8_AST_AST_H_ |
6 #define V8_AST_AST_H_ | 6 #define V8_AST_AST_H_ |
7 | 7 |
8 #include "src/ast/ast-types.h" | 8 #include "src/ast/ast-types.h" |
9 #include "src/ast/ast-value-factory.h" | 9 #include "src/ast/ast-value-factory.h" |
10 #include "src/ast/modules.h" | 10 #include "src/ast/modules.h" |
(...skipping 1519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1530 | 1530 |
1531 int const flags_; | 1531 int const flags_; |
1532 const AstRawString* const pattern_; | 1532 const AstRawString* const pattern_; |
1533 }; | 1533 }; |
1534 | 1534 |
1535 | 1535 |
1536 // An array literal has a literals object that is used | 1536 // An array literal has a literals object that is used |
1537 // for minimizing the work when constructing it at runtime. | 1537 // for minimizing the work when constructing it at runtime. |
1538 class ArrayLiteral final : public MaterializedLiteral { | 1538 class ArrayLiteral final : public MaterializedLiteral { |
1539 public: | 1539 public: |
1540 Handle<FixedArray> constant_elements() const { return constant_elements_; } | 1540 Handle<ConstantElementsPair> constant_elements() const { |
| 1541 return constant_elements_; |
| 1542 } |
1541 ElementsKind constant_elements_kind() const { | 1543 ElementsKind constant_elements_kind() const { |
1542 DCHECK_EQ(2, constant_elements_->length()); | 1544 return static_cast<ElementsKind>(constant_elements()->elements_kind()); |
1543 return static_cast<ElementsKind>( | |
1544 Smi::cast(constant_elements_->get(0))->value()); | |
1545 } | 1545 } |
1546 | 1546 |
1547 ZoneList<Expression*>* values() const { return values_; } | 1547 ZoneList<Expression*>* values() const { return values_; } |
1548 | 1548 |
1549 BailoutId CreateLiteralId() const { return BailoutId(local_id(0)); } | 1549 BailoutId CreateLiteralId() const { return BailoutId(local_id(0)); } |
1550 | 1550 |
1551 // Return an AST id for an element that is used in simulate instructions. | 1551 // Return an AST id for an element that is used in simulate instructions. |
1552 BailoutId GetIdForElement(int i) { return BailoutId(local_id(i + 1)); } | 1552 BailoutId GetIdForElement(int i) { return BailoutId(local_id(i + 1)); } |
1553 | 1553 |
1554 // Unlike other AST nodes, this number of bailout IDs allocated for an | 1554 // Unlike other AST nodes, this number of bailout IDs allocated for an |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1597 int literal_index, int pos) | 1597 int literal_index, int pos) |
1598 : MaterializedLiteral(literal_index, pos, kArrayLiteral), | 1598 : MaterializedLiteral(literal_index, pos, kArrayLiteral), |
1599 first_spread_index_(first_spread_index), | 1599 first_spread_index_(first_spread_index), |
1600 values_(values) {} | 1600 values_(values) {} |
1601 | 1601 |
1602 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } | 1602 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } |
1603 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1603 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
1604 | 1604 |
1605 int first_spread_index_; | 1605 int first_spread_index_; |
1606 FeedbackVectorSlot literal_slot_; | 1606 FeedbackVectorSlot literal_slot_; |
1607 Handle<FixedArray> constant_elements_; | 1607 Handle<ConstantElementsPair> constant_elements_; |
1608 ZoneList<Expression*>* values_; | 1608 ZoneList<Expression*>* values_; |
1609 }; | 1609 }; |
1610 | 1610 |
1611 | 1611 |
1612 class VariableProxy final : public Expression { | 1612 class VariableProxy final : public Expression { |
1613 public: | 1613 public: |
1614 bool IsValidReferenceExpression() const { | 1614 bool IsValidReferenceExpression() const { |
1615 return !is_this() && !is_new_target(); | 1615 return !is_this() && !is_new_target(); |
1616 } | 1616 } |
1617 | 1617 |
(...skipping 2007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3625 : NULL; \ | 3625 : NULL; \ |
3626 } | 3626 } |
3627 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3627 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3628 #undef DECLARE_NODE_FUNCTIONS | 3628 #undef DECLARE_NODE_FUNCTIONS |
3629 | 3629 |
3630 | 3630 |
3631 } // namespace internal | 3631 } // namespace internal |
3632 } // namespace v8 | 3632 } // namespace v8 |
3633 | 3633 |
3634 #endif // V8_AST_AST_H_ | 3634 #endif // V8_AST_AST_H_ |
OLD | NEW |