mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibJS: Don't generate bytecode after we've encountered a parser error
This commit is contained in:
parent
319a60043b
commit
3a8f913eee
Notes:
sideshowbarker
2024-07-18 12:29:09 +09:00
Author: https://github.com/gunnarbeutner Commit: https://github.com/SerenityOS/serenity/commit/3a8f913eee3 Pull-request: https://github.com/SerenityOS/serenity/pull/7973
1 changed files with 20 additions and 20 deletions
|
@ -512,25 +512,6 @@ static bool parse_and_run(JS::Interpreter& interpreter, const StringView& source
|
||||||
if (s_dump_ast)
|
if (s_dump_ast)
|
||||||
program->dump(0);
|
program->dump(0);
|
||||||
|
|
||||||
if (s_dump_bytecode || s_run_bytecode) {
|
|
||||||
auto unit = JS::Bytecode::Generator::generate(*program);
|
|
||||||
if (s_dump_bytecode) {
|
|
||||||
for (auto& block : unit.basic_blocks)
|
|
||||||
block.dump(unit);
|
|
||||||
if (!unit.string_table->is_empty()) {
|
|
||||||
outln();
|
|
||||||
unit.string_table->dump();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s_run_bytecode) {
|
|
||||||
JS::Bytecode::Interpreter bytecode_interpreter(interpreter.global_object());
|
|
||||||
bytecode_interpreter.run(unit);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parser.has_errors()) {
|
if (parser.has_errors()) {
|
||||||
auto error = parser.errors()[0];
|
auto error = parser.errors()[0];
|
||||||
auto hint = error.source_location_hint(source);
|
auto hint = error.source_location_hint(source);
|
||||||
|
@ -538,7 +519,26 @@ static bool parse_and_run(JS::Interpreter& interpreter, const StringView& source
|
||||||
outln("{}", hint);
|
outln("{}", hint);
|
||||||
vm->throw_exception<JS::SyntaxError>(interpreter.global_object(), error.to_string());
|
vm->throw_exception<JS::SyntaxError>(interpreter.global_object(), error.to_string());
|
||||||
} else {
|
} else {
|
||||||
interpreter.run(interpreter.global_object(), *program);
|
if (s_dump_bytecode || s_run_bytecode) {
|
||||||
|
auto unit = JS::Bytecode::Generator::generate(*program);
|
||||||
|
if (s_dump_bytecode) {
|
||||||
|
for (auto& block : unit.basic_blocks)
|
||||||
|
block.dump(unit);
|
||||||
|
if (!unit.string_table->is_empty()) {
|
||||||
|
outln();
|
||||||
|
unit.string_table->dump();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s_run_bytecode) {
|
||||||
|
JS::Bytecode::Interpreter bytecode_interpreter(interpreter.global_object());
|
||||||
|
bytecode_interpreter.run(unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
interpreter.run(interpreter.global_object(), *program);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto handle_exception = [&] {
|
auto handle_exception = [&] {
|
||||||
|
|
Loading…
Reference in a new issue