Mark some more commonjs modules

This commit is contained in:
Jarred Sumner
2022-11-16 05:15:56 -08:00
parent 4985a44fe2
commit 29f72efac3
2 changed files with 34 additions and 7 deletions

View File

@@ -1,15 +1,33 @@
#include "../bindings/ZigGlobalObject.h"
#include "../bindings/JSStringDecoder.h"
#include "../bindings/ZigGlobalObject.h"
#include "JavaScriptCore/JSGlobalObject.h"
namespace Zig {
inline void generateStringDecoderSourceCode(JSC::JSGlobalObject* lexicalGlobalObject, JSC::Identifier moduleKey, Vector<JSC::Identifier, 4>& exportNames, JSC::MarkedArgumentBuffer& exportValues) {
JSC::VM& vm = lexicalGlobalObject->vm();
GlobalObject* globalObject = reinterpret_cast<GlobalObject*>(lexicalGlobalObject);
inline void
generateStringDecoderSourceCode(JSC::JSGlobalObject *lexicalGlobalObject,
JSC::Identifier moduleKey,
Vector<JSC::Identifier, 4> &exportNames,
JSC::MarkedArgumentBuffer &exportValues) {
JSC::VM &vm = lexicalGlobalObject->vm();
GlobalObject *globalObject =
reinterpret_cast<GlobalObject *>(lexicalGlobalObject);
exportNames.append(JSC::Identifier::fromString(vm, "StringDecoder"_s));
exportValues.append(globalObject->JSStringDecoder());
exportNames.append(JSC::Identifier::fromString(vm, "StringDecoder"_s));
exportValues.append(globalObject->JSStringDecoder());
JSC::JSObject *defaultObject = constructEmptyObject(globalObject);
defaultObject->putDirect(vm,
PropertyName(Identifier::fromUid(
vm.symbolRegistry().symbolForKey("CommonJS"_s))),
jsNumber(0), 0);
for (size_t i = 0; i < exportNames.size(); i++) {
defaultObject->putDirect(vm, exportNames[i], exportValues.at(i), 0);
}
exportNames.append(vm.propertyNames->defaultKeyword);
exportValues.append(defaultObject);
}
}
} // namespace Zig

View File

@@ -62,6 +62,15 @@ inline void generateTTYSourceCode(JSC::JSGlobalObject *lexicalGlobalObject,
tty->putDirect(vm, JSC::Identifier::fromString(vm, "WriteStream"_s), notimpl);
exportValues.append(notimpl);
tty->putDirect(vm,
PropertyName(Identifier::fromUid(
vm.symbolRegistry().symbolForKey("CommonJS"_s))),
jsNumber(0), 0);
for (size_t i = 0; i < exportNames.size(); i++) {
tty->putDirect(vm, exportNames[i], exportValues.at(i), 0);
}
exportNames.append(vm.propertyNames->defaultKeyword);
exportValues.append(tty);
}