diff options
Diffstat (limited to 'Userland/Libraries/LibJS/Script.cpp')
-rw-r--r-- | Userland/Libraries/LibJS/Script.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/Userland/Libraries/LibJS/Script.cpp b/Userland/Libraries/LibJS/Script.cpp index d5a76c4def..6c6c55fc5e 100644 --- a/Userland/Libraries/LibJS/Script.cpp +++ b/Userland/Libraries/LibJS/Script.cpp @@ -13,7 +13,7 @@ namespace JS { // 16.1.5 ParseScript ( sourceText, realm, hostDefined ), https://tc39.es/ecma262/#sec-parse-script -Result<NonnullRefPtr<Script>, Vector<Parser::Error>> Script::parse(StringView source_text, Realm& realm, StringView filename, HostDefined* host_defined, size_t line_number_offset) +Result<NonnullGCPtr<Script>, Vector<Parser::Error>> Script::parse(StringView source_text, Realm& realm, StringView filename, HostDefined* host_defined, size_t line_number_offset) { // 1. Let script be ParseText(sourceText, Script). auto parser = Parser(Lexer(source_text, filename, line_number_offset)); @@ -24,16 +24,25 @@ Result<NonnullRefPtr<Script>, Vector<Parser::Error>> Script::parse(StringView so return parser.errors(); // 3. Return Script Record { [[Realm]]: realm, [[ECMAScriptCode]]: script, [[HostDefined]]: hostDefined }. - return adopt_ref(*new Script(realm, filename, move(script), host_defined)); + return NonnullGCPtr(*realm.heap().allocate_without_realm<Script>(realm, filename, move(script), host_defined)); } Script::Script(Realm& realm, StringView filename, NonnullRefPtr<Program> parse_node, HostDefined* host_defined) - : m_vm(realm.vm()) - , m_realm(make_handle(&realm)) + : m_realm(realm) , m_parse_node(move(parse_node)) , m_filename(filename) , m_host_defined(host_defined) { } +Script::~Script() +{ +} + +void Script::visit_edges(Cell::Visitor& visitor) +{ + Base::visit_edges(visitor); + visitor.visit(m_realm); +} + } |