From 6d39c5876efbcae17df6c6d45d371b9194fb0b28 Mon Sep 17 00:00:00 2001 From: Oliver Horn Date: Mon, 7 Oct 2019 20:29:52 +0200 Subject: wasm-objdump: Fix type signature for multi-value result types (#1179) Previously only the first result type was printed, even for multiple results. This change prints multiple result types in parenthesized form whereas single result types are printed as before. The `func-result-multi.txt` test case is modified to cover the Type section as well. --- src/binary-reader-objdump.cc | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/binary-reader-objdump.cc') diff --git a/src/binary-reader-objdump.cc b/src/binary-reader-objdump.cc index 4b52f86e..054ac21f 100644 --- a/src/binary-reader-objdump.cc +++ b/src/binary-reader-objdump.cc @@ -1029,10 +1029,23 @@ Result BinaryReaderObjdump::OnType(Index index, printf("%s", GetTypeName(param_types[i])); } printf(") -> "); - if (result_count) { - printf("%s", GetTypeName(result_types[0])); - } else { - printf("nil"); + switch (result_count) { + case 0: + printf("nil"); + break; + case 1: + printf("%s", GetTypeName(result_types[0])); + break; + default: + printf("("); + for (Index i = 0; i < result_count; i++) { + if (i != 0) { + printf(", "); + } + printf("%s", GetTypeName(result_types[i])); + } + printf(")"); + break; } printf("\n"); return Result::Ok; -- cgit v1.2.3