OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // A simple interpreter for the Irregexp byte code. | 5 // A simple interpreter for the Irregexp byte code. |
6 | 6 |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/ast.h" | 10 #include "src/ast.h" |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 Handle<ByteArray> code_array, | 577 Handle<ByteArray> code_array, |
578 Handle<String> subject, | 578 Handle<String> subject, |
579 int* registers, | 579 int* registers, |
580 int start_position) { | 580 int start_position) { |
581 DCHECK(subject->IsFlat()); | 581 DCHECK(subject->IsFlat()); |
582 | 582 |
583 DisallowHeapAllocation no_gc; | 583 DisallowHeapAllocation no_gc; |
584 const byte* code_base = code_array->GetDataStartAddress(); | 584 const byte* code_base = code_array->GetDataStartAddress(); |
585 uc16 previous_char = '\n'; | 585 uc16 previous_char = '\n'; |
586 String::FlatContent subject_content = subject->GetFlatContent(); | 586 String::FlatContent subject_content = subject->GetFlatContent(); |
587 if (subject_content.IsAscii()) { | 587 if (subject_content.IsOneByte()) { |
588 Vector<const uint8_t> subject_vector = subject_content.ToOneByteVector(); | 588 Vector<const uint8_t> subject_vector = subject_content.ToOneByteVector(); |
589 if (start_position != 0) previous_char = subject_vector[start_position - 1]; | 589 if (start_position != 0) previous_char = subject_vector[start_position - 1]; |
590 return RawMatch(isolate, | 590 return RawMatch(isolate, |
591 code_base, | 591 code_base, |
592 subject_vector, | 592 subject_vector, |
593 registers, | 593 registers, |
594 start_position, | 594 start_position, |
595 previous_char); | 595 previous_char); |
596 } else { | 596 } else { |
597 DCHECK(subject_content.IsTwoByte()); | 597 DCHECK(subject_content.IsTwoByte()); |
598 Vector<const uc16> subject_vector = subject_content.ToUC16Vector(); | 598 Vector<const uc16> subject_vector = subject_content.ToUC16Vector(); |
599 if (start_position != 0) previous_char = subject_vector[start_position - 1]; | 599 if (start_position != 0) previous_char = subject_vector[start_position - 1]; |
600 return RawMatch(isolate, | 600 return RawMatch(isolate, |
601 code_base, | 601 code_base, |
602 subject_vector, | 602 subject_vector, |
603 registers, | 603 registers, |
604 start_position, | 604 start_position, |
605 previous_char); | 605 previous_char); |
606 } | 606 } |
607 } | 607 } |
608 | 608 |
609 } } // namespace v8::internal | 609 } } // namespace v8::internal |
OLD | NEW |