2021-09-14 19:35:23 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <LibJS/Heap/Handle.h>
|
|
|
|
#include <LibJS/Runtime/Realm.h>
|
|
|
|
|
|
|
|
namespace JS {
|
|
|
|
|
|
|
|
// 16.2.1.4 Abstract Module Records, https://tc39.es/ecma262/#sec-abstract-module-records
|
|
|
|
class Module : public RefCounted<Module> {
|
|
|
|
public:
|
|
|
|
virtual ~Module();
|
|
|
|
|
|
|
|
Realm& realm() { return *m_realm.cell(); }
|
|
|
|
Realm const& realm() const { return *m_realm.cell(); }
|
|
|
|
|
2022-01-18 19:21:42 +01:00
|
|
|
StringView filename() const { return m_filename; }
|
|
|
|
|
2021-09-14 19:35:23 +02:00
|
|
|
Environment* environment() { return m_environment.cell(); }
|
|
|
|
Object* namespace_() { return m_namespace.cell(); }
|
|
|
|
|
|
|
|
protected:
|
2022-01-18 19:21:42 +01:00
|
|
|
explicit Module(Realm&, StringView filename);
|
2021-09-14 19:35:23 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Handles are not safe unless we keep the VM alive.
|
|
|
|
NonnullRefPtr<VM> m_vm;
|
|
|
|
|
|
|
|
Handle<Realm> m_realm; // [[Realm]]
|
|
|
|
Handle<Environment> m_environment; // [[Environment]]
|
|
|
|
Handle<Object> m_namespace; // [[Namespace]]
|
2022-01-18 19:21:42 +01:00
|
|
|
|
|
|
|
// Needed for potential lookups of modules.
|
|
|
|
String m_filename;
|
2021-09-14 19:35:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|