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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 // internally. | 418 // internally. |
419 return (IrregexpNumberOfCaptures(FixedArray::cast(regexp->data())) + 1) * 2; | 419 return (IrregexpNumberOfCaptures(FixedArray::cast(regexp->data())) + 1) * 2; |
420 #endif // V8_INTERPRETED_REGEXP | 420 #endif // V8_INTERPRETED_REGEXP |
421 } | 421 } |
422 | 422 |
423 | 423 |
424 RegExpImpl::IrregexpResult RegExpImpl::IrregexpExecOnce( | 424 RegExpImpl::IrregexpResult RegExpImpl::IrregexpExecOnce( |
425 Handle<JSRegExp> regexp, | 425 Handle<JSRegExp> regexp, |
426 Handle<String> subject, | 426 Handle<String> subject, |
427 int index, | 427 int index, |
428 Vector<int32_t> output) { | 428 Vector<int> output) { |
429 Handle<FixedArray> irregexp(FixedArray::cast(regexp->data())); | 429 Handle<FixedArray> irregexp(FixedArray::cast(regexp->data())); |
430 | 430 |
431 ASSERT(index >= 0); | 431 ASSERT(index >= 0); |
432 ASSERT(index <= subject->length()); | 432 ASSERT(index <= subject->length()); |
433 ASSERT(subject->IsFlat()); | 433 ASSERT(subject->IsFlat()); |
434 | 434 |
435 // A flat ASCII string might have a two-byte first part. | 435 // A flat ASCII string might have a two-byte first part. |
436 if (subject->IsConsString()) { | 436 if (subject->IsConsString()) { |
437 subject = Handle<String>(ConsString::cast(*subject)->first()); | 437 subject = Handle<String>(ConsString::cast(*subject)->first()); |
438 } | 438 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 int required_registers = RegExpImpl::IrregexpPrepare(jsregexp, subject); | 514 int required_registers = RegExpImpl::IrregexpPrepare(jsregexp, subject); |
515 if (required_registers < 0) { | 515 if (required_registers < 0) { |
516 // Compiling failed with an exception. | 516 // Compiling failed with an exception. |
517 ASSERT(Top::has_pending_exception()); | 517 ASSERT(Top::has_pending_exception()); |
518 return Handle<Object>::null(); | 518 return Handle<Object>::null(); |
519 } | 519 } |
520 | 520 |
521 OffsetsVector registers(required_registers); | 521 OffsetsVector registers(required_registers); |
522 | 522 |
523 IrregexpResult res = RegExpImpl::IrregexpExecOnce( | 523 IrregexpResult res = RegExpImpl::IrregexpExecOnce( |
524 jsregexp, subject, previous_index, Vector<int32_t>(registers.vector(), | 524 jsregexp, subject, previous_index, Vector<int>(registers.vector(), |
525 registers.length())); | 525 registers.length())); |
526 if (res == RE_SUCCESS) { | 526 if (res == RE_SUCCESS) { |
527 int capture_register_count = | 527 int capture_register_count = |
528 (IrregexpNumberOfCaptures(FixedArray::cast(jsregexp->data())) + 1) * 2; | 528 (IrregexpNumberOfCaptures(FixedArray::cast(jsregexp->data())) + 1) * 2; |
529 last_match_info->EnsureSize(capture_register_count + kLastMatchOverhead); | 529 last_match_info->EnsureSize(capture_register_count + kLastMatchOverhead); |
530 AssertNoAllocation no_gc; | 530 AssertNoAllocation no_gc; |
531 int* register_vector = registers.vector(); | 531 int* register_vector = registers.vector(); |
532 FixedArray* array = FixedArray::cast(last_match_info->elements()); | 532 FixedArray* array = FixedArray::cast(last_match_info->elements()); |
533 for (int i = 0; i < capture_register_count; i += 2) { | 533 for (int i = 0; i < capture_register_count; i += 2) { |
534 SetCapture(array, i, register_vector[i]); | 534 SetCapture(array, i, register_vector[i]); |
535 SetCapture(array, i + 1, register_vector[i + 1]); | 535 SetCapture(array, i + 1, register_vector[i + 1]); |
(...skipping 4795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5331 node, | 5331 node, |
5332 data->capture_count, | 5332 data->capture_count, |
5333 pattern); | 5333 pattern); |
5334 } | 5334 } |
5335 | 5335 |
5336 | 5336 |
5337 int OffsetsVector::static_offsets_vector_[ | 5337 int OffsetsVector::static_offsets_vector_[ |
5338 OffsetsVector::kStaticOffsetsVectorSize]; | 5338 OffsetsVector::kStaticOffsetsVectorSize]; |
5339 | 5339 |
5340 }} // namespace v8::internal | 5340 }} // namespace v8::internal |
OLD | NEW |