 Chromium Code Reviews
 Chromium Code Reviews Issue 9854020:
  RegExp: Add support for table-based character class  (Closed) 
  Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
    
  
    Issue 9854020:
  RegExp: Add support for table-based character class  (Closed) 
  Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/| OLD | NEW | 
|---|---|
| 1 // Copyright 2008-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2008-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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 345 uc16 minus, | 345 uc16 minus, | 
| 346 uc16 mask, | 346 uc16 mask, | 
| 347 Label* on_not_equal) { | 347 Label* on_not_equal) { | 
| 348 Emit(BC_MINUS_AND_CHECK_NOT_CHAR, c); | 348 Emit(BC_MINUS_AND_CHECK_NOT_CHAR, c); | 
| 349 Emit16(minus); | 349 Emit16(minus); | 
| 350 Emit16(mask); | 350 Emit16(mask); | 
| 351 EmitOrLink(on_not_equal); | 351 EmitOrLink(on_not_equal); | 
| 352 } | 352 } | 
| 353 | 353 | 
| 354 | 354 | 
| 355 void RegExpMacroAssemblerIrregexp::CheckCharacterInRange( | |
| 356 uc16 from, | |
| 357 uc16 to, | |
| 358 Label* on_in_range) { | |
| 359 Emit(BC_CHECK_CHAR_IN_RANGE, 0); | |
| 360 Emit16(from); | |
| 361 Emit16(to); | |
| 362 EmitOrLink(on_in_range); | |
| 363 } | |
| 364 | |
| 365 | |
| 366 void RegExpMacroAssemblerIrregexp::CheckCharacterNotInRange( | |
| 367 uc16 from, | |
| 368 uc16 to, | |
| 369 Label* on_not_in_range) { | |
| 370 Emit(BC_CHECK_CHAR_NOT_IN_RANGE, 0); | |
| 371 Emit16(from); | |
| 372 Emit16(to); | |
| 373 EmitOrLink(on_not_in_range); | |
| 374 } | |
| 375 | |
| 376 | |
| 377 void RegExpMacroAssemblerIrregexp::CheckBitInTable( | |
| 378 Handle<ByteArray> table, Label* on_bit_set) { | |
| 379 Emit(BC_CHECK_BIT_IN_TABLE, 0); | |
| 380 EmitOrLink(on_bit_set); | |
| 381 for (int i = 0; i < kTableSize; i += kBitsPerByte) { | |
| 382 int byte = 0; | |
| 383 for (int j = 0; j < kBitsPerByte; j++) { | |
| 384 byte <<= 1; | |
| 385 byte |= (table->get(i + j) != 0) ? 1 : 0; | |
| 
ulan
2012/03/27 11:02:43
I think it should be (table->get(i * kBitsPerByte
 
Erik Corry
2012/03/28 09:40:26
Done, but I kept the get(i + j) because I think it
 | |
| 386 } | |
| 387 Emit8(byte); | |
| 388 } | |
| 389 } | |
| 390 | |
| 391 | |
| 355 void RegExpMacroAssemblerIrregexp::CheckNotBackReference(int start_reg, | 392 void RegExpMacroAssemblerIrregexp::CheckNotBackReference(int start_reg, | 
| 356 Label* on_not_equal) { | 393 Label* on_not_equal) { | 
| 357 ASSERT(start_reg >= 0); | 394 ASSERT(start_reg >= 0); | 
| 358 ASSERT(start_reg <= kMaxRegister); | 395 ASSERT(start_reg <= kMaxRegister); | 
| 359 Emit(BC_CHECK_NOT_BACK_REF, start_reg); | 396 Emit(BC_CHECK_NOT_BACK_REF, start_reg); | 
| 360 EmitOrLink(on_not_equal); | 397 EmitOrLink(on_not_equal); | 
| 361 } | 398 } | 
| 362 | 399 | 
| 363 | 400 | 
| 364 void RegExpMacroAssemblerIrregexp::CheckNotBackReferenceIgnoreCase( | 401 void RegExpMacroAssemblerIrregexp::CheckNotBackReferenceIgnoreCase( | 
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 462 own_buffer_ = true; | 499 own_buffer_ = true; | 
| 463 memcpy(buffer_.start(), old_buffer.start(), old_buffer.length()); | 500 memcpy(buffer_.start(), old_buffer.start(), old_buffer.length()); | 
| 464 if (old_buffer_was_our_own) { | 501 if (old_buffer_was_our_own) { | 
| 465 old_buffer.Dispose(); | 502 old_buffer.Dispose(); | 
| 466 } | 503 } | 
| 467 } | 504 } | 
| 468 | 505 | 
| 469 #endif // V8_INTERPRETED_REGEXP | 506 #endif // V8_INTERPRETED_REGEXP | 
| 470 | 507 | 
| 471 } } // namespace v8::internal | 508 } } // namespace v8::internal | 
| OLD | NEW |