diff --git a/Cargo.lock b/Cargo.lock index c871242..2908fee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -161,7 +161,7 @@ checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" [[package]] name = "wasmer-interface-types-fl" -version = "0.17.15" +version = "0.17.16" dependencies = [ "log", "nom", diff --git a/Cargo.toml b/Cargo.toml index d1334b9..7f2accb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasmer-interface-types-fl" -version = "0.17.15" +version = "0.17.16" description = "WebAssembly Interface Types library for Wasmer" license = "MIT" authors = ["The Wasmer Engineering Team "] diff --git a/src/decoders/wat.rs b/src/decoders/wat.rs index abe8dcf..ac0c1ca 100644 --- a/src/decoders/wat.rs +++ b/src/decoders/wat.rs @@ -32,7 +32,7 @@ mod keyword { custom_keyword!(u32); custom_keyword!(u64); custom_keyword!(string); - custom_keyword!(Array); + custom_keyword!(array); // Instructions. custom_keyword!(argument_get = "arg.get"); @@ -86,7 +86,6 @@ mod keyword { impl Parse<'_> for InterfaceType { fn parse(parser: Parser<'_>) -> Result { let mut lookahead = parser.lookahead1(); - if lookahead.peek::() { parser.parse::()?; @@ -131,10 +130,12 @@ impl Parse<'_> for InterfaceType { parser.parse::()?; Ok(InterfaceType::String) - } else if lookahead.peek::() { - parser.parse::()?; + } else if lookahead.peek::() { + parser.parse::()?; - Ok(InterfaceType::Array(Box::new(parser.parse()?))) + let array_type = parser.parens(|p| p.parse())?; + + Ok(InterfaceType::Array(Box::new(array_type))) } else if lookahead.peek::() { parser.parse::()?; @@ -148,6 +149,8 @@ impl Parse<'_> for InterfaceType { Ok(InterfaceType::I64) } else if lookahead.peek::() { + parser.parse::()?; + Ok(InterfaceType::Record(parser.parse()?)) } else { Err(lookahead.error()) diff --git a/src/encoders/wat.rs b/src/encoders/wat.rs index 91ac722..5ec7f79 100644 --- a/src/encoders/wat.rs +++ b/src/encoders/wat.rs @@ -73,7 +73,7 @@ impl ToString for &InterfaceType { InterfaceType::F32 => "f32".to_string(), InterfaceType::F64 => "f64".to_string(), InterfaceType::String => "string".to_string(), - InterfaceType::Array(ty) => format!("Array<{:?}>", ty), + InterfaceType::Array(ty) => format!("array ({})", ty.as_ref().to_string()), InterfaceType::Anyref => "anyref".to_string(), InterfaceType::I32 => "i32".to_string(), InterfaceType::I64 => "i64".to_string(), @@ -85,7 +85,7 @@ impl ToString for &InterfaceType { impl ToString for &RecordType { fn to_string(&self) -> String { format!( - "record ${} {{\n{fields}}}", + "record ${} (\n{fields})", self.name, fields = self .fields @@ -145,10 +145,10 @@ impl ToString for &Instruction { Instruction::StringLowerMemory => "string.lower_memory".into(), Instruction::StringSize => "string.size".into(), Instruction::ArrayLiftMemory { value_type } => { - format!("array.lift_memory {:?}", value_type) + format!("array.lift_memory {}", value_type.to_string()) } Instruction::ArrayLowerMemory { value_type } => { - format!("array.lower_memory {:?}", value_type) + format!("array.lower_memory {}", value_type.to_string()) } /* Instruction::ArraySize => "byte_array.size".into(),