Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1283 | 1283 |
| 1284 | 1284 |
| 1285 int FullCodeGenerator::TryCatch::Exit(int stack_depth) { | 1285 int FullCodeGenerator::TryCatch::Exit(int stack_depth) { |
| 1286 // The macros used here must preserve the result register. | 1286 // The macros used here must preserve the result register. |
| 1287 __ Drop(stack_depth); | 1287 __ Drop(stack_depth); |
| 1288 __ PopTryHandler(); | 1288 __ PopTryHandler(); |
| 1289 return 0; | 1289 return 0; |
| 1290 } | 1290 } |
| 1291 | 1291 |
| 1292 | 1292 |
| 1293 bool FullCodeGenerator::TryLiteralCompare(Token::Value op, | |
| 1294 Expression* left, | |
| 1295 Expression* right, | |
| 1296 Label* if_true, | |
| 1297 Label* if_false, | |
| 1298 Label* fall_through) { | |
| 1299 if (op != Token::EQ && op != Token::EQ_STRICT) return false; | |
| 1300 | |
| 1301 UnaryOperation* left_unary = left->AsUnaryOperation(); | |
| 1302 UnaryOperation* right_unary = right->AsUnaryOperation(); | |
| 1303 Literal* left_literal = left->AsLiteral(); | |
| 1304 Literal* right_literal = right->AsLiteral(); | |
| 1305 | |
| 1306 // Check for the pattern: typeof <expression> == <string literal>. | |
| 1307 if (left_unary != NULL && left_unary->op() == Token::TYPEOF && | |
| 1308 right_literal != NULL && right_literal->handle()->IsString()) { | |
| 1309 EmitLiteralCompareTypeof(left_unary->expression(), | |
| 1310 Handle<String>::cast(right_literal->handle()), | |
| 1311 if_true, if_false, fall_through); | |
| 1312 return true; | |
| 1313 } | |
| 1314 | |
| 1315 // Check for the pattern: <string literal> == typeof <expression>. | |
| 1316 if (right_unary != NULL && right_unary->op() == Token::TYPEOF && | |
| 1317 left_literal != NULL && left_literal->handle()->IsString()) { | |
| 1318 EmitLiteralCompareTypeof(right_unary->expression(), | |
| 1319 Handle<String>::cast(left_literal->handle()), | |
| 1320 if_true, if_false, fall_through); | |
| 1321 return true; | |
| 1322 } | |
| 1323 | |
|
fschneider
2011/06/21 11:36:08
Remove extra line.
Steven
2011/06/22 10:00:53
Done.
| |
| 1324 | |
| 1325 if (op != Token::EQ_STRICT) return false; | |
| 1326 | |
| 1327 // Check for the pattern: <expression> === void <literal>. | |
| 1328 if (right_unary != NULL && right_unary->op() == Token::VOID && | |
| 1329 right_unary->expression()->AsLiteral() != NULL) { | |
| 1330 EmitLiteralCompareUndefined(left, if_true, if_false, fall_through); | |
| 1331 return true; | |
| 1332 } | |
| 1333 | |
| 1334 // Check for the pattern: void <literal> === <expression>. | |
| 1335 if (left_unary != NULL && left_unary->op() == Token::VOID && | |
| 1336 left_unary->expression()->AsLiteral() != NULL) { | |
| 1337 EmitLiteralCompareUndefined(right, if_true, if_false, fall_through); | |
| 1338 return true; | |
| 1339 } | |
| 1340 | |
| 1341 return false; | |
| 1342 } | |
| 1343 | |
| 1344 | |
| 1293 #undef __ | 1345 #undef __ |
| 1294 | 1346 |
| 1295 | 1347 |
| 1296 } } // namespace v8::internal | 1348 } } // namespace v8::internal |
| OLD | NEW |