forked from oven-sh/bun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BunCommonStrings.cpp
39 lines (32 loc) · 1.4 KB
/
BunCommonStrings.cpp
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
#include "root.h"
#include "BunBuiltinNames.h"
#include "BunCommonStrings.h"
#include <JavaScriptCore/JSString.h>
#include <JavaScriptCore/JSGlobalObject.h>
#include <JavaScriptCore/LazyProperty.h>
#include <JavaScriptCore/LazyPropertyInlines.h>
#include "ZigGlobalObject.h"
#include <JavaScriptCore/SlotVisitorInlines.h>
#include <JavaScriptCore/VMTrapsInlines.h>
namespace Bun {
using namespace JSC;
#define BUN_COMMON_STRINGS_LAZY_PROPERTY_DEFINITION(jsName) \
this->m_commonString_##jsName.initLater( \
[](const JSC::LazyProperty<JSGlobalObject, JSString>::Initializer& init) { \
auto& names = WebCore::builtinNames(init.vm); \
auto name = names.jsName##PublicName(); \
init.set(jsOwnedString(init.vm, name.string())); \
});
#define BUN_COMMON_STRINGS_LAZY_PROPERTY_VISITOR(name) this->m_commonString_##name.visit(visitor);
void CommonStrings::initialize()
{
BUN_COMMON_STRINGS_EACH_NAME(BUN_COMMON_STRINGS_LAZY_PROPERTY_DEFINITION)
}
template<typename Visitor>
void CommonStrings::visit(Visitor& visitor)
{
BUN_COMMON_STRINGS_EACH_NAME(BUN_COMMON_STRINGS_LAZY_PROPERTY_VISITOR)
}
template void CommonStrings::visit(JSC::AbstractSlotVisitor&);
template void CommonStrings::visit(JSC::SlotVisitor&);
} // namespace Bun