Skip to content

Commit 7257522

Browse files
committed
fixup! Updates for wasmparser apis
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
1 parent 66aa8a8 commit 7257522

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

src/hyperlight_component_util/src/etypes.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,13 @@ pub struct Param<'a> {
136136
pub ty: Value<'a>,
137137
}
138138

139+
pub type Result<'a> = Option<Value<'a>>;
140+
139141
/// functype_e in the specification
140142
#[derive(Debug, Clone)]
141143
pub struct Func<'a> {
142144
pub params: Vec<Param<'a>>,
143-
pub result: Option<Value<'a>>,
145+
pub result: Result<'a>,
144146
}
145147

146148
/// In the spec, this does not exist, but a validation rule ensures an

src/hyperlight_component_util/src/hl.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use proc_macro2::{Ident, TokenStream};
1919
use quote::{format_ident, quote};
2020

2121
use crate::emit::{State, kebab_to_cons, kebab_to_var};
22-
use crate::etypes::{Defined, Handleable, TypeBound, Tyvar, Value};
22+
use crate::etypes::{self, Defined, Handleable, TypeBound, Tyvar, Value};
2323
use crate::rtypes;
2424

2525
/// Construct a string that can be used "on the wire" to identify a
@@ -653,7 +653,7 @@ pub fn emit_hl_unmarshal_param(s: &mut State, id: Ident, pt: &Value) -> TokenStr
653653
///
654654
/// Precondition: the result type must only be a named result if there
655655
/// are no names in it (i.e. a unit type)
656-
pub fn emit_hl_unmarshal_result(s: &mut State, id: Ident, rt: &Option<Value<'_>>) -> TokenStream {
656+
pub fn emit_hl_unmarshal_result(s: &mut State, id: Ident, rt: &etypes::Result<'_>) -> TokenStream {
657657
match rt {
658658
Some(vt) => {
659659
let toks = emit_hl_unmarshal_value(s, id, vt);
@@ -677,7 +677,7 @@ pub fn emit_hl_marshal_param(s: &mut State, id: Ident, pt: &Value) -> TokenStrea
677677
///
678678
/// Precondition: the result type must only be a named result if there
679679
/// are no names in it (a unit type)
680-
pub fn emit_hl_marshal_result(s: &mut State, id: Ident, rt: &Option<Value<'_>>) -> TokenStream {
680+
pub fn emit_hl_marshal_result(s: &mut State, id: Ident, rt: &etypes::Result) -> TokenStream {
681681
match rt {
682682
None => quote! { ::alloc::vec::Vec::new() },
683683
Some(vt) => {

src/hyperlight_component_util/src/rtypes.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ use crate::emit::{
2929
split_wit_name,
3030
};
3131
use crate::etypes::{
32-
Component, Defined, ExternDecl, ExternDesc, Func, Handleable, ImportExport, Instance, Param,
33-
TypeBound, Tyvar, Value,
32+
self, Component, Defined, ExternDecl, ExternDesc, Func, Handleable, ImportExport, Instance,
33+
Param, TypeBound, Tyvar, Value,
3434
};
3535

3636
/// When referring to an instance or resource trait, emit a token
@@ -521,7 +521,7 @@ pub fn emit_func_param(s: &mut State, p: &Param) -> TokenStream {
521521
///
522522
/// Precondition: the result type must only be a named result if there
523523
/// are no names in it (i.e. a unit type)
524-
pub fn emit_func_result(s: &mut State, r: &Option<Value<'_>>) -> TokenStream {
524+
pub fn emit_func_result(s: &mut State, r: &etypes::Result<'_>) -> TokenStream {
525525
match r {
526526
Some(vt) => emit_value(s, vt),
527527
None => quote! { () },

src/hyperlight_component_util/src/substitute.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ where
134134
pts.iter().map(|pt| self.param(pt)).collect()
135135
}
136136

137-
fn result(&self, rt: &Option<Value<'a>>) -> Result<Option<Value<'a>>, Self::Error> {
137+
fn result(
138+
&self,
139+
rt: &crate::etypes::Result<'a>,
140+
) -> Result<crate::etypes::Result<'a>, Self::Error> {
138141
Ok(match rt {
139142
Some(vt) => Some(self.value(vt)?),
140143
None => None,

0 commit comments

Comments
 (0)