Skip to content

Commit

Permalink
Merge #1232
Browse files Browse the repository at this point in the history
1232: feat(interface-types) Implement the WAT decoder r=Hywan a=Hywan

WIP

The goal is the define a minimal WAT to AST decoder for WIT, so that it's muuuuuuch easier to develop and debug.

Co-authored-by: Ivan Enderlin <ivan.enderlin@hoa-project.net>
  • Loading branch information
bors[bot] and Hywan authored Feb 21, 2020
2 parents 5455616 + 4b0a1ef commit a96c436
Show file tree
Hide file tree
Showing 9 changed files with 933 additions and 25 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## **[Unreleased]**

- [#1232](https://github.com/wasmerio/wasmer/pull/1232) `wasmer-interface-types` has a WAT decoder.

## 0.14.0 - 2020-02-20

- [#1233](https://github.com/wasmerio/wasmer/pull/1233) Improved Wasmer C API release artifacts.
Expand Down
16 changes: 16 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions lib/interface-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ edition = "2018"

[dependencies]
nom = "5.1"
wast = "8.0"
4 changes: 2 additions & 2 deletions lib/interface-types/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::interpreter::Instruction;
use std::str;

/// Represents the types supported by WIT.
#[derive(PartialEq, Clone, Debug)]
#[derive(PartialEq, Debug)]
pub enum InterfaceType {
/// An integer.
Int,
Expand Down Expand Up @@ -190,7 +190,7 @@ pub struct Forward<'input> {

/// Represents a set of interfaces, i.e. it entirely describes a WIT
/// definition.
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Default, Debug)]
pub struct Interfaces<'input> {
/// All the exported functions.
pub exports: Vec<Export<'input>>,
Expand Down
5 changes: 3 additions & 2 deletions lib/interface-types/src/decoders/binary.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Parse the WIT binary representation into an AST.
//! Parse the WIT binary representation into an [AST](crate::ast).

use crate::{ast::*, interpreter::Instruction};
use nom::{
Expand Down Expand Up @@ -432,7 +432,8 @@ fn interfaces<'input, E: ParseError<&'input [u8]>>(
}

/// Parse a sequence of bytes, expecting it to be a valid WIT binary
/// representation, into an `ast::Interfaces`.
/// representation, into an [`Interfaces`](crate::ast::Interfaces)
/// structure.
///
/// # Example
///
Expand Down
4 changes: 3 additions & 1 deletion lib/interface-types/src/decoders/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//! Reads the AST from a particular data representation; for instance,
//! `decoders::binary` reads the AST from a binary.
//! [`decoders::binary`](binary) reads the [AST](crate::ast)
//! from a binary.

pub mod binary;
pub mod wat;
Loading

0 comments on commit a96c436

Please sign in to comment.