Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Side by Side Diff: src/regexp/jsregexp.cc

Issue 2050343002: [regexp] Experimental support for regexp named captures (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/regexp/jsregexp.h ('k') | src/regexp/regexp-ast.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 #include "src/regexp/jsregexp.h" 5 #include "src/regexp/jsregexp.h"
6 6
7 #include "src/ast/ast.h" 7 #include "src/ast/ast.h"
8 #include "src/base/platform/platform.h" 8 #include "src/base/platform/platform.h"
9 #include "src/compilation-cache.h" 9 #include "src/compilation-cache.h"
10 #include "src/compiler.h" 10 #include "src/compiler.h"
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 if (result.error_message != NULL) { 390 if (result.error_message != NULL) {
391 // Unable to compile regexp. 391 // Unable to compile regexp.
392 Handle<String> error_message = isolate->factory()->NewStringFromUtf8( 392 Handle<String> error_message = isolate->factory()->NewStringFromUtf8(
393 CStrVector(result.error_message)).ToHandleChecked(); 393 CStrVector(result.error_message)).ToHandleChecked();
394 ThrowRegExpException(re, error_message); 394 ThrowRegExpException(re, error_message);
395 return false; 395 return false;
396 } 396 }
397 397
398 Handle<FixedArray> data = Handle<FixedArray>(FixedArray::cast(re->data())); 398 Handle<FixedArray> data = Handle<FixedArray>(FixedArray::cast(re->data()));
399 data->set(JSRegExp::code_index(is_one_byte), result.code); 399 data->set(JSRegExp::code_index(is_one_byte), result.code);
400 SetIrregexpCaptureNameMap(*data, compile_data.capture_name_map);
400 int register_max = IrregexpMaxRegisterCount(*data); 401 int register_max = IrregexpMaxRegisterCount(*data);
401 if (result.num_registers > register_max) { 402 if (result.num_registers > register_max) {
402 SetIrregexpMaxRegisterCount(*data, result.num_registers); 403 SetIrregexpMaxRegisterCount(*data, result.num_registers);
403 } 404 }
404 405
405 return true; 406 return true;
406 } 407 }
407 408
408 409
409 int RegExpImpl::IrregexpMaxRegisterCount(FixedArray* re) { 410 int RegExpImpl::IrregexpMaxRegisterCount(FixedArray* re) {
410 return Smi::cast( 411 return Smi::cast(
411 re->get(JSRegExp::kIrregexpMaxRegisterCountIndex))->value(); 412 re->get(JSRegExp::kIrregexpMaxRegisterCountIndex))->value();
412 } 413 }
413 414
414 415
415 void RegExpImpl::SetIrregexpMaxRegisterCount(FixedArray* re, int value) { 416 void RegExpImpl::SetIrregexpMaxRegisterCount(FixedArray* re, int value) {
416 re->set(JSRegExp::kIrregexpMaxRegisterCountIndex, Smi::FromInt(value)); 417 re->set(JSRegExp::kIrregexpMaxRegisterCountIndex, Smi::FromInt(value));
417 } 418 }
418 419
420 void RegExpImpl::SetIrregexpCaptureNameMap(FixedArray* re,
421 Handle<FixedArray> value) {
422 if (value.is_null()) {
423 re->set(JSRegExp::kIrregexpCaptureNameMapIndex, Smi::FromInt(0));
424 } else {
425 re->set(JSRegExp::kIrregexpCaptureNameMapIndex, *value);
426 }
427 }
419 428
420 int RegExpImpl::IrregexpNumberOfCaptures(FixedArray* re) { 429 int RegExpImpl::IrregexpNumberOfCaptures(FixedArray* re) {
421 return Smi::cast(re->get(JSRegExp::kIrregexpCaptureCountIndex))->value(); 430 return Smi::cast(re->get(JSRegExp::kIrregexpCaptureCountIndex))->value();
422 } 431 }
423 432
424 433
425 int RegExpImpl::IrregexpNumberOfRegisters(FixedArray* re) { 434 int RegExpImpl::IrregexpNumberOfRegisters(FixedArray* re) {
426 return Smi::cast(re->get(JSRegExp::kIrregexpMaxRegisterCountIndex))->value(); 435 return Smi::cast(re->get(JSRegExp::kIrregexpMaxRegisterCountIndex))->value();
427 } 436 }
428 437
(...skipping 6437 matching lines...) Expand 10 before | Expand all | Expand 10 after
6866 6875
6867 6876
6868 void RegExpResultsCache::Clear(FixedArray* cache) { 6877 void RegExpResultsCache::Clear(FixedArray* cache) {
6869 for (int i = 0; i < kRegExpResultsCacheSize; i++) { 6878 for (int i = 0; i < kRegExpResultsCacheSize; i++) {
6870 cache->set(i, Smi::FromInt(0)); 6879 cache->set(i, Smi::FromInt(0));
6871 } 6880 }
6872 } 6881 }
6873 6882
6874 } // namespace internal 6883 } // namespace internal
6875 } // namespace v8 6884 } // namespace v8
OLDNEW
« no previous file with comments | « src/regexp/jsregexp.h ('k') | src/regexp/regexp-ast.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698