diff options
author | Sam Clegg <sbc@chromium.org> | 2018-02-28 14:47:19 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-28 14:47:19 -0800 |
commit | c40f1b51714e2191f9dec1c3cfbaf9e3d536e561 (patch) | |
tree | 3a8dc6be8cddab4ca4c2e3a23d6d78fef431d8e1 /src/binary-reader.cc | |
parent | 3c356d1291b2896c544cef12e94eefad885ad4a9 (diff) | |
download | wabt-c40f1b51714e2191f9dec1c3cfbaf9e3d536e561.tar.gz wabt-c40f1b51714e2191f9dec1c3cfbaf9e3d536e561.tar.bz2 wabt-c40f1b51714e2191f9dec1c3cfbaf9e3d536e561.zip |
Use uint8 when reading import kind (#781)
This matches the spec (and the existing code which already exists
in this file for export kind).
Diffstat (limited to 'src/binary-reader.cc')
-rw-r--r-- | src/binary-reader.cc | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/binary-reader.cc b/src/binary-reader.cc index 3bd92c7c..4ab88fe6 100644 --- a/src/binary-reader.cc +++ b/src/binary-reader.cc @@ -1551,8 +1551,8 @@ Result BinaryReader::ReadImportSection(Offset section_size) { string_view field_name; CHECK_RESULT(ReadStr(&field_name, "import field name")); - uint32_t kind; - CHECK_RESULT(ReadU32Leb128(&kind, "import kind")); + uint8_t kind; + CHECK_RESULT(ReadU8(&kind, "import kind")); switch (static_cast<ExternalKind>(kind)) { case ExternalKind::Func: { Index sig_index; @@ -1691,14 +1691,14 @@ Result BinaryReader::ReadExportSection(Offset section_size) { string_view name; CHECK_RESULT(ReadStr(&name, "export item name")); - uint8_t external_kind = 0; - CHECK_RESULT(ReadU8(&external_kind, "export external kind")); - ERROR_UNLESS(is_valid_external_kind(external_kind), - "invalid export external kind: %d", external_kind); + uint8_t kind = 0; + CHECK_RESULT(ReadU8(&kind, "export kind")); + ERROR_UNLESS(is_valid_external_kind(kind), + "invalid export external kind: %d", kind); Index item_index; CHECK_RESULT(ReadIndex(&item_index, "export item index")); - switch (static_cast<ExternalKind>(external_kind)) { + switch (static_cast<ExternalKind>(kind)) { case ExternalKind::Func: ERROR_UNLESS(item_index < NumTotalFuncs(), "invalid export func index: %" PRIindex, item_index); @@ -1722,8 +1722,7 @@ Result BinaryReader::ReadExportSection(Offset section_size) { break; } - CALLBACK(OnExport, i, static_cast<ExternalKind>(external_kind), item_index, - name); + CALLBACK(OnExport, i, static_cast<ExternalKind>(kind), item_index, name); } CALLBACK0(EndExportSection); return Result::Ok; |