@@ -368,6 +368,7 @@ impl Interpreter {
368
368
369
369
context. contribute_arg ( Argument :: Object ( Arc :: new ( Object :: Integer ( typ) ) ) ) ;
370
370
}
371
+ Opcode :: SizeOf => self . do_size_of ( & mut context, op) ?,
371
372
_ => panic ! ( "Unexpected operation has created in-flight op!" ) ,
372
373
}
373
374
}
@@ -782,7 +783,7 @@ impl Interpreter {
782
783
Opcode :: DerefOf => todo ! ( ) ,
783
784
Opcode :: ConcatRes => todo ! ( ) ,
784
785
Opcode :: Notify => todo ! ( ) ,
785
- Opcode :: SizeOf => todo ! ( ) ,
786
+ Opcode :: SizeOf => context . start_in_flight_op ( OpInFlight :: new ( opcode , 1 ) ) ,
786
787
Opcode :: Index => todo ! ( ) ,
787
788
Opcode :: Match => todo ! ( ) ,
788
789
@@ -957,6 +958,21 @@ impl Interpreter {
957
958
context. contribute_arg ( Argument :: Object ( Arc :: new ( result) ) ) ;
958
959
Ok ( ( ) )
959
960
}
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
+ }
960
976
fn do_store (
961
977
& self ,
962
978
context : & mut MethodContext ,
0 commit comments