| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are |
| 4 // met: |
| 5 // |
| 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. |
| 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 |
| 28 #ifndef V8_JSREGEXP_INL_H_ |
| 29 #define V8_JSREGEXP_INL_H_ |
| 30 |
| 31 |
| 32 #include "jsregexp.h" |
| 33 |
| 34 |
| 35 namespace v8 { |
| 36 namespace internal { |
| 37 |
| 38 |
| 39 CharacterClass CharacterClass::SingletonField(uc16 value) { |
| 40 CharacterClass result(FIELD); |
| 41 result.segment_ = segment_of(value); |
| 42 result.data_.u_field = long_bit(value & kSegmentMask); |
| 43 return result; |
| 44 } |
| 45 |
| 46 |
| 47 CharacterClass CharacterClass::RangeField(Range range) { |
| 48 CharacterClass result; |
| 49 result.InitializeFieldFrom(Vector<Range>(&range, 1)); |
| 50 return result; |
| 51 } |
| 52 |
| 53 |
| 54 CharacterClass CharacterClass::Union(CharacterClass* left, |
| 55 CharacterClass* right) { |
| 56 CharacterClass result(UNION); |
| 57 result.data_.u_union.left = left; |
| 58 result.data_.u_union.right = right; |
| 59 return result; |
| 60 } |
| 61 |
| 62 |
| 63 void CharacterClass::write_nibble(int index, byte value) { |
| 64 ASSERT(0 <= index && index < 16); |
| 65 data_.u_field |= static_cast<uint64_t>(value) << (4 * index); |
| 66 } |
| 67 |
| 68 |
| 69 byte CharacterClass::read_nibble(int index) { |
| 70 ASSERT(0 <= index && index < 16); |
| 71 return (data_.u_field >> (4 * index)) & 0xf; |
| 72 } |
| 73 |
| 74 |
| 75 unsigned CharacterClass::segment_of(uc16 value) { |
| 76 return value >> CharacterClass::kFieldSegmentWidth; |
| 77 } |
| 78 |
| 79 |
| 80 uc16 CharacterClass::segment_start(unsigned segment) { |
| 81 return segment << CharacterClass::kFieldSegmentWidth; |
| 82 } |
| 83 |
| 84 |
| 85 |
| 86 } // namespace internal |
| 87 } // namespace v8 |
| 88 |
| 89 |
| 90 #endif // V8_JSREGEXP_INL_H_ |
| OLD | NEW |