aboutsummaryrefslogtreecommitdiff
path: root/src/javascript/jsc/bindings/DefaultGlobal.h
blob: 6bc5eb0c9e31eaf3a88b8ef4f3d2a1017a297e85 (plain) (blame)
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
#pragma once 

namespace JSC {
    class Structure;
    class Identifier;
    
}

#include "root.h"
#include <JavaScriptCore/JSGlobalObject.h>
#include "JSCInlines.h"

using namespace JSC;


namespace Wundle {

class Script;

class DefaultGlobal final : public JSC::JSGlobalObject {
public:
    using Base = JSC::JSGlobalObject;

    DECLARE_EXPORT_INFO;
    static const JSC::GlobalObjectMethodTable s_globalObjectMethodTable;

    static constexpr bool needsDestruction = true;
    template<typename CellType, SubspaceAccess mode>
    static JSC::IsoSubspace* subspaceFor(JSC::VM& vm)
    {
        return vm.apiGlobalObjectSpace<mode>();
    }

    static DefaultGlobal* create(JSC::VM& vm, JSC::Structure* structure)
    {
        auto* object = new (NotNull, allocateCell<DefaultGlobal>(vm.heap)) DefaultGlobal(vm, structure);
        object->finishCreation(vm);
        return object;
    }

    static Structure* createStructure(JSC::VM& vm, JSC::JSValue prototype)
    {
        auto* result = Structure::create(vm, nullptr, prototype, TypeInfo(GlobalObjectType, StructureFlags), info());
        result->setTransitionWatchpointIsLikelyToBeFired(true);
        return result;
    }

    static void reportUncaughtExceptionAtEventLoop(JSGlobalObject*, Exception*);

    static JSInternalPromise* moduleLoaderImportModule(JSGlobalObject*, JSModuleLoader*, JSC::JSString* moduleNameValue, JSValue parameters, const SourceOrigin&);
    static JSC::Identifier moduleLoaderResolve(JSGlobalObject*, JSModuleLoader*, JSValue keyValue, JSValue referrerValue, JSValue);
    static JSInternalPromise* moduleLoaderFetch(JSGlobalObject*, JSModuleLoader*, JSValue, JSValue, JSValue);
    static JSC::JSObject* moduleLoaderCreateImportMetaProperties(JSGlobalObject*, JSModuleLoader*, JSValue, JSModuleRecord*, JSValue);
    static JSValue moduleLoaderEvaluate(JSGlobalObject*, JSModuleLoader*, JSValue, JSValue, JSValue, JSValue, JSValue);


private:
    DefaultGlobal(JSC::VM& vm, JSC::Structure* structure)
        : Base(vm, structure, &s_globalObjectMethodTable)
    { }
};


}