@@ -312,6 +312,24 @@ where
312312 let [ Argument :: Object ( object) , target] = & op. arguments [ ..] else { panic ! ( ) } ;
313313 self . do_store ( & mut context, & target, object. clone ( ) ) ?;
314314 }
315+ Opcode :: RefOf => {
316+ let [ Argument :: Object ( object) ] = & op. arguments [ ..] else { panic ! ( ) } ;
317+ let reference =
318+ Arc :: new ( Object :: Reference { kind : ReferenceKind :: RefOf , inner : object. clone ( ) } ) ;
319+ context. contribute_arg ( Argument :: Object ( reference) ) ;
320+ }
321+ Opcode :: CondRefOf => {
322+ let [ Argument :: Object ( object) , target] = & op. arguments [ ..] else { panic ! ( ) } ;
323+ let result = if let Object :: Reference { kind : ReferenceKind :: Unresolved , .. } = * * object {
324+ Object :: Integer ( 0 )
325+ } else {
326+ let reference =
327+ Arc :: new ( Object :: Reference { kind : ReferenceKind :: RefOf , inner : object. clone ( ) } ) ;
328+ self . do_store ( & mut context, target, reference) ?;
329+ Object :: Integer ( u64:: MAX )
330+ } ;
331+ context. contribute_arg ( Argument :: Object ( Arc :: new ( result) ) ) ;
332+ }
315333 Opcode :: Sleep => {
316334 let [ Argument :: Object ( msec) ] = & op. arguments [ ..] else { panic ! ( ) } ;
317335 self . handler . sleep ( msec. as_integer ( ) ?) ;
@@ -642,7 +660,6 @@ where
642660 let name = name. resolve ( & context. current_scope ) ?;
643661 self . namespace . lock ( ) . insert ( name, Arc :: new ( Object :: Event ) ) ?;
644662 }
645- Opcode :: CondRefOf => todo ! ( ) ,
646663 Opcode :: LoadTable => todo ! ( ) ,
647664 Opcode :: Load => todo ! ( ) ,
648665 Opcode :: Stall => context. start_in_flight_op ( OpInFlight :: new ( Opcode :: Stall , 1 ) ) ,
@@ -798,7 +815,8 @@ where
798815 } ) ) ) ;
799816 }
800817 Opcode :: Store => context. start_in_flight_op ( OpInFlight :: new ( Opcode :: Store , 2 ) ) ,
801- Opcode :: RefOf => todo ! ( ) ,
818+ Opcode :: RefOf => context. start_in_flight_op ( OpInFlight :: new ( Opcode :: RefOf , 1 ) ) ,
819+ Opcode :: CondRefOf => context. start_in_flight_op ( OpInFlight :: new ( opcode, 2 ) ) ,
802820
803821 Opcode :: DualNamePrefix
804822 | Opcode :: MultiNamePrefix
@@ -822,7 +840,9 @@ where
822840 }
823841 }
824842 Err ( AmlError :: ObjectDoesNotExist ( _) ) => {
825- if context. current_block . kind == BlockKind :: Package {
843+ let allow_unresolved = context. current_block . kind == BlockKind :: Package
844+ || context. in_flight . last ( ) . map ( |op| op. op == Opcode :: CondRefOf ) . unwrap_or ( false ) ;
845+ if allow_unresolved {
826846 let reference = Object :: Reference {
827847 kind : ReferenceKind :: Unresolved ,
828848 inner : Arc :: new ( Object :: String ( name. to_string ( ) ) ) ,
0 commit comments