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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 case Token::DIV: | 330 case Token::DIV: |
331 case Token::MOD: | 331 case Token::MOD: |
332 return true; | 332 return true; |
333 default: | 333 default: |
334 UNREACHABLE(); | 334 UNREACHABLE(); |
335 } | 335 } |
336 return false; | 336 return false; |
337 } | 337 } |
338 | 338 |
339 | 339 |
340 bool CompareOperation::IsLiteralCompareTypeof(Expression** expr, | |
341 Handle<String>* check) { | |
342 if (op_ != Token::EQ && op_ != Token::EQ_STRICT) return false; | |
343 | |
344 UnaryOperation* left_unary = left_->AsUnaryOperation(); | |
345 UnaryOperation* right_unary = right_->AsUnaryOperation(); | |
346 Literal* left_literal = left_->AsLiteral(); | |
347 Literal* right_literal = right_->AsLiteral(); | |
348 | |
349 // Check for the pattern: typeof <expression> == <string literal>. | |
350 if (left_unary != NULL && left_unary->op() == Token::TYPEOF && | |
351 right_literal != NULL && right_literal->handle()->IsString()) { | |
352 *expr = left_unary->expression(); | |
353 *check = Handle<String>::cast(right_literal->handle()); | |
354 return true; | |
355 } | |
356 | |
357 // Check for the pattern: <string literal> == typeof <expression>. | |
358 if (right_unary != NULL && right_unary->op() == Token::TYPEOF && | |
359 left_literal != NULL && left_literal->handle()->IsString()) { | |
360 *expr = right_unary->expression(); | |
361 *check = Handle<String>::cast(left_literal->handle()); | |
362 return true; | |
363 } | |
364 | |
365 return false; | |
366 } | |
367 | |
368 | |
369 bool CompareOperation::IsLiteralCompareUndefined(Expression **expr) { | |
fschneider
2011/06/24 12:04:42
For consistency:
Expression** expr
Steven
2011/06/24 14:33:29
Done.
| |
370 if (op_ != Token::EQ_STRICT) return false; | |
371 | |
372 UnaryOperation* left_unary = left_->AsUnaryOperation(); | |
373 UnaryOperation* right_unary = right_->AsUnaryOperation(); | |
374 | |
375 // Check for the pattern: <expression> === void <literal>. | |
376 if (right_unary != NULL && right_unary->op() == Token::VOID && | |
377 right_unary->expression()->AsLiteral() != NULL) { | |
378 *expr = left_; | |
379 return true; | |
380 } | |
381 | |
382 // Check for the pattern: void <literal> === <expression>. | |
383 if (left_unary != NULL && left_unary->op() == Token::VOID && | |
384 left_unary->expression()->AsLiteral() != NULL) { | |
385 *expr = right_; | |
386 return true; | |
387 } | |
388 | |
389 return false; | |
390 } | |
391 | |
392 | |
340 // ---------------------------------------------------------------------------- | 393 // ---------------------------------------------------------------------------- |
341 // Inlining support | 394 // Inlining support |
342 | 395 |
343 bool Declaration::IsInlineable() const { | 396 bool Declaration::IsInlineable() const { |
344 return proxy()->var()->IsStackAllocated() && fun() == NULL; | 397 return proxy()->var()->IsStackAllocated() && fun() == NULL; |
345 } | 398 } |
346 | 399 |
347 | 400 |
348 bool TargetCollector::IsInlineable() const { | 401 bool TargetCollector::IsInlineable() const { |
349 UNREACHABLE(); | 402 UNREACHABLE(); |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1142 int pos) | 1195 int pos) |
1143 : label_(label), | 1196 : label_(label), |
1144 statements_(statements), | 1197 statements_(statements), |
1145 position_(pos), | 1198 position_(pos), |
1146 compare_type_(NONE), | 1199 compare_type_(NONE), |
1147 compare_id_(AstNode::GetNextId()), | 1200 compare_id_(AstNode::GetNextId()), |
1148 entry_id_(AstNode::GetNextId()) { | 1201 entry_id_(AstNode::GetNextId()) { |
1149 } | 1202 } |
1150 | 1203 |
1151 } } // namespace v8::internal | 1204 } } // namespace v8::internal |
OLD | NEW |