5 #ifndef V8_OBJECTS_JS_REGEXP_INL_H_ 6 #define V8_OBJECTS_JS_REGEXP_INL_H_ 8 #include "src/objects/js-regexp.h" 10 #include "src/objects-inl.h" 11 #include "src/objects/smi.h" 12 #include "src/objects/string.h" 15 #include "src/objects/object-macros.h" 20 CAST_ACCESSOR(JSRegExp)
22 ACCESSORS(JSRegExp, data, Object, kDataOffset)
23 ACCESSORS(JSRegExp, flags, Object, kFlagsOffset)
24 ACCESSORS(JSRegExp, source, Object, kSourceOffset)
25 ACCESSORS(JSRegExp, last_index, Object, kLastIndexOffset)
27 JSRegExp::Type JSRegExp::TypeTag() {
28 Object* data = this->data();
29 if (data->IsUndefined())
return JSRegExp::NOT_COMPILED;
30 Smi smi = Smi::cast(FixedArray::cast(data)->
get(kTagIndex));
31 return static_cast<JSRegExp::Type
>(smi->value());
34 int JSRegExp::CaptureCount() {
39 return Smi::ToInt(DataAt(kIrregexpCaptureCountIndex));
45 JSRegExp::Flags JSRegExp::GetFlags() {
46 DCHECK(this->data()->IsFixedArray());
47 Object* data = this->data();
48 Smi smi = Smi::cast(FixedArray::cast(data)->
get(kFlagsIndex));
49 return Flags(smi->value());
52 String JSRegExp::Pattern() {
53 DCHECK(this->data()->IsFixedArray());
54 Object* data = this->data();
55 String pattern = String::cast(FixedArray::cast(data)->
get(kSourceIndex));
59 Object* JSRegExp::CaptureNameMap() {
60 DCHECK(this->data()->IsFixedArray());
61 DCHECK_EQ(TypeTag(), IRREGEXP);
62 Object* value = DataAt(kIrregexpCaptureNameMapIndex);
63 DCHECK_NE(value, Smi::FromInt(JSRegExp::kUninitializedValue));
67 Object* JSRegExp::DataAt(
int index) {
68 DCHECK(TypeTag() != NOT_COMPILED);
69 return FixedArray::cast(data())->get(index);
72 void JSRegExp::SetDataAt(
int index, Object* value) {
73 DCHECK(TypeTag() != NOT_COMPILED);
76 FixedArray::cast(data())->set(index, value);
82 #include "src/objects/object-macros-undef.h" 84 #endif // V8_OBJECTS_JS_REGEXP_INL_H_