OLD | NEW |
1 // Copyright 2008 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 |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 bool IrregexpInterpreter::Match(Isolate* isolate, | 628 bool IrregexpInterpreter::Match(Isolate* isolate, |
629 Handle<ByteArray> code_array, | 629 Handle<ByteArray> code_array, |
630 Handle<String> subject, | 630 Handle<String> subject, |
631 int* registers, | 631 int* registers, |
632 int start_position) { | 632 int start_position) { |
633 ASSERT(subject->IsFlat()); | 633 ASSERT(subject->IsFlat()); |
634 | 634 |
635 AssertNoAllocation a; | 635 AssertNoAllocation a; |
636 const byte* code_base = code_array->GetDataStartAddress(); | 636 const byte* code_base = code_array->GetDataStartAddress(); |
637 uc16 previous_char = '\n'; | 637 uc16 previous_char = '\n'; |
638 if (subject->IsAsciiRepresentation()) { | 638 String::FlatContent subject_content = subject->GetFlatContent(a); |
639 Vector<const char> subject_vector = subject->ToAsciiVector(); | 639 if (subject_content.IsAscii()) { |
| 640 Vector<const char> subject_vector = subject_content.ToAsciiVector(); |
640 if (start_position != 0) previous_char = subject_vector[start_position - 1]; | 641 if (start_position != 0) previous_char = subject_vector[start_position - 1]; |
641 return RawMatch(isolate, | 642 return RawMatch(isolate, |
642 code_base, | 643 code_base, |
643 subject_vector, | 644 subject_vector, |
644 registers, | 645 registers, |
645 start_position, | 646 start_position, |
646 previous_char); | 647 previous_char); |
647 } else { | 648 } else { |
648 Vector<const uc16> subject_vector = subject->ToUC16Vector(); | 649 ASSERT(subject_content.IsTwoByte()); |
| 650 Vector<const uc16> subject_vector = subject_content.ToUC16Vector(); |
649 if (start_position != 0) previous_char = subject_vector[start_position - 1]; | 651 if (start_position != 0) previous_char = subject_vector[start_position - 1]; |
650 return RawMatch(isolate, | 652 return RawMatch(isolate, |
651 code_base, | 653 code_base, |
652 subject_vector, | 654 subject_vector, |
653 registers, | 655 registers, |
654 start_position, | 656 start_position, |
655 previous_char); | 657 previous_char); |
656 } | 658 } |
657 } | 659 } |
658 | 660 |
659 } } // namespace v8::internal | 661 } } // namespace v8::internal |
OLD | NEW |