@@ -10,7 +10,7 @@ import lib::llvm::{ llvm, TypeRef, ValueRef,
10
10
StructRetAttribute , ByValAttribute
11
11
} ;
12
12
import syntax :: { ast, ast_util} ;
13
- import back:: link;
13
+ import back :: { link, abi } ;
14
14
import common:: * ;
15
15
import build:: * ;
16
16
import base:: * ;
@@ -842,63 +842,65 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::native_item,
842
842
let vp_ty = substs. tys [ 1 ] ;
843
843
let visitor = get_param ( decl, first_real_arg) ;
844
844
845
- // We're going to synthesize a monomorphized vtbl call here much
846
- // like what impl::trans_monomorphized_callee does, but without
847
- // having quite as much source machinery to go on.
845
+ let ( tyname, args) = alt ty:: get ( tp_ty) . struct {
846
+ ty:: ty_bot { ( "bot" , [ ] ) }
847
+ ty:: ty_nil { ( "nil" , [ ] ) }
848
+ ty:: ty_bool { ( "bool" , [ ] ) }
849
+ ty:: ty_int ( ast:: ty_i) { ( "int" , [ ] ) }
850
+ ty:: ty_int ( ast:: ty_char) { ( "char" , [ ] ) }
851
+ ty:: ty_int ( ast:: ty_i8) { ( "i8" , [ ] ) }
852
+ ty:: ty_int ( ast:: ty_i16) { ( "i16" , [ ] ) }
853
+ ty:: ty_int ( ast:: ty_i32) { ( "i32" , [ ] ) }
854
+ ty:: ty_int ( ast:: ty_i64) { ( "i64" , [ ] ) }
855
+ ty:: ty_uint ( ast:: ty_u) { ( "uint" , [ ] ) }
856
+ ty:: ty_uint ( ast:: ty_u8) { ( "u8" , [ ] ) }
857
+ ty:: ty_uint ( ast:: ty_u16) { ( "u16" , [ ] ) }
858
+ ty:: ty_uint ( ast:: ty_u32) { ( "u32" , [ ] ) }
859
+ ty:: ty_uint ( ast:: ty_u64) { ( "u64" , [ ] ) }
860
+ ty:: ty_float ( ast:: ty_f) { ( "float" , [ ] ) }
861
+ ty:: ty_float ( ast:: ty_f32) { ( "f32" , [ ] ) }
862
+ ty:: ty_float ( ast:: ty_f64) { ( "f64" , [ ] ) }
863
+ ty:: ty_str { ( "str" , [ ] ) }
864
+ _ {
865
+ bcx. sess ( ) . unimpl ( "trans::native::visit_ty on "
866
+ + ty_to_str ( ccx. tcx , tp_ty) ) ;
867
+ }
868
+ } ;
869
+
870
+ let mth_name = "visit_" + tyname;
871
+ let dest = ignore;
848
872
849
873
alt impl:: find_vtable_in_fn_ctxt ( substs,
850
874
1 u, /* n_param */
851
875
0 u /* n_bound */ ) {
852
876
853
877
typeck:: vtable_static ( impl_did, impl_substs, sub_origins) {
854
-
855
- let ( tyname, args) = alt ty:: get ( tp_ty) . struct {
856
- ty:: ty_bot { ( "bot" , [ ] ) }
857
- ty:: ty_nil { ( "nil" , [ ] ) }
858
- ty:: ty_bool { ( "bool" , [ ] ) }
859
- ty:: ty_int ( ast:: ty_i) { ( "int" , [ ] ) }
860
- ty:: ty_int ( ast:: ty_char) { ( "char" , [ ] ) }
861
- ty:: ty_int ( ast:: ty_i8) { ( "i8" , [ ] ) }
862
- ty:: ty_int ( ast:: ty_i16) { ( "i16" , [ ] ) }
863
- ty:: ty_int ( ast:: ty_i32) { ( "i32" , [ ] ) }
864
- ty:: ty_int ( ast:: ty_i64) { ( "i64" , [ ] ) }
865
- ty:: ty_uint ( ast:: ty_u) { ( "uint" , [ ] ) }
866
- ty:: ty_uint ( ast:: ty_u8) { ( "u8" , [ ] ) }
867
- ty:: ty_uint ( ast:: ty_u16) { ( "u16" , [ ] ) }
868
- ty:: ty_uint ( ast:: ty_u32) { ( "u32" , [ ] ) }
869
- ty:: ty_uint ( ast:: ty_u64) { ( "u64" , [ ] ) }
870
- ty:: ty_float ( ast:: ty_f) { ( "float" , [ ] ) }
871
- ty:: ty_float ( ast:: ty_f32) { ( "f32" , [ ] ) }
872
- ty:: ty_float ( ast:: ty_f64) { ( "f64" , [ ] ) }
873
- ty:: ty_str { ( "str" , [ ] ) }
874
- _ {
875
- bcx. sess ( ) . unimpl ( "trans::native::visit_ty on "
876
- + ty_to_str ( ccx. tcx , tp_ty) ) ;
877
- }
878
- } ;
879
-
880
- let mth_id = impl:: method_with_name ( ccx, impl_did,
881
- "visit_" + tyname) ;
878
+ let mth_id = impl:: method_with_name ( ccx, impl_did, mth_name) ;
882
879
let mth_ty = ty:: lookup_item_type ( ccx. tcx , mth_id) . ty ;
883
-
884
880
// FIXME: is this safe? There is no callee AST node,
885
881
// we're synthesizing it.
886
882
let callee_id = ( -1 ) as ast:: node_id ;
883
+ let get_lval = { |bcx|
884
+ let lval = lval_static_fn_inner ( bcx, mth_id, callee_id,
885
+ impl_substs,
886
+ some ( sub_origins) ) ;
887
+ { env: self_env ( visitor, vp_ty, none) with lval}
888
+ } ;
889
+ bcx = trans_call_inner ( bcx, mth_ty, ty:: mk_bool ( ccx. tcx ) ,
890
+ get_lval, arg_vals ( args) , dest) ;
891
+ }
887
892
888
- let dest = ignore;
889
-
890
- bcx = trans_call_inner ( bcx,
891
- mth_ty,
892
- ty:: mk_nil ( ccx. tcx ) ,
893
- { |bcx|
894
- let lval =
895
- lval_static_fn_inner
896
- ( bcx, mth_id, callee_id,
897
- impl_substs, some ( sub_origins) ) ;
898
- { env: self_env ( visitor, vp_ty, none)
899
- with lval}
900
- } , arg_vals ( args) , dest) ;
893
+ typeck:: vtable_iface ( iid, _tps) {
894
+ let methods = ty:: iface_methods ( ccx. tcx , iid) ;
895
+ let mth_idx = option:: get ( ty:: method_idx ( mth_name, * methods) ) ;
896
+ let mth_ty = ty:: mk_fn ( ccx. tcx , methods[ mth_idx] . fty ) ;
897
+ let get_lval = { |bcx|
898
+ impl:: trans_iface_callee ( bcx, visitor, mth_ty, mth_idx)
899
+ } ;
900
+ bcx = trans_call_inner ( bcx, mth_ty, ty:: mk_bool ( ccx. tcx ) ,
901
+ get_lval, arg_vals ( args) , dest) ;
901
902
}
903
+
902
904
_ {
903
905
ccx. sess . span_bug ( item. span ,
904
906
"non-static callee in 'visit_ty' intrinsinc" ) ;
0 commit comments