diff options
| author | 2023-01-17 23:41:01 -0800 | |
|---|---|---|
| committer | 2023-01-17 23:41:17 -0800 | |
| commit | bd5b90fbf143756f5de8ba5eb560cb6449177300 (patch) | |
| tree | 59bcbf7c2cbe91dba887ea1b788410d90ba1e07a /src/bun.js/bindings/ImportMetaObject.h | |
| parent | bba4054da3a5cbc2f234b9cf4b3ebdb7bb19e69d (diff) | |
| download | bun-bd5b90fbf143756f5de8ba5eb560cb6449177300.tar.gz bun-bd5b90fbf143756f5de8ba5eb560cb6449177300.tar.zst bun-bd5b90fbf143756f5de8ba5eb560cb6449177300.zip | |
Fix lifetime issue in require.resolve
Diffstat (limited to 'src/bun.js/bindings/ImportMetaObject.h')
| -rw-r--r-- | src/bun.js/bindings/ImportMetaObject.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/bun.js/bindings/ImportMetaObject.h b/src/bun.js/bindings/ImportMetaObject.h index ff32c85d4..b9b7cce77 100644 --- a/src/bun.js/bindings/ImportMetaObject.h +++ b/src/bun.js/bindings/ImportMetaObject.h @@ -11,6 +11,7 @@ extern "C" JSC_DECLARE_HOST_FUNCTION(functionImportMeta__resolveSync); extern "C" EncodedJSValue Bun__resolve(JSC::JSGlobalObject* global, JSC::EncodedJSValue specifier, JSC::EncodedJSValue from, bool is_esm); extern "C" EncodedJSValue Bun__resolveSync(JSC::JSGlobalObject* global, JSC::EncodedJSValue specifier, JSC::EncodedJSValue from, bool is_esm); +extern "C" EncodedJSValue Bun__resolveSyncWithSource(JSC::JSGlobalObject* global, JSC::EncodedJSValue specifier, ZigString* from, bool is_esm); namespace Zig { @@ -28,9 +29,15 @@ public: return ptr; } + static JSC::Structure* createResolveFunctionStructure(JSC::VM& vm, Zig::GlobalObject* globalObject); + static JSValue createResolveFunctionPrototype(JSC::VM& vm, Zig::GlobalObject* globalObject); + static JSObject* createRequireFunction(VM& vm, JSGlobalObject* lexicalGlobalObject, const WTF::String& pathString); + static ImportMetaObject* create(JSC::JSGlobalObject* globalObject, JSC::JSValue key); + static inline Zig::ImportMetaObject* create(JSC::JSGlobalObject* globalObject, JSC::JSString* keyString) { + // TODO: optimize this by reusing the same JSC::Structure object and using putDirectOffset auto& vm = globalObject->vm(); auto view = keyString->value(globalObject); JSC::Structure* structure = WebCore::getDOMStructure<Zig::ImportMetaObject>(vm, *reinterpret_cast<Zig::GlobalObject*>(globalObject)); @@ -94,8 +101,6 @@ public: static JSObject* createPrototype(VM& vm, JSDOMGlobalObject& globalObject); static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); - static JSObject* createRequireFunction(VM& vm, JSGlobalObject* globalObject, WTF::String& pathString); - private: ImportMetaObject(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) : Base(vm, structure) |
