mirror of
https://github.com/fluencelabs/interface-types
synced 2025-06-26 13:11:41 +00:00
feat(interface-types) Introduce the record type.
This patch updates the `Type` type to be an enum with 2 variants: `Function` and `Record`, resp. to represent: 1. `(@interface type (func (param i32 i32) (result string)))` 2. `(@interface type (record string i32))` This patch updates the binary encoder and decoder, along with the WAT encoder and decoder.
This commit is contained in:
43
src/ast.rs
43
src/ast.rs
@ -50,18 +50,41 @@ pub enum InterfaceType {
|
||||
I64,
|
||||
}
|
||||
|
||||
/// Represents a type signature.
|
||||
///
|
||||
/// ```wasm,ignore
|
||||
/// (@interface type (param i32 i32) (result string))
|
||||
/// ```
|
||||
/// Represents the kind of type.
|
||||
#[derive(PartialEq, Debug)]
|
||||
pub struct Type {
|
||||
/// Types for the parameters (`(param …)`).
|
||||
pub inputs: Vec<InterfaceType>,
|
||||
pub enum TypeKind {
|
||||
/// A function type.
|
||||
Function,
|
||||
|
||||
/// Types for the results (`(result …)`).
|
||||
pub outputs: Vec<InterfaceType>,
|
||||
/// A record type.
|
||||
Record,
|
||||
}
|
||||
|
||||
/// Represents a type.
|
||||
#[derive(PartialEq, Debug)]
|
||||
pub enum Type {
|
||||
/// A function type, like:
|
||||
///
|
||||
/// ```wasm,ignore
|
||||
/// (@interface type (func (param i32 i32) (result string)))
|
||||
/// ```
|
||||
Function {
|
||||
/// Types for the parameters (`(param …)`).
|
||||
inputs: Vec<InterfaceType>,
|
||||
|
||||
/// Types for the results (`(result …)`).
|
||||
outputs: Vec<InterfaceType>,
|
||||
},
|
||||
|
||||
/// A record type, like:
|
||||
///
|
||||
/// ```wasm,ignore
|
||||
/// (@interface type (record string i32))
|
||||
/// ```
|
||||
Record {
|
||||
/// Types representing the fields.
|
||||
fields: Vec<InterfaceType>,
|
||||
},
|
||||
}
|
||||
|
||||
/// Represents an imported function.
|
||||
|
Reference in New Issue
Block a user