forked from oven-sh/bun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ImportMetaObject.h
69 lines (51 loc) · 2.7 KB
/
ImportMetaObject.h
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
#pragma once
#include "root.h"
#include "BunBuiltinNames.h"
#include "BunClientData.h"
#include "ZigGlobalObject.h"
#include "JSDOMWrapperCache.h"
extern "C" JSC_DECLARE_HOST_FUNCTION(functionImportMeta__resolveSync);
extern "C" JSC_DECLARE_HOST_FUNCTION(functionImportMeta__resolveSyncPrivate);
extern "C" JSC::EncodedJSValue Bun__resolve(JSC::JSGlobalObject* global, JSC::EncodedJSValue specifier, JSC::EncodedJSValue from, bool is_esm);
extern "C" JSC::EncodedJSValue Bun__resolveSync(JSC::JSGlobalObject* global, JSC::EncodedJSValue specifier, JSC::EncodedJSValue from, bool is_esm);
extern "C" JSC::EncodedJSValue Bun__resolveSyncWithSource(JSC::JSGlobalObject* global, JSC::EncodedJSValue specifier, BunString* from, bool is_esm);
namespace Zig {
using namespace JSC;
using namespace WebCore;
class ImportMetaObject final : public JSC::JSNonFinalObject {
public:
using Base = JSC::JSNonFinalObject;
static ImportMetaObject* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, const WTF::String& url);
static JSObject* createRequireFunction(VM& vm, JSGlobalObject* lexicalGlobalObject, const WTF::String& pathString);
static ImportMetaObject* create(JSC::JSGlobalObject* globalObject, JSC::JSString* keyString);
static ImportMetaObject* create(JSC::JSGlobalObject* globalObject, JSValue keyString);
DECLARE_INFO;
DECLARE_VISIT_CHILDREN;
template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
{
if constexpr (mode == JSC::SubspaceAccess::Concurrently)
return nullptr;
return WebCore::subspaceForImpl<ImportMetaObject, UseCustomHeapCellType::No>(
vm,
[](auto& spaces) { return spaces.m_clientSubspaceForImportMeta.get(); },
[](auto& spaces, auto&& space) { spaces.m_clientSubspaceForImportMeta = std::forward<decltype(space)>(space); },
[](auto& spaces) { return spaces.m_subspaceForImportMeta.get(); },
[](auto& spaces, auto&& space) { spaces.m_subspaceForImportMeta = std::forward<decltype(space)>(space); });
}
static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject);
static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
WTF::String url;
LazyProperty<JSObject, JSFunction> requireProperty;
LazyProperty<JSObject, JSString> dirProperty;
LazyProperty<JSObject, JSString> urlProperty;
LazyProperty<JSObject, JSString> fileProperty;
LazyProperty<JSObject, JSString> pathProperty;
private:
ImportMetaObject(JSC::VM& vm, JSC::Structure* structure, const WTF::String& url)
: Base(vm, structure)
, url(url)
{
}
void finishCreation(JSC::VM&);
};
}