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-value-factory.h" | 8 #include "src/ast/ast-value-factory.h" |
9 #include "src/ast/modules.h" | 9 #include "src/ast/modules.h" |
10 #include "src/ast/variables.h" | 10 #include "src/ast/variables.h" |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 // True iff the expression is a valid reference expression. | 307 // True iff the expression is a valid reference expression. |
308 bool IsValidReferenceExpression() const; | 308 bool IsValidReferenceExpression() const; |
309 | 309 |
310 // Helpers for ToBoolean conversion. | 310 // Helpers for ToBoolean conversion. |
311 bool ToBooleanIsTrue() const; | 311 bool ToBooleanIsTrue() const; |
312 bool ToBooleanIsFalse() const; | 312 bool ToBooleanIsFalse() const; |
313 | 313 |
314 // Symbols that cannot be parsed as array indices are considered property | 314 // Symbols that cannot be parsed as array indices are considered property |
315 // names. We do not treat symbols that can be array indexes as property | 315 // names. We do not treat symbols that can be array indexes as property |
316 // names because [] for string objects is handled only by keyed ICs. | 316 // names because [] for string objects is handled only by keyed ICs. |
317 // Produces the same result whether |deref_mode| is kAllowed or kDisallowed, | 317 bool IsPropertyName() const; |
318 // although may be faster with kAllowed. | |
319 bool IsPropertyName( | |
320 HandleDereferenceMode deref_mode = HandleDereferenceMode::kAllowed) const; | |
321 | 318 |
322 // True iff the expression is a class or function expression without | 319 // True iff the expression is a class or function expression without |
323 // a syntactic name. | 320 // a syntactic name. |
324 bool IsAnonymousFunctionDefinition() const; | 321 bool IsAnonymousFunctionDefinition() const; |
325 | 322 |
326 // True iff the expression is a literal represented as a smi. | 323 // True iff the expression is a literal represented as a smi. |
327 bool IsSmiLiteral() const; | 324 bool IsSmiLiteral() const; |
328 | 325 |
329 // True iff the expression is a string literal. | 326 // True iff the expression is a string literal. |
330 bool IsStringLiteral() const; | 327 bool IsStringLiteral() const; |
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1189 | 1186 |
1190 Statement* statement_; | 1187 Statement* statement_; |
1191 Scope* const scope_; | 1188 Scope* const scope_; |
1192 SloppyBlockFunctionStatement* next_; | 1189 SloppyBlockFunctionStatement* next_; |
1193 }; | 1190 }; |
1194 | 1191 |
1195 | 1192 |
1196 class Literal final : public Expression { | 1193 class Literal final : public Expression { |
1197 public: | 1194 public: |
1198 // Returns true if literal represents a property name (i.e. cannot be parsed | 1195 // Returns true if literal represents a property name (i.e. cannot be parsed |
1199 // as array indices). Produces the same result whether |deref_mode| is | 1196 // as array indices). |
1200 // kAllowed or kDisallowed, although may be faster with kAllowed. | 1197 bool IsPropertyName() const { return value_->IsPropertyName(); } |
1201 bool IsPropertyName(HandleDereferenceMode deref_mode = | |
1202 HandleDereferenceMode::kAllowed) const { | |
1203 return value_->IsPropertyName(deref_mode); | |
1204 } | |
1205 | 1198 |
1206 Handle<String> AsPropertyName() { | 1199 Handle<String> AsPropertyName() { |
1207 DCHECK(IsPropertyName(HandleDereferenceMode::kDisallowed)); | 1200 DCHECK(IsPropertyName()); |
1208 return Handle<String>::cast(value()); | 1201 return Handle<String>::cast(value()); |
1209 } | 1202 } |
1210 | 1203 |
1211 const AstRawString* AsRawPropertyName() { | 1204 const AstRawString* AsRawPropertyName() { |
1212 DCHECK(IsPropertyName()); | 1205 DCHECK(IsPropertyName()); |
1213 return value_->AsString(); | 1206 return value_->AsString(); |
1214 } | 1207 } |
1215 | 1208 |
1216 bool ToBooleanIsTrue() const { return raw_value()->BooleanValue(); } | 1209 bool ToBooleanIsTrue() const { return raw_value()->BooleanValue(); } |
1217 bool ToBooleanIsFalse() const { return !raw_value()->BooleanValue(); } | 1210 bool ToBooleanIsFalse() const { return !raw_value()->BooleanValue(); } |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1737 FeedbackVectorSlotKind kind = key()->IsPropertyName() | 1730 FeedbackVectorSlotKind kind = key()->IsPropertyName() |
1738 ? FeedbackVectorSlotKind::LOAD_IC | 1731 ? FeedbackVectorSlotKind::LOAD_IC |
1739 : FeedbackVectorSlotKind::KEYED_LOAD_IC; | 1732 : FeedbackVectorSlotKind::KEYED_LOAD_IC; |
1740 property_feedback_slot_ = spec->AddSlot(kind); | 1733 property_feedback_slot_ = spec->AddSlot(kind); |
1741 } | 1734 } |
1742 | 1735 |
1743 FeedbackVectorSlot PropertyFeedbackSlot() const { | 1736 FeedbackVectorSlot PropertyFeedbackSlot() const { |
1744 return property_feedback_slot_; | 1737 return property_feedback_slot_; |
1745 } | 1738 } |
1746 | 1739 |
1747 // Returns the properties assign type. Produces the same result whether | 1740 // Returns the properties assign type. |
1748 // |deref_mode| is kAllowed or kDisallowed, although may be faster with | |
1749 // kAllowed. | |
1750 static LhsKind GetAssignType( | 1741 static LhsKind GetAssignType( |
1751 Property* property, | 1742 Property* property, |
1752 HandleDereferenceMode deref_mode = HandleDereferenceMode::kAllowed) { | 1743 HandleDereferenceMode deref_mode = HandleDereferenceMode::kAllowed) { |
1753 if (property == NULL) return VARIABLE; | 1744 if (property == NULL) return VARIABLE; |
1754 bool super_access = property->IsSuperAccess(); | 1745 bool super_access = property->IsSuperAccess(); |
1755 return (property->key()->IsPropertyName(deref_mode)) | 1746 return (property->key()->IsPropertyName()) |
1756 ? (super_access ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY) | 1747 ? (super_access ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY) |
1757 : (super_access ? KEYED_SUPER_PROPERTY : KEYED_PROPERTY); | 1748 : (super_access ? KEYED_SUPER_PROPERTY : KEYED_PROPERTY); |
1758 } | 1749 } |
1759 | 1750 |
1760 private: | 1751 private: |
1761 friend class AstNodeFactory; | 1752 friend class AstNodeFactory; |
1762 | 1753 |
1763 Property(Zone* zone, Expression* obj, Expression* key, int pos) | 1754 Property(Zone* zone, Expression* obj, Expression* key, int pos) |
1764 : Expression(zone, pos, kProperty), | 1755 : Expression(zone, pos, kProperty), |
1765 bit_field_(IsForCallField::encode(false) | | 1756 bit_field_(IsForCallField::encode(false) | |
(...skipping 1720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3486 : NULL; \ | 3477 : NULL; \ |
3487 } | 3478 } |
3488 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3479 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3489 #undef DECLARE_NODE_FUNCTIONS | 3480 #undef DECLARE_NODE_FUNCTIONS |
3490 | 3481 |
3491 | 3482 |
3492 } // namespace internal | 3483 } // namespace internal |
3493 } // namespace v8 | 3484 } // namespace v8 |
3494 | 3485 |
3495 #endif // V8_AST_AST_H_ | 3486 #endif // V8_AST_AST_H_ |
OLD | NEW |