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

Refactor the wast component resolver #614

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion crates/wast/src/component/component.rs
Expand Up @@ -195,6 +195,12 @@ impl<'a> From<TypeField<'a>> for ComponentField<'a> {
}
}

impl<'a> From<Alias<'a>> for ComponentField<'a> {
fn from(field: Alias<'a>) -> ComponentField<'a> {
ComponentField::Alias(field)
}
}

/// A function to call at instantiation time.
#[derive(Debug)]
pub struct Start<'a> {
Expand All @@ -211,7 +217,7 @@ impl<'a> Parse<'a> for Start<'a> {
parser.parse::<kw::start>()?;
let func = parser.parse::<IndexOrRef<_>>()?.0;
let mut args = Vec::new();
while !parser.peek2::<kw::result>() {
while !parser.is_empty() && !parser.peek2::<kw::result>() {
args.push(parser.parse()?);
}
let result = if !parser.is_empty() {
Expand Down
12 changes: 12 additions & 0 deletions crates/wast/src/component/deftype.rs
Expand Up @@ -249,6 +249,12 @@ impl<'a> From<TypeField<'a>> for ComponentTypeField<'a> {
}
}

impl<'a> From<Alias<'a>> for ComponentTypeField<'a> {
fn from(field: Alias<'a>) -> ComponentTypeField<'a> {
ComponentTypeField::Alias(field)
}
}

/// A type for a nested instance
#[derive(Debug)]
pub struct InstanceType<'a> {
Expand Down Expand Up @@ -302,6 +308,12 @@ impl<'a> From<TypeField<'a>> for InstanceTypeField<'a> {
}
}

impl<'a> From<Alias<'a>> for InstanceTypeField<'a> {
fn from(field: Alias<'a>) -> InstanceTypeField<'a> {
InstanceTypeField::Alias(field)
}
}

/// A value type.
#[derive(Debug, Clone)]
pub struct ValueType<'a> {
Expand Down