OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |