@@ -131,7 +131,8 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
131131 Ok ( ( ) )
132132 }
133133
134- /// Decides whether it is okay to call the method with signature `real_sig` using signature `sig`
134+ /// Decides whether it is okay to call the method with signature `real_sig` using signature `sig`.
135+ /// FIXME: This should take into account the platform-dependent ABI description.
135136 fn check_sig_compat (
136137 & mut self ,
137138 sig : ty:: FnSig < ' tcx > ,
@@ -284,12 +285,6 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
284285 trace ! ( "arg_locals: {:?}" , self . frame( ) . mir. args_iter( ) . collect:: <Vec <_>>( ) ) ;
285286 trace ! ( "arg_operands: {:?}" , arg_operands) ;
286287 match sig. abi {
287- Abi :: Rust | Abi :: C => {
288- for ( arg_local, ( arg_val, arg_ty) ) in arg_locals. zip ( args) {
289- let dest = self . eval_lvalue ( & mir:: Lvalue :: Local ( arg_local) ) ?;
290- self . write_value ( arg_val, dest, arg_ty) ?;
291- }
292- }
293288 Abi :: RustCall => {
294289 assert_eq ! ( args. len( ) , 2 ) ;
295290
@@ -332,8 +327,13 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
332327 } else {
333328 bug ! ( "rust-call ABI tuple argument was {:?}, {:?}" , arg_ty, layout) ;
334329 }
330+ } ,
331+ _ => {
332+ for ( arg_local, ( arg_val, arg_ty) ) in arg_locals. zip ( args) {
333+ let dest = self . eval_lvalue ( & mir:: Lvalue :: Local ( arg_local) ) ?;
334+ self . write_value ( arg_val, dest, arg_ty) ?;
335+ }
335336 }
336- _ => unimplemented ! ( ) ,
337337 }
338338 Ok ( ( ) )
339339 } ,
@@ -520,7 +520,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
520520 // Still, we can make many things mostly work by "emulating" or ignoring some functions.
521521 match & path[ ..] {
522522 "std::io::_print" => {
523- trace ! ( "Ignoring output." ) ;
523+ trace ! ( "Ignoring output. To run programs that print, make sure you have a libstd with full MIR. " ) ;
524524 self . goto_block ( destination. unwrap ( ) . 1 ) ;
525525 Ok ( ( ) )
526526 } ,
@@ -595,15 +595,16 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
595595 }
596596
597597 "__rust_maybe_catch_panic" => {
598+ // fn __rust_maybe_catch_panic(f: fn(*mut u8), data: *mut u8, data_ptr: *mut usize, vtable_ptr: *mut usize) -> u32
598599 // We abort on panic, so not much is going on here, but we still have to call the closure
599600 let u8_ptr_ty = self . tcx . mk_mut_ptr ( self . tcx . types . u8 ) ;
600601 let f = args[ 0 ] . read_ptr ( & self . memory ) ?;
601- let data = args[ 1 ] . read_ptr ( & self . memory ) ?; // FIXME: Why does value_to_primval(args[2], u8_ptr_ty)?.to_ptr()? here end up doing the Wrong Thing (TM)?
602+ let data = args[ 1 ] . read_ptr ( & self . memory ) ?;
602603 let f_instance = self . memory . get_fn ( f. alloc_id ) ?;
603604 self . write_primval ( dest, PrimVal :: Bytes ( 0 ) , dest_ty) ?;
604605
605- // Now we make a functon call. TODO: Consider making this re-usable? EvalContext::step does sth. similar for the TLS dtors,
606- // and of coruse eval_main.
606+ // Now we make a function call. TODO: Consider making this re-usable? EvalContext::step does sth. similar for the TLS dtors,
607+ // and of course eval_main.
607608 let mir = self . load_mir ( f_instance. def ) ?;
608609 self . push_stack_frame (
609610 f_instance,
@@ -614,11 +615,13 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
614615 ) ?;
615616
616617 let arg_local = self . frame ( ) . mir . args_iter ( ) . next ( ) . ok_or ( EvalError :: AbiViolation ( "Argument to __rust_maybe_catch_panic does not take enough arguments." . to_owned ( ) ) ) ?;
617- let dest = self . eval_lvalue ( & mir:: Lvalue :: Local ( arg_local) ) ?;
618- self . write_value ( Value :: ByVal ( PrimVal :: Ptr ( data) ) , dest, u8_ptr_ty) ?;
618+ let arg_dest = self . eval_lvalue ( & mir:: Lvalue :: Local ( arg_local) ) ?;
619+ self . write_value ( Value :: ByVal ( PrimVal :: Ptr ( data) ) , arg_dest, u8_ptr_ty) ?;
620+
621+ // We ourselbes return 0
622+ self . write_primval ( dest, PrimVal :: Bytes ( 0 ) , dest_ty) ?;
619623
620624 // Don't fall through
621- // FIXME: Do we have to do self.dump_local(ret) anywhere?
622625 return Ok ( ( ) ) ;
623626 }
624627
0 commit comments