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

Side by Side Diff: src/jsregexp.cc

Issue 12511: Added the v8::jscre namespace around the jscre functions to avoid link errors... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 12 years 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 | Annotate | Revision Log
« no previous file with comments | « src/api.cc ('k') | src/third_party/jscre/pcre.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 if (needle_length == 0) index++; 309 if (needle_length == 0) index++;
310 } 310 }
311 return result; 311 return result;
312 } 312 }
313 313
314 314
315 static inline Object* DoCompile(String* pattern, 315 static inline Object* DoCompile(String* pattern,
316 JSRegExp::Flags flags, 316 JSRegExp::Flags flags,
317 unsigned* number_of_captures, 317 unsigned* number_of_captures,
318 const char** error_message, 318 const char** error_message,
319 JscreRegExp** code) { 319 v8::jscre::JscreRegExp** code) {
320 JSRegExpIgnoreCaseOption case_option = flags.is_ignore_case() 320 v8::jscre::JSRegExpIgnoreCaseOption case_option = flags.is_ignore_case()
321 ? JSRegExpIgnoreCase 321 ? v8::jscre::JSRegExpIgnoreCase
322 : JSRegExpDoNotIgnoreCase; 322 : v8::jscre::JSRegExpDoNotIgnoreCase;
323 JSRegExpMultilineOption multiline_option = flags.is_multiline() 323 v8::jscre::JSRegExpMultilineOption multiline_option = flags.is_multiline()
324 ? JSRegExpMultiline 324 ? v8::jscre::JSRegExpMultiline
325 : JSRegExpSingleLine; 325 : v8::jscre::JSRegExpSingleLine;
326 *error_message = NULL; 326 *error_message = NULL;
327 malloc_failure = Failure::Exception(); 327 malloc_failure = Failure::Exception();
328 *code = jsRegExpCompile(pattern->GetTwoByteData(), 328 *code = v8::jscre::jsRegExpCompile(pattern->GetTwoByteData(),
329 pattern->length(), 329 pattern->length(),
330 case_option, 330 case_option,
331 multiline_option, 331 multiline_option,
332 number_of_captures, 332 number_of_captures,
333 error_message, 333 error_message,
334 &JSREMalloc, 334 &JSREMalloc,
335 &JSREFree); 335 &JSREFree);
336 if (*code == NULL && (malloc_failure->IsRetryAfterGC() || 336 if (*code == NULL && (malloc_failure->IsRetryAfterGC() ||
337 malloc_failure->IsOutOfMemoryFailure())) { 337 malloc_failure->IsOutOfMemoryFailure())) {
338 return malloc_failure; 338 return malloc_failure;
339 } else { 339 } else {
340 // It doesn't matter which object we return here, we just need to return 340 // It doesn't matter which object we return here, we just need to return
341 // a non-failure to indicate to the GC-retry code that there was no 341 // a non-failure to indicate to the GC-retry code that there was no
342 // allocation failure. 342 // allocation failure.
343 return pattern; 343 return pattern;
344 } 344 }
345 } 345 }
346 346
347 347
348 void CompileWithRetryAfterGC(Handle<String> pattern, 348 void CompileWithRetryAfterGC(Handle<String> pattern,
349 JSRegExp::Flags flags, 349 JSRegExp::Flags flags,
350 unsigned* number_of_captures, 350 unsigned* number_of_captures,
351 const char** error_message, 351 const char** error_message,
352 JscreRegExp** code) { 352 v8::jscre::JscreRegExp** code) {
353 CALL_HEAP_FUNCTION_VOID(DoCompile(*pattern, 353 CALL_HEAP_FUNCTION_VOID(DoCompile(*pattern,
354 flags, 354 flags,
355 number_of_captures, 355 number_of_captures,
356 error_message, 356 error_message,
357 code)); 357 code));
358 } 358 }
359 359
360 360
361 Handle<Object> RegExpImpl::JsreCompile(Handle<JSRegExp> re, 361 Handle<Object> RegExpImpl::JsreCompile(Handle<JSRegExp> re,
362 Handle<String> pattern, 362 Handle<String> pattern,
363 JSRegExp::Flags flags) { 363 JSRegExp::Flags flags) {
364 Handle<String> two_byte_pattern = StringToTwoByte(pattern); 364 Handle<String> two_byte_pattern = StringToTwoByte(pattern);
365 365
366 unsigned number_of_captures; 366 unsigned number_of_captures;
367 const char* error_message = NULL; 367 const char* error_message = NULL;
368 368
369 JscreRegExp* code = NULL; 369 v8::jscre::JscreRegExp* code = NULL;
370 FlattenString(pattern); 370 FlattenString(pattern);
371 371
372 CompileWithRetryAfterGC(two_byte_pattern, 372 CompileWithRetryAfterGC(two_byte_pattern,
373 flags, 373 flags,
374 &number_of_captures, 374 &number_of_captures,
375 &error_message, 375 &error_message,
376 &code); 376 &code);
377 377
378 if (code == NULL) { 378 if (code == NULL) {
379 // Throw an exception. 379 // Throw an exception.
(...skipping 24 matching lines...) Expand all
404 int num_captures, 404 int num_captures,
405 Handle<String> subject, 405 Handle<String> subject,
406 int previous_index, 406 int previous_index,
407 const uc16* two_byte_subject, 407 const uc16* two_byte_subject,
408 int* offsets_vector, 408 int* offsets_vector,
409 int offsets_vector_length) { 409 int offsets_vector_length) {
410 int rc; 410 int rc;
411 { 411 {
412 AssertNoAllocation a; 412 AssertNoAllocation a;
413 ByteArray* internal = JsreInternal(regexp); 413 ByteArray* internal = JsreInternal(regexp);
414 const JscreRegExp* js_regexp = 414 const v8::jscre::JscreRegExp* js_regexp =
415 reinterpret_cast<JscreRegExp*>(internal->GetDataStartAddress()); 415 reinterpret_cast<v8::jscre::JscreRegExp*>(
416 internal->GetDataStartAddress());
416 417
417 LOG(RegExpExecEvent(regexp, previous_index, subject)); 418 LOG(RegExpExecEvent(regexp, previous_index, subject));
418 419
419 rc = jsRegExpExecute(js_regexp, 420 rc = v8::jscre::jsRegExpExecute(js_regexp,
420 two_byte_subject, 421 two_byte_subject,
421 subject->length(), 422 subject->length(),
422 previous_index, 423 previous_index,
423 offsets_vector, 424 offsets_vector,
424 offsets_vector_length); 425 offsets_vector_length);
425 } 426 }
426 427
427 // The KJS JavaScript engine returns null (ie, a failed match) when 428 // The KJS JavaScript engine returns null (ie, a failed match) when
428 // JSRE's internal match limit is exceeded. We duplicate that behavior here. 429 // JSRE's internal match limit is exceeded. We duplicate that behavior here.
429 if (rc == JSRegExpErrorNoMatch 430 if (rc == v8::jscre::JSRegExpErrorNoMatch
430 || rc == JSRegExpErrorHitLimit) { 431 || rc == v8::jscre::JSRegExpErrorHitLimit) {
431 return Factory::null_value(); 432 return Factory::null_value();
432 } 433 }
433 434
434 // Other JSRE errors: 435 // Other JSRE errors:
435 if (rc < 0) { 436 if (rc < 0) {
436 // Throw an exception. 437 // Throw an exception.
437 Handle<Object> code(Smi::FromInt(rc)); 438 Handle<Object> code(Smi::FromInt(rc));
438 Handle<Object> args[2] = { Factory::LookupAsciiSymbol("jsre_exec"), code }; 439 Handle<Object> args[2] = { Factory::LookupAsciiSymbol("jsre_exec"), code };
439 Handle<Object> regexp_err( 440 Handle<Object> regexp_err(
440 Factory::NewTypeError("jsre_error", HandleVector(args, 2))); 441 Factory::NewTypeError("jsre_error", HandleVector(args, 2)));
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 return Smi::cast(value->get(CAPTURE_INDEX))->value(); 568 return Smi::cast(value->get(CAPTURE_INDEX))->value();
568 } 569 }
569 570
570 571
571 ByteArray* RegExpImpl::JsreInternal(Handle<JSRegExp> re) { 572 ByteArray* RegExpImpl::JsreInternal(Handle<JSRegExp> re) {
572 FixedArray* value = FixedArray::cast(re->DataAt(JSRegExp::kJscreDataIndex)); 573 FixedArray* value = FixedArray::cast(re->DataAt(JSRegExp::kJscreDataIndex));
573 return ByteArray::cast(value->get(INTERNAL_INDEX)); 574 return ByteArray::cast(value->get(INTERNAL_INDEX));
574 } 575 }
575 576
576 }} // namespace v8::internal 577 }} // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/third_party/jscre/pcre.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698