1// Copyright 2021 the V8 project authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef V8_OBJECTS_REGEXP_MATCH_INFO_INL_H_ 6#define V8_OBJECTS_REGEXP_MATCH_INFO_INL_H_ 7 8#include "src/objects/fixed-array-inl.h" 9#include "src/objects/regexp-match-info.h" 10 11// Has to be the last include (doesn't have include guards): 12#include "src/objects/object-macros.h" 13 14namespace v8 { 15namespace internal { 16 17#include "torque-generated/src/objects/regexp-match-info-tq-inl.inc" 18 19TQ_OBJECT_CONSTRUCTORS_IMPL(RegExpMatchInfo) 20 21int RegExpMatchInfo::NumberOfCaptureRegisters() { 22 DCHECK_GE(length(), kLastMatchOverhead); 23 Object obj = get(kNumberOfCapturesIndex); 24 return Smi::ToInt(obj); 25} 26 27void RegExpMatchInfo::SetNumberOfCaptureRegisters(int value) { 28 DCHECK_GE(length(), kLastMatchOverhead); 29 set(kNumberOfCapturesIndex, Smi::FromInt(value)); 30} 31 32String RegExpMatchInfo::LastSubject() { 33 DCHECK_GE(length(), kLastMatchOverhead); 34 return String::cast(get(kLastSubjectIndex)); 35} 36 37void RegExpMatchInfo::SetLastSubject(String value, WriteBarrierMode mode) { 38 DCHECK_GE(length(), kLastMatchOverhead); 39 set(kLastSubjectIndex, value, mode); 40} 41 42Object RegExpMatchInfo::LastInput() { 43 DCHECK_GE(length(), kLastMatchOverhead); 44 return get(kLastInputIndex); 45} 46 47void RegExpMatchInfo::SetLastInput(Object value, WriteBarrierMode mode) { 48 DCHECK_GE(length(), kLastMatchOverhead); 49 set(kLastInputIndex, value, mode); 50} 51 52int RegExpMatchInfo::Capture(int i) { 53 DCHECK_LT(i, NumberOfCaptureRegisters()); 54 Object obj = get(kFirstCaptureIndex + i); 55 return Smi::ToInt(obj); 56} 57 58void RegExpMatchInfo::SetCapture(int i, int value) { 59 DCHECK_LT(i, NumberOfCaptureRegisters()); 60 set(kFirstCaptureIndex + i, Smi::FromInt(value)); 61} 62 63} // namespace internal 64} // namespace v8 65 66#include "src/objects/object-macros-undef.h" 67 68#endif // V8_OBJECTS_REGEXP_MATCH_INFO_INL_H_ 69