@@ -80,13 +80,12 @@ fn type_of_explicit_args(cx: @crate_ctxt, sp: span, inputs: [ty::arg]) ->
80
80
// - create_llargs_for_fn_args.
81
81
// - new_fn_ctxt
82
82
// - trans_args
83
- fn type_of_fn( cx : @crate_ctxt , sp : span ,
84
- is_method : bool , inputs : [ ty:: arg ] ,
85
- output : ty:: t , params : [ ty:: param_bounds ] )
86
- : non_ty_var ( cx , output ) -> TypeRef {
83
+ fn type_of_fn ( cx : @crate_ctxt , sp : span , is_method : bool , inputs : [ ty:: arg ] ,
84
+ output : ty:: t , params : [ ty:: param_bounds ] ) -> TypeRef {
87
85
let atys: [ TypeRef ] = [ ] ;
88
86
89
87
// Arg 0: Output pointer.
88
+ check non_ty_var( cx, output) ;
90
89
let out_ty = T_ptr ( type_of_inner ( cx, sp, output) ) ;
91
90
atys += [ out_ty] ;
92
91
@@ -117,7 +116,6 @@ fn type_of_fn_from_ty(cx: @crate_ctxt, sp: span, fty: ty::t,
117
116
// by returns_non_ty_var(t). Make that a postcondition
118
117
// (see Issue #586)
119
118
let ret_ty = ty:: ty_fn_ret ( cx. tcx , fty) ;
120
- check non_ty_var( cx, ret_ty) ;
121
119
ret type_of_fn( cx, sp, false , ty:: ty_fn_args ( cx. tcx , fty) ,
122
120
ret_ty, param_bounds) ;
123
121
}
@@ -2771,8 +2769,6 @@ fn trans_object_field_inner(bcx: @block_ctxt, o: ValueRef,
2771
2769
let fn_ty: ty:: t = ty:: mk_fn ( tcx, mths[ ix] . fty ) ;
2772
2770
let ret_ty = ty:: ty_fn_ret ( tcx, fn_ty) ;
2773
2771
// FIXME: constrain ty_obj?
2774
- check non_ty_var( ccx, ret_ty) ;
2775
-
2776
2772
let ll_fn_ty = type_of_fn ( ccx, bcx. sp , true ,
2777
2773
ty:: ty_fn_args ( tcx, fn_ty) , ret_ty, [ ] ) ;
2778
2774
v = Load ( bcx, PointerCast ( bcx, v, T_ptr ( T_ptr ( ll_fn_ty) ) ) ) ;
@@ -5123,8 +5119,6 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
5123
5119
ty: ty:: mk_vec ( ccx. tcx , { ty: unit_ty, mut: ast:: imm} ) } ;
5124
5120
// FIXME: mk_nil should have a postcondition
5125
5121
let nt = ty:: mk_nil ( ccx. tcx ) ;
5126
- check non_ty_var( ccx, nt) ;
5127
-
5128
5122
let llfty = type_of_fn ( ccx, sp, false , [ vecarg_ty] , nt, [ ] ) ;
5129
5123
let llfdecl = decl_fn ( ccx. llmod , "_rust_main" ,
5130
5124
lib:: llvm:: LLVMCCallConv , llfty) ;
@@ -5223,7 +5217,6 @@ fn native_fn_wrapper_type(cx: @crate_ctxt, sp: span,
5223
5217
x : ty:: t ) -> TypeRef {
5224
5218
alt ty:: struct ( cx. tcx , x) {
5225
5219
ty:: ty_native_fn ( args, out) {
5226
- check non_ty_var ( cx, out) ;
5227
5220
ret type_of_fn ( cx, sp, false , args, out, param_bounds) ;
5228
5221
}
5229
5222
}
@@ -5377,7 +5370,7 @@ fn trans_constant(ccx: @crate_ctxt, it: @ast::item, &&pt: [str],
5377
5370
ast:: item_tag ( variants, _) {
5378
5371
let i = 0 u;
5379
5372
for variant in variants {
5380
- let p = new_pt + [ it . ident , variant. node . name , "discrim" ] ;
5373
+ let p = new_pt + [ variant. node . name , "discrim" ] ;
5381
5374
let s = mangle_exported_name ( ccx, p, ty:: mk_int ( ccx. tcx ) ) ;
5382
5375
let discrim_gvar = str:: as_buf ( s, { |buf|
5383
5376
llvm:: LLVMAddGlobal ( ccx. llmod , ccx. int_type , buf)
@@ -5390,6 +5383,28 @@ fn trans_constant(ccx: @crate_ctxt, it: @ast::item, &&pt: [str],
5390
5383
i += 1 u;
5391
5384
}
5392
5385
}
5386
+ ast:: item_impl ( tps, some ( @{ node: ast:: ty_path ( _, id) , _} ) , _, ms) {
5387
+ let i_did = ast_util:: def_id_of_def ( ccx. tcx . def_map . get ( id) ) ;
5388
+ let ty = ty:: lookup_item_type ( ccx. tcx , i_did) . ty ;
5389
+ // FIXME[impl] use the same name as used in collect_items, for
5390
+ // slightly more consistent symbol names?
5391
+ let new_pt = pt + [ ccx. names . next ( it. ident ) ] ;
5392
+ let extra_tps = vec:: map ( tps, { |p| param_bounds ( ccx, p) } ) ;
5393
+ let tbl = C_struct ( vec:: map ( * ty:: iface_methods ( ccx. tcx , i_did) , { |im|
5394
+ alt vec:: find ( ms, { |m| m. ident == im. ident } ) {
5395
+ some ( m) {
5396
+ trans_impl:: trans_wrapper ( ccx, new_pt, extra_tps, m)
5397
+ }
5398
+ }
5399
+ } ) ) ;
5400
+ let s = mangle_exported_name ( ccx, new_pt + [ "!vtable" ] , ty) ;
5401
+ let vt_gvar = str:: as_buf ( s, { |buf|
5402
+ llvm:: LLVMAddGlobal ( ccx. llmod , val_ty ( tbl) , buf)
5403
+ } ) ;
5404
+ llvm:: LLVMSetInitializer ( vt_gvar, tbl) ;
5405
+ llvm:: LLVMSetGlobalConstant ( vt_gvar, True ) ;
5406
+ ccx. item_ids . insert ( it. id , vt_gvar) ;
5407
+ }
5393
5408
_ { }
5394
5409
}
5395
5410
}
0 commit comments