1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
#pragma once
#include "root.h"
#include "BunBuiltinNames.h"
#include "BunClientData.h"
#include "ZigGlobalObject.h"
extern "C" JSC::EncodedJSValue jsFunctionGetOnigurumaRegExpConstructor(JSC::JSGlobalObject* lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName attributeName);
namespace Zig {
using namespace JSC;
using namespace WebCore;
class OnigurumaRegEx final : public JSC::JSDestructibleObject {
public:
using Base = JSC::JSDestructibleObject;
static OnigurumaRegEx* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
{
OnigurumaRegEx* ptr = new (NotNull, JSC::allocateCell<OnigurumaRegEx>(vm)) OnigurumaRegEx(vm, globalObject, structure);
ptr->finishCreation(vm);
return ptr;
}
static OnigurumaRegEx* create(JSC::JSGlobalObject* globalObject, WTF::String&& pattern, WTF::String&& flags)
{
auto* structure = reinterpret_cast<Zig::GlobalObject*>(globalObject)->OnigurumaRegExpStructure();
auto* object = create(globalObject->vm(), globalObject, structure);
object->m_flagsString = WTFMove(flags);
object->m_patternString = WTFMove(pattern);
return object;
}
DECLARE_EXPORT_INFO;
template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
{
if constexpr (mode == JSC::SubspaceAccess::Concurrently)
return nullptr;
return WebCore::subspaceForImpl<OnigurumaRegEx, UseCustomHeapCellType::No>(
vm,
[](auto& spaces) { return spaces.m_clientSubspaceForOnigurumaRegExp.get(); },
[](auto& spaces, auto&& space) { spaces.m_clientSubspaceForOnigurumaRegExp = WTFMove(space); },
[](auto& spaces) { return spaces.m_subspaceForOnigurumaRegExp.get(); },
[](auto& spaces, auto&& space) { spaces.m_subspaceForOnigurumaRegExp = WTFMove(space); });
}
static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
{
return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(RegExpObjectType, StructureFlags), info());
}
// static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
const WTF::String& flagsString() const { return m_flagsString; }
void setFlagsString(const WTF::String& flagsString) { m_flagsString = flagsString; }
const WTF::String& patternString() const { return m_patternString; }
void setPatternString(const WTF::String& patternString) { m_patternString = patternString; }
int32_t m_lastIndex = 0;
private:
OnigurumaRegEx(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
: Base(vm, structure)
{
}
void finishCreation(JSC::VM&)
{
Base::finishCreation(vm());
}
WTF::String m_patternString = {};
WTF::String m_flagsString = {};
};
class OnigurumaRegExpConstructor final : public JSC::InternalFunction {
public:
using Base = JSC::InternalFunction;
static OnigurumaRegExpConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSValue prototype);
// Must be defined for each specialization class.
static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
DECLARE_EXPORT_INFO;
static JSC::Structure* createClassStructure(JSC::JSGlobalObject*, JSC::JSValue prototype);
static JSC::JSObject* createPrototype(JSC::JSGlobalObject*);
static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
{
return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
}
private:
OnigurumaRegExpConstructor(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction nativeFunction)
: Base(vm, structure, nativeFunction, nativeFunction)
{
}
void finishCreation(JSC::VM&, JSValue prototype);
};
}
|