[gardening] Disassembler print missing position information

When trying to disassemble, we should have position information.
However, when it's missing it would be better to show this instead of
crashing. The CFE validator should validate that position information
is included everywhere.

TEST=tests/language/unsorted/disassemble_test.dart

Bug: https://github.com/dart-lang/sdk/issues/53348
Change-Id: I94142ef4c875d2738141ee8fd0def309469ca92d
Cq-Include-Trybots: luci.dart.try:vm-linux-debug-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322663
Reviewed-by: Martin Kustermann <kustermann@google.com>
This commit is contained in:
Daco Harkes 2023-08-25 15:25:17 +00:00
parent d00706a8eb
commit 3094d06f81

View file

@ -10971,11 +10971,19 @@ static void FunctionPrintNameHelper(const Function& fun,
}
if (params.disambiguate_names &&
fun.name() == Symbols::AnonymousClosure().ptr()) {
printer->Printf("<anonymous closure @%" Pd ">", fun.token_pos().Pos());
if (fun.token_pos().IsReal()) {
printer->Printf("<anonymous closure @%" Pd ">", fun.token_pos().Pos());
} else {
printer->Printf("<anonymous closure @no position>");
}
} else {
printer->AddString(fun.NameCString(params.name_visibility));
if (params.disambiguate_names) {
printer->Printf("@<%" Pd ">", fun.token_pos().Pos());
if (fun.token_pos().IsReal()) {
printer->Printf("@<%" Pd ">", fun.token_pos().Pos());
} else {
printer->Printf("@<no position>");
}
}
}
return;