mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:28:11 +00:00
LibJS: Add [[HostDefined]] internal slot to Script objects
In C++, this is a raw pointer to a Script::HostDefined.
This commit is contained in:
parent
77a1ef06a4
commit
6ddbe8f953
2 changed files with 13 additions and 7 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021-2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -20,17 +20,21 @@ class Script
|
|||
: public RefCounted<Script>
|
||||
, public Weakable<Script> {
|
||||
public:
|
||||
struct HostDefined {
|
||||
virtual ~HostDefined() = default;
|
||||
};
|
||||
|
||||
~Script();
|
||||
static Result<NonnullRefPtr<Script>, Vector<Parser::Error>> parse(StringView source_text, Realm&, StringView filename = {});
|
||||
static Result<NonnullRefPtr<Script>, Vector<Parser::Error>> parse(StringView source_text, Realm&, StringView filename = {}, HostDefined* = nullptr);
|
||||
|
||||
Realm& realm() { return *m_realm.cell(); }
|
||||
Program const& parse_node() const { return *m_parse_node; }
|
||||
|
||||
HostDefined* host_defined() { return m_host_defined; }
|
||||
StringView filename() const { return m_filename; }
|
||||
|
||||
private:
|
||||
Script(Realm&, StringView filename, NonnullRefPtr<Program>);
|
||||
|
||||
Script(Realm&, StringView filename, NonnullRefPtr<Program>, HostDefined* = nullptr);
|
||||
// Handles are not safe unless we keep the VM alive.
|
||||
NonnullRefPtr<VM> m_vm;
|
||||
|
||||
|
@ -39,6 +43,7 @@ private:
|
|||
|
||||
// Needed for potential lookups of modules.
|
||||
String m_filename;
|
||||
HostDefined* m_host_defined { nullptr }; // [[HostDefined]]
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue