diff --git a/tests/wasm_poc2_box_operations.rs b/tests/archive/wasm_poc2_box_operations.rs similarity index 100% rename from tests/wasm_poc2_box_operations.rs rename to tests/archive/wasm_poc2_box_operations.rs diff --git a/tests/mir_phase6_vm_ref_ops.rs b/tests/mir_phase6_vm_ref_ops.rs index fd1c09fc..bc0d93a0 100644 --- a/tests/mir_phase6_vm_ref_ops.rs +++ b/tests/mir_phase6_vm_ref_ops.rs @@ -6,10 +6,10 @@ use nyash_rust::mir::{ MirModule, MirFunction, FunctionSignature, MirType, EffectMask, - BasicBlock, BasicBlockId, ValueId, MirInstruction, ConstValue + BasicBlock, BasicBlockId, ValueId, MirInstruction, ConstValue, AtomicOrdering }; -use nyash_rust::backend::{VM, VMValue}; -use nyash_rust::box_trait::{IntegerBox, NyashBox}; +use nyash_rust::backend::VM; +use nyash_rust::box_trait::IntegerBox; #[test] fn test_mir_phase6_vm_ref_ops() { @@ -45,6 +45,7 @@ fn test_mir_phase6_vm_ref_ops() { let obj_ref = ValueId::new(1); let one_val = ValueId::new(2); let x_val = ValueId::new(3); + let print_func = ValueId::new(4); // Add instructions @@ -54,10 +55,18 @@ fn test_mir_phase6_vm_ref_ops() { value: ConstValue::String("Obj".to_string()), }); - // %1 = ref_new %0 - block.add_instruction(MirInstruction::RefNew { + // %4 = const "@print" (for intrinsic call) + block.add_instruction(MirInstruction::Const { + dst: print_func, + value: ConstValue::String("@print".to_string()), + }); + + // %1 = new Obj() + // Phase 5: RefNew is deprecated - use NewBox instead + block.add_instruction(MirInstruction::NewBox { dst: obj_ref, - box_val: obj_type_val, + box_type: "Obj".to_string(), + args: vec![], }); // %2 = const 1 @@ -66,28 +75,34 @@ fn test_mir_phase6_vm_ref_ops() { value: ConstValue::Integer(1), }); - // barrier_write %1 - block.add_instruction(MirInstruction::BarrierWrite { - ptr: obj_ref, + // atomic_fence release + // Phase 5: BarrierWrite is deprecated - use AtomicFence instead + block.add_instruction(MirInstruction::AtomicFence { + ordering: AtomicOrdering::Release, }); - // ref_set %1, "x", %2 - block.add_instruction(MirInstruction::RefSet { - reference: obj_ref, + // %1.x = %2 + // Phase 5: RefSet is deprecated - use BoxFieldStore instead + block.add_instruction(MirInstruction::BoxFieldStore { + box_val: obj_ref, field: "x".to_string(), value: one_val, }); - // %3 = ref_get %1, "x" - block.add_instruction(MirInstruction::RefGet { + // %3 = %1.x + // Phase 5: RefGet is deprecated - use BoxFieldLoad instead + block.add_instruction(MirInstruction::BoxFieldLoad { dst: x_val, - reference: obj_ref, + box_val: obj_ref, field: "x".to_string(), }); - // print %3 - block.add_instruction(MirInstruction::Print { - value: x_val, + // call @print(%3) + // Phase 5: Print is deprecated - use Call @print instead + block.add_instruction(MirInstruction::Call { + dst: None, + func: print_func, + args: vec![x_val], effects: EffectMask::IO, }); @@ -168,13 +183,14 @@ fn test_barrier_no_op() { value: ConstValue::Integer(42), }); - // Test barrier instructions (should be no-ops) - block.add_instruction(MirInstruction::BarrierRead { - ptr: test_val, + // Test atomic fence instructions (replace barriers) + // Phase 5: BarrierRead/BarrierWrite are deprecated - use AtomicFence + block.add_instruction(MirInstruction::AtomicFence { + ordering: AtomicOrdering::Acquire, }); - block.add_instruction(MirInstruction::BarrierWrite { - ptr: test_val, + block.add_instruction(MirInstruction::AtomicFence { + ordering: AtomicOrdering::Release, }); block.add_instruction(MirInstruction::Return { diff --git a/tests/mir_phase7_async_ops.rs b/tests/mir_phase7_async_ops.rs index 32e94f63..45cc5ed7 100644 --- a/tests/mir_phase7_async_ops.rs +++ b/tests/mir_phase7_async_ops.rs @@ -107,17 +107,17 @@ fn test_mir_phase7_basic_nowait_await() { .flat_map(|block| &block.instructions) .collect(); - // Should contain FutureNew instruction - let has_future_new = instructions.iter().any(|inst| { - matches!(inst, nyash_rust::mir::MirInstruction::FutureNew { .. }) + // Phase 5: FutureNew is deprecated - should contain NewBox "FutureBox" instead + let has_future_box = instructions.iter().any(|inst| { + matches!(inst, nyash_rust::mir::MirInstruction::NewBox { box_type, .. } if box_type == "FutureBox") }); - assert!(has_future_new, "MIR should contain FutureNew instruction"); + assert!(has_future_box, "MIR should contain NewBox FutureBox instruction"); - // Should contain Await instruction - let has_await = instructions.iter().any(|inst| { - matches!(inst, nyash_rust::mir::MirInstruction::Await { .. }) + // Phase 5: Await is deprecated - should contain BoxCall "await" instead + let has_await_call = instructions.iter().any(|inst| { + matches!(inst, nyash_rust::mir::MirInstruction::BoxCall { method, .. } if method == "await") }); - assert!(has_await, "MIR should contain Await instruction"); + assert!(has_await_call, "MIR should contain BoxCall await instruction"); // Test VM execution let mut vm = VM::new();