mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 12:15:07 +00:00
LibJS: Add filename tracking to Script and Module
This will allow us to resolve modules dynamically loaded from a script.
This commit is contained in:
parent
57c5a59cab
commit
12c2f30c54
6 changed files with 22 additions and 10 deletions
|
@ -9,7 +9,7 @@
|
|||
namespace JS {
|
||||
|
||||
// 16.2.1.6.1 ParseModule ( sourceText, realm, hostDefined ), https://tc39.es/ecma262/#sec-parsemodule
|
||||
Result<NonnullRefPtr<SourceTextModule>, Vector<Parser::Error>> SourceTextModule::parse(StringView source_text, Realm& realm, [[maybe_unused]] StringView filename)
|
||||
Result<NonnullRefPtr<SourceTextModule>, Vector<Parser::Error>> SourceTextModule::parse(StringView source_text, Realm& realm, StringView filename)
|
||||
{
|
||||
// 1. Let body be ParseText(sourceText, Module).
|
||||
auto parser = Parser(Lexer(source_text, filename), Program::Type::Module);
|
||||
|
@ -20,11 +20,11 @@ Result<NonnullRefPtr<SourceTextModule>, Vector<Parser::Error>> SourceTextModule:
|
|||
return parser.errors();
|
||||
|
||||
// FIXME: Implement the rest of ParseModule.
|
||||
return adopt_ref(*new SourceTextModule(realm, move(body)));
|
||||
return adopt_ref(*new SourceTextModule(realm, filename, move(body)));
|
||||
}
|
||||
|
||||
SourceTextModule::SourceTextModule(Realm& realm, NonnullRefPtr<Program> program)
|
||||
: Module(realm)
|
||||
SourceTextModule::SourceTextModule(Realm& realm, StringView filename, NonnullRefPtr<Program> program)
|
||||
: Module(realm, filename)
|
||||
, m_ecmascript_code(move(program))
|
||||
{
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue