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

Side by Side Diff: src/parser.cc

Issue 7887037: Nuke CompareToNull AST node. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « src/parser.h ('k') | src/prettyprinter.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 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 2596 matching lines...) Expand 10 before | Expand all | Expand 10 after
2607 // operations. (We could combine the two and get rid of this 2607 // operations. (We could combine the two and get rid of this
2608 // code and AST node eventually.) 2608 // code and AST node eventually.)
2609 if (Token::IsCompareOp(op)) { 2609 if (Token::IsCompareOp(op)) {
2610 // We have a comparison. 2610 // We have a comparison.
2611 Token::Value cmp = op; 2611 Token::Value cmp = op;
2612 switch (op) { 2612 switch (op) {
2613 case Token::NE: cmp = Token::EQ; break; 2613 case Token::NE: cmp = Token::EQ; break;
2614 case Token::NE_STRICT: cmp = Token::EQ_STRICT; break; 2614 case Token::NE_STRICT: cmp = Token::EQ_STRICT; break;
2615 default: break; 2615 default: break;
2616 } 2616 }
2617 x = NewCompareNode(cmp, x, y, position); 2617 x = new(zone()) CompareOperation(isolate(), cmp, x, y, position);
2618 if (cmp != op) { 2618 if (cmp != op) {
2619 // The comparison was negated - add a NOT. 2619 // The comparison was negated - add a NOT.
2620 x = new(zone()) UnaryOperation(isolate(), Token::NOT, x, position); 2620 x = new(zone()) UnaryOperation(isolate(), Token::NOT, x, position);
2621 } 2621 }
2622 2622
2623 } else { 2623 } else {
2624 // We have a "normal" binary operation. 2624 // We have a "normal" binary operation.
2625 x = new(zone()) BinaryOperation(isolate(), op, x, y, position); 2625 x = new(zone()) BinaryOperation(isolate(), op, x, y, position);
2626 } 2626 }
2627 } 2627 }
2628 } 2628 }
2629 return x; 2629 return x;
2630 } 2630 }
2631 2631
2632 2632
2633 Expression* Parser::NewCompareNode(Token::Value op,
2634 Expression* x,
2635 Expression* y,
2636 int position) {
2637 ASSERT(op != Token::NE && op != Token::NE_STRICT);
2638 if (op == Token::EQ || op == Token::EQ_STRICT) {
2639 bool is_strict = (op == Token::EQ_STRICT);
2640 Literal* x_literal = x->AsLiteral();
2641 if (x_literal != NULL && x_literal->IsNull()) {
2642 return new(zone()) CompareToNull(isolate(), is_strict, y);
2643 }
2644
2645 Literal* y_literal = y->AsLiteral();
2646 if (y_literal != NULL && y_literal->IsNull()) {
2647 return new(zone()) CompareToNull(isolate(), is_strict, x);
2648 }
2649 }
2650 return new(zone()) CompareOperation(isolate(), op, x, y, position);
2651 }
2652
2653
2654 Expression* Parser::ParseUnaryExpression(bool* ok) { 2633 Expression* Parser::ParseUnaryExpression(bool* ok) {
2655 // UnaryExpression :: 2634 // UnaryExpression ::
2656 // PostfixExpression 2635 // PostfixExpression
2657 // 'delete' UnaryExpression 2636 // 'delete' UnaryExpression
2658 // 'void' UnaryExpression 2637 // 'void' UnaryExpression
2659 // 'typeof' UnaryExpression 2638 // 'typeof' UnaryExpression
2660 // '++' UnaryExpression 2639 // '++' UnaryExpression
2661 // '--' UnaryExpression 2640 // '--' UnaryExpression
2662 // '+' UnaryExpression 2641 // '+' UnaryExpression
2663 // '-' UnaryExpression 2642 // '-' UnaryExpression
(...skipping 2559 matching lines...) Expand 10 before | Expand all | Expand 10 after
5223 result = parser.ParseProgram(source, 5202 result = parser.ParseProgram(source,
5224 info->is_global(), 5203 info->is_global(),
5225 info->StrictMode()); 5204 info->StrictMode());
5226 } 5205 }
5227 } 5206 }
5228 info->SetFunction(result); 5207 info->SetFunction(result);
5229 return (result != NULL); 5208 return (result != NULL);
5230 } 5209 }
5231 5210
5232 } } // namespace v8::internal 5211 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/parser.h ('k') | src/prettyprinter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698