@@ -8,6 +8,7 @@ use rustc::ty::layout::{self, Layout, Size};
8
8
use rustc:: ty:: subst:: { self , Subst , Substs } ;
9
9
use rustc:: ty:: { self , Ty , TyCtxt , BareFnTy } ;
10
10
use rustc:: util:: nodemap:: DefIdMap ;
11
+ use rustc_data_structures:: indexed_vec:: Idx ;
11
12
use std:: cell:: RefCell ;
12
13
use std:: ops:: Deref ;
13
14
use std:: rc:: Rc ;
@@ -118,7 +119,7 @@ struct ConstantId<'tcx> {
118
119
119
120
#[ derive( Clone , Debug , Eq , PartialEq , Hash ) ]
120
121
enum ConstantKind {
121
- Promoted ( usize ) ,
122
+ Promoted ( mir :: Promoted ) ,
122
123
/// Statics, constants and associated constants
123
124
Global ,
124
125
}
@@ -426,24 +427,38 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
426
427
assert_eq ! ( ptr. offset, 0 ) ;
427
428
let fn_ptr = self . memory . read_ptr ( ptr) ?;
428
429
let ( def_id, substs) = self . memory . get_fn ( fn_ptr. alloc_id ) ?;
429
- self . eval_fn_call ( def_id, substs, bare_fn_ty, return_ptr, args, terminator. span ) ?
430
+ self . eval_fn_call ( def_id, substs, bare_fn_ty, return_ptr, args,
431
+ terminator. source_info . span ) ?
430
432
} ,
431
433
ty:: TyFnDef ( def_id, substs, fn_ty) => {
432
- self . eval_fn_call ( def_id, substs, fn_ty, return_ptr, args, terminator. span ) ?
434
+ self . eval_fn_call ( def_id, substs, fn_ty, return_ptr, args,
435
+ terminator. source_info . span ) ?
433
436
}
434
437
435
438
_ => return Err ( EvalError :: Unimplemented ( format ! ( "can't handle callee of type {:?}" , func_ty) ) ) ,
436
439
}
437
440
}
438
441
439
- Drop { ref value , target, .. } => {
440
- let ptr = self . eval_lvalue ( value ) ?. to_ptr ( ) ;
441
- let ty = self . lvalue_ty ( value ) ;
442
+ Drop { ref location , target, .. } => {
443
+ let ptr = self . eval_lvalue ( location ) ?. to_ptr ( ) ;
444
+ let ty = self . lvalue_ty ( location ) ;
442
445
self . drop ( ptr, ty) ?;
443
446
self . frame_mut ( ) . next_block = target;
444
447
}
445
448
449
+ Assert { ref cond, expected, ref msg, target, cleanup } => {
450
+ let actual_ptr = self . eval_operand ( cond) ?;
451
+ let actual = self . memory . read_bool ( actual_ptr) ?;
452
+ if actual == expected {
453
+ self . frame_mut ( ) . next_block = target;
454
+ } else {
455
+ panic ! ( "unimplemented: jump to {:?} and print {:?}" , cleanup, msg) ;
456
+ }
457
+ }
458
+
459
+ DropAndReplace { .. } => unimplemented ! ( ) ,
446
460
Resume => unimplemented ! ( ) ,
461
+ Unreachable => unimplemented ! ( ) ,
447
462
}
448
463
449
464
Ok ( ( ) )
@@ -867,6 +882,25 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
867
882
self . memory . write_primval ( dest, val) ?;
868
883
}
869
884
885
+ // FIXME(solson): Factor this out with BinaryOp.
886
+ CheckedBinaryOp ( bin_op, ref left, ref right) => {
887
+ let left_ptr = self . eval_operand ( left) ?;
888
+ let left_ty = self . operand_ty ( left) ;
889
+ let left_val = self . read_primval ( left_ptr, left_ty) ?;
890
+
891
+ let right_ptr = self . eval_operand ( right) ?;
892
+ let right_ty = self . operand_ty ( right) ;
893
+ let right_val = self . read_primval ( right_ptr, right_ty) ?;
894
+
895
+ let val = primval:: binary_op ( bin_op, left_val, right_val) ?;
896
+ self . memory . write_primval ( dest, val) ?;
897
+
898
+ // FIXME(solson): Find the result type size properly. Perhaps refactor out
899
+ // Projection calculations so we can do the equivalent of `dest.1` here.
900
+ let s = self . type_size ( left_ty, self . substs ( ) ) ;
901
+ self . memory . write_bool ( dest. offset ( s as isize ) , false ) ?;
902
+ }
903
+
870
904
UnaryOp ( un_op, ref operand) => {
871
905
let ptr = self . eval_operand ( operand) ?;
872
906
let ty = self . operand_ty ( operand) ;
@@ -1048,7 +1082,6 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
1048
1082
}
1049
1083
}
1050
1084
1051
- Slice { .. } => unimplemented ! ( ) ,
1052
1085
InlineAsm { .. } => unimplemented ! ( ) ,
1053
1086
}
1054
1087
@@ -1161,9 +1194,9 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
1161
1194
let ptr = match * lvalue {
1162
1195
ReturnPointer => self . frame ( ) . return_ptr
1163
1196
. expect ( "ReturnPointer used in a function with no return value" ) ,
1164
- Arg ( i) => self . frame ( ) . locals [ i as usize ] ,
1165
- Var ( i) => self . frame ( ) . locals [ self . frame ( ) . var_offset + i as usize ] ,
1166
- Temp ( i) => self . frame ( ) . locals [ self . frame ( ) . temp_offset + i as usize ] ,
1197
+ Arg ( i) => self . frame ( ) . locals [ i. index ( ) ] ,
1198
+ Var ( i) => self . frame ( ) . locals [ self . frame ( ) . var_offset + i. index ( ) ] ,
1199
+ Temp ( i) => self . frame ( ) . locals [ self . frame ( ) . temp_offset + i. index ( ) ] ,
1167
1200
1168
1201
Static ( def_id) => {
1169
1202
let substs = self . tcx . mk_substs ( subst:: Substs :: empty ( ) ) ;
@@ -1248,6 +1281,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
1248
1281
}
1249
1282
1250
1283
ConstantIndex { .. } => unimplemented ! ( ) ,
1284
+ Subslice { .. } => unimplemented ! ( ) ,
1251
1285
}
1252
1286
}
1253
1287
} ;
0 commit comments