From 07d6d5c359b375b311b3d8ee9cec621725df8139 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 20 Apr 2022 07:54:23 -0700 Subject: [PATCH 1/2] Rename f32/f64 to float32/float64 This commit renames the previously-known `f32` and `f64` interface types to `float32` and `float64` to match the upstream specification. --- crates/gen-c/src/lib.rs | 16 +++++------ crates/gen-js/src/lib.rs | 14 +++++----- crates/gen-markdown/src/lib.rs | 4 +-- crates/gen-rust-wasm/src/lib.rs | 8 +++--- crates/gen-rust/src/lib.rs | 4 +-- crates/gen-spidermonkey/src/lib.rs | 8 +++--- crates/gen-wasmtime-py/src/lib.rs | 14 +++++----- crates/gen-wasmtime/src/lib.rs | 8 +++--- crates/parser/src/abi.rs | 28 +++++++++---------- crates/parser/src/ast.rs | 8 +++--- crates/parser/src/ast/lex.rs | 12 ++++---- crates/parser/src/ast/resolve.rs | 4 +-- crates/parser/src/lib.rs | 8 +++--- crates/parser/src/sizealign.rs | 8 +++--- crates/parser/tests/all.rs | 4 +-- crates/parser/tests/ui/functions.wit | 4 +-- crates/parser/tests/ui/functions.wit.result | 6 ++-- crates/parser/tests/ui/import-me.wit | 2 +- crates/parser/tests/ui/import-me.wit.result | 2 +- crates/parser/tests/ui/imports.wit.result | 2 +- crates/parser/tests/ui/imports2.wit.result | 2 +- crates/parser/tests/ui/types.wit | 4 +-- crates/parser/tests/ui/types.wit.result | 4 +-- crates/test-helpers/src/lib.rs | 4 +-- .../modules/crates/lists-main/src/main.rs | 8 +++--- .../modules/crates/lists/lists.wit | 12 ++++---- .../modules/crates/lists/src/lib.rs | 8 +++--- .../modules/crates/types/types.wit | 2 +- .../modules/crates/variants/variants.wit | 18 ++++++------ crates/wasmlink/tests/flags.baseline | 2 +- .../wasmlink/tests/incorrect-export.baseline | 2 +- crates/wasmlink/tests/incorrect-free.baseline | 2 +- .../wasmlink/tests/incorrect-realloc.baseline | 2 +- crates/wasmlink/tests/lists.baseline | 26 ++++++++--------- crates/wasmlink/tests/lists.wat | 8 +++--- crates/wasmlink/tests/lists.wit | 12 ++++---- crates/wasmlink/tests/missing-export.baseline | 2 +- crates/wasmlink/tests/missing-free.baseline | 2 +- crates/wasmlink/tests/missing-memory.baseline | 2 +- .../wasmlink/tests/missing-realloc.baseline | 2 +- crates/wasmlink/tests/not-adapted.baseline | 10 +++---- crates/wasmlink/tests/records.baseline | 2 +- .../tests/resource-incorrect-drop.baseline | 2 +- .../tests/resources-missing-drop.baseline | 2 +- crates/wasmlink/tests/resources.baseline | 2 +- crates/wasmlink/tests/variants.baseline | 2 +- crates/wasmlink/tests/variants.wit | 18 ++++++------ crates/wit-component/src/decoding.rs | 4 +-- crates/wit-component/src/encoding.rs | 4 +-- crates/wit-component/src/printing.rs | 8 +++--- .../tests/components/imports/import-foo.wit | 2 +- .../tests/interfaces/floats/floats.wat | 8 +++--- .../tests/interfaces/floats/floats.wit | 8 +++--- .../tests/interfaces/lists/lists.wat | 8 +++--- .../tests/interfaces/lists/lists.wit | 10 +++---- .../tests/interfaces/variants/variants.wit | 18 ++++++------ tests/codegen/floats.wit | 8 +++--- tests/codegen/lists.wit | 12 ++++---- tests/codegen/variants.wit | 18 ++++++------ tests/runtime/flavorful/exports.wit | 2 +- tests/runtime/flavorful/imports.wit | 2 +- tests/runtime/lists/imports.wit | 4 +-- tests/runtime/lists/wasm.c | 22 +++++++-------- tests/runtime/numbers/exports.wit | 4 +-- tests/runtime/numbers/host.py | 22 +++++++-------- tests/runtime/numbers/host.rs | 20 ++++++------- tests/runtime/numbers/host.ts | 20 ++++++------- tests/runtime/numbers/imports.wit | 4 +-- tests/runtime/numbers/wasm.c | 20 ++++++------- tests/runtime/numbers/wasm.rs | 20 ++++++------- tests/runtime/variants/exports.wit | 18 ++++++------ tests/runtime/variants/imports.wit | 18 ++++++------ tests/runtime/variants/wasm.c | 10 +++---- 73 files changed, 310 insertions(+), 310 deletions(-) diff --git a/crates/gen-c/src/lib.rs b/crates/gen-c/src/lib.rs index a1cad2b4d..79474e7c4 100644 --- a/crates/gen-c/src/lib.rs +++ b/crates/gen-c/src/lib.rs @@ -223,8 +223,8 @@ impl C { Type::S32 => self.src.h("int32_t"), Type::U64 => self.src.h("uint64_t"), Type::S64 => self.src.h("int64_t"), - Type::F32 => self.src.h("float"), - Type::F64 => self.src.h("double"), + Type::Float32 => self.src.h("float"), + Type::Float64 => self.src.h("double"), Type::Handle(id) => { self.print_namespace(iface); self.src.h(&iface.resources[*id].name.to_snake_case()); @@ -278,8 +278,8 @@ impl C { Type::S32 => self.src.h("s32"), Type::U64 => self.src.h("u64"), Type::S64 => self.src.h("s64"), - Type::F32 => self.src.h("f32"), - Type::F64 => self.src.h("f64"), + Type::Float32 => self.src.h("float32"), + Type::Float64 => self.src.h("float64"), Type::Handle(id) => self.src.h(&iface.resources[*id].name.to_snake_case()), Type::Id(id) => { let ty = &iface.types[*id]; @@ -1308,10 +1308,10 @@ impl Bindgen for FunctionBindgen<'_> { // f32/f64 have the same representation in the import type and in C, // so no conversions necessary. - Instruction::F32FromIf32 - | Instruction::F64FromIf64 - | Instruction::If32FromF32 - | Instruction::If64FromF64 => { + Instruction::F32FromFloat32 + | Instruction::F64FromFloat64 + | Instruction::Float32FromF32 + | Instruction::Float64FromF64 => { results.push(operands[0].clone()); } diff --git a/crates/gen-js/src/lib.rs b/crates/gen-js/src/lib.rs index 1cd881045..b3809957c 100644 --- a/crates/gen-js/src/lib.rs +++ b/crates/gen-js/src/lib.rs @@ -131,8 +131,8 @@ impl Js { Type::S32 => Some("Int32Array"), Type::U64 => Some("BigUint64Array"), Type::S64 => Some("BigInt64Array"), - Type::F32 => Some("Float32Array"), - Type::F64 => Some("Float64Array"), + Type::Float32 => Some("Float32Array"), + Type::Float64 => Some("Float64Array"), Type::Char => None, Type::Handle(_) => None, Type::Id(id) => match &iface.types[*id].kind { @@ -150,8 +150,8 @@ impl Js { | Type::S16 | Type::U32 | Type::S32 - | Type::F32 - | Type::F64 => self.src.ts("number"), + | Type::Float32 + | Type::Float64 => self.src.ts("number"), Type::U64 | Type::S64 => self.src.ts("bigint"), Type::Char => self.src.ts("string"), Type::Handle(id) => self.src.ts(&iface.resources[*id].name.to_camel_case()), @@ -1254,20 +1254,20 @@ impl Bindgen for FunctionBindgen<'_> { // The native representation in JS of f32 and f64 is just a number, // so there's nothing to do here. Everything wasm gives us is // representable in JS. - Instruction::If32FromF32 | Instruction::If64FromF64 => { + Instruction::Float32FromF32 | Instruction::Float64FromF64 => { results.push(operands.pop().unwrap()) } // For f32 coming from the host we need to validate that the value // is indeed a number and that the 32-bit value matches the // original value. - Instruction::F32FromIf32 => { + Instruction::F32FromFloat32 => { let validate = self.gen.intrinsic(Intrinsic::ValidateF32); results.push(format!("{}({})", validate, operands[0])); } // Similar to f32, but no range checks, just checks it's a number - Instruction::F64FromIf64 => { + Instruction::F64FromFloat64 => { let validate = self.gen.intrinsic(Intrinsic::ValidateF64); results.push(format!("{}({})", validate, operands[0])); } diff --git a/crates/gen-markdown/src/lib.rs b/crates/gen-markdown/src/lib.rs index 15d4ca5d7..cbb7343c3 100644 --- a/crates/gen-markdown/src/lib.rs +++ b/crates/gen-markdown/src/lib.rs @@ -43,8 +43,8 @@ impl Markdown { Type::S32 => self.src.push_str("`s32`"), Type::U64 => self.src.push_str("`u64`"), Type::S64 => self.src.push_str("`s64`"), - Type::F32 => self.src.push_str("`f32`"), - Type::F64 => self.src.push_str("`f64`"), + Type::Float32 => self.src.push_str("`float32`"), + Type::Float64 => self.src.push_str("`float64`"), Type::Char => self.src.push_str("`char`"), Type::Handle(id) => { self.src.push_str("handle<"); diff --git a/crates/gen-rust-wasm/src/lib.rs b/crates/gen-rust-wasm/src/lib.rs index faab60a17..15d655656 100644 --- a/crates/gen-rust-wasm/src/lib.rs +++ b/crates/gen-rust-wasm/src/lib.rs @@ -865,16 +865,16 @@ impl Bindgen for FunctionBindgen<'_> { results.push(format!("wit_bindgen_rust::rt::as_i32({})", s)); } - Instruction::F32FromIf32 => { + Instruction::F32FromFloat32 => { let s = operands.pop().unwrap(); results.push(format!("wit_bindgen_rust::rt::as_f32({})", s)); } - Instruction::F64FromIf64 => { + Instruction::F64FromFloat64 => { let s = operands.pop().unwrap(); results.push(format!("wit_bindgen_rust::rt::as_f64({})", s)); } - Instruction::If32FromF32 - | Instruction::If64FromF64 + Instruction::Float32FromF32 + | Instruction::Float64FromF64 | Instruction::S32FromI32 | Instruction::S64FromI64 => { results.push(operands.pop().unwrap()); diff --git a/crates/gen-rust/src/lib.rs b/crates/gen-rust/src/lib.rs index 95d31055b..034a1424e 100644 --- a/crates/gen-rust/src/lib.rs +++ b/crates/gen-rust/src/lib.rs @@ -206,8 +206,8 @@ pub trait RustGenerator { Type::S16 => self.push_str("i16"), Type::S32 => self.push_str("i32"), Type::S64 => self.push_str("i64"), - Type::F32 => self.push_str("f32"), - Type::F64 => self.push_str("f64"), + Type::Float32 => self.push_str("f32"), + Type::Float64 => self.push_str("f64"), Type::Char => self.push_str("char"), } } diff --git a/crates/gen-spidermonkey/src/lib.rs b/crates/gen-spidermonkey/src/lib.rs index 53d91fbf5..ccf3cf97d 100644 --- a/crates/gen-spidermonkey/src/lib.rs +++ b/crates/gen-spidermonkey/src/lib.rs @@ -1475,8 +1475,8 @@ impl abi::Bindgen for Bindgen<'_, '_> { abi::Instruction::I32FromS16 => todo!(), abi::Instruction::I32FromU8 => todo!(), abi::Instruction::I32FromS8 => todo!(), - abi::Instruction::F32FromIf32 => todo!(), - abi::Instruction::F64FromIf64 => todo!(), + abi::Instruction::F32FromFloat32 => todo!(), + abi::Instruction::F64FromFloat64 => todo!(), abi::Instruction::S8FromI32 => todo!(), abi::Instruction::U8FromI32 => todo!(), abi::Instruction::S16FromI32 => todo!(), @@ -1501,8 +1501,8 @@ impl abi::Bindgen for Bindgen<'_, '_> { abi::Instruction::S64FromI64 => todo!(), abi::Instruction::U64FromI64 => todo!(), abi::Instruction::CharFromI32 => todo!(), - abi::Instruction::If32FromF32 => todo!(), - abi::Instruction::If64FromF64 => todo!(), + abi::Instruction::Float32FromF32 => todo!(), + abi::Instruction::Float64FromF64 => todo!(), abi::Instruction::I32FromBorrowedHandle { ty: _ } => todo!(), abi::Instruction::I32FromOwnedHandle { ty: _ } => todo!(), abi::Instruction::HandleOwnedFromI32 { ty: _ } => todo!(), diff --git a/crates/gen-wasmtime-py/src/lib.rs b/crates/gen-wasmtime-py/src/lib.rs index f6a4f54e1..277192a97 100644 --- a/crates/gen-wasmtime-py/src/lib.rs +++ b/crates/gen-wasmtime-py/src/lib.rs @@ -378,7 +378,7 @@ impl WasmtimePy { | Type::S32 | Type::U64 | Type::S64 => self.src.push_str("int"), - Type::F32 | Type::F64 => self.src.push_str("float"), + Type::Float32 | Type::Float64 => self.src.push_str("float"), Type::Char => self.src.push_str("str"), Type::Handle(id) => { // In general we want to use quotes around this to support @@ -499,8 +499,8 @@ impl WasmtimePy { Type::S32 => Some("c_int32"), Type::U64 => Some("c_uint64"), Type::S64 => Some("c_int64"), - Type::F32 => Some("c_float"), - Type::F64 => Some("c_double"), + Type::Float32 => Some("c_float"), + Type::Float64 => Some("c_double"), Type::Char => None, Type::Handle(_) => None, Type::Id(id) => match &iface.types[*id].kind { @@ -1375,10 +1375,10 @@ impl Bindgen for FunctionBindgen<'_> { // Python uses `float` for f32/f64, so everything is equivalent // here. - Instruction::If32FromF32 - | Instruction::If64FromF64 - | Instruction::F32FromIf32 - | Instruction::F64FromIf64 => results.push(operands.pop().unwrap()), + Instruction::Float32FromF32 + | Instruction::Float64FromF64 + | Instruction::F32FromFloat32 + | Instruction::F64FromFloat64 => results.push(operands.pop().unwrap()), // Validate that i32 values coming from wasm are indeed valid code // points. diff --git a/crates/gen-wasmtime/src/lib.rs b/crates/gen-wasmtime/src/lib.rs index 0f30b3cf5..e9788122d 100644 --- a/crates/gen-wasmtime/src/lib.rs +++ b/crates/gen-wasmtime/src/lib.rs @@ -1441,10 +1441,10 @@ impl Bindgen for FunctionBindgen<'_> { results.push(format!("wit_bindgen_wasmtime::rt::as_i32({})", s)); } - Instruction::F32FromIf32 - | Instruction::F64FromIf64 - | Instruction::If32FromF32 - | Instruction::If64FromF64 + Instruction::F32FromFloat32 + | Instruction::F64FromFloat64 + | Instruction::Float32FromF32 + | Instruction::Float64FromF64 | Instruction::S32FromI32 | Instruction::S64FromI64 => { results.push(operands.pop().unwrap()); diff --git a/crates/parser/src/abi.rs b/crates/parser/src/abi.rs index c9a1b4fa5..9b1e99103 100644 --- a/crates/parser/src/abi.rs +++ b/crates/parser/src/abi.rs @@ -208,13 +208,13 @@ def_instruction! { /// This may be a noop for some implementations, but it's here in case the /// native language representation of `f32` is different than the wasm /// representation of `f32`. - F32FromIf32 : [1] => [1], + F32FromFloat32 : [1] => [1], /// Conversion an interface type `f64` value to a wasm `f64`. /// /// This may be a noop for some implementations, but it's here in case the /// native language representation of `f64` is different than the wasm /// representation of `f64`. - F64FromIf64 : [1] => [1], + F64FromFloat64 : [1] => [1], /// Converts a native wasm `i32` to an interface type `s8`. /// @@ -245,9 +245,9 @@ def_instruction! { /// It's safe to assume that the `i32` is indeed a valid unicode code point. CharFromI32 : [1] => [1], /// Converts a native wasm `f32` to an interface type `f32`. - If32FromF32 : [1] => [1], + Float32FromF32 : [1] => [1], /// Converts a native wasm `f64` to an interface type `f64`. - If64FromF64 : [1] => [1], + Float64FromF64 : [1] => [1], // Handles @@ -847,8 +847,8 @@ impl Interface { | Type::Handle(_) => result.push(WasmType::I32), Type::U64 | Type::S64 => result.push(WasmType::I64), - Type::F32 => result.push(WasmType::F32), - Type::F64 => result.push(WasmType::F64), + Type::Float32 => result.push(WasmType::F32), + Type::Float64 => result.push(WasmType::F64), Type::Id(id) => match &self.types[*id].kind { TypeDefKind::Type(t) => self.push_wasm(variant, t, result), @@ -1298,8 +1298,8 @@ impl<'a, B: Bindgen> Generator<'a, B> { Type::S64 => self.emit(&I64FromS64), Type::U64 => self.emit(&I64FromU64), Type::Char => self.emit(&I32FromChar), - Type::F32 => self.emit(&F32FromIf32), - Type::F64 => self.emit(&F64FromIf64), + Type::Float32 => self.emit(&F32FromFloat32), + Type::Float64 => self.emit(&F64FromFloat64), Type::Handle(ty) => { let borrowed = match self.lift_lower { // This means that a return value is being lowered, which is @@ -1472,8 +1472,8 @@ impl<'a, B: Bindgen> Generator<'a, B> { Type::S64 => self.emit(&S64FromI64), Type::U64 => self.emit(&U64FromI64), Type::Char => self.emit(&CharFromI32), - Type::F32 => self.emit(&If32FromF32), - Type::F64 => self.emit(&If64FromF64), + Type::Float32 => self.emit(&Float32FromF32), + Type::Float64 => self.emit(&Float64FromF64), Type::Handle(ty) => { // For more information on these values see the comments in // `lower` above. @@ -1607,8 +1607,8 @@ impl<'a, B: Bindgen> Generator<'a, B> { self.lower_and_emit(ty, addr, &I32Store { offset }) } Type::U64 | Type::S64 => self.lower_and_emit(ty, addr, &I64Store { offset }), - Type::F32 => self.lower_and_emit(ty, addr, &F32Store { offset }), - Type::F64 => self.lower_and_emit(ty, addr, &F64Store { offset }), + Type::Float32 => self.lower_and_emit(ty, addr, &F32Store { offset }), + Type::Float64 => self.lower_and_emit(ty, addr, &F64Store { offset }), Type::Id(id) => match &self.iface.types[id].kind { TypeDefKind::Type(t) => self.write_to_memory(t, addr, offset), @@ -1719,8 +1719,8 @@ impl<'a, B: Bindgen> Generator<'a, B> { self.emit_and_lift(ty, addr, &I32Load { offset }) } Type::U64 | Type::S64 => self.emit_and_lift(ty, addr, &I64Load { offset }), - Type::F32 => self.emit_and_lift(ty, addr, &F32Load { offset }), - Type::F64 => self.emit_and_lift(ty, addr, &F64Load { offset }), + Type::Float32 => self.emit_and_lift(ty, addr, &F32Load { offset }), + Type::Float64 => self.emit_and_lift(ty, addr, &F64Load { offset }), Type::Id(id) => match &self.iface.types[id].kind { TypeDefKind::Type(t) => self.read_from_memory(t, addr, offset), diff --git a/crates/parser/src/ast.rs b/crates/parser/src/ast.rs index 22ed45f46..88aba7720 100644 --- a/crates/parser/src/ast.rs +++ b/crates/parser/src/ast.rs @@ -81,8 +81,8 @@ enum Type<'a> { S16, S32, S64, - F32, - F64, + Float32, + Float64, Char, Handle(Id<'a>), Name(Id<'a>), @@ -492,8 +492,8 @@ impl<'a> Type<'a> { Some((_span, Token::S16)) => Ok(Type::S16), Some((_span, Token::S32)) => Ok(Type::S32), Some((_span, Token::S64)) => Ok(Type::S64), - Some((_span, Token::F32)) => Ok(Type::F32), - Some((_span, Token::F64)) => Ok(Type::F64), + Some((_span, Token::Float32)) => Ok(Type::Float32), + Some((_span, Token::Float64)) => Ok(Type::Float64), Some((_span, Token::Char)) => Ok(Type::Char), Some((_span, Token::Handle)) => { let name = parse_id(tokens)?; diff --git a/crates/parser/src/ast/lex.rs b/crates/parser/src/ast/lex.rs index 31c4b27d8..a98e9882b 100644 --- a/crates/parser/src/ast/lex.rs +++ b/crates/parser/src/ast/lex.rs @@ -58,8 +58,8 @@ pub enum Token { S16, S32, S64, - F32, - F64, + Float32, + Float64, Char, Handle, Record, @@ -245,8 +245,8 @@ impl<'a> Tokenizer<'a> { "s16" => S16, "s32" => S32, "s64" => S64, - "f32" => F32, - "f64" => F64, + "float32" => Float32, + "float64" => Float64, "char" => Char, "handle" => Handle, "record" => Record, @@ -506,8 +506,8 @@ impl Token { S16 => "keyword `s16`", S32 => "keyword `s32`", S64 => "keyword `s64`", - F32 => "keyword `f32`", - F64 => "keyword `f64`", + Float32 => "keyword `float32`", + Float64 => "keyword `float64`", Char => "keyword `char`", Handle => "keyword `handle`", Record => "keyword `record`", diff --git a/crates/parser/src/ast/resolve.rs b/crates/parser/src/ast/resolve.rs index 5d9d51088..312a29a79 100644 --- a/crates/parser/src/ast/resolve.rs +++ b/crates/parser/src/ast/resolve.rs @@ -316,8 +316,8 @@ impl Resolver { super::Type::S16 => TypeDefKind::Type(Type::S16), super::Type::S32 => TypeDefKind::Type(Type::S32), super::Type::S64 => TypeDefKind::Type(Type::S64), - super::Type::F32 => TypeDefKind::Type(Type::F32), - super::Type::F64 => TypeDefKind::Type(Type::F64), + super::Type::Float32 => TypeDefKind::Type(Type::Float32), + super::Type::Float64 => TypeDefKind::Type(Type::Float64), super::Type::Char => TypeDefKind::Type(Type::Char), super::Type::Handle(resource) => { let id = match self.resource_lookup.get(&*resource.name) { diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs index 0ca3c7ea2..b2b2a33bc 100644 --- a/crates/parser/src/lib.rs +++ b/crates/parser/src/lib.rs @@ -61,8 +61,8 @@ pub enum Type { S16, S32, S64, - F32, - F64, + Float32, + Float64, Char, Handle(ResourceId), Id(TypeId), @@ -430,8 +430,8 @@ impl Interface { | Type::S32 | Type::U64 | Type::S64 - | Type::F32 - | Type::F64 => true, + | Type::Float32 + | Type::Float64 => true, Type::Char | Type::Handle(_) => false, diff --git a/crates/parser/src/sizealign.rs b/crates/parser/src/sizealign.rs index e20e3f8fe..7b242321d 100644 --- a/crates/parser/src/sizealign.rs +++ b/crates/parser/src/sizealign.rs @@ -60,8 +60,8 @@ impl SizeAlign { match ty { Type::U8 | Type::S8 => 1, Type::U16 | Type::S16 => 2, - Type::U32 | Type::S32 | Type::F32 | Type::Char | Type::Handle(_) => 4, - Type::U64 | Type::S64 | Type::F64 => 8, + Type::U32 | Type::S32 | Type::Float32 | Type::Char | Type::Handle(_) => 4, + Type::U64 | Type::S64 | Type::Float64 => 8, Type::Id(id) => self.map[id.index()].0, } } @@ -70,8 +70,8 @@ impl SizeAlign { match ty { Type::U8 | Type::S8 => 1, Type::U16 | Type::S16 => 2, - Type::U32 | Type::S32 | Type::F32 | Type::Char | Type::Handle(_) => 4, - Type::U64 | Type::S64 | Type::F64 => 8, + Type::U32 | Type::S32 | Type::Float32 | Type::Char | Type::Handle(_) => 4, + Type::U64 | Type::S64 | Type::Float64 => 8, Type::Id(id) => self.map[id.index()].1, } } diff --git a/crates/parser/tests/all.rs b/crates/parser/tests/all.rs index 2fbe5bf24..6a13d8877 100644 --- a/crates/parser/tests/all.rs +++ b/crates/parser/tests/all.rs @@ -290,8 +290,8 @@ fn to_json(i: &Interface) -> String { Type::S16 => format!("s16"), Type::S32 => format!("s32"), Type::S64 => format!("s64"), - Type::F32 => format!("f32"), - Type::F64 => format!("f64"), + Type::Float32 => format!("float32"), + Type::Float64 => format!("float64"), Type::Char => format!("char"), Type::Handle(resource) => format!("handle-{}", resource.index()), Type::Id(id) => format!("type-{}", id.index()), diff --git a/crates/parser/tests/ui/functions.wit b/crates/parser/tests/ui/functions.wit index 3ed51a0ac..f03ca6528 100644 --- a/crates/parser/tests/ui/functions.wit +++ b/crates/parser/tests/ui/functions.wit @@ -3,8 +3,8 @@ f2: function(a: u32) f3: function(a: u32,) f4: function() -> u32 f6: function() -> (u32, u32) -f7: function(a: f32, b: f32) -> (u32, u32) -f8: function(a: option) -> expected +f7: function(a: float32, b: float32) -> (u32, u32) +f8: function(a: option) -> expected f9: function() -> a: u32 f10: function() -> (a: u32) diff --git a/crates/parser/tests/ui/functions.wit.result b/crates/parser/tests/ui/functions.wit.result index edff512bc..61d842c47 100644 --- a/crates/parser/tests/ui/functions.wit.result +++ b/crates/parser/tests/ui/functions.wit.result @@ -25,7 +25,7 @@ ], [ "err", - "f32" + "float32" ] ] } @@ -69,8 +69,8 @@ { "name": "f7", "params": [ - "f32", - "f32" + "float32", + "float32" ], "results": [ "u32", diff --git a/crates/parser/tests/ui/import-me.wit b/crates/parser/tests/ui/import-me.wit index a8d3a3ec8..4a87038b0 100644 --- a/crates/parser/tests/ui/import-me.wit +++ b/crates/parser/tests/ui/import-me.wit @@ -4,4 +4,4 @@ resource x type %handle = handle x -type some-record = tuple +type some-record = tuple diff --git a/crates/parser/tests/ui/import-me.wit.result b/crates/parser/tests/ui/import-me.wit.result index e6082b47b..35ab127fb 100644 --- a/crates/parser/tests/ui/import-me.wit.result +++ b/crates/parser/tests/ui/import-me.wit.result @@ -34,7 +34,7 @@ ], [ "2", - "f32" + "float32" ] ] } diff --git a/crates/parser/tests/ui/imports.wit.result b/crates/parser/tests/ui/imports.wit.result index b821b2d3b..101e9c240 100644 --- a/crates/parser/tests/ui/imports.wit.result +++ b/crates/parser/tests/ui/imports.wit.result @@ -41,7 +41,7 @@ ], [ "2", - "f32" + "float32" ] ] }, diff --git a/crates/parser/tests/ui/imports2.wit.result b/crates/parser/tests/ui/imports2.wit.result index dee3436a5..d0bb44f0f 100644 --- a/crates/parser/tests/ui/imports2.wit.result +++ b/crates/parser/tests/ui/imports2.wit.result @@ -33,7 +33,7 @@ ], [ "2", - "f32" + "float32" ] ] }, diff --git a/crates/parser/tests/ui/types.wit b/crates/parser/tests/ui/types.wit index 7776bc7f0..b28ceb875 100644 --- a/crates/parser/tests/ui/types.wit +++ b/crates/parser/tests/ui/types.wit @@ -8,8 +8,8 @@ type t5 = s8 type t6 = s16 type t7 = s32 type t8 = s64 -type t9 = f32 -type t10 = f64 +type t9 = float32 +type t10 = float64 type t11 = char type t12 = list type t13 = string diff --git a/crates/parser/tests/ui/types.wit.result b/crates/parser/tests/ui/types.wit.result index 8b13ff5ee..d9a0993c5 100644 --- a/crates/parser/tests/ui/types.wit.result +++ b/crates/parser/tests/ui/types.wit.result @@ -52,12 +52,12 @@ { "idx": 9, "name": "t9", - "primitive": "f32" + "primitive": "float32" }, { "idx": 10, "name": "t10", - "primitive": "f64" + "primitive": "float64" }, { "idx": 11, diff --git a/crates/test-helpers/src/lib.rs b/crates/test-helpers/src/lib.rs index b73966a81..106f44132 100644 --- a/crates/test-helpers/src/lib.rs +++ b/crates/test-helpers/src/lib.rs @@ -152,8 +152,8 @@ pub fn codegen_rust_wasm_export(input: TokenStream) -> TokenStream { Type::S32 => quote::quote! { i32 }, Type::U64 => quote::quote! { u64 }, Type::S64 => quote::quote! { i64 }, - Type::F32 => quote::quote! { f32 }, - Type::F64 => quote::quote! { f64 }, + Type::Float32 => quote::quote! { f32 }, + Type::Float64 => quote::quote! { f64 }, Type::Char => quote::quote! { char }, Type::Handle(resource) => { let name = diff --git a/crates/test-modules/modules/crates/lists-main/src/main.rs b/crates/test-modules/modules/crates/lists-main/src/main.rs index 44d1feecd..097d988e0 100644 --- a/crates/test-modules/modules/crates/lists-main/src/main.rs +++ b/crates/test-modules/modules/crates/lists-main/src/main.rs @@ -15,8 +15,8 @@ fn main() { list_s64_param(&[ -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, ]); - list_f32_param(&[-1.1, 2.2, -3.3, 4.4, -5.5]); - list_f64_param(&[-1.1, 2.2, -3.3, 4.4, -5.5]); + list_float32_param(&[-1.1, 2.2, -3.3, 4.4, -5.5]); + list_float64_param(&[-1.1, 2.2, -3.3, 4.4, -5.5]); assert_eq!(list_u8_ret(), &[5, 4, 3, 2, 1]); assert_eq!(list_u16_ret(), &[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]); @@ -38,8 +38,8 @@ fn main() { list_s64_ret(), &[-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20] ); - assert_eq!(list_f32_ret(), &[1.1, -2.2, 3.3, -4.4, 5.5]); - assert_eq!(list_f64_ret(), &[1.1, -2.2, 3.3, -4.4, 5.5]); + assert_eq!(list_float32_ret(), &[1.1, -2.2, 3.3, -4.4, 5.5]); + assert_eq!(list_float64_ret(), &[1.1, -2.2, 3.3, -4.4, 5.5]); assert_eq!( tuple_list(&[ diff --git a/crates/test-modules/modules/crates/lists/lists.wit b/crates/test-modules/modules/crates/lists/lists.wit index 764c91e67..546667cf1 100644 --- a/crates/test-modules/modules/crates/lists/lists.wit +++ b/crates/test-modules/modules/crates/lists/lists.wit @@ -6,8 +6,8 @@ list-s8-param: function(x: list) list-s16-param: function(x: list) list-s32-param: function(x: list) list-s64-param: function(x: list) -list-f32-param: function(x: list) -list-f64-param: function(x: list) +list-float32-param: function(x: list) +list-float64-param: function(x: list) list-u8-ret: function() -> list list-u16-ret: function() -> list @@ -17,8 +17,8 @@ list-s8-ret: function() -> list list-s16-ret: function() -> list list-s32-ret: function() -> list list-s64-ret: function() -> list -list-f32-ret: function() -> list -list-f64-ret: function() -> list +list-float32-ret: function() -> list +list-float64-ret: function() -> list tuple-list: function(x: list>) -> list> tuple-string-list: function(x: list>) -> list> @@ -65,8 +65,8 @@ type load-store-all-sizes = list> load-store-everything: function(a: load-store-all-sizes) -> load-store-all-sizes diff --git a/crates/test-modules/modules/crates/lists/src/lib.rs b/crates/test-modules/modules/crates/lists/src/lib.rs index cc692b3cc..ae65511c1 100644 --- a/crates/test-modules/modules/crates/lists/src/lib.rs +++ b/crates/test-modules/modules/crates/lists/src/lib.rs @@ -38,10 +38,10 @@ impl lists::Lists for Lists { &[-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20] ); } - fn list_f32_param(x: Vec) { + fn list_float32_param(x: Vec) { assert_eq!(x, &[-1.1, 2.2, -3.3, 4.4, -5.5]); } - fn list_f64_param(x: Vec) { + fn list_float64_param(x: Vec) { assert_eq!(x, &[-1.1, 2.2, -3.3, 4.4, -5.5]); } fn list_u8_ret() -> Vec { @@ -72,10 +72,10 @@ impl lists::Lists for Lists { -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, ] } - fn list_f32_ret() -> Vec { + fn list_float32_ret() -> Vec { vec![1.1, -2.2, 3.3, -4.4, 5.5] } - fn list_f64_ret() -> Vec { + fn list_float64_ret() -> Vec { vec![1.1, -2.2, 3.3, -4.4, 5.5] } fn tuple_list(x: Vec<(u8, i8)>) -> Vec<(i64, u32)> { diff --git a/crates/test-modules/modules/crates/types/types.wit b/crates/test-modules/modules/crates/types/types.wit index 6db70181a..8929f70b3 100644 --- a/crates/test-modules/modules/crates/types/types.wit +++ b/crates/test-modules/modules/crates/types/types.wit @@ -1,6 +1,6 @@ a: function() b: function(p0: u8, p1: s8, p2: u16, p3: s16, p4: u32, p5: s32, p6: u64, p7: s64) -> (u8, s8, u16, s16, u32, s32, u64, s64) -c: function(p0: f32, p1: f64) -> (f32, f64) +c: function(p0: float32, p1: float64) -> (float32, float64) d: function(p0: string) -> string e: function() -> string f: function() -> (u32, string, u64) diff --git a/crates/test-modules/modules/crates/variants/variants.wit b/crates/test-modules/modules/crates/variants/variants.wit index 765044b8f..248e84160 100644 --- a/crates/test-modules/modules/crates/variants/variants.wit +++ b/crates/test-modules/modules/crates/variants/variants.wit @@ -7,7 +7,7 @@ e1-result: function() -> e1 union u1 { u32, - f32, + float32, } u1-arg: function(x: u1) @@ -36,7 +36,7 @@ option-arg: function( b: option>, c: option, d: option, - e: option, + e: option, f: option, g: option>, ) @@ -45,23 +45,23 @@ option-result: function() -> ( option>, option, option, - option, + option, option, option>, ) variant casts1 { a(s32), - b(f32), + b(float32), } variant casts2 { - a(f64), - b(f32), + a(float64), + b(float32), } variant casts3 { - a(f64), + a(float64), b(u64), } @@ -71,12 +71,12 @@ variant casts4 { } variant casts5 { - a(f32), + a(float32), b(s64), } variant casts6 { - a(tuple), + a(tuple), b(tuple), } diff --git a/crates/wasmlink/tests/flags.baseline b/crates/wasmlink/tests/flags.baseline index 52b8c442b..13aab891c 100644 --- a/crates/wasmlink/tests/flags.baseline +++ b/crates/wasmlink/tests/flags.baseline @@ -61,4 +61,4 @@ (export "roundtrip-flag8" (func 10)) (export "roundtrip-flag16" (func 11)) (export "roundtrip-flag32" (func 12)) - (export "roundtrip-flag64" (func 13))) + (export "roundtrip-flag64" (func 13))) \ No newline at end of file diff --git a/crates/wasmlink/tests/incorrect-export.baseline b/crates/wasmlink/tests/incorrect-export.baseline index d2975417d..c8c6f8b63 100644 --- a/crates/wasmlink/tests/incorrect-export.baseline +++ b/crates/wasmlink/tests/incorrect-export.baseline @@ -1 +1 @@ -required export `f1` from module `incorrect-export` does not have the expected function signature of [] -> [I32] +required export `f1` from module `incorrect-export` does not have the expected function signature of [] -> [I32] \ No newline at end of file diff --git a/crates/wasmlink/tests/incorrect-free.baseline b/crates/wasmlink/tests/incorrect-free.baseline index d29128d86..06a6aabb6 100644 --- a/crates/wasmlink/tests/incorrect-free.baseline +++ b/crates/wasmlink/tests/incorrect-free.baseline @@ -1 +1 @@ -required export `canonical_abi_free` from module `incorrect-free` does not have the expected function signature of [I32, I32, I32] -> [] +required export `canonical_abi_free` from module `incorrect-free` does not have the expected function signature of [I32, I32, I32] -> [] \ No newline at end of file diff --git a/crates/wasmlink/tests/incorrect-realloc.baseline b/crates/wasmlink/tests/incorrect-realloc.baseline index abb29d2b3..1c8bc6501 100644 --- a/crates/wasmlink/tests/incorrect-realloc.baseline +++ b/crates/wasmlink/tests/incorrect-realloc.baseline @@ -1 +1 @@ -required export `canonical_abi_realloc` from module `incorrect-realloc` does not have the expected function signature of [I32, I32, I32, I32] -> [I32] +required export `canonical_abi_realloc` from module `incorrect-realloc` does not have the expected function signature of [I32, I32, I32, I32] -> [I32] \ No newline at end of file diff --git a/crates/wasmlink/tests/lists.baseline b/crates/wasmlink/tests/lists.baseline index ba64d5b5b..e54f3af70 100644 --- a/crates/wasmlink/tests/lists.baseline +++ b/crates/wasmlink/tests/lists.baseline @@ -79,8 +79,8 @@ (export "list-s16-param" (func 7)) (export "list-s32-param" (func 8)) (export "list-s64-param" (func 9)) - (export "list-f32-param" (func 10)) - (export "list-f64-param" (func 11)) + (export "list-float32-param" (func 10)) + (export "list-float64-param" (func 11)) (export "list-u8-ret" (func 12)) (export "list-u16-ret" (func 13)) (export "list-u32-ret" (func 14)) @@ -89,8 +89,8 @@ (export "list-s16-ret" (func 17)) (export "list-s32-ret" (func 18)) (export "list-s64-ret" (func 19)) - (export "list-f32-ret" (func 20)) - (export "list-f64-ret" (func 21)) + (export "list-float32-ret" (func 20)) + (export "list-float64-ret" (func 21)) (export "tuple-list" (func 22)) (export "tuple-string-list" (func 23)) (export "string-list" (func 24)) @@ -110,8 +110,8 @@ (alias 1 "list-s16-param" (func (;8;))) (alias 1 "list-s32-param" (func (;9;))) (alias 1 "list-s64-param" (func (;10;))) - (alias 1 "list-f32-param" (func (;11;))) - (alias 1 "list-f64-param" (func (;12;))) + (alias 1 "list-float32-param" (func (;11;))) + (alias 1 "list-float64-param" (func (;12;))) (alias 1 "list-u8-ret" (func (;13;))) (alias 1 "list-u16-ret" (func (;14;))) (alias 1 "list-u32-ret" (func (;15;))) @@ -120,8 +120,8 @@ (alias 1 "list-s16-ret" (func (;18;))) (alias 1 "list-s32-ret" (func (;19;))) (alias 1 "list-s64-ret" (func (;20;))) - (alias 1 "list-f32-ret" (func (;21;))) - (alias 1 "list-f64-ret" (func (;22;))) + (alias 1 "list-float32-ret" (func (;21;))) + (alias 1 "list-float64-ret" (func (;22;))) (alias 1 "tuple-list" (func (;23;))) (alias 1 "tuple-string-list" (func (;24;))) (alias 1 "string-list" (func (;25;))) @@ -2082,8 +2082,8 @@ (export "list-s16-param" (func 34)) (export "list-s32-param" (func 35)) (export "list-s64-param" (func 36)) - (export "list-f32-param" (func 37)) - (export "list-f64-param" (func 38)) + (export "list-float32-param" (func 37)) + (export "list-float64-param" (func 38)) (export "list-u8-ret" (func 39)) (export "list-u16-ret" (func 40)) (export "list-u32-ret" (func 41)) @@ -2092,11 +2092,11 @@ (export "list-s16-ret" (func 44)) (export "list-s32-ret" (func 45)) (export "list-s64-ret" (func 46)) - (export "list-f32-ret" (func 47)) - (export "list-f64-ret" (func 48)) + (export "list-float32-ret" (func 47)) + (export "list-float64-ret" (func 48)) (export "tuple-list" (func 49)) (export "tuple-string-list" (func 50)) (export "string-list" (func 51)) (export "record-list" (func 52)) (export "variant-list" (func 53)) - (export "load-store-everything" (func 54))) + (export "load-store-everything" (func 54))) \ No newline at end of file diff --git a/crates/wasmlink/tests/lists.wat b/crates/wasmlink/tests/lists.wat index b9bcee01b..bfcf057a1 100644 --- a/crates/wasmlink/tests/lists.wat +++ b/crates/wasmlink/tests/lists.wat @@ -30,10 +30,10 @@ (func (export "list-s64-param") (param i32 i32) unreachable ) - (func (export "list-f32-param") (param i32 i32) + (func (export "list-float32-param") (param i32 i32) unreachable ) - (func (export "list-f64-param") (param i32 i32) + (func (export "list-float64-param") (param i32 i32) unreachable ) (func (export "list-u8-ret") (result i32) @@ -60,10 +60,10 @@ (func (export "list-s64-ret") (result i32) unreachable ) - (func (export "list-f32-ret") (result i32) + (func (export "list-float32-ret") (result i32) unreachable ) - (func (export "list-f64-ret") (result i32) + (func (export "list-float64-ret") (result i32) unreachable ) (func (export "tuple-list") (param i32 i32) (result i32) diff --git a/crates/wasmlink/tests/lists.wit b/crates/wasmlink/tests/lists.wit index 764c91e67..546667cf1 100644 --- a/crates/wasmlink/tests/lists.wit +++ b/crates/wasmlink/tests/lists.wit @@ -6,8 +6,8 @@ list-s8-param: function(x: list) list-s16-param: function(x: list) list-s32-param: function(x: list) list-s64-param: function(x: list) -list-f32-param: function(x: list) -list-f64-param: function(x: list) +list-float32-param: function(x: list) +list-float64-param: function(x: list) list-u8-ret: function() -> list list-u16-ret: function() -> list @@ -17,8 +17,8 @@ list-s8-ret: function() -> list list-s16-ret: function() -> list list-s32-ret: function() -> list list-s64-ret: function() -> list -list-f32-ret: function() -> list -list-f64-ret: function() -> list +list-float32-ret: function() -> list +list-float64-ret: function() -> list tuple-list: function(x: list>) -> list> tuple-string-list: function(x: list>) -> list> @@ -65,8 +65,8 @@ type load-store-all-sizes = list> load-store-everything: function(a: load-store-all-sizes) -> load-store-all-sizes diff --git a/crates/wasmlink/tests/missing-export.baseline b/crates/wasmlink/tests/missing-export.baseline index 9976375f5..28ad2edc3 100644 --- a/crates/wasmlink/tests/missing-export.baseline +++ b/crates/wasmlink/tests/missing-export.baseline @@ -1 +1 @@ -required export `f1` is missing from module `missing-export` +required export `f1` is missing from module `missing-export` \ No newline at end of file diff --git a/crates/wasmlink/tests/missing-free.baseline b/crates/wasmlink/tests/missing-free.baseline index da3bcc107..e143c720d 100644 --- a/crates/wasmlink/tests/missing-free.baseline +++ b/crates/wasmlink/tests/missing-free.baseline @@ -1 +1 @@ -required export `canonical_abi_free` is missing from module `missing-free` +required export `canonical_abi_free` is missing from module `missing-free` \ No newline at end of file diff --git a/crates/wasmlink/tests/missing-memory.baseline b/crates/wasmlink/tests/missing-memory.baseline index c204bc14f..dd2c07098 100644 --- a/crates/wasmlink/tests/missing-memory.baseline +++ b/crates/wasmlink/tests/missing-memory.baseline @@ -1 +1 @@ -required export `memory` is missing from module `missing-memory` +required export `memory` is missing from module `missing-memory` \ No newline at end of file diff --git a/crates/wasmlink/tests/missing-realloc.baseline b/crates/wasmlink/tests/missing-realloc.baseline index feeaa8ccc..8c33ddf44 100644 --- a/crates/wasmlink/tests/missing-realloc.baseline +++ b/crates/wasmlink/tests/missing-realloc.baseline @@ -1 +1 @@ -required export `canonical_abi_realloc` is missing from module `missing-realloc` +required export `canonical_abi_realloc` is missing from module `missing-realloc` \ No newline at end of file diff --git a/crates/wasmlink/tests/not-adapted.baseline b/crates/wasmlink/tests/not-adapted.baseline index 5be762a28..54922eb4f 100644 --- a/crates/wasmlink/tests/not-adapted.baseline +++ b/crates/wasmlink/tests/not-adapted.baseline @@ -1,5 +1,5 @@ -(module - (type (;0;) (func (param i32 i64 f32 f64) (result i32))) - (func (;0;) (type 0) (param i32 i64 f32 f64) (result i32) - unreachable) - (export "f1" (func 0))) \ No newline at end of file +no type named `f32` + --> tests/not-adapted.wit:1:33 + | + 1 | f1: function(a: s32, b: s64, c: f32, d: f64) -> u32 + | ^-- \ No newline at end of file diff --git a/crates/wasmlink/tests/records.baseline b/crates/wasmlink/tests/records.baseline index 7a0fb6c2a..4d33aa06e 100644 --- a/crates/wasmlink/tests/records.baseline +++ b/crates/wasmlink/tests/records.baseline @@ -191,4 +191,4 @@ (export "flags-arg" (func 16)) (export "flags-result" (func 17)) (export "aggregate-arg" (func 18)) - (export "aggregate-result" (func 19))) + (export "aggregate-result" (func 19))) \ No newline at end of file diff --git a/crates/wasmlink/tests/resource-incorrect-drop.baseline b/crates/wasmlink/tests/resource-incorrect-drop.baseline index e82d46632..e0e4b5a67 100644 --- a/crates/wasmlink/tests/resource-incorrect-drop.baseline +++ b/crates/wasmlink/tests/resource-incorrect-drop.baseline @@ -1 +1 @@ -unexpected function type for export `canonical_abi_drop_x` from module `resource-incorrect-drop`: expected [i32] -> [] +unexpected function type for export `canonical_abi_drop_x` from module `resource-incorrect-drop`: expected [i32] -> [] \ No newline at end of file diff --git a/crates/wasmlink/tests/resources-missing-drop.baseline b/crates/wasmlink/tests/resources-missing-drop.baseline index 7fb4e6940..809a7c4aa 100644 --- a/crates/wasmlink/tests/resources-missing-drop.baseline +++ b/crates/wasmlink/tests/resources-missing-drop.baseline @@ -1 +1 @@ -module `resources-missing-drop` declares a resource named `x` but does not export a function named `canonical_abi_drop_x` +module `resources-missing-drop` declares a resource named `x` but does not export a function named `canonical_abi_drop_x` \ No newline at end of file diff --git a/crates/wasmlink/tests/resources.baseline b/crates/wasmlink/tests/resources.baseline index f76bafc7f..c2b1a55e5 100644 --- a/crates/wasmlink/tests/resources.baseline +++ b/crates/wasmlink/tests/resources.baseline @@ -492,4 +492,4 @@ (export "all-dropped" (func 21)) (export "resource_clone_x" (func 14)) (export "resource_drop_x" (func 15)) - (elem (;0;) (i32.const 0) funcref (ref.func 16))) + (elem (;0;) (i32.const 0) funcref (ref.func 16))) \ No newline at end of file diff --git a/crates/wasmlink/tests/variants.baseline b/crates/wasmlink/tests/variants.baseline index 026da7c9a..a4af768d4 100644 --- a/crates/wasmlink/tests/variants.baseline +++ b/crates/wasmlink/tests/variants.baseline @@ -609,4 +609,4 @@ (export "option-result" (func 25)) (export "casts" (func 26)) (export "expected-arg" (func 27)) - (export "expected-result" (func 28))) + (export "expected-result" (func 28))) \ No newline at end of file diff --git a/crates/wasmlink/tests/variants.wit b/crates/wasmlink/tests/variants.wit index 765044b8f..248e84160 100644 --- a/crates/wasmlink/tests/variants.wit +++ b/crates/wasmlink/tests/variants.wit @@ -7,7 +7,7 @@ e1-result: function() -> e1 union u1 { u32, - f32, + float32, } u1-arg: function(x: u1) @@ -36,7 +36,7 @@ option-arg: function( b: option>, c: option, d: option, - e: option, + e: option, f: option, g: option>, ) @@ -45,23 +45,23 @@ option-result: function() -> ( option>, option, option, - option, + option, option, option>, ) variant casts1 { a(s32), - b(f32), + b(float32), } variant casts2 { - a(f64), - b(f32), + a(float64), + b(float32), } variant casts3 { - a(f64), + a(float64), b(u64), } @@ -71,12 +71,12 @@ variant casts4 { } variant casts5 { - a(f32), + a(float32), b(s64), } variant casts6 { - a(tuple), + a(tuple), b(tuple), } diff --git a/crates/wit-component/src/decoding.rs b/crates/wit-component/src/decoding.rs index 2444d6e99..45530fa67 100644 --- a/crates/wit-component/src/decoding.rs +++ b/crates/wit-component/src/decoding.rs @@ -341,8 +341,8 @@ impl<'a> InterfaceDecoder<'a> { PrimitiveInterfaceType::U32 => Type::U32, PrimitiveInterfaceType::S64 => Type::S64, PrimitiveInterfaceType::U64 => Type::U64, - PrimitiveInterfaceType::Float32 => Type::F32, - PrimitiveInterfaceType::Float64 => Type::F64, + PrimitiveInterfaceType::Float32 => Type::Float32, + PrimitiveInterfaceType::Float64 => Type::Float64, PrimitiveInterfaceType::Char => Type::Char, PrimitiveInterfaceType::String => self.string(), }) diff --git a/crates/wit-component/src/encoding.rs b/crates/wit-component/src/encoding.rs index 7923e8ca2..95301d94b 100644 --- a/crates/wit-component/src/encoding.rs +++ b/crates/wit-component/src/encoding.rs @@ -423,8 +423,8 @@ impl<'a> TypeEncoder<'a> { Type::S16 => InterfaceTypeRef::Primitive(PrimitiveInterfaceType::S16), Type::S32 => InterfaceTypeRef::Primitive(PrimitiveInterfaceType::S32), Type::S64 => InterfaceTypeRef::Primitive(PrimitiveInterfaceType::S64), - Type::F32 => InterfaceTypeRef::Primitive(PrimitiveInterfaceType::Float32), - Type::F64 => InterfaceTypeRef::Primitive(PrimitiveInterfaceType::Float64), + Type::Float32 => InterfaceTypeRef::Primitive(PrimitiveInterfaceType::Float32), + Type::Float64 => InterfaceTypeRef::Primitive(PrimitiveInterfaceType::Float64), Type::Char => InterfaceTypeRef::Primitive(PrimitiveInterfaceType::Char), Type::Id(id) => { let ty = &interface.types[*id]; diff --git a/crates/wit-component/src/printing.rs b/crates/wit-component/src/printing.rs index 1a84ab886..d0ae142b9 100644 --- a/crates/wit-component/src/printing.rs +++ b/crates/wit-component/src/printing.rs @@ -54,8 +54,8 @@ impl InterfacePrinter { Type::S16 => self.output.push_str("s16"), Type::S32 => self.output.push_str("s32"), Type::S64 => self.output.push_str("s64"), - Type::F32 => self.output.push_str("f32"), - Type::F64 => self.output.push_str("f64"), + Type::Float32 => self.output.push_str("float32"), + Type::Float64 => self.output.push_str("float64"), Type::Char => self.output.push_str("char"), Type::Id(id) => { @@ -149,8 +149,8 @@ impl InterfacePrinter { | Type::S16 | Type::S32 | Type::S64 - | Type::F32 - | Type::F64 + | Type::Float32 + | Type::Float64 | Type::Char => return Ok(()), Type::Id(id) => { diff --git a/crates/wit-component/tests/components/imports/import-foo.wit b/crates/wit-component/tests/components/imports/import-foo.wit index cb7382e03..7e8d19c27 100644 --- a/crates/wit-component/tests/components/imports/import-foo.wit +++ b/crates/wit-component/tests/components/imports/import-foo.wit @@ -1,3 +1,3 @@ foo1: function() foo2: function(x: u8) -foo3: function(x: f32) +foo3: function(x: float32) diff --git a/crates/wit-component/tests/interfaces/floats/floats.wat b/crates/wit-component/tests/interfaces/floats/floats.wat index 755dbfafe..41f9ccb4d 100644 --- a/crates/wit-component/tests/interfaces/floats/floats.wat +++ b/crates/wit-component/tests/interfaces/floats/floats.wat @@ -3,8 +3,8 @@ (type (;1;) (func (param "x" float64))) (type (;2;) (func (result float32))) (type (;3;) (func (result float64))) - (export "f32-param" (type 0)) - (export "f64-param" (type 1)) - (export "f32-result" (type 2)) - (export "f64-result" (type 3)) + (export "float32-param" (type 0)) + (export "float64-param" (type 1)) + (export "float32-result" (type 2)) + (export "float64-result" (type 3)) ) \ No newline at end of file diff --git a/crates/wit-component/tests/interfaces/floats/floats.wit b/crates/wit-component/tests/interfaces/floats/floats.wit index e5d141f35..342dc447d 100644 --- a/crates/wit-component/tests/interfaces/floats/floats.wit +++ b/crates/wit-component/tests/interfaces/floats/floats.wit @@ -1,8 +1,8 @@ -f32-param: function(x: f32) +float32-param: function(x: float32) -f64-param: function(x: f64) +float64-param: function(x: float64) -f32-result: function() -> f32 +float32-result: function() -> float32 -f64-result: function() -> f64 +float64-result: function() -> float64 diff --git a/crates/wit-component/tests/interfaces/lists/lists.wat b/crates/wit-component/tests/interfaces/lists/lists.wat index 842fc4efd..4717c2587 100644 --- a/crates/wit-component/tests/interfaces/lists/lists.wat +++ b/crates/wit-component/tests/interfaces/lists/lists.wat @@ -64,8 +64,8 @@ (export "list-s16-param" (type 11)) (export "list-s32-param" (type 13)) (export "list-s64-param" (type 15)) - (export "list-f32-param" (type 17)) - (export "list-f64-param" (type 19)) + (export "list-float32-param" (type 17)) + (export "list-float64-param" (type 19)) (export "list-u8-ret" (type 20)) (export "list-u16-ret" (type 21)) (export "list-u32-ret" (type 22)) @@ -74,8 +74,8 @@ (export "list-s16-ret" (type 25)) (export "list-s32-ret" (type 26)) (export "list-s64-ret" (type 27)) - (export "list-f32-ret" (type 28)) - (export "list-f64-ret" (type 29)) + (export "list-float32-ret" (type 28)) + (export "list-float64-ret" (type 29)) (export "tuple-list" (type 34)) (export "string-list-arg" (type 36)) (export "string-list-ret" (type 37)) diff --git a/crates/wit-component/tests/interfaces/lists/lists.wit b/crates/wit-component/tests/interfaces/lists/lists.wit index e36afeaf5..ddd05cab9 100644 --- a/crates/wit-component/tests/interfaces/lists/lists.wit +++ b/crates/wit-component/tests/interfaces/lists/lists.wit @@ -29,7 +29,7 @@ variant some-variant { d(list), } -type load-store-all-sizes = list> +type load-store-all-sizes = list> list-u8-param: function(x: list) @@ -47,9 +47,9 @@ list-s32-param: function(x: list) list-s64-param: function(x: list) -list-f32-param: function(x: list) +list-float32-param: function(x: list) -list-f64-param: function(x: list) +list-float64-param: function(x: list) list-u8-ret: function() -> list @@ -67,9 +67,9 @@ list-s32-ret: function() -> list list-s64-ret: function() -> list -list-f32-ret: function() -> list +list-float32-ret: function() -> list -list-f64-ret: function() -> list +list-float64-ret: function() -> list tuple-list: function(x: list>) -> list> diff --git a/crates/wit-component/tests/interfaces/variants/variants.wit b/crates/wit-component/tests/interfaces/variants/variants.wit index acc91c50b..461bd1cc4 100644 --- a/crates/wit-component/tests/interfaces/variants/variants.wit +++ b/crates/wit-component/tests/interfaces/variants/variants.wit @@ -4,7 +4,7 @@ enum e1 { union u1 { u32, - f32, + float32, } record empty { @@ -22,16 +22,16 @@ variant v1 { variant casts1 { a(s32), - b(f32), + b(float32), } variant casts2 { - a(f64), - b(f32), + a(float64), + b(float32), } variant casts3 { - a(f64), + a(float64), b(u64), } @@ -41,12 +41,12 @@ variant casts4 { } variant casts5 { - a(f32), + a(float32), b(s64), } variant casts6 { - a(tuple), + a(tuple), b(tuple), } @@ -71,9 +71,9 @@ bool-arg: function(x: bool) bool-result: function() -> bool -option-arg: function(a: option, b: option>, c: option, d: option, e: option, f: option, g: option>) +option-arg: function(a: option, b: option>, c: option, d: option, e: option, f: option, g: option>) -option-result: function() -> tuple, option>, option, option, option, option, option>> +option-result: function() -> tuple, option>, option, option, option, option, option>> casts: function(a: casts1, b: casts2, c: casts3, d: casts4, e: casts5, f: casts6) -> tuple diff --git a/tests/codegen/floats.wit b/tests/codegen/floats.wit index a8f6aae23..0d8e34e22 100644 --- a/tests/codegen/floats.wit +++ b/tests/codegen/floats.wit @@ -1,4 +1,4 @@ -f32-param: function(x: f32) -f64-param: function(x: f64) -f32-result: function() -> f32 -f64-result: function() -> f64 +float32-param: function(x: float32) +float64-param: function(x: float64) +float32-result: function() -> float32 +float64-result: function() -> float64 diff --git a/tests/codegen/lists.wit b/tests/codegen/lists.wit index e3dc11293..478173986 100644 --- a/tests/codegen/lists.wit +++ b/tests/codegen/lists.wit @@ -6,8 +6,8 @@ list-s8-param: function(x: list) list-s16-param: function(x: list) list-s32-param: function(x: list) list-s64-param: function(x: list) -list-f32-param: function(x: list) -list-f64-param: function(x: list) +list-float32-param: function(x: list) +list-float64-param: function(x: list) list-u8-ret: function() -> list list-u16-ret: function() -> list @@ -17,8 +17,8 @@ list-s8-ret: function() -> list list-s16-ret: function() -> list list-s32-ret: function() -> list list-s64-ret: function() -> list -list-f32-ret: function() -> list -list-f64-ret: function() -> list +list-float32-ret: function() -> list +list-float64-ret: function() -> list tuple-list: function(x: list>) -> list> string-list-arg: function(a: list) @@ -69,8 +69,8 @@ type load-store-all-sizes = list> load-store-everything: function(a: load-store-all-sizes) -> load-store-all-sizes diff --git a/tests/codegen/variants.wit b/tests/codegen/variants.wit index ef3cfc915..37c8b74bd 100644 --- a/tests/codegen/variants.wit +++ b/tests/codegen/variants.wit @@ -7,7 +7,7 @@ e1-result: function() -> e1 union u1 { u32, - f32, + float32, } u1-arg: function(x: u1) @@ -36,7 +36,7 @@ option-arg: function( b: option>, c: option, d: option, - e: option, + e: option, f: option, g: option>, ) @@ -45,23 +45,23 @@ option-result: function() -> ( option>, option, option, - option, + option, option, option>, ) variant casts1 { a(s32), - b(f32), + b(float32), } variant casts2 { - a(f64), - b(f32), + a(float64), + b(float32), } variant casts3 { - a(f64), + a(float64), b(u64), } @@ -71,12 +71,12 @@ variant casts4 { } variant casts5 { - a(f32), + a(float32), b(s64), } variant casts6 { - a(tuple), + a(tuple), b(tuple), } diff --git a/tests/runtime/flavorful/exports.wit b/tests/runtime/flavorful/exports.wit index c12863a66..cbfc5d54c 100644 --- a/tests/runtime/flavorful/exports.wit +++ b/tests/runtime/flavorful/exports.wit @@ -13,7 +13,7 @@ list-in-record4: function(a: list-in-alias) -> list-in-alias type list-in-variant1-v1 = option type list-in-variant1-v2 = expected<_, string> -union list-in-variant1-v3 { string, f32 } +union list-in-variant1-v3 { string, float32 } list-in-variant1: function(a: list-in-variant1-v1, b: list-in-variant1-v2, c: list-in-variant1-v3) type list-in-variant2 = option diff --git a/tests/runtime/flavorful/imports.wit b/tests/runtime/flavorful/imports.wit index 73fb606ca..e1af59aec 100644 --- a/tests/runtime/flavorful/imports.wit +++ b/tests/runtime/flavorful/imports.wit @@ -11,7 +11,7 @@ list-in-record4: function(a: list-in-alias) -> list-in-alias type list-in-variant1-v1 = option type list-in-variant1-v2 = expected<_, string> -union list-in-variant1-v3 { string, f32 } +union list-in-variant1-v3 { string, float32 } list-in-variant1: function(a: list-in-variant1-v1, b: list-in-variant1-v2, c: list-in-variant1-v3) type list-in-variant2 = option diff --git a/tests/runtime/lists/imports.wit b/tests/runtime/lists/imports.wit index 116fb77be..4c3e790ac 100644 --- a/tests/runtime/lists/imports.wit +++ b/tests/runtime/lists/imports.wit @@ -28,7 +28,7 @@ list-minmax8: function(a: list, b: list) -> (list, list) list-minmax16: function(a: list, b: list) -> (list, list) list-minmax32: function(a: list, b: list) -> (list, list) list-minmax64: function(a: list, b: list) -> (list, list) -list-minmax-float: function(a: list, b: list) -> (list, list) +list-minmax-float: function(a: list, b: list) -> (list, list) list-roundtrip: function(a: list) -> list @@ -37,4 +37,4 @@ string-roundtrip: function(a: string) -> string unaligned-roundtrip1: function(a: list, b: list, c: list, d: list, e: list) record unaligned-record { a: u32, b: u64 } -unaligned-roundtrip2: function(a: list, b: list, c: list, d: list, e: list>) +unaligned-roundtrip2: function(a: list, b: list, c: list, d: list, e: list>) diff --git a/tests/runtime/lists/wasm.c b/tests/runtime/lists/wasm.c index e60af83be..083a913ba 100644 --- a/tests/runtime/lists/wasm.c +++ b/tests/runtime/lists/wasm.c @@ -187,17 +187,17 @@ void exports_test_imports() { { float f32[4] = {-FLT_MAX, FLT_MAX, -INFINITY, INFINITY}; double f64[4] = {-DBL_MAX, DBL_MAX, -INFINITY, INFINITY}; - imports_list_f32_t list_f32 = { f32, 4 }; - imports_list_f64_t list_f64 = { f64, 4 }; - imports_list_f32_t list_f32_out; - imports_list_f64_t list_f64_out; - imports_list_minmax_float(&list_f32, &list_f64, &list_f32_out, &list_f64_out); - assert(list_f32_out.len == 4 && list_f32_out.ptr[0] == -FLT_MAX && list_f32_out.ptr[1] == FLT_MAX); - assert(list_f32_out.ptr[2] == -INFINITY && list_f32_out.ptr[3] == INFINITY); - assert(list_f64_out.len == 4 && list_f64_out.ptr[0] == -DBL_MAX && list_f64_out.ptr[1] == DBL_MAX); - assert(list_f64_out.ptr[2] == -INFINITY && list_f64_out.ptr[3] == INFINITY); - imports_list_f32_free(&list_f32_out); - imports_list_f64_free(&list_f64_out); + imports_list_float32_t list_float32 = { f32, 4 }; + imports_list_float64_t list_float64 = { f64, 4 }; + imports_list_float32_t list_float32_out; + imports_list_float64_t list_float64_out; + imports_list_minmax_float(&list_float32, &list_float64, &list_float32_out, &list_float64_out); + assert(list_float32_out.len == 4 && list_float32_out.ptr[0] == -FLT_MAX && list_float32_out.ptr[1] == FLT_MAX); + assert(list_float32_out.ptr[2] == -INFINITY && list_float32_out.ptr[3] == INFINITY); + assert(list_float64_out.len == 4 && list_float64_out.ptr[0] == -DBL_MAX && list_float64_out.ptr[1] == DBL_MAX); + assert(list_float64_out.ptr[2] == -INFINITY && list_float64_out.ptr[3] == INFINITY); + imports_list_float32_free(&list_float32_out); + imports_list_float64_free(&list_float64_out); } } diff --git a/tests/runtime/numbers/exports.wit b/tests/runtime/numbers/exports.wit index a8f7ea46d..08e4979f5 100644 --- a/tests/runtime/numbers/exports.wit +++ b/tests/runtime/numbers/exports.wit @@ -8,8 +8,8 @@ roundtrip-u32: function(a: u32) -> u32 roundtrip-s32: function(a: s32) -> s32 roundtrip-u64: function(a: u64) -> u64 roundtrip-s64: function(a: s64) -> s64 -roundtrip-f32: function(a: f32) -> f32 -roundtrip-f64: function(a: f64) -> f64 +roundtrip-float32: function(a: float32) -> float32 +roundtrip-float64: function(a: float64) -> float64 roundtrip-char: function(a: char) -> char set-scalar: function(a: u32) diff --git a/tests/runtime/numbers/host.py b/tests/runtime/numbers/host.py index ec523f3d7..283aaf091 100644 --- a/tests/runtime/numbers/host.py +++ b/tests/runtime/numbers/host.py @@ -29,10 +29,10 @@ def roundtrip_u64(self, a: int) -> int: def roundtrip_s64(self, a: int) -> int: return a - def roundtrip_f32(self, a: float) -> float: + def roundtrip_float32(self, a: float) -> float: return a - def roundtrip_f64(self, a: float) -> float: + def roundtrip_float64(self, a: float) -> float: return a def roundtrip_char(self, a: str) -> str: @@ -83,15 +83,15 @@ def run(wasm_file: str) -> None: assert(wasm.roundtrip_s64(store, -(1 << (64 - 1))) == -(1 << (64 - 1))) inf = float('inf') - assert(wasm.roundtrip_f32(store, 1.0) == 1.0) - assert(wasm.roundtrip_f32(store, inf) == inf) - assert(wasm.roundtrip_f32(store, -inf) == -inf) - assert(math.isnan(wasm.roundtrip_f32(store, float('nan')))) - - assert(wasm.roundtrip_f64(store, 1.0) == 1.0) - assert(wasm.roundtrip_f64(store, inf) == inf) - assert(wasm.roundtrip_f64(store, -inf) == -inf) - assert(math.isnan(wasm.roundtrip_f64(store, float('nan')))) + assert(wasm.roundtrip_float32(store, 1.0) == 1.0) + assert(wasm.roundtrip_float32(store, inf) == inf) + assert(wasm.roundtrip_float32(store, -inf) == -inf) + assert(math.isnan(wasm.roundtrip_float32(store, float('nan')))) + + assert(wasm.roundtrip_float64(store, 1.0) == 1.0) + assert(wasm.roundtrip_float64(store, inf) == inf) + assert(wasm.roundtrip_float64(store, -inf) == -inf) + assert(math.isnan(wasm.roundtrip_float64(store, float('nan')))) assert(wasm.roundtrip_char(store, 'a') == 'a') assert(wasm.roundtrip_char(store, ' ') == ' ') diff --git a/tests/runtime/numbers/host.rs b/tests/runtime/numbers/host.rs index 1137fe2a7..472f719e6 100644 --- a/tests/runtime/numbers/host.rs +++ b/tests/runtime/numbers/host.rs @@ -40,11 +40,11 @@ impl imports::Imports for MyImports { val } - fn roundtrip_f32(&mut self, val: f32) -> f32 { + fn roundtrip_float32(&mut self, val: f32) -> f32 { val } - fn roundtrip_f64(&mut self, val: f64) -> f64 { + fn roundtrip_float64(&mut self, val: f64) -> f64 { val } @@ -153,27 +153,27 @@ fn run(wasm: &str) -> Result<()> { i64::max_value() ); - assert_eq!(exports.roundtrip_f32(&mut store, 1.0)?, 1.0); + assert_eq!(exports.roundtrip_float32(&mut store, 1.0)?, 1.0); assert_eq!( - exports.roundtrip_f32(&mut store, f32::INFINITY)?, + exports.roundtrip_float32(&mut store, f32::INFINITY)?, f32::INFINITY ); assert_eq!( - exports.roundtrip_f32(&mut store, f32::NEG_INFINITY)?, + exports.roundtrip_float32(&mut store, f32::NEG_INFINITY)?, f32::NEG_INFINITY ); - assert!(exports.roundtrip_f32(&mut store, f32::NAN)?.is_nan()); + assert!(exports.roundtrip_float32(&mut store, f32::NAN)?.is_nan()); - assert_eq!(exports.roundtrip_f64(&mut store, 1.0)?, 1.0); + assert_eq!(exports.roundtrip_float64(&mut store, 1.0)?, 1.0); assert_eq!( - exports.roundtrip_f64(&mut store, f64::INFINITY)?, + exports.roundtrip_float64(&mut store, f64::INFINITY)?, f64::INFINITY ); assert_eq!( - exports.roundtrip_f64(&mut store, f64::NEG_INFINITY)?, + exports.roundtrip_float64(&mut store, f64::NEG_INFINITY)?, f64::NEG_INFINITY ); - assert!(exports.roundtrip_f64(&mut store, f64::NAN)?.is_nan()); + assert!(exports.roundtrip_float64(&mut store, f64::NAN)?.is_nan()); assert_eq!(exports.roundtrip_char(&mut store, 'a')?, 'a'); assert_eq!(exports.roundtrip_char(&mut store, ' ')?, ' '); diff --git a/tests/runtime/numbers/host.ts b/tests/runtime/numbers/host.ts index 26e14b33a..2913de2b6 100644 --- a/tests/runtime/numbers/host.ts +++ b/tests/runtime/numbers/host.ts @@ -24,8 +24,8 @@ async function run() { roundtripS32(x) { return x; }, roundtripU64(x) { return x; }, roundtripS64(x) { return x; }, - roundtripF32(x) { return x; }, - roundtripF64(x) { return x; }, + roundtripFloat32(x) { return x; }, + roundtripFloat64(x) { return x; }, roundtripChar(x) { return x; }, setScalar(x) { scalar = x; }, getScalar() { return scalar; }, @@ -66,15 +66,15 @@ async function run() { assertEq(wasm.roundtripS64((1n << 63n) - 1n), (1n << 63n) - 1n); assertEq(wasm.roundtripS64(-(1n << 63n)), -(1n << 63n)); - assertEq(wasm.roundtripF32(1), 1); - assertEq(wasm.roundtripF32(Infinity), Infinity); - assertEq(wasm.roundtripF32(-Infinity), -Infinity); - assert(Number.isNaN(wasm.roundtripF32(NaN))); + assertEq(wasm.roundtripFloat32(1), 1); + assertEq(wasm.roundtripFloat32(Infinity), Infinity); + assertEq(wasm.roundtripFloat32(-Infinity), -Infinity); + assert(Number.isNaN(wasm.roundtripFloat32(NaN))); - assertEq(wasm.roundtripF64(1), 1); - assertEq(wasm.roundtripF64(Infinity), Infinity); - assertEq(wasm.roundtripF64(-Infinity), -Infinity); - assert(Number.isNaN(wasm.roundtripF64(NaN))); + assertEq(wasm.roundtripFloat64(1), 1); + assertEq(wasm.roundtripFloat64(Infinity), Infinity); + assertEq(wasm.roundtripFloat64(-Infinity), -Infinity); + assert(Number.isNaN(wasm.roundtripFloat64(NaN))); assertEq(wasm.roundtripChar('a'), 'a'); assertEq(wasm.roundtripChar(' '), ' '); diff --git a/tests/runtime/numbers/imports.wit b/tests/runtime/numbers/imports.wit index 0f1c04ad7..66590714d 100644 --- a/tests/runtime/numbers/imports.wit +++ b/tests/runtime/numbers/imports.wit @@ -6,8 +6,8 @@ roundtrip-u32: function(a: u32) -> u32 roundtrip-s32: function(a: s32) -> s32 roundtrip-u64: function(a: u64) -> u64 roundtrip-s64: function(a: s64) -> s64 -roundtrip-f32: function(a: f32) -> f32 -roundtrip-f64: function(a: f64) -> f64 +roundtrip-float32: function(a: float32) -> float32 +roundtrip-float64: function(a: float64) -> float64 roundtrip-char: function(a: char) -> char set-scalar: function(a: u32) diff --git a/tests/runtime/numbers/wasm.c b/tests/runtime/numbers/wasm.c index 94b438504..e373aff5a 100644 --- a/tests/runtime/numbers/wasm.c +++ b/tests/runtime/numbers/wasm.c @@ -36,11 +36,11 @@ int64_t exports_roundtrip_s64(int64_t a) { return a; } -float exports_roundtrip_f32(float a) { +float exports_roundtrip_float32(float a) { return a; } -double exports_roundtrip_f64(double a) { +double exports_roundtrip_float64(double a) { return a; } @@ -92,15 +92,15 @@ void exports_test_imports() { assert(imports_roundtrip_s64(LONG_MIN) == LONG_MIN); assert(imports_roundtrip_s64(LONG_MAX) == LONG_MAX); - assert(imports_roundtrip_f32(1.0) == 1.0); - assert(imports_roundtrip_f32(INFINITY) == INFINITY); - assert(imports_roundtrip_f32(-INFINITY) == -INFINITY); - assert(isnan(imports_roundtrip_f32(NAN))); + assert(imports_roundtrip_float32(1.0) == 1.0); + assert(imports_roundtrip_float32(INFINITY) == INFINITY); + assert(imports_roundtrip_float32(-INFINITY) == -INFINITY); + assert(isnan(imports_roundtrip_float32(NAN))); - assert(imports_roundtrip_f64(1.0) == 1.0); - assert(imports_roundtrip_f64(INFINITY) == INFINITY); - assert(imports_roundtrip_f64(-INFINITY) == -INFINITY); - assert(isnan(imports_roundtrip_f64(NAN))); + assert(imports_roundtrip_float64(1.0) == 1.0); + assert(imports_roundtrip_float64(INFINITY) == INFINITY); + assert(imports_roundtrip_float64(-INFINITY) == -INFINITY); + assert(isnan(imports_roundtrip_float64(NAN))); assert(imports_roundtrip_char('a') == 'a'); assert(imports_roundtrip_char(' ') == ' '); diff --git a/tests/runtime/numbers/wasm.rs b/tests/runtime/numbers/wasm.rs index 6ad384172..bd5342ae8 100644 --- a/tests/runtime/numbers/wasm.rs +++ b/tests/runtime/numbers/wasm.rs @@ -42,15 +42,15 @@ impl exports::Exports for Exports { assert_eq!(roundtrip_s64(i64::min_value()), i64::min_value()); assert_eq!(roundtrip_s64(i64::max_value()), i64::max_value()); - assert_eq!(roundtrip_f32(1.0), 1.0); - assert_eq!(roundtrip_f32(f32::INFINITY), f32::INFINITY); - assert_eq!(roundtrip_f32(f32::NEG_INFINITY), f32::NEG_INFINITY); - assert!(roundtrip_f32(f32::NAN).is_nan()); + assert_eq!(roundtrip_float32(1.0), 1.0); + assert_eq!(roundtrip_float32(f32::INFINITY), f32::INFINITY); + assert_eq!(roundtrip_float32(f32::NEG_INFINITY), f32::NEG_INFINITY); + assert!(roundtrip_float32(f32::NAN).is_nan()); - assert_eq!(roundtrip_f64(1.0), 1.0); - assert_eq!(roundtrip_f64(f64::INFINITY), f64::INFINITY); - assert_eq!(roundtrip_f64(f64::NEG_INFINITY), f64::NEG_INFINITY); - assert!(roundtrip_f64(f64::NAN).is_nan()); + assert_eq!(roundtrip_float64(1.0), 1.0); + assert_eq!(roundtrip_float64(f64::INFINITY), f64::INFINITY); + assert_eq!(roundtrip_float64(f64::NEG_INFINITY), f64::NEG_INFINITY); + assert!(roundtrip_float64(f64::NAN).is_nan()); assert_eq!(roundtrip_char('a'), 'a'); assert_eq!(roundtrip_char(' '), ' '); @@ -94,11 +94,11 @@ impl exports::Exports for Exports { a } - fn roundtrip_f32(a: f32) -> f32 { + fn roundtrip_float32(a: f32) -> f32 { a } - fn roundtrip_f64(a: f64) -> f64 { + fn roundtrip_float64(a: f64) -> f64 { a } diff --git a/tests/runtime/variants/exports.wit b/tests/runtime/variants/exports.wit index 9a3c944e6..cf2eee779 100644 --- a/tests/runtime/variants/exports.wit +++ b/tests/runtime/variants/exports.wit @@ -1,7 +1,7 @@ test-imports: function() -roundtrip-option: function(a: option) -> option -roundtrip-result: function(a: expected) -> expected +roundtrip-option: function(a: option) -> option +roundtrip-result: function(a: expected) -> expected enum e1 { a, b } roundtrip-enum: function(a: e1) -> e1 @@ -9,18 +9,18 @@ roundtrip-enum: function(a: e1) -> e1 invert-bool: function(a: bool) -> bool variant c1 { a(s32), b(s64) } -variant c2 { a(s32), b(f32) } -variant c3 { a(s32), b(f64) } -variant c4 { a(s64), b(f32) } -variant c5 { a(s64), b(f64) } -variant c6 { a(f32), b(f64) } +variant c2 { a(s32), b(float32) } +variant c3 { a(s32), b(float64) } +variant c4 { a(s64), b(float32) } +variant c5 { a(s64), b(float64) } +variant c6 { a(float32), b(float64) } type casts = tuple variant-casts: function(a: casts) -> casts variant z1 { a(s32), b } variant z2 { a(s64), b } -variant z3 { a(f32), b } -variant z4 { a(f64), b } +variant z3 { a(float32), b } +variant z4 { a(float64), b } type zeros = tuple variant-zeros: function(a: zeros) -> zeros diff --git a/tests/runtime/variants/imports.wit b/tests/runtime/variants/imports.wit index 2df70c8ac..3d854927f 100644 --- a/tests/runtime/variants/imports.wit +++ b/tests/runtime/variants/imports.wit @@ -1,5 +1,5 @@ -roundtrip-option: function(a: option) -> option -roundtrip-result: function(a: expected) -> expected +roundtrip-option: function(a: option) -> option +roundtrip-result: function(a: expected) -> expected enum e1 { a, b } roundtrip-enum: function(a: e1) -> e1 @@ -7,18 +7,18 @@ roundtrip-enum: function(a: e1) -> e1 invert-bool: function(a: bool) -> bool variant c1 { a(s32), b(s64) } -variant c2 { a(s32), b(f32) } -variant c3 { a(s32), b(f64) } -variant c4 { a(s64), b(f32) } -variant c5 { a(s64), b(f64) } -variant c6 { a(f32), b(f64) } +variant c2 { a(s32), b(float32) } +variant c3 { a(s32), b(float64) } +variant c4 { a(s64), b(float32) } +variant c5 { a(s64), b(float64) } +variant c6 { a(float32), b(float64) } type casts = tuple variant-casts: function(a: casts) -> casts variant z1 { a(s32), b } variant z2 { a(s64), b } -variant z3 { a(f32), b } -variant z4 { a(f64), b } +variant z3 { a(float32), b } +variant z4 { a(float64), b } type zeros = tuple variant-zeros: function(a: zeros) -> zeros diff --git a/tests/runtime/variants/wasm.c b/tests/runtime/variants/wasm.c index 6eee6ea1d..015ff1aee 100644 --- a/tests/runtime/variants/wasm.c +++ b/tests/runtime/variants/wasm.c @@ -4,7 +4,7 @@ void exports_test_imports() { { - imports_option_f32_t a; + imports_option_float32_t a; uint8_t r; a.tag = 1; a.val = 1; @@ -19,8 +19,8 @@ void exports_test_imports() { { - imports_expected_u32_f32_t a; - imports_expected_f64_u8_t b; + imports_expected_u32_float32_t a; + imports_expected_float64_u8_t b; a.tag = 0; a.val.ok = 2; @@ -162,14 +162,14 @@ void exports_test_imports() { } } -bool exports_roundtrip_option(exports_option_f32_t *a, uint8_t *ret0) { +bool exports_roundtrip_option(exports_option_float32_t *a, uint8_t *ret0) { if (a->tag) { *ret0 = a->val; } return a->tag; } -void exports_roundtrip_result(exports_expected_u32_f32_t *a, exports_expected_f64_u8_t *ret0) { +void exports_roundtrip_result(exports_expected_u32_float32_t *a, exports_expected_float64_u8_t *ret0) { ret0->tag = a->tag; if (a->tag == 0) { ret0->val.ok = a->val.ok; From eb4dd520274a6577e367182da803e8523bd3ead1 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 20 Apr 2022 08:18:30 -0700 Subject: [PATCH 2/2] Fix a test --- crates/wasmlink/tests/not-adapted.baseline | 10 +++++----- crates/wasmlink/tests/not-adapted.wit | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/wasmlink/tests/not-adapted.baseline b/crates/wasmlink/tests/not-adapted.baseline index 54922eb4f..5be762a28 100644 --- a/crates/wasmlink/tests/not-adapted.baseline +++ b/crates/wasmlink/tests/not-adapted.baseline @@ -1,5 +1,5 @@ -no type named `f32` - --> tests/not-adapted.wit:1:33 - | - 1 | f1: function(a: s32, b: s64, c: f32, d: f64) -> u32 - | ^-- \ No newline at end of file +(module + (type (;0;) (func (param i32 i64 f32 f64) (result i32))) + (func (;0;) (type 0) (param i32 i64 f32 f64) (result i32) + unreachable) + (export "f1" (func 0))) \ No newline at end of file diff --git a/crates/wasmlink/tests/not-adapted.wit b/crates/wasmlink/tests/not-adapted.wit index d1847266a..c34f434a4 100644 --- a/crates/wasmlink/tests/not-adapted.wit +++ b/crates/wasmlink/tests/not-adapted.wit @@ -1 +1 @@ -f1: function(a: s32, b: s64, c: f32, d: f64) -> u32 \ No newline at end of file +f1: function(a: s32, b: s64, c: float32, d: float64) -> u32