1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:47:35 +00:00

LibJS: Capture UnrealizedSourceRanges in ExecutionContext, not ASTNodes

This loosens the connection to the AST interpreter and will allow us to
generate SourceRanges for the Bytecode interpreter in the future as well

Moves UnrealizedSourceRanges from TracebackFrame to the JS namespace for
this
This commit is contained in:
Hediadyoin1 2023-07-27 14:40:01 +02:00 committed by Andreas Kling
parent cd9bb985d4
commit 50bf303edd
11 changed files with 33 additions and 32 deletions

View file

@ -23,7 +23,7 @@ SourceRange const& TracebackFrame::source_range() const
static auto dummy_source_code = SourceCode::create(String {}, String {});
return SourceRange { dummy_source_code, {}, {} };
}
return unrealized->source_code->range_from_offsets(unrealized->start_offset, unrealized->end_offset);
return unrealized->realize();
}();
source_range_storage = move(source_range);
}
@ -85,20 +85,9 @@ void Error::populate_stack()
TracebackFrame frame {
.function_name = move(function_name),
.source_range_storage = TracebackFrame::UnrealizedSourceRange {},
.source_range_storage = context->source_range,
};
// We might not have an AST node associated with the execution context, e.g. in promise
// reaction jobs (which aren't called anywhere from the source code).
// They're not going to generate any _unhandled_ exceptions though, so a meaningless
// source range is fine.
if (context->current_node) {
auto* unrealized = frame.source_range_storage.get_pointer<TracebackFrame::UnrealizedSourceRange>();
unrealized->source_code = context->current_node->source_code();
unrealized->start_offset = context->current_node->start_offset();
unrealized->end_offset = context->current_node->end_offset();
}
m_traceback.append(move(frame));
}
}