@@ -1431,8 +1431,7 @@ where
1431
1431
} ;
1432
1432
1433
1433
let result = Object :: Integer ( result) . wrap ( ) ;
1434
- // TODO: use result for arg
1435
- self . do_store ( target, result. clone ( ) ) ?;
1434
+ let result = self . do_store ( target, result) ?;
1436
1435
context. contribute_arg ( Argument :: Object ( result) ) ;
1437
1436
context. retire_op ( op) ;
1438
1437
Ok ( ( ) )
@@ -1582,8 +1581,7 @@ where
1582
1581
}
1583
1582
. wrap ( ) ;
1584
1583
1585
- // TODO: use result of store
1586
- self . do_store ( target, result. clone ( ) ) ?;
1584
+ let result = self . do_store ( target, result) ?;
1587
1585
context. contribute_arg ( Argument :: Object ( result) ) ;
1588
1586
context. retire_op ( op) ;
1589
1587
Ok ( ( ) )
@@ -1627,8 +1625,7 @@ where
1627
1625
}
1628
1626
. wrap ( ) ;
1629
1627
1630
- // TODO: use result of store
1631
- self . do_store ( target, result. clone ( ) ) ?;
1628
+ let result = self . do_store ( target, result) ?;
1632
1629
context. contribute_arg ( Argument :: Object ( result) ) ;
1633
1630
context. retire_op ( op) ;
1634
1631
Ok ( ( ) )
@@ -1655,8 +1652,7 @@ where
1655
1652
}
1656
1653
. wrap ( ) ;
1657
1654
1658
- // TODO: use result of store
1659
- self . do_store ( target, result. clone ( ) ) ?;
1655
+ let result = self . do_store ( target, result) ?;
1660
1656
context. contribute_arg ( Argument :: Object ( result) ) ;
1661
1657
context. retire_op ( op) ;
1662
1658
Ok ( ( ) )
@@ -1698,8 +1694,7 @@ where
1698
1694
}
1699
1695
. wrap ( ) ;
1700
1696
1701
- // TODO: use result of store
1702
- self . do_store ( target, result. clone ( ) ) ?;
1697
+ let result = self . do_store ( target, result) ?;
1703
1698
context. contribute_arg ( Argument :: Object ( result) ) ;
1704
1699
context. retire_op ( op) ;
1705
1700
Ok ( ( ) )
@@ -1797,8 +1792,8 @@ where
1797
1792
Object :: String ( source1 + & source2) . wrap ( )
1798
1793
}
1799
1794
} ;
1800
- // TODO: use result of store
1801
- self . do_store ( target, result. clone ( ) ) ?;
1795
+
1796
+ let result = self . do_store ( target, result) ?;
1802
1797
context. contribute_arg ( Argument :: Object ( result) ) ;
1803
1798
context. retire_op ( op) ;
1804
1799
Ok ( ( ) )
@@ -1906,18 +1901,21 @@ where
1906
1901
Ok ( ( ) )
1907
1902
}
1908
1903
1909
- // TODO: this might actually do weird stuff to your data if written to a field with BufferAcc
1910
- // access. I guess we need to return something here really and use it instead of the result
1911
- // when returning?? We need to look carefully at all use-sites to make sure it actually returns
1912
- // the result of the store, not the object it passed to us.
1913
- fn do_store ( & self , target : & Argument , object : WrappedObject ) -> Result < ( ) , AmlError > {
1914
- // TODO: find the destination (need to handle references, debug objects, etc.)
1915
- // TODO: convert object to be of the type of destination, in line with 19.3.5 of the spec
1916
- // TODO: write the object to the destination, including e.g. field writes that then lead to
1917
- // literally god knows what.
1904
+ fn do_store ( & self , target : & Argument , object : WrappedObject ) -> Result < WrappedObject , AmlError > {
1918
1905
let object = object. unwrap_transparent_reference ( ) ;
1919
1906
let token = self . object_token . lock ( ) ;
1920
1907
1908
+ /*
1909
+ * TODO: stores should do more implicit conversion to the type of the destination in some
1910
+ * cases, in line with section 19.3.5 of the spec
1911
+ *
1912
+ * TODO: stores to fields with `BufferAcc` can actually return a value of the store that
1913
+ * differs from what was written into the field. This is used for complex field types with
1914
+ * a write-then-read pattern. The return value is then used as the 'result' of the storing
1915
+ * expression.
1916
+ */
1917
+ let to_return = object. clone ( ) ;
1918
+
1921
1919
match target {
1922
1920
Argument :: Object ( target) => match unsafe { target. gain_mut ( & * token) } {
1923
1921
Object :: Integer ( target) => match unsafe { object. gain_mut ( & * token) } {
@@ -1975,12 +1973,13 @@ where
1975
1973
_ => panic ! ( "Stores to objects like {:?} are not yet supported" , target) ,
1976
1974
} ,
1977
1975
1978
- Argument :: Namestring ( _) => { }
1976
+ Argument :: Namestring ( _) => todo ! ( ) ,
1979
1977
Argument :: ByteData ( _) | Argument :: DWordData ( _) | Argument :: TrackedPc ( _) | Argument :: PkgLength ( _) => {
1980
1978
panic ! ( )
1981
1979
}
1982
1980
}
1983
- Ok ( ( ) )
1981
+
1982
+ Ok ( to_return)
1984
1983
}
1985
1984
1986
1985
/// Do a read from a field by performing one or more well-formed accesses to the underlying
0 commit comments