@@ -497,24 +497,37 @@ where
497497 self . do_unary_maths ( & mut context, op) ?;
498498 }
499499 Opcode :: Increment | Opcode :: Decrement => {
500- let [ Argument :: Object ( operand) ] = & op . arguments [ .. ] else { panic ! ( ) } ;
500+ extract_args ! ( op => [ Argument :: Object ( operand) ] ) ;
501501 let operand = operand. clone ( ) . unwrap_transparent_reference ( ) ;
502502 let token = self . object_token . lock ( ) ;
503503
504- let Object :: Integer ( operand) = ( unsafe { operand. gain_mut ( & token) } ) else {
505- Err ( AmlError :: ObjectNotOfExpectedType {
506- expected : ObjectType :: Integer ,
507- got : operand. typ ( ) ,
508- } ) ?
504+ let operand = unsafe { operand. gain_mut ( & token) } ;
505+ let value = match operand {
506+ Object :: Integer ( operand) => {
507+ * operand
508+ }
509+ Object :: BufferField { ..} => {
510+ operand. to_integer ( self . integer_size ) ?
511+ }
512+ _ => Err ( AmlError :: ObjectNotOfExpectedType { expected : ObjectType :: Integer , got : operand. typ ( ) } ) ?
509513 } ;
510514
511515 let new_value = match op. op {
512- Opcode :: Increment => operand . wrapping_add ( 1 ) ,
513- Opcode :: Decrement => operand . wrapping_sub ( 1 ) ,
516+ Opcode :: Increment => value . wrapping_add ( 1 ) ,
517+ Opcode :: Decrement => value . wrapping_sub ( 1 ) ,
514518 _ => unreachable ! ( ) ,
515519 } ;
516520
517- * operand = new_value;
521+ match operand {
522+ Object :: Integer ( operand) => {
523+ * operand = new_value;
524+ }
525+ Object :: BufferField { ..} => {
526+ operand. write_buffer_field ( & new_value. to_le_bytes ( ) , & token) ?;
527+ }
528+ _ => unreachable ! ( )
529+ }
530+
518531 context. contribute_arg ( Argument :: Object ( Object :: Integer ( new_value) . wrap ( ) ) ) ;
519532 context. retire_op ( op) ;
520533 }
0 commit comments