(
&mut self,
_resolve: &Resolve,
inst: &Instruction<'_>,
operands: &mut Vec<String>,
results: &mut Vec<String>,
)
| 436 | type Operand = String; |
| 437 | |
| 438 | fn emit( |
| 439 | &mut self, |
| 440 | _resolve: &Resolve, |
| 441 | inst: &Instruction<'_>, |
| 442 | operands: &mut Vec<String>, |
| 443 | results: &mut Vec<String>, |
| 444 | ) { |
| 445 | match inst { |
| 446 | Instruction::GetArg { nth } => results.push(self.params[*nth].clone()), |
| 447 | Instruction::I32Const { val } => results.push(val.to_string()), |
| 448 | Instruction::ConstZero { tys } => results.extend(tys.iter().map(|ty| { |
| 449 | match ty { |
| 450 | WasmType::I32 => "0", |
| 451 | WasmType::I64 => "0L", |
| 452 | WasmType::F32 => "0.0F", |
| 453 | WasmType::F64 => "0.0D", |
| 454 | WasmType::Pointer => "0", |
| 455 | WasmType::PointerOrI64 => "0L", |
| 456 | WasmType::Length => "0", |
| 457 | } |
| 458 | .to_owned() |
| 459 | })), |
| 460 | Instruction::I32Load { offset } | Instruction::LengthLoad { offset } => { |
| 461 | results.push(format!( |
| 462 | "new global::System.Span<int>((void*)((byte*){} + {offset}), 1)[0]", |
| 463 | operands[0], |
| 464 | offset = offset.size_wasm32() |
| 465 | )) |
| 466 | } |
| 467 | Instruction::PointerLoad { offset } => results.push(format!( |
| 468 | "new global::System.Span<nint>((void*)((byte*){} + {offset}), 1)[0]", |
| 469 | operands[0], |
| 470 | offset = offset.size_wasm32() |
| 471 | )), |
| 472 | Instruction::I32Load8U { offset } => results.push(format!( |
| 473 | "new global::System.Span<byte>((byte*){} + {offset}, 1)[0]", |
| 474 | operands[0], |
| 475 | offset = offset.size_wasm32() |
| 476 | )), |
| 477 | Instruction::I32Load8S { offset } => results.push(format!( |
| 478 | "(sbyte)new global::System.Span<byte>((byte*){} + {offset}, 1)[0]", |
| 479 | operands[0], |
| 480 | offset = offset.size_wasm32() |
| 481 | )), |
| 482 | Instruction::I32Load16U { offset } => results.push(format!( |
| 483 | "new global::System.Span<ushort>((void*)((byte*){} + {offset}), 1)[0]", |
| 484 | operands[0], |
| 485 | offset = offset.size_wasm32() |
| 486 | )), |
| 487 | Instruction::I32Load16S { offset } => results.push(format!( |
| 488 | "new global::System.Span<short>((void*)((byte*){} + {offset}), 1)[0]", |
| 489 | operands[0], |
| 490 | offset = offset.size_wasm32() |
| 491 | )), |
| 492 | Instruction::I64Load { offset } => results.push(format!( |
| 493 | "new global::System.Span<long>((void*)((byte*){} + {offset}), 1)[0]", |
| 494 | operands[0], |
| 495 | offset = offset.size_wasm32() |
nothing calls this directly
no test coverage detected