| // Copyright 2019 the V8 project authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| @hasSameInstanceTypeAsParent |
| @doNotGenerateCast |
| extern class RegExpMatchInfo extends FixedArray { |
| macro GetStartOfCapture(implicit context: Context)(captureIndex: |
| constexpr int31): Smi { |
| const index: constexpr int31 = GetStartOfCaptureIndex(captureIndex); |
| return UnsafeCast<Smi>(this.objects[index]); |
| } |
| macro GetEndOfCapture(implicit context: Context)(captureIndex: |
| constexpr int31): Smi { |
| const index: constexpr int31 = GetStartOfCaptureIndex(captureIndex) + 1; |
| return UnsafeCast<Smi>(this.objects[index]); |
| } |
| macro NumberOfCaptures(implicit context: Context)(): Smi { |
| return UnsafeCast<Smi>(this.objects[kRegExpMatchInfoNumberOfCapturesIndex]); |
| } |
| } |
| |
| const kRegExpMatchInfoFirstCaptureIndex: |
| constexpr int31 generates 'RegExpMatchInfo::kFirstCaptureIndex'; |
| const kRegExpMatchInfoNumberOfCapturesIndex: |
| constexpr int31 generates 'RegExpMatchInfo::kNumberOfCapturesIndex'; |
| |
| macro GetStartOfCaptureIndex(captureIndex: constexpr int31): constexpr int31 { |
| return kRegExpMatchInfoFirstCaptureIndex + (captureIndex * 2); |
| } |