1+ use core:: ops:: { BitAnd , BitOr , BitXor } ;
2+
13use super :: { DefaultRuntime , Stack } ;
24use crate :: {
35 get_label_args,
@@ -10,7 +12,9 @@ use log::info;
1012use tinywasm_types:: Instruction ;
1113
1214mod macros;
15+ mod traits;
1316use macros:: * ;
17+ use traits:: * ;
1418
1519impl DefaultRuntime {
1620 pub ( crate ) fn exec ( & self , store : & mut Store , stack : & mut Stack , module : ModuleInstance ) -> Result < ( ) > {
@@ -311,10 +315,19 @@ fn exec_one(
311315 I32DivU => checked_arithmetic_method_cast ! ( checked_div, i32 , u32 , stack, crate :: Trap :: DivisionByZero ) ,
312316 I64DivU => checked_arithmetic_method_cast ! ( checked_div, i64 , u64 , stack, crate :: Trap :: DivisionByZero ) ,
313317
314- I32RemS => checked_arithmetic_method ! ( checked_rem, i32 , stack, crate :: Trap :: DivisionByZero ) ,
315- I64RemS => checked_arithmetic_method ! ( checked_rem, i64 , stack, crate :: Trap :: DivisionByZero ) ,
316- I32RemU => checked_arithmetic_method_cast ! ( checked_rem, i32 , u32 , stack, crate :: Trap :: DivisionByZero ) ,
317- I64RemU => checked_arithmetic_method_cast ! ( checked_rem, i64 , u64 , stack, crate :: Trap :: DivisionByZero ) ,
318+ I32RemS => checked_arithmetic_method ! ( checked_wrapping_rem, i32 , stack, crate :: Trap :: DivisionByZero ) ,
319+ I64RemS => checked_arithmetic_method ! ( checked_wrapping_rem, i64 , stack, crate :: Trap :: DivisionByZero ) ,
320+ I32RemU => checked_arithmetic_method_cast ! ( checked_wrapping_rem, i32 , u32 , stack, crate :: Trap :: DivisionByZero ) ,
321+ I64RemU => checked_arithmetic_method_cast ! ( checked_wrapping_rem, i64 , u64 , stack, crate :: Trap :: DivisionByZero ) ,
322+
323+ I32And => arithmetic_method ! ( bitand, i32 , stack) ,
324+ I64And => arithmetic_method ! ( bitand, i64 , stack) ,
325+ I32Or => arithmetic_method ! ( bitor, i32 , stack) ,
326+ I64Or => arithmetic_method ! ( bitor, i64 , stack) ,
327+ I32Xor => arithmetic_method ! ( bitxor, i32 , stack) ,
328+ I64Xor => arithmetic_method ! ( bitxor, i64 , stack) ,
329+ I32Shl => arithmetic_method ! ( shl_i32, i32 , stack) ,
330+ I64Shl => arithmetic_method ! ( shl_i64, i64 , stack) ,
318331
319332 F32ConvertI32S => conv_1 ! ( i32 , f32 , stack) ,
320333 F32ConvertI64S => conv_1 ! ( i64 , f32 , stack) ,
0 commit comments