@@ -8,6 +8,7 @@ use rustc::ty::layout::{self, Layout, Size};
88use rustc:: ty:: subst:: { self , Subst , Substs } ;
99use rustc:: ty:: { self , Ty , TyCtxt , BareFnTy } ;
1010use rustc:: util:: nodemap:: DefIdMap ;
11+ use rustc_data_structures:: indexed_vec:: Idx ;
1112use std:: cell:: RefCell ;
1213use std:: ops:: Deref ;
1314use std:: rc:: Rc ;
@@ -118,7 +119,7 @@ struct ConstantId<'tcx> {
118119
119120#[ derive( Clone , Debug , Eq , PartialEq , Hash ) ]
120121enum ConstantKind {
121- Promoted ( usize ) ,
122+ Promoted ( mir :: Promoted ) ,
122123 /// Statics, constants and associated constants
123124 Global ,
124125}
@@ -426,24 +427,38 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
426427 assert_eq ! ( ptr. offset, 0 ) ;
427428 let fn_ptr = self . memory . read_ptr ( ptr) ?;
428429 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 ) ?
430432 } ,
431433 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 ) ?
433436 }
434437
435438 _ => return Err ( EvalError :: Unimplemented ( format ! ( "can't handle callee of type {:?}" , func_ty) ) ) ,
436439 }
437440 }
438441
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 ) ;
442445 self . drop ( ptr, ty) ?;
443446 self . frame_mut ( ) . next_block = target;
444447 }
445448
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 ! ( ) ,
446460 Resume => unimplemented ! ( ) ,
461+ Unreachable => unimplemented ! ( ) ,
447462 }
448463
449464 Ok ( ( ) )
@@ -867,6 +882,25 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
867882 self . memory . write_primval ( dest, val) ?;
868883 }
869884
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+
870904 UnaryOp ( un_op, ref operand) => {
871905 let ptr = self . eval_operand ( operand) ?;
872906 let ty = self . operand_ty ( operand) ;
@@ -1048,7 +1082,6 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
10481082 }
10491083 }
10501084
1051- Slice { .. } => unimplemented ! ( ) ,
10521085 InlineAsm { .. } => unimplemented ! ( ) ,
10531086 }
10541087
@@ -1161,9 +1194,9 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
11611194 let ptr = match * lvalue {
11621195 ReturnPointer => self . frame ( ) . return_ptr
11631196 . 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 ( ) ] ,
11671200
11681201 Static ( def_id) => {
11691202 let substs = self . tcx . mk_substs ( subst:: Substs :: empty ( ) ) ;
@@ -1248,6 +1281,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
12481281 }
12491282
12501283 ConstantIndex { .. } => unimplemented ! ( ) ,
1284+ Subslice { .. } => unimplemented ! ( ) ,
12511285 }
12521286 }
12531287 } ;
0 commit comments