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

Side by Side Diff: src/ast.cc

Issue 19523005: Better fix for LiteralCompareTypeof (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 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/arm/full-codegen-arm.cc ('k') | src/hydrogen.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 } 356 }
357 357
358 358
359 // Check for the pattern: typeof <expression> equals <string literal>. 359 // Check for the pattern: typeof <expression> equals <string literal>.
360 static bool MatchLiteralCompareTypeof(Expression* left, 360 static bool MatchLiteralCompareTypeof(Expression* left,
361 Token::Value op, 361 Token::Value op,
362 Expression* right, 362 Expression* right,
363 Expression** expr, 363 Expression** expr,
364 Handle<String>* check) { 364 Handle<String>* check) {
365 if (IsTypeof(left) && right->IsStringLiteral() && Token::IsEqualityOp(op)) { 365 if (IsTypeof(left) && right->IsStringLiteral() && Token::IsEqualityOp(op)) {
366 *expr = left; 366 *expr = left->AsUnaryOperation()->expression();
367 *check = Handle<String>::cast(right->AsLiteral()->value()); 367 *check = Handle<String>::cast(right->AsLiteral()->value());
368 return true; 368 return true;
369 } 369 }
370 return false; 370 return false;
371 } 371 }
372 372
373 373
374 bool CompareOperation::IsLiteralCompareTypeof(Expression** expr, 374 bool CompareOperation::IsLiteralCompareTypeof(Expression** expr,
375 Handle<String>* check) { 375 Handle<String>* check) {
376 return MatchLiteralCompareTypeof(left_, op_, right_, expr, check) || 376 return MatchLiteralCompareTypeof(left_, op_, right_, expr, check) ||
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 OS::SNPrintF(buffer, "%d", Smi::cast(*value_)->value()); 1195 OS::SNPrintF(buffer, "%d", Smi::cast(*value_)->value());
1196 str = arr; 1196 str = arr;
1197 } else { 1197 } else {
1198 str = DoubleToCString(value_->Number(), buffer); 1198 str = DoubleToCString(value_->Number(), buffer);
1199 } 1199 }
1200 return factory->NewStringFromAscii(CStrVector(str)); 1200 return factory->NewStringFromAscii(CStrVector(str));
1201 } 1201 }
1202 1202
1203 1203
1204 } } // namespace v8::internal 1204 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/full-codegen-arm.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698