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

Side by Side Diff: src/ast.h

Issue 943543002: [strong] Declaration-after-use errors. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: computed prop names comment fix Created 5 years, 10 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/ast.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/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/assembler.h" 10 #include "src/assembler.h"
(...skipping 1613 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 bool is_assigned() const { return IsAssignedField::decode(bit_field_); } 1624 bool is_assigned() const { return IsAssignedField::decode(bit_field_); }
1625 void set_is_assigned() { 1625 void set_is_assigned() {
1626 bit_field_ = IsAssignedField::update(bit_field_, true); 1626 bit_field_ = IsAssignedField::update(bit_field_, true);
1627 } 1627 }
1628 1628
1629 bool is_resolved() const { return IsResolvedField::decode(bit_field_); } 1629 bool is_resolved() const { return IsResolvedField::decode(bit_field_); }
1630 void set_is_resolved() { 1630 void set_is_resolved() {
1631 bit_field_ = IsResolvedField::update(bit_field_, true); 1631 bit_field_ = IsResolvedField::update(bit_field_, true);
1632 } 1632 }
1633 1633
1634 int end_position() const { return end_position_; }
1635
1634 // Bind this proxy to the variable var. 1636 // Bind this proxy to the variable var.
1635 void BindTo(Variable* var); 1637 void BindTo(Variable* var);
1636 1638
1637 bool UsesVariableFeedbackSlot() const { 1639 bool UsesVariableFeedbackSlot() const {
1638 return FLAG_vector_ics && (var()->IsUnallocated() || var()->IsLookupSlot()); 1640 return FLAG_vector_ics && (var()->IsUnallocated() || var()->IsLookupSlot());
1639 } 1641 }
1640 1642
1641 virtual FeedbackVectorRequirements ComputeFeedbackRequirements( 1643 virtual FeedbackVectorRequirements ComputeFeedbackRequirements(
1642 Isolate* isolate) OVERRIDE { 1644 Isolate* isolate) OVERRIDE {
1643 return FeedbackVectorRequirements(0, UsesVariableFeedbackSlot() ? 1 : 0); 1645 return FeedbackVectorRequirements(0, UsesVariableFeedbackSlot() ? 1 : 0);
1644 } 1646 }
1645 1647
1646 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) OVERRIDE { 1648 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) OVERRIDE {
1647 variable_feedback_slot_ = slot; 1649 variable_feedback_slot_ = slot;
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 start_position,
1659 int end_position);
1657 1660
1658 VariableProxy(Zone* zone, const AstRawString* name, bool is_this, 1661 VariableProxy(Zone* zone, const AstRawString* name, bool is_this,
1659 int position); 1662 int start_position, int end_position);
1660 1663
1661 class IsThisField : public BitField8<bool, 0, 1> {}; 1664 class IsThisField : public BitField8<bool, 0, 1> {};
1662 class IsAssignedField : public BitField8<bool, 1, 1> {}; 1665 class IsAssignedField : public BitField8<bool, 1, 1> {};
1663 class IsResolvedField : public BitField8<bool, 2, 1> {}; 1666 class IsResolvedField : public BitField8<bool, 2, 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 };
1676 // Position is stored in the AstNode superclass, but VariableProxy needs to
1677 // know its end position too (for error messages). It cannot be inferred from
1678 // the variable name length because it can contain escapes.
1679 int end_position_;
1673 }; 1680 };
1674 1681
1675 1682
1676 class Property FINAL : public Expression { 1683 class Property FINAL : public Expression {
1677 public: 1684 public:
1678 DECLARE_NODE_TYPE(Property) 1685 DECLARE_NODE_TYPE(Property)
1679 1686
1680 bool IsValidReferenceExpression() const OVERRIDE { return true; } 1687 bool IsValidReferenceExpression() const OVERRIDE { return true; }
1681 1688
1682 Expression* obj() const { return obj_; } 1689 Expression* obj() const { return obj_; }
(...skipping 1663 matching lines...) Expand 10 before | Expand all | Expand 10 after
3346 return new (zone_) RegExpLiteral(zone_, pattern, flags, literal_index, pos); 3353 return new (zone_) RegExpLiteral(zone_, pattern, flags, literal_index, pos);
3347 } 3354 }
3348 3355
3349 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, 3356 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values,
3350 int literal_index, 3357 int literal_index,
3351 int pos) { 3358 int pos) {
3352 return new (zone_) ArrayLiteral(zone_, values, literal_index, pos); 3359 return new (zone_) ArrayLiteral(zone_, values, literal_index, pos);
3353 } 3360 }
3354 3361
3355 VariableProxy* NewVariableProxy(Variable* var, 3362 VariableProxy* NewVariableProxy(Variable* var,
3356 int pos = RelocInfo::kNoPosition) { 3363 int start_position = RelocInfo::kNoPosition,
3357 return new (zone_) VariableProxy(zone_, var, pos); 3364 int end_position = RelocInfo::kNoPosition) {
3365 return new (zone_) VariableProxy(zone_, var, start_position, end_position);
3358 } 3366 }
3359 3367
3360 VariableProxy* NewVariableProxy(const AstRawString* name, 3368 VariableProxy* NewVariableProxy(const AstRawString* name, bool is_this,
3361 bool is_this, 3369 int start_position = RelocInfo::kNoPosition,
3362 int position = RelocInfo::kNoPosition) { 3370 int end_position = RelocInfo::kNoPosition) {
3363 return new (zone_) VariableProxy(zone_, name, is_this, position); 3371 return new (zone_)
3372 VariableProxy(zone_, name, is_this, start_position, end_position);
3364 } 3373 }
3365 3374
3366 Property* NewProperty(Expression* obj, Expression* key, int pos) { 3375 Property* NewProperty(Expression* obj, Expression* key, int pos) {
3367 return new (zone_) Property(zone_, obj, key, pos); 3376 return new (zone_) Property(zone_, obj, key, pos);
3368 } 3377 }
3369 3378
3370 Call* NewCall(Expression* expression, 3379 Call* NewCall(Expression* expression,
3371 ZoneList<Expression*>* arguments, 3380 ZoneList<Expression*>* arguments,
3372 int pos) { 3381 int pos) {
3373 return new (zone_) Call(zone_, expression, arguments, pos); 3382 return new (zone_) Call(zone_, expression, arguments, pos);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
3490 3499
3491 private: 3500 private:
3492 Zone* zone_; 3501 Zone* zone_;
3493 AstValueFactory* ast_value_factory_; 3502 AstValueFactory* ast_value_factory_;
3494 }; 3503 };
3495 3504
3496 3505
3497 } } // namespace v8::internal 3506 } } // namespace v8::internal
3498 3507
3499 #endif // V8_AST_H_ 3508 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698