diff options
author | Ben Smith <binji@chromium.org> | 2020-03-23 18:54:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-23 18:54:14 -0700 |
commit | 7898e57f28c89565b99e894e764e058346e28fbe (patch) | |
tree | 91d72a1bcef76ecb83f3f550710bee8f9152b8ce /src/binary-reader-logging.cc | |
parent | dc396c9d57d59c33c99f5f6c6c1b8f67de086dc8 (diff) | |
download | wabt-7898e57f28c89565b99e894e764e058346e28fbe.tar.gz wabt-7898e57f28c89565b99e894e764e058346e28fbe.tar.bz2 wabt-7898e57f28c89565b99e894e764e058346e28fbe.zip |
Parse ArrayTypes (#1364)
The following formats are supported:
* (type (array i32))
* (type (array (field i32)))
* (type (array (field (mut i32))))
This PR adds support for reading/writing binary and text, but no
interpreter support yet.
Diffstat (limited to 'src/binary-reader-logging.cc')
-rw-r--r-- | src/binary-reader-logging.cc | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/binary-reader-logging.cc b/src/binary-reader-logging.cc index 8f1cbb1c..801b96b0 100644 --- a/src/binary-reader-logging.cc +++ b/src/binary-reader-logging.cc @@ -99,6 +99,16 @@ void BinaryReaderLogging::LogTypes(TypeVector& types) { LogTypes(types.size(), types.data()); } +void BinaryReaderLogging::LogField(TypeMut field) { + if (field.mutable_) { + LOGF_NOINDENT("(mut "); + } + LogType(field.type); + if (field.mutable_) { + LOGF_NOINDENT(")"); + } +} + bool BinaryReaderLogging::OnError(const Error& error) { return reader_->OnError(error); } @@ -149,13 +159,7 @@ Result BinaryReaderLogging::OnStructType(Index index, LOGF("OnStructType(index: %" PRIindex ", fields: ", index); LOGF_NOINDENT("["); for (Index i = 0; i < field_count; ++i) { - if (fields[i].mutable_) { - LOGF_NOINDENT("(mut "); - } - LogType(fields[i].type); - if (fields[i].mutable_) { - LOGF_NOINDENT(")"); - } + LogField(fields[i]); if (i != field_count - 1) { LOGF_NOINDENT(", "); } @@ -164,6 +168,13 @@ Result BinaryReaderLogging::OnStructType(Index index, return reader_->OnStructType(index, field_count, fields); } +Result BinaryReaderLogging::OnArrayType(Index index, TypeMut field) { + LOGF("OnArrayType(index: %" PRIindex ", field: ", index); + LogField(field); + LOGF_NOINDENT(")\n"); + return reader_->OnArrayType(index, field); +} + Result BinaryReaderLogging::OnImport(Index index, ExternalKind kind, string_view module_name, |