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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 } | 350 } |
351 | 351 |
352 | 352 |
353 // Check for the pattern: typeof <expression> equals <string literal>. | 353 // Check for the pattern: typeof <expression> equals <string literal>. |
354 static bool MatchLiteralCompareTypeof(Expression* left, | 354 static bool MatchLiteralCompareTypeof(Expression* left, |
355 Token::Value op, | 355 Token::Value op, |
356 Expression* right, | 356 Expression* right, |
357 Expression** expr, | 357 Expression** expr, |
358 Handle<String>* check) { | 358 Handle<String>* check) { |
359 if (IsTypeof(left) && right->IsStringLiteral() && Token::IsEqualityOp(op)) { | 359 if (IsTypeof(left) && right->IsStringLiteral() && Token::IsEqualityOp(op)) { |
360 *expr = left->AsUnaryOperation()->expression(); | 360 *expr = left; |
361 *check = Handle<String>::cast(right->AsLiteral()->value()); | 361 *check = Handle<String>::cast(right->AsLiteral()->value()); |
362 return true; | 362 return true; |
363 } | 363 } |
364 return false; | 364 return false; |
365 } | 365 } |
366 | 366 |
367 | 367 |
368 bool CompareOperation::IsLiteralCompareTypeof(Expression** expr, | 368 bool CompareOperation::IsLiteralCompareTypeof(Expression** expr, |
369 Handle<String>* check) { | 369 Handle<String>* check) { |
370 return MatchLiteralCompareTypeof(left_, op_, right_, expr, check) || | 370 return MatchLiteralCompareTypeof(left_, op_, right_, expr, check) || |
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 OS::SNPrintF(buffer, "%d", Smi::cast(*value_)->value()); | 1187 OS::SNPrintF(buffer, "%d", Smi::cast(*value_)->value()); |
1188 str = arr; | 1188 str = arr; |
1189 } else { | 1189 } else { |
1190 str = DoubleToCString(value_->Number(), buffer); | 1190 str = DoubleToCString(value_->Number(), buffer); |
1191 } | 1191 } |
1192 return factory->NewStringFromAscii(CStrVector(str)); | 1192 return factory->NewStringFromAscii(CStrVector(str)); |
1193 } | 1193 } |
1194 | 1194 |
1195 | 1195 |
1196 } } // namespace v8::internal | 1196 } } // namespace v8::internal |
OLD | NEW |