OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 V(Assignment) \ | 83 V(Assignment) \ |
84 V(Throw) \ | 84 V(Throw) \ |
85 V(Property) \ | 85 V(Property) \ |
86 V(Call) \ | 86 V(Call) \ |
87 V(CallNew) \ | 87 V(CallNew) \ |
88 V(CallRuntime) \ | 88 V(CallRuntime) \ |
89 V(UnaryOperation) \ | 89 V(UnaryOperation) \ |
90 V(CountOperation) \ | 90 V(CountOperation) \ |
91 V(BinaryOperation) \ | 91 V(BinaryOperation) \ |
92 V(CompareOperation) \ | 92 V(CompareOperation) \ |
93 V(CompareToNull) \ | |
94 V(ThisFunction) | 93 V(ThisFunction) |
95 | 94 |
96 #define AST_NODE_LIST(V) \ | 95 #define AST_NODE_LIST(V) \ |
97 V(Declaration) \ | 96 V(Declaration) \ |
98 STATEMENT_NODE_LIST(V) \ | 97 STATEMENT_NODE_LIST(V) \ |
99 EXPRESSION_NODE_LIST(V) | 98 EXPRESSION_NODE_LIST(V) |
100 | 99 |
101 // Forward declarations | 100 // Forward declarations |
102 class BitVector; | 101 class BitVector; |
103 class DefinitionInfo; | 102 class DefinitionInfo; |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 // (faster) prefix increments. | 281 // (faster) prefix increments. |
283 virtual void MarkAsStatement() { /* do nothing */ } | 282 virtual void MarkAsStatement() { /* do nothing */ } |
284 | 283 |
285 // True iff the result can be safely overwritten (to avoid allocation). | 284 // True iff the result can be safely overwritten (to avoid allocation). |
286 // False for operations that can return one of their operands. | 285 // False for operations that can return one of their operands. |
287 virtual bool ResultOverwriteAllowed() { return false; } | 286 virtual bool ResultOverwriteAllowed() { return false; } |
288 | 287 |
289 // True iff the expression is a literal represented as a smi. | 288 // True iff the expression is a literal represented as a smi. |
290 virtual bool IsSmiLiteral() { return false; } | 289 virtual bool IsSmiLiteral() { return false; } |
291 | 290 |
| 291 // True iff the expression is a string literal. |
| 292 virtual bool IsStringLiteral() { return false; } |
| 293 |
| 294 // True iff the expression is the null literal. |
| 295 virtual bool IsNullLiteral() { return false; } |
| 296 |
292 // Type feedback information for assignments and properties. | 297 // Type feedback information for assignments and properties. |
293 virtual bool IsMonomorphic() { | 298 virtual bool IsMonomorphic() { |
294 UNREACHABLE(); | 299 UNREACHABLE(); |
295 return false; | 300 return false; |
296 } | 301 } |
297 virtual bool IsArrayLength() { | 302 virtual bool IsArrayLength() { |
298 UNREACHABLE(); | 303 UNREACHABLE(); |
299 return false; | 304 return false; |
300 } | 305 } |
301 virtual SmallMapList* GetReceiverTypes() { | 306 virtual SmallMapList* GetReceiverTypes() { |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 | 889 |
885 class Literal: public Expression { | 890 class Literal: public Expression { |
886 public: | 891 public: |
887 Literal(Isolate* isolate, Handle<Object> handle) | 892 Literal(Isolate* isolate, Handle<Object> handle) |
888 : Expression(isolate), handle_(handle) { } | 893 : Expression(isolate), handle_(handle) { } |
889 | 894 |
890 DECLARE_NODE_TYPE(Literal) | 895 DECLARE_NODE_TYPE(Literal) |
891 | 896 |
892 virtual bool IsTrivial() { return true; } | 897 virtual bool IsTrivial() { return true; } |
893 virtual bool IsSmiLiteral() { return handle_->IsSmi(); } | 898 virtual bool IsSmiLiteral() { return handle_->IsSmi(); } |
| 899 virtual bool IsStringLiteral() { return handle_->IsString(); } |
| 900 virtual bool IsNullLiteral() { return handle_->IsNull(); } |
894 | 901 |
895 // Check if this literal is identical to the other literal. | 902 // Check if this literal is identical to the other literal. |
896 bool IsIdenticalTo(const Literal* other) const { | 903 bool IsIdenticalTo(const Literal* other) const { |
897 return handle_.is_identical_to(other->handle_); | 904 return handle_.is_identical_to(other->handle_); |
898 } | 905 } |
899 | 906 |
900 virtual bool IsPropertyName() { | 907 virtual bool IsPropertyName() { |
901 if (handle_->IsSymbol()) { | 908 if (handle_->IsSymbol()) { |
902 uint32_t ignored; | 909 uint32_t ignored; |
903 return !String::cast(*handle_)->AsArrayIndex(&ignored); | 910 return !String::cast(*handle_)->AsArrayIndex(&ignored); |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1458 virtual bool IsInlineable() const; | 1465 virtual bool IsInlineable() const; |
1459 | 1466 |
1460 // Type feedback information. | 1467 // Type feedback information. |
1461 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 1468 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
1462 bool IsSmiCompare() { return compare_type_ == SMI_ONLY; } | 1469 bool IsSmiCompare() { return compare_type_ == SMI_ONLY; } |
1463 bool IsObjectCompare() { return compare_type_ == OBJECT_ONLY; } | 1470 bool IsObjectCompare() { return compare_type_ == OBJECT_ONLY; } |
1464 | 1471 |
1465 // Match special cases. | 1472 // Match special cases. |
1466 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); | 1473 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); |
1467 bool IsLiteralCompareUndefined(Expression** expr); | 1474 bool IsLiteralCompareUndefined(Expression** expr); |
| 1475 bool IsLiteralCompareNull(Expression** expr); |
1468 | 1476 |
1469 private: | 1477 private: |
1470 Token::Value op_; | 1478 Token::Value op_; |
1471 Expression* left_; | 1479 Expression* left_; |
1472 Expression* right_; | 1480 Expression* right_; |
1473 int pos_; | 1481 int pos_; |
1474 | 1482 |
1475 enum CompareTypeFeedback { NONE, SMI_ONLY, OBJECT_ONLY }; | 1483 enum CompareTypeFeedback { NONE, SMI_ONLY, OBJECT_ONLY }; |
1476 CompareTypeFeedback compare_type_; | 1484 CompareTypeFeedback compare_type_; |
1477 }; | 1485 }; |
1478 | 1486 |
1479 | 1487 |
1480 class CompareToNull: public Expression { | |
1481 public: | |
1482 CompareToNull(Isolate* isolate, bool is_strict, Expression* expression) | |
1483 : Expression(isolate), is_strict_(is_strict), expression_(expression) { } | |
1484 | |
1485 DECLARE_NODE_TYPE(CompareToNull) | |
1486 | |
1487 virtual bool IsInlineable() const; | |
1488 | |
1489 bool is_strict() const { return is_strict_; } | |
1490 Token::Value op() const { return is_strict_ ? Token::EQ_STRICT : Token::EQ; } | |
1491 Expression* expression() const { return expression_; } | |
1492 | |
1493 private: | |
1494 bool is_strict_; | |
1495 Expression* expression_; | |
1496 }; | |
1497 | |
1498 | |
1499 class Conditional: public Expression { | 1488 class Conditional: public Expression { |
1500 public: | 1489 public: |
1501 Conditional(Isolate* isolate, | 1490 Conditional(Isolate* isolate, |
1502 Expression* condition, | 1491 Expression* condition, |
1503 Expression* then_expression, | 1492 Expression* then_expression, |
1504 Expression* else_expression, | 1493 Expression* else_expression, |
1505 int then_expression_position, | 1494 int then_expression_position, |
1506 int else_expression_position) | 1495 int else_expression_position) |
1507 : Expression(isolate), | 1496 : Expression(isolate), |
1508 condition_(condition), | 1497 condition_(condition), |
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2140 | 2129 |
2141 private: | 2130 private: |
2142 Isolate* isolate_; | 2131 Isolate* isolate_; |
2143 bool stack_overflow_; | 2132 bool stack_overflow_; |
2144 }; | 2133 }; |
2145 | 2134 |
2146 | 2135 |
2147 } } // namespace v8::internal | 2136 } } // namespace v8::internal |
2148 | 2137 |
2149 #endif // V8_AST_H_ | 2138 #endif // V8_AST_H_ |
OLD | NEW |