feat(interface-types) Introduce RecordType for InterfaceType and Type.

The `Type::Record` variant now is defined by `RecordType`. In
addition, `InterfaceType` has a new variant: `Record`, that is also
defined by `RecordType`. Encoders and decoders are updated to consider
`RecordType`, which removes code duplication and simplify code.
This commit is contained in:
Ivan Enderlin
2020-03-26 13:17:36 +01:00
parent b528e965c5
commit 41f9c231c0
6 changed files with 384 additions and 141 deletions

View File

@ -48,6 +48,16 @@ pub enum InterfaceType {
/// A 64-bits integer (as defiend in WebAssembly core).
I64,
/// A record.
Record(RecordType),
}
/// Representing a record type.
#[derive(PartialEq, Debug, Clone)]
pub struct RecordType {
/// Types representing the fields.
pub fields: Vec<InterfaceType>,
}
/// Represents the kind of type.
@ -81,10 +91,7 @@ pub enum Type {
/// ```wasm,ignore
/// (@interface type (record string i32))
/// ```
Record {
/// Types representing the fields.
fields: Vec<InterfaceType>,
},
Record(RecordType),
}
/// Represents an imported function.