@@ -517,24 +517,37 @@ where
517517 self . do_unary_maths ( & mut context, op) ?;
518518 }
519519 Opcode :: Increment | Opcode :: Decrement => {
520- let [ Argument :: Object ( operand) ] = & op . arguments [ .. ] else { panic ! ( ) } ;
520+ extract_args ! ( op => [ Argument :: Object ( operand) ] ) ;
521521 let operand = operand. clone ( ) . unwrap_reference ( ) ;
522522 let token = self . object_token . lock ( ) ;
523523
524- let Object :: Integer ( operand) = ( unsafe { operand. gain_mut ( & token) } ) else {
525- Err ( AmlError :: ObjectNotOfExpectedType {
526- expected : ObjectType :: Integer ,
527- got : operand. typ ( ) ,
528- } ) ?
524+ let operand = unsafe { operand. gain_mut ( & token) } ;
525+ let value = match operand {
526+ Object :: Integer ( operand) => {
527+ * operand
528+ }
529+ Object :: BufferField { ..} => {
530+ operand. to_integer ( self . integer_size ) ?
531+ }
532+ _ => Err ( AmlError :: ObjectNotOfExpectedType { expected : ObjectType :: Integer , got : operand. typ ( ) } ) ?
529533 } ;
530534
531535 let new_value = match op. op {
532- Opcode :: Increment => operand . wrapping_add ( 1 ) ,
533- Opcode :: Decrement => operand . wrapping_sub ( 1 ) ,
536+ Opcode :: Increment => value . wrapping_add ( 1 ) ,
537+ Opcode :: Decrement => value . wrapping_sub ( 1 ) ,
534538 _ => unreachable ! ( ) ,
535539 } ;
536540
537- * operand = new_value;
541+ match operand {
542+ Object :: Integer ( operand) => {
543+ * operand = new_value;
544+ }
545+ Object :: BufferField { ..} => {
546+ operand. write_buffer_field ( & new_value. to_le_bytes ( ) , & token) ?;
547+ }
548+ _ => unreachable ! ( )
549+ }
550+
538551 context. contribute_arg ( Argument :: Object ( Object :: Integer ( new_value) . wrap ( ) ) ) ;
539552 context. retire_op ( op) ;
540553 }
0 commit comments