@@ -568,19 +568,17 @@ impl Vm {
568
568
( Value :: Integer ( lhs) , Value :: Integer ( rhs) ) => int_op ( lhs, rhs) ,
569
569
( Value :: Float ( lhs) , Value :: Float ( rhs) ) => float_op ( lhs, rhs) ,
570
570
( lhs, rhs) => {
571
- let ordering = match vm_try ! ( self . call_instance_fn( lhs, Protocol :: CMP , ( & rhs, ) ) ) {
572
- CallResult :: Ok ( ( ) ) => {
573
- vm_try ! ( <Ordering >:: from_value( vm_try!( self . stack. pop( ) ) ) )
574
- }
575
- CallResult :: Unsupported ( lhs) => {
576
- return err ( VmErrorKind :: UnsupportedBinaryOperation {
577
- op,
578
- lhs : vm_try ! ( lhs. type_info( ) ) ,
579
- rhs : vm_try ! ( rhs. type_info( ) ) ,
580
- } ) ;
581
- }
582
- } ;
571
+ if let CallResult :: Unsupported ( lhs) =
572
+ vm_try ! ( self . call_instance_fn( lhs, Protocol :: CMP , ( & rhs, ) ) )
573
+ {
574
+ return err ( VmErrorKind :: UnsupportedBinaryOperation {
575
+ op,
576
+ lhs : vm_try ! ( lhs. type_info( ) ) ,
577
+ rhs : vm_try ! ( rhs. type_info( ) ) ,
578
+ } ) ;
579
+ }
583
580
581
+ let ordering = vm_try ! ( <Ordering >:: from_value( vm_try!( self . stack. pop( ) ) ) ) ;
584
582
match_ordering ( ordering)
585
583
}
586
584
} ;
@@ -983,7 +981,7 @@ impl Vm {
983
981
984
982
match vm_try ! ( self . call_field_fn( Protocol :: SET , target, hash, ( value, ) ) ) {
985
983
CallResult :: Ok ( ( ) ) => {
986
- vm_try ! ( self . stack. pop( ) ) ;
984
+ vm_try ! ( < ( ) > :: from_value ( vm_try! ( self . stack. pop( ) ) ) ) ;
987
985
CallResult :: Ok ( ( ) )
988
986
}
989
987
result => result,
@@ -1205,28 +1203,28 @@ impl Vm {
1205
1203
TargetValue :: Fallback ( fallback) => fallback,
1206
1204
} ;
1207
1205
1208
- self . target_fallback ( fallback, protocol)
1206
+ self . target_fallback_assign ( fallback, protocol)
1209
1207
}
1210
1208
1211
1209
/// Execute a fallback operation.
1212
- fn target_fallback (
1210
+ fn target_fallback_assign (
1213
1211
& mut self ,
1214
1212
fallback : TargetFallback < ' _ > ,
1215
1213
protocol : Protocol ,
1216
1214
) -> VmResult < ( ) > {
1217
1215
match fallback {
1218
1216
TargetFallback :: Value ( lhs, rhs) => {
1219
- match vm_try ! ( self . call_instance_fn( lhs, protocol, ( & rhs, ) ) ) {
1220
- CallResult :: Ok ( ( ) ) => vm_try ! ( <( ) >:: from_value( vm_try!( self . stack. pop( ) ) ) ) ,
1221
- CallResult :: Unsupported ( lhs) => {
1222
- return err ( VmErrorKind :: UnsupportedBinaryOperation {
1223
- op : protocol. name ,
1224
- lhs : vm_try ! ( lhs. type_info( ) ) ,
1225
- rhs : vm_try ! ( rhs. type_info( ) ) ,
1226
- } ) ;
1227
- }
1217
+ if let CallResult :: Unsupported ( lhs) =
1218
+ vm_try ! ( self . call_instance_fn( lhs, protocol, ( & rhs, ) ) )
1219
+ {
1220
+ return err ( VmErrorKind :: UnsupportedBinaryOperation {
1221
+ op : protocol. name ,
1222
+ lhs : vm_try ! ( lhs. type_info( ) ) ,
1223
+ rhs : vm_try ! ( rhs. type_info( ) ) ,
1224
+ } ) ;
1228
1225
} ;
1229
1226
1227
+ vm_try ! ( <( ) >:: from_value( vm_try!( self . stack. pop( ) ) ) ) ;
1230
1228
VmResult :: Ok ( ( ) )
1231
1229
}
1232
1230
TargetFallback :: Field ( lhs, hash, rhs) => {
@@ -1287,14 +1285,14 @@ impl Vm {
1287
1285
1288
1286
if let CallResult :: Unsupported ( lhs) = vm_try ! ( self . call_instance_fn( lhs, protocol, ( & rhs, ) ) )
1289
1287
{
1290
- err ( VmErrorKind :: UnsupportedBinaryOperation {
1288
+ return err ( VmErrorKind :: UnsupportedBinaryOperation {
1291
1289
op : protocol. name ,
1292
1290
lhs : vm_try ! ( lhs. type_info( ) ) ,
1293
1291
rhs : vm_try ! ( rhs. type_info( ) ) ,
1294
- } )
1295
- } else {
1296
- VmResult :: Ok ( ( ) )
1292
+ } ) ;
1297
1293
}
1294
+
1295
+ VmResult :: Ok ( ( ) )
1298
1296
}
1299
1297
1300
1298
/// Internal impl of a numeric operation.
@@ -1318,14 +1316,14 @@ impl Vm {
1318
1316
1319
1317
if let CallResult :: Unsupported ( lhs) = vm_try ! ( self . call_instance_fn( lhs, protocol, ( & rhs, ) ) )
1320
1318
{
1321
- err ( VmErrorKind :: UnsupportedBinaryOperation {
1319
+ return err ( VmErrorKind :: UnsupportedBinaryOperation {
1322
1320
op : protocol. name ,
1323
1321
lhs : vm_try ! ( lhs. type_info( ) ) ,
1324
1322
rhs : vm_try ! ( rhs. type_info( ) ) ,
1325
- } )
1326
- } else {
1327
- VmResult :: Ok ( ( ) )
1323
+ } ) ;
1328
1324
}
1325
+
1326
+ VmResult :: Ok ( ( ) )
1329
1327
}
1330
1328
1331
1329
/// Internal impl of a numeric operation.
@@ -1354,14 +1352,14 @@ impl Vm {
1354
1352
1355
1353
if let CallResult :: Unsupported ( lhs) = vm_try ! ( self . call_instance_fn( lhs, protocol, ( & rhs, ) ) )
1356
1354
{
1357
- err ( VmErrorKind :: UnsupportedBinaryOperation {
1355
+ return err ( VmErrorKind :: UnsupportedBinaryOperation {
1358
1356
op : protocol. name ,
1359
1357
lhs : vm_try ! ( lhs. type_info( ) ) ,
1360
1358
rhs : vm_try ! ( rhs. type_info( ) ) ,
1361
- } )
1362
- } else {
1363
- VmResult :: Ok ( ( ) )
1359
+ } ) ;
1364
1360
}
1361
+
1362
+ VmResult :: Ok ( ( ) )
1365
1363
}
1366
1364
1367
1365
fn internal_infallible_bitwise_assign (
@@ -1384,7 +1382,7 @@ impl Vm {
1384
1382
TargetValue :: Fallback ( fallback) => fallback,
1385
1383
} ;
1386
1384
1387
- self . target_fallback ( fallback, protocol)
1385
+ self . target_fallback_assign ( fallback, protocol)
1388
1386
}
1389
1387
1390
1388
fn internal_bitwise (
@@ -1409,14 +1407,14 @@ impl Vm {
1409
1407
1410
1408
if let CallResult :: Unsupported ( lhs) = vm_try ! ( self . call_instance_fn( lhs, protocol, ( & rhs, ) ) )
1411
1409
{
1412
- err ( VmErrorKind :: UnsupportedBinaryOperation {
1410
+ return err ( VmErrorKind :: UnsupportedBinaryOperation {
1413
1411
op : protocol. name ,
1414
1412
lhs : vm_try ! ( lhs. type_info( ) ) ,
1415
1413
rhs : vm_try ! ( rhs. type_info( ) ) ,
1416
- } )
1417
- } else {
1418
- VmResult :: Ok ( ( ) )
1414
+ } ) ;
1419
1415
}
1416
+
1417
+ VmResult :: Ok ( ( ) )
1420
1418
}
1421
1419
1422
1420
fn internal_bitwise_assign (
@@ -1441,7 +1439,7 @@ impl Vm {
1441
1439
TargetValue :: Fallback ( fallback) => fallback,
1442
1440
} ;
1443
1441
1444
- self . target_fallback ( fallback, protocol)
1442
+ self . target_fallback_assign ( fallback, protocol)
1445
1443
}
1446
1444
1447
1445
#[ cfg_attr( feature = "bench" , inline( never) ) ]
@@ -2005,17 +2003,17 @@ impl Vm {
2005
2003
if let CallResult :: Unsupported ( target) =
2006
2004
vm_try ! ( self . call_instance_fn( target, Protocol :: INDEX_SET , ( & index, & value) ) )
2007
2005
{
2008
- err ( VmErrorKind :: UnsupportedIndexSet {
2006
+ return err ( VmErrorKind :: UnsupportedIndexSet {
2009
2007
target : vm_try ! ( target. type_info( ) ) ,
2010
2008
index : vm_try ! ( index. type_info( ) ) ,
2011
2009
value : vm_try ! ( value. type_info( ) ) ,
2012
- } )
2013
- } else {
2014
- // Calling index set should not produce a value on the stack, but all
2015
- // handler functions to produce a value. So pop it here.
2016
- vm_try ! ( <( ) >:: from_value( vm_try!( self . stack. pop( ) ) ) ) ;
2017
- VmResult :: Ok ( ( ) )
2010
+ } ) ;
2018
2011
}
2012
+
2013
+ // Calling index set should not produce a value on the stack, but all
2014
+ // handler functions to produce a value. So pop it here.
2015
+ vm_try ! ( <( ) >:: from_value( vm_try!( self . stack. pop( ) ) ) ) ;
2016
+ VmResult :: Ok ( ( ) )
2019
2017
}
2020
2018
2021
2019
#[ inline]
@@ -2160,13 +2158,14 @@ impl Vm {
2160
2158
if let CallResult :: Unsupported ( target) =
2161
2159
vm_try ! ( self . call_instance_fn( target, Protocol :: INDEX_GET , ( & index, ) ) )
2162
2160
{
2163
- err ( VmErrorKind :: UnsupportedIndexGet {
2161
+ return err ( VmErrorKind :: UnsupportedIndexGet {
2164
2162
target : vm_try ! ( target. type_info( ) ) ,
2165
2163
index : vm_try ! ( index. type_info( ) ) ,
2166
- } )
2167
- } else {
2168
- VmResult :: Ok ( ( ) )
2164
+ } ) ;
2169
2165
}
2166
+
2167
+ // NB: Should leave a value on the stack.
2168
+ VmResult :: Ok ( ( ) )
2170
2169
}
2171
2170
2172
2171
/// Perform an index get operation specialized for tuples.
@@ -2188,7 +2187,7 @@ impl Vm {
2188
2187
} ) ;
2189
2188
}
2190
2189
2191
- // NB: should leave a value on the stack.
2190
+ // NB: Should leave a value on the stack.
2192
2191
VmResult :: Ok ( ( ) )
2193
2192
}
2194
2193
@@ -2228,6 +2227,7 @@ impl Vm {
2228
2227
} ) ;
2229
2228
}
2230
2229
2230
+ // NB: Should leave a value on the stack.
2231
2231
VmResult :: Ok ( ( ) )
2232
2232
}
2233
2233
@@ -2268,12 +2268,12 @@ impl Vm {
2268
2268
if let CallResult :: Unsupported ( target) =
2269
2269
vm_try ! ( self . try_object_slot_index_set( target, string_slot, value) )
2270
2270
{
2271
- err ( VmErrorKind :: UnsupportedObjectSlotIndexSet {
2271
+ return err ( VmErrorKind :: UnsupportedObjectSlotIndexSet {
2272
2272
target : vm_try ! ( target. type_info( ) ) ,
2273
- } )
2274
- } else {
2275
- VmResult :: Ok ( ( ) )
2273
+ } ) ;
2276
2274
}
2275
+
2276
+ VmResult :: Ok ( ( ) )
2277
2277
}
2278
2278
2279
2279
/// Perform a specialized index get operation on an object.
@@ -2479,6 +2479,7 @@ impl Vm {
2479
2479
actual : vm_try ! ( target. type_info( ) ) ,
2480
2480
} ) ;
2481
2481
}
2482
+
2482
2483
vm_try ! ( <Result <Value , Value >>:: from_value( vm_try!( self
2483
2484
. stack
2484
2485
. pop( ) ) ) )
0 commit comments