mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 21:59:07 +00:00
Everywhere: Hoist the Libraries folder to the top-level
This commit is contained in:
parent
950e819ee7
commit
93712b24bf
Notes:
github-actions[bot]
2024-11-10 11:51:52 +00:00
Author: https://github.com/trflynn89
Commit: 93712b24bf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
4547 changed files with 104 additions and 113 deletions
54
Libraries/LibJS/Script.cpp
Normal file
54
Libraries/LibJS/Script.cpp
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Andreas Kling <andreas@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/AST.h>
|
||||
#include <LibJS/Lexer.h>
|
||||
#include <LibJS/Parser.h>
|
||||
#include <LibJS/Runtime/VM.h>
|
||||
#include <LibJS/Script.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(Script);
|
||||
|
||||
// 16.1.5 ParseScript ( sourceText, realm, hostDefined ), https://tc39.es/ecma262/#sec-parse-script
|
||||
Result<NonnullGCPtr<Script>, Vector<ParserError>> 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));
|
||||
auto script = parser.parse_program();
|
||||
|
||||
// 2. If script is a List of errors, return body.
|
||||
if (parser.has_errors())
|
||||
return parser.errors();
|
||||
|
||||
// 3. Return Script Record { [[Realm]]: realm, [[ECMAScriptCode]]: script, [[HostDefined]]: hostDefined }.
|
||||
return 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_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);
|
||||
if (m_host_defined)
|
||||
m_host_defined->visit_host_defined_self(visitor);
|
||||
for (auto const& loaded_module : m_loaded_modules)
|
||||
visitor.visit(loaded_module.module);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue