@@ -368,6 +368,7 @@ impl Interpreter {
368368
369369 context. contribute_arg ( Argument :: Object ( Arc :: new ( Object :: Integer ( typ) ) ) ) ;
370370 }
371+ Opcode :: SizeOf => self . do_size_of ( & mut context, op) ?,
371372 _ => panic ! ( "Unexpected operation has created in-flight op!" ) ,
372373 }
373374 }
@@ -782,7 +783,7 @@ impl Interpreter {
782783 Opcode :: DerefOf => todo ! ( ) ,
783784 Opcode :: ConcatRes => todo ! ( ) ,
784785 Opcode :: Notify => todo ! ( ) ,
785- Opcode :: SizeOf => todo ! ( ) ,
786+ Opcode :: SizeOf => context . start_in_flight_op ( OpInFlight :: new ( opcode , 1 ) ) ,
786787 Opcode :: Index => todo ! ( ) ,
787788 Opcode :: Match => todo ! ( ) ,
788789
@@ -957,6 +958,21 @@ impl Interpreter {
957958 context. contribute_arg ( Argument :: Object ( Arc :: new ( result) ) ) ;
958959 Ok ( ( ) )
959960 }
961+
962+ fn do_size_of ( & self , context : & mut MethodContext , op : OpInFlight ) -> Result < ( ) , AmlError > {
963+ let [ Argument :: Object ( object) ] = & op. arguments [ ..] else { Err ( AmlError :: InvalidOperationOnObject ) ? } ;
964+ let object = object. clone ( ) . unwrap_reference ( ) ;
965+
966+ let result = match * object {
967+ Object :: Buffer ( ref buffer) => buffer. len ( ) ,
968+ Object :: String ( ref str) => str. len ( ) ,
969+ Object :: Package ( ref package) => package. len ( ) ,
970+ _ => Err ( AmlError :: InvalidOperationOnObject ) ?,
971+ } ;
972+
973+ context. contribute_arg ( Argument :: Object ( Arc :: new ( Object :: Integer ( result as u64 ) ) ) ) ;
974+ Ok ( ( ) )
975+ }
960976 fn do_store (
961977 & self ,
962978 context : & mut MethodContext ,
0 commit comments