Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(interface-types) Implement the record instructions #1331

Merged
merged 44 commits into from
Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
bbb4f1f
feat(interface-types) Introduce the record type.
Hywan Mar 24, 2020
734795c
test(interface-types) Test `Type::Record`.
Hywan Mar 26, 2020
3c02c50
chore(interface-types) Move the `instruction.rs` module in `instructi…
Hywan Mar 26, 2020
bd9226e
feat(interface-types) Introduce `RecordType` for `InterfaceType` and …
Hywan Mar 26, 2020
a99ae6b
feat(interface-types) Add the `Record` WIT value.
Hywan Mar 30, 2020
154dcba
feat(interface-types) Implement Serde deserializing for WIT records t…
Hywan Mar 30, 2020
c87c2ef
feat(interface-values) Improve the `TypeMismatch` error.
Hywan Mar 31, 2020
ee57b47
feat(interface-types) Improve the `Deserializer` API.
Hywan Mar 31, 2020
3655ef8
chore(interface-types) Reorganize the serde module.
Hywan Mar 31, 2020
0af1076
feat(interface-types) Encodes/decodes the `record.lift` instruction.
Hywan Mar 31, 2020
02b7e21
feat(interface-types) Implement the `record.lift` instruction.
Hywan Mar 31, 2020
1a17cbb
test(interface-types) Deserialize WIT record to Rust struct.
Hywan Mar 31, 2020
5ba6fda
chore(interface-types) Improve code readibility of `string` instructi…
Hywan Apr 2, 2020
3411ac7
feat(interface-types) Move `serde::InterfaceTypeIterator` into `value…
Hywan Apr 2, 2020
aab82c1
feat(interface-types) Implement `From<&Vec<InterfaceValue>>` for `Rec…
Hywan Apr 2, 2020
a1551b5
test(interface-types) Rename a test case.
Hywan Apr 2, 2020
b8ef82d
test(interface-types) Rename test cases.
Hywan Apr 2, 2020
11687c5
feat(interface-types) Encodes/decodes the `record.lower` instruction.
Hywan Apr 2, 2020
0023eea
feat(interface-types) Implement the `record.lower` instruction.
Hywan Apr 2, 2020
8f8c5f1
chore(interface-types) Improve code readabilit of the `record.lift` i…
Hywan Apr 2, 2020
bac56a6
Merge branch 'master' into feat-interface-types-record-instructions
Hywan Apr 2, 2020
f850753
fix(interface-types) Fix a `git-merge` issue.
Hywan Apr 2, 2020
7b18241
feat(interface-types) Make `serde` optional behind a feature flag.
Hywan Apr 2, 2020
8868d64
feat(interface-types) Rename `from_values` to `from_interface_values`.
Hywan Apr 2, 2020
f9832fe
feat(interface-types) Implement a serializer for WIT values.
Hywan Apr 2, 2020
d6f7e3f
doc(interface-types) Describe `to_interface_value`.
Hywan Apr 2, 2020
ee0596d
feat(interface-types) Restrict supported type in the `Deserializer`.
Hywan Apr 2, 2020
b0af014
doc(interface-types) Update an example.
Hywan Apr 2, 2020
e385bf6
feat(interface-types) Make `unwrap`s safe by introducing more errors.
Hywan Apr 2, 2020
010b10d
chore(cargo) Update `Cargo.lock`.
Hywan Apr 2, 2020
be66ac8
doc(interface-types) Improve `serde` module documentation.
Hywan Apr 2, 2020
2011fda
chore(interface-types) Split the `serde` module…
Hywan Apr 2, 2020
6cef1c2
doc(interface-types) Fix typos.
Hywan Apr 3, 2020
3159da5
feat(interface-types) Add the `Vec1` type to represent a non-empty ve…
Hywan Apr 3, 2020
d186142
doc(interface-types) Fix a typo.
Hywan Apr 3, 2020
e160feb
fix(interface-types) Use lazy evaluation in the deserializer.
Hywan Apr 3, 2020
398d791
fix(interface-types) Also apply another lazy evaluation in the deseri…
Hywan Apr 3, 2020
e4921bd
feat(interface-types) Use `Vec::last_mut` to simplify code.
Hywan Apr 3, 2020
5119b6a
feat(interface-types) Simplify `FlattenInterfaceValueIterator` with `…
Hywan Apr 3, 2020
4ad3d7f
doc(interface-types) Explain a part of an algorithm.
Hywan Apr 4, 2020
4faf827
feat(interface-types) Avoid clones by using owned items in an iterator.
Hywan Apr 6, 2020
c2b1b87
feat(interface-types) Use `VecDeque` to remove unsafe code.
Hywan Apr 6, 2020
27053d5
doc(interface-types) Rewrite `record_lift_` documentation.
Hywan Apr 6, 2020
9f10b7a
doc(interface-types) Update `from_interface_values`'s doc.
Hywan Apr 6, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions lib/interface-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ edition = "2018"
[dependencies]
nom = "5.1"
wast = "8.0"

# `serde` is useful only to simplify the users' life. It is not
# required by WIT itself, is is used to transform WIT values like
# `record`s to Rust sum types.
serde = { version = "1.0", features = ["derive"], optional = true }

[features]
default = ["serde"]
50 changes: 40 additions & 10 deletions lib/interface-types/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,50 @@ 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 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(RecordType),
}

/// Represents an imported function.
Expand Down
Loading