summaryrefslogtreecommitdiff
path: root/src/binary-reader-objdump.cc
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2017-03-29 14:09:40 -0700
committerGitHub <noreply@github.com>2017-03-29 14:09:40 -0700
commitb8e6c1c82d91fb6d3da2bbf825babda097685c0e (patch)
treea9bdcf6741319056947ae73e4f5b02e09d76e65c /src/binary-reader-objdump.cc
parentaad6e98314bc4225dca7e12aa9795cb0ad87f21e (diff)
downloadwabt-b8e6c1c82d91fb6d3da2bbf825babda097685c0e.tar.gz
wabt-b8e6c1c82d91fb6d3da2bbf825babda097685c0e.tar.bz2
wabt-b8e6c1c82d91fb6d3da2bbf825babda097685c0e.zip
wasmdump: Fix output of local names (#372)
Previously we could nest the local names inside the function names, but in the new names sections the locals all come later on.
Diffstat (limited to 'src/binary-reader-objdump.cc')
-rw-r--r--src/binary-reader-objdump.cc17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/binary-reader-objdump.cc b/src/binary-reader-objdump.cc
index 47f05770..bb251fa2 100644
--- a/src/binary-reader-objdump.cc
+++ b/src/binary-reader-objdump.cc
@@ -598,15 +598,12 @@ static Result on_function_name(uint32_t index,
StringSlice name,
void* user_data) {
Context* ctx = static_cast<Context*>(user_data);
- print_details(ctx, " - func[%d] " PRIstringslice "\n", index,
- WABT_PRINTF_STRING_SLICE_ARG(name));
if (ctx->options->mode == ObjdumpMode::Prepass) {
- while (ctx->options->function_names.size() < index) {
- ctx->options->function_names.emplace_back();
- }
- if (ctx->options->function_names.size() == index) {
- ctx->options->function_names.push_back(string_slice_to_string(name));
- }
+ ctx->options->function_names.resize(index+1);
+ ctx->options->function_names[index] = string_slice_to_string(name);
+ } else {
+ print_details(ctx, " - func[%d] " PRIstringslice "\n", index,
+ WABT_PRINTF_STRING_SLICE_ARG(name));
}
return Result::Ok;
}
@@ -617,8 +614,8 @@ static Result on_local_name(uint32_t func_index,
void* user_data) {
Context* ctx = static_cast<Context*>(user_data);
if (name.length) {
- print_details(ctx, " - local[%d] " PRIstringslice "\n", local_index,
- WABT_PRINTF_STRING_SLICE_ARG(name));
+ print_details(ctx, " - func[%d] local[%d] " PRIstringslice "\n", func_index,
+ local_index, WABT_PRINTF_STRING_SLICE_ARG(name));
}
return Result::Ok;
}