OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 Handle<String> needle(String::cast(re->DataAt(JSRegExp::kAtomPatternIndex))); | 247 Handle<String> needle(String::cast(re->DataAt(JSRegExp::kAtomPatternIndex))); |
248 | 248 |
249 uint32_t start_index = index; | 249 uint32_t start_index = index; |
250 | 250 |
251 int value = Runtime::StringMatch(subject, needle, start_index); | 251 int value = Runtime::StringMatch(subject, needle, start_index); |
252 if (value == -1) return Factory::null_value(); | 252 if (value == -1) return Factory::null_value(); |
253 ASSERT(last_match_info->HasFastElements()); | 253 ASSERT(last_match_info->HasFastElements()); |
254 | 254 |
255 { | 255 { |
256 NoHandleAllocation no_handles; | 256 NoHandleAllocation no_handles; |
257 FixedArray* array = last_match_info->elements(); | 257 FixedArray* array = FixedArray::cast(last_match_info->elements()); |
258 SetAtomLastCapture(array, *subject, value, value + needle->length()); | 258 SetAtomLastCapture(array, *subject, value, value + needle->length()); |
259 } | 259 } |
260 return last_match_info; | 260 return last_match_info; |
261 } | 261 } |
262 | 262 |
263 | 263 |
264 // Irregexp implementation. | 264 // Irregexp implementation. |
265 | 265 |
266 // Ensures that the regexp object contains a compiled version of the | 266 // Ensures that the regexp object contains a compiled version of the |
267 // source for either ASCII or non-ASCII strings. | 267 // source for either ASCII or non-ASCII strings. |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 } while (res == RegExpMacroAssemblerIA32::RETRY); | 435 } while (res == RegExpMacroAssemblerIA32::RETRY); |
436 if (res == RegExpMacroAssemblerIA32::EXCEPTION) { | 436 if (res == RegExpMacroAssemblerIA32::EXCEPTION) { |
437 ASSERT(Top::has_pending_exception()); | 437 ASSERT(Top::has_pending_exception()); |
438 return Handle<Object>::null(); | 438 return Handle<Object>::null(); |
439 } | 439 } |
440 ASSERT(res == RegExpMacroAssemblerIA32::SUCCESS | 440 ASSERT(res == RegExpMacroAssemblerIA32::SUCCESS |
441 || res == RegExpMacroAssemblerIA32::FAILURE); | 441 || res == RegExpMacroAssemblerIA32::FAILURE); |
442 | 442 |
443 if (res != RegExpMacroAssemblerIA32::SUCCESS) return Factory::null_value(); | 443 if (res != RegExpMacroAssemblerIA32::SUCCESS) return Factory::null_value(); |
444 | 444 |
445 array = Handle<FixedArray>(last_match_info->elements()); | 445 array = Handle<FixedArray>(FixedArray::cast(last_match_info->elements())); |
446 ASSERT(array->length() >= number_of_capture_registers + kLastMatchOverhead); | 446 ASSERT(array->length() >= number_of_capture_registers + kLastMatchOverhead); |
447 // The captures come in (start, end+1) pairs. | 447 // The captures come in (start, end+1) pairs. |
448 for (int i = 0; i < number_of_capture_registers; i += 2) { | 448 for (int i = 0; i < number_of_capture_registers; i += 2) { |
449 SetCapture(*array, i, captures_vector[i]); | 449 SetCapture(*array, i, captures_vector[i]); |
450 SetCapture(*array, i + 1, captures_vector[i + 1]); | 450 SetCapture(*array, i + 1, captures_vector[i + 1]); |
451 } | 451 } |
452 #else // !V8_TARGET_ARCH_IA32 | 452 #else // !V8_TARGET_ARCH_IA32 |
453 UNREACHABLE(); | 453 UNREACHABLE(); |
454 #endif // V8_TARGET_ARCH_IA32 | 454 #endif // V8_TARGET_ARCH_IA32 |
455 #else // !V8_NATIVE_REGEXP | 455 #else // !V8_NATIVE_REGEXP |
(...skipping 12 matching lines...) Expand all Loading... |
468 } | 468 } |
469 Handle<ByteArray> byte_codes(IrregexpByteCode(*regexp, is_ascii)); | 469 Handle<ByteArray> byte_codes(IrregexpByteCode(*regexp, is_ascii)); |
470 | 470 |
471 if (!IrregexpInterpreter::Match(byte_codes, | 471 if (!IrregexpInterpreter::Match(byte_codes, |
472 subject, | 472 subject, |
473 register_vector, | 473 register_vector, |
474 previous_index)) { | 474 previous_index)) { |
475 return Factory::null_value(); | 475 return Factory::null_value(); |
476 } | 476 } |
477 | 477 |
478 array = Handle<FixedArray>(last_match_info->elements()); | 478 array = Handle<FixedArray>(FixedArray::cast(last_match_info->elements())); |
479 ASSERT(array->length() >= number_of_capture_registers + kLastMatchOverhead); | 479 ASSERT(array->length() >= number_of_capture_registers + kLastMatchOverhead); |
480 // The captures come in (start, end+1) pairs. | 480 // The captures come in (start, end+1) pairs. |
481 for (int i = 0; i < number_of_capture_registers; i += 2) { | 481 for (int i = 0; i < number_of_capture_registers; i += 2) { |
482 SetCapture(*array, i, register_vector[i]); | 482 SetCapture(*array, i, register_vector[i]); |
483 SetCapture(*array, i + 1, register_vector[i + 1]); | 483 SetCapture(*array, i + 1, register_vector[i + 1]); |
484 } | 484 } |
485 #endif // V8_NATIVE_REGEXP | 485 #endif // V8_NATIVE_REGEXP |
486 | 486 |
487 SetLastCaptureCount(*array, number_of_capture_registers); | 487 SetLastCaptureCount(*array, number_of_capture_registers); |
488 SetLastSubject(*array, *subject); | 488 SetLastSubject(*array, *subject); |
(...skipping 3996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4485 EmbeddedVector<byte, 1024> codes; | 4485 EmbeddedVector<byte, 1024> codes; |
4486 RegExpMacroAssemblerIrregexp macro_assembler(codes); | 4486 RegExpMacroAssemblerIrregexp macro_assembler(codes); |
4487 return compiler.Assemble(¯o_assembler, | 4487 return compiler.Assemble(¯o_assembler, |
4488 node, | 4488 node, |
4489 data->capture_count, | 4489 data->capture_count, |
4490 pattern); | 4490 pattern); |
4491 #endif // V8_NATIVE_REGEXP | 4491 #endif // V8_NATIVE_REGEXP |
4492 } | 4492 } |
4493 | 4493 |
4494 }} // namespace v8::internal | 4494 }} // namespace v8::internal |
OLD | NEW |