-
Notifications
You must be signed in to change notification settings - Fork 245
Open
Labels
gen-c#Related to the C# code generatorRelated to the C# code generator
Description
Final nit, why we are doing the BitConverter.ToInt32 dance ?
this is coming from one of the other instructions that are generated via the wit-bindgen abi (
wit-bindgen/crates/csharp/src/function.rs
Lines 400 to 407 in 5d8fa61
| | Instruction::LengthLoad { offset } => results.push(format!("BitConverter.ToInt32(new Span<byte>((void*)({} + {offset}), 4))",operands[0])), | |
| Instruction::I32Load8U { offset } => results.push(format!("new Span<byte>((void*)({} + {offset}), 1)[0]",operands[0])), | |
| Instruction::I32Load8S { offset } => results.push(format!("(sbyte)new Span<byte>((void*)({} + {offset}), 1)[0]",operands[0])), | |
| Instruction::I32Load16U { offset } => results.push(format!("BitConverter.ToUInt16(new Span<byte>((void*)({} + {offset}), 2))",operands[0])), | |
| Instruction::I32Load16S { offset } => results.push(format!("BitConverter.ToInt16(new Span<byte>((void*)({} + {offset}), 2))",operands[0])), | |
| Instruction::I64Load { offset } => results.push(format!("BitConverter.ToInt64(new Span<byte>((void*)({} + {offset}), 8))",operands[0])), | |
| Instruction::F32Load { offset } => results.push(format!("BitConverter.ToSingle(new Span<byte>((void*)({} + {offset}), 4))",operands[0])), | |
| Instruction::F64Load { offset } => results.push(format!("BitConverter.ToDouble(new Span<byte>((void*)({} + {offset}), 8))",operands[0])), |
Maybe we don't need BitConverter.ToInt32 in other cases? Maybe that something else to clean up (in a separate pr)
Originally posted by @jsturtevant in #1145 (comment)
Metadata
Metadata
Assignees
Labels
gen-c#Related to the C# code generatorRelated to the C# code generator