Skip to content
This repository was archived by the owner on Oct 3, 2025. It is now read-only.

Commit 28b8a55

Browse files
chore: add ref instructions
Signed-off-by: Henry <mail@henrygressmann.de>
1 parent 1041182 commit 28b8a55

File tree

5 files changed

+27
-11
lines changed

5 files changed

+27
-11
lines changed

crates/parser/src/conversion.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,9 @@ pub(crate) fn process_const_operators(ops: OperatorsReader) -> Result<ConstInstr
296296

297297
pub fn process_const_operator(op: wasmparser::Operator) -> Result<ConstInstruction> {
298298
match op {
299+
wasmparser::Operator::RefNull { ty } => Ok(ConstInstruction::RefNull(convert_valtype(&ty))),
300+
wasmparser::Operator::RefFunc { function_index } => Ok(ConstInstruction::RefFunc(function_index)),
301+
299302
wasmparser::Operator::I32Const { value } => Ok(ConstInstruction::I32Const(value)),
300303
wasmparser::Operator::I64Const { value } => Ok(ConstInstruction::I64Const(value)),
301304
wasmparser::Operator::F32Const { value } => Ok(ConstInstruction::F32Const(f32::from_bits(value.bits()))), // TODO: check if this is correct
@@ -414,12 +417,15 @@ pub fn process_operators<'a>(
414417
LocalTee { local_index } => Instruction::LocalTee(local_index),
415418
GlobalGet { global_index } => Instruction::GlobalGet(global_index),
416419
GlobalSet { global_index } => Instruction::GlobalSet(global_index),
417-
MemorySize { .. } => Instruction::MemorySize,
418-
MemoryGrow { .. } => Instruction::MemoryGrow,
420+
MemorySize { mem, mem_byte } => Instruction::MemorySize(mem, mem_byte),
421+
MemoryGrow { mem, mem_byte } => Instruction::MemoryGrow(mem, mem_byte),
419422
I32Const { value } => Instruction::I32Const(value),
420423
I64Const { value } => Instruction::I64Const(value),
421-
F32Const { value } => Instruction::F32Const(f32::from_bits(value.bits())), // TODO: check if this is correct
422-
F64Const { value } => Instruction::F64Const(f64::from_bits(value.bits())), // TODO: check if this is correct
424+
F32Const { value } => Instruction::F32Const(f32::from_bits(value.bits())),
425+
F64Const { value } => Instruction::F64Const(f64::from_bits(value.bits())),
426+
RefNull { ty } => Instruction::RefNull(convert_valtype(&ty)),
427+
RefIsNull => Instruction::RefIsNull,
428+
RefFunc { function_index } => Instruction::RefFunc(function_index),
423429
I32Load { memarg } => Instruction::I32Load(convert_memarg(memarg)),
424430
I64Load { memarg } => Instruction::I64Load(convert_memarg(memarg)),
425431
F32Load { memarg } => Instruction::F32Load(convert_memarg(memarg)),
@@ -580,10 +586,11 @@ pub fn process_operators<'a>(
580586
I64TruncSatF64S => Instruction::I64TruncSatF64S,
581587
I64TruncSatF64U => Instruction::I64TruncSatF64U,
582588
op => {
589+
log::error!("Unsupported instruction: {:?}", op);
583590
return Err(crate::ParseError::UnsupportedOperator(format!(
584591
"Unsupported instruction: {:?}",
585592
op
586-
)))
593+
)));
587594
}
588595
};
589596

0 commit comments

Comments
 (0)