Index: src/ast.cc |
diff --git a/src/ast.cc b/src/ast.cc |
index d6af89b38c0fd2342a267752bab58ecc9877c0da..d241355fc1b8bf4aa654f790db2cc8bcd2f9efb5 100644 |
--- a/src/ast.cc |
+++ b/src/ast.cc |
@@ -70,6 +70,11 @@ bool Expression::IsNullLiteral() { |
} |
+bool Expression::IsUndefinedLiteral() { |
+ return AsLiteral() != NULL && AsLiteral()->handle()->IsUndefined(); |
+} |
+ |
+ |
VariableProxy::VariableProxy(Isolate* isolate, Variable* var) |
: Expression(isolate), |
name_(var->name()), |
@@ -352,7 +357,8 @@ static bool IsVoidOfLiteral(Expression* expr) { |
} |
-// Check for the pattern: void <literal> equals <expression> |
+// Check for the pattern: void <literal> equals <expression> or |
+// undefined equals <expression> |
static bool MatchLiteralCompareUndefined(Expression* left, |
Token::Value op, |
Expression* right, |
@@ -361,6 +367,10 @@ static bool MatchLiteralCompareUndefined(Expression* left, |
*expr = right; |
return true; |
} |
+ if (left->IsUndefinedLiteral() && Token::IsEqualityOp(op)) { |
+ *expr = right; |
+ return true; |
+ } |
return false; |
} |