blob: d6317b4e9bfdac2a6fa243fb3783462dc73e1b80 [file] [log] [blame]
// 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
extern class RegExpMatchInfo extends FixedArray {
GetStartOfCapture(implicit context: Context)(captureIndex: constexpr int31):
Smi {
const index: constexpr int31 = GetStartOfCaptureIndex(captureIndex);
return UnsafeCast<Smi>(this.objects[index]);
}
GetEndOfCapture(implicit context: Context)(captureIndex: constexpr int31):
Smi {
const index: constexpr int31 = GetStartOfCaptureIndex(captureIndex) + 1;
return UnsafeCast<Smi>(this.objects[index]);
}
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);
}