Start drafting out flags datatype generation (#11)

* Adds support for flags datatype

This commit adds support for `FlagsDatatype`. In WASI, flags are
represented as bitfields/bitflags, therefore, it is important
for the type to have bitwise operations implemented, and some
way of checking whether the current set of flags contains some
other set (i.e., they intersect). Thus, this commit automatically
derives `BitAnd`, etc. for the derived flags datatype. It also
automatically provides an `ALL_FLAGS` value which corresponds to
a bitwise-or of all flag values present and is provided for
convenience.

* Simplify read_from_guest
This commit is contained in:
Jakub Konka
2020-02-21 09:58:43 +01:00
committed by GitHub
parent 898af8e2fb
commit 3ef24a04fe
6 changed files with 261 additions and 4 deletions

View File

@@ -3,6 +3,8 @@ use thiserror::Error;
#[derive(Debug, Error, PartialEq, Eq)]
pub enum GuestError {
#[error("Invalid flag value {0}")]
InvalidFlagValue(&'static str),
#[error("Invalid enum value {0}")]
InvalidEnumValue(&'static str),
#[error("Pointer out of bounds: {0:?}")]