Index: src/ast.cc |
=================================================================== |
--- src/ast.cc (revision 9281) |
+++ src/ast.cc (working copy) |
@@ -380,6 +380,27 @@ |
} |
+bool CompareOperation::IsLiteralCompareNull(Expression** expr) { |
+ if (op_ != Token::EQ && op_ != Token::EQ_STRICT) return false; |
+ |
+ // Check for the pattern: <expression> equals null. |
+ Literal* right_literal = right_->AsLiteral(); |
+ if (right_literal != NULL && right_literal->handle()->IsNull()) { |
+ *expr = left_; |
+ return true; |
+ } |
+ |
+ // Check for the pattern: null equals <expression>. |
+ Literal* left_literal = left_->AsLiteral(); |
+ if (left_literal != NULL && left_literal->handle()->IsNull()) { |
+ *expr = right_; |
+ return true; |
+ } |
+ |
+ return false; |
+} |
+ |
+ |
// ---------------------------------------------------------------------------- |
// Inlining support |
@@ -598,11 +619,6 @@ |
} |
-bool CompareToNull::IsInlineable() const { |
- return expression()->IsInlineable(); |
-} |
- |
- |
bool CountOperation::IsInlineable() const { |
return expression()->IsInlineable(); |
} |