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

Side by Side Diff: src/preparser.h

Issue 917703003: [strong] no sloppy equality (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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
OLDNEW
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_PREPARSER_H 5 #ifndef V8_PREPARSER_H
6 #define V8_PREPARSER_H 6 #define V8_PREPARSER_H
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 2427 matching lines...) Expand 10 before | Expand all | Expand 10 after
2438 // Precedence >= 4 2438 // Precedence >= 4
2439 template <class Traits> 2439 template <class Traits>
2440 typename ParserBase<Traits>::ExpressionT 2440 typename ParserBase<Traits>::ExpressionT
2441 ParserBase<Traits>::ParseBinaryExpression(int prec, bool accept_IN, bool* ok) { 2441 ParserBase<Traits>::ParseBinaryExpression(int prec, bool accept_IN, bool* ok) {
2442 DCHECK(prec >= 4); 2442 DCHECK(prec >= 4);
2443 ExpressionT x = this->ParseUnaryExpression(CHECK_OK); 2443 ExpressionT x = this->ParseUnaryExpression(CHECK_OK);
2444 for (int prec1 = Precedence(peek(), accept_IN); prec1 >= prec; prec1--) { 2444 for (int prec1 = Precedence(peek(), accept_IN); prec1 >= prec; prec1--) {
2445 // prec1 >= 4 2445 // prec1 >= 4
2446 while (Precedence(peek(), accept_IN) == prec1) { 2446 while (Precedence(peek(), accept_IN) == prec1) {
2447 Token::Value op = Next(); 2447 Token::Value op = Next();
2448 Scanner::Location op_location = scanner()->location();
2448 int pos = position(); 2449 int pos = position();
2449 ExpressionT y = ParseBinaryExpression(prec1 + 1, accept_IN, CHECK_OK); 2450 ExpressionT y = ParseBinaryExpression(prec1 + 1, accept_IN, CHECK_OK);
2450 2451
2451 if (this->ShortcutNumericLiteralBinaryExpression(&x, y, op, pos, 2452 if (this->ShortcutNumericLiteralBinaryExpression(&x, y, op, pos,
2452 factory())) { 2453 factory())) {
2453 continue; 2454 continue;
2454 } 2455 }
2455 2456
2456 // For now we distinguish between comparisons and other binary 2457 // For now we distinguish between comparisons and other binary
2457 // operations. (We could combine the two and get rid of this 2458 // operations. (We could combine the two and get rid of this
2458 // code and AST node eventually.) 2459 // code and AST node eventually.)
2459 if (Token::IsCompareOp(op)) { 2460 if (Token::IsCompareOp(op)) {
2460 // We have a comparison. 2461 // We have a comparison.
2461 Token::Value cmp = op; 2462 Token::Value cmp = op;
2462 switch (op) { 2463 switch (op) {
2463 case Token::NE: cmp = Token::EQ; break; 2464 case Token::NE: cmp = Token::EQ; break;
2464 case Token::NE_STRICT: cmp = Token::EQ_STRICT; break; 2465 case Token::NE_STRICT: cmp = Token::EQ_STRICT; break;
2465 default: break; 2466 default: break;
2466 } 2467 }
2468 if (cmp == Token::EQ && is_strong(language_mode())) {
2469 ReportMessageAt(op_location, "strong_equal");
2470 *ok = false;
2471 return this->EmptyExpression();
2472 }
2467 x = factory()->NewCompareOperation(cmp, x, y, pos); 2473 x = factory()->NewCompareOperation(cmp, x, y, pos);
2468 if (cmp != op) { 2474 if (cmp != op) {
2469 // The comparison was negated - add a NOT. 2475 // The comparison was negated - add a NOT.
2470 x = factory()->NewUnaryOperation(Token::NOT, x, pos); 2476 x = factory()->NewUnaryOperation(Token::NOT, x, pos);
2471 } 2477 }
2472 2478
2473 } else { 2479 } else {
2474 // We have a "normal" binary operation. 2480 // We have a "normal" binary operation.
2475 x = factory()->NewBinaryOperation(op, x, y, pos); 2481 x = factory()->NewBinaryOperation(op, x, y, pos);
2476 } 2482 }
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
3082 *ok = false; 3088 *ok = false;
3083 return; 3089 return;
3084 } 3090 }
3085 has_seen_constructor_ = true; 3091 has_seen_constructor_ = true;
3086 return; 3092 return;
3087 } 3093 }
3088 } 3094 }
3089 } } // v8::internal 3095 } } // v8::internal
3090 3096
3091 #endif // V8_PREPARSER_H 3097 #endif // V8_PREPARSER_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698