1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:07:36 +00:00

LibWeb: Use inline script tag source line as javascript line offset

This makes JS exception line numbers meaningful for inline script tags.
This commit is contained in:
Idan Horowitz 2022-03-13 23:17:35 +02:00 committed by Andreas Kling
parent 47d0d9fd65
commit c575710e5e
7 changed files with 12 additions and 7 deletions

View file

@ -13,10 +13,10 @@
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)
Result<NonnullRefPtr<Script>, Vector<Parser::Error>> Script::parse(StringView source_text, Realm& realm, StringView filename, HostDefined* host_defined, size_t line_number_offset)
{
// 1. Let body be ParseText(sourceText, Script).
auto parser = Parser(Lexer(source_text, filename));
auto parser = Parser(Lexer(source_text, filename, line_number_offset));
auto body = parser.parse_program();
// 2. If body is a List of errors, return body.

View file

@ -25,7 +25,7 @@ public:
};
~Script();
static Result<NonnullRefPtr<Script>, Vector<Parser::Error>> parse(StringView source_text, Realm&, StringView filename = {}, HostDefined* = nullptr);
static Result<NonnullRefPtr<Script>, Vector<Parser::Error>> parse(StringView source_text, Realm&, StringView filename = {}, HostDefined* = nullptr, size_t line_number_offset = 1);
Realm& realm() { return *m_realm.cell(); }
Program const& parse_node() const { return *m_parse_node; }