Skip to content

Commit 553beda

Browse files
committed
Add span information to create_vtbl and friends.
1 parent 41f6a3d commit 553beda

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

src/comp/middle/trans.rs

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7022,7 +7022,7 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
70227022
// create_vtbl() with no "additional methods". What's happening
70237023
// is that, since *all* of the methods are "additional", we can
70247024
// get away with acting like none of them are.
7025-
vtbl = create_vtbl(bcx.fcx.lcx, llouter_obj_ty, outer_obj_ty,
7025+
vtbl = create_vtbl(bcx.fcx.lcx, sp, llouter_obj_ty, outer_obj_ty,
70267026
wrapper_obj, ty_params, none,
70277027
additional_field_tys);
70287028
}
@@ -7045,7 +7045,7 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
70457045
// one with a matching name and type being added, we'll need to
70467046
// create a forwarding slot. And, of course, we need to create a
70477047
// normal vtable entry for every method being added.
7048-
vtbl = create_vtbl(bcx.fcx.lcx, llouter_obj_ty, outer_obj_ty,
7048+
vtbl = create_vtbl(bcx.fcx.lcx, sp, llouter_obj_ty, outer_obj_ty,
70497049
wrapper_obj, ty_params,
70507050
some(with_obj_ty),
70517051
additional_field_tys);
@@ -7822,8 +7822,9 @@ fn trans_fn(@local_ctxt cx, &span sp, &ast::_fn f, ValueRef llfndecl,
78227822
// process_fwding_mthd: Create the forwarding function that appears in a
78237823
// vtable slot for method calls that "fall through" to an inner object. A
78247824
// helper function for create_vtbl.
7825-
fn process_fwding_mthd(@local_ctxt cx, @ty::method m, TypeRef llself_ty,
7826-
ty::t self_ty, &vec[ast::ty_param] ty_params,
7825+
fn process_fwding_mthd(@local_ctxt cx, &span sp, @ty::method m,
7826+
TypeRef llself_ty, ty::t self_ty,
7827+
&vec[ast::ty_param] ty_params,
78277828
ty::t with_obj_ty,
78287829
ty::t[] additional_field_tys) -> ValueRef {
78297830

@@ -7840,11 +7841,6 @@ fn process_fwding_mthd(@local_ctxt cx, @ty::method m, TypeRef llself_ty,
78407841
// on. That object won't exist until run-time, but we know its type
78417842
// statically.
78427843

7843-
// Create a fake span for functions that expect it. Shouldn't matter what
7844-
// it is, since this isn't user-written code. (Possibly better: have
7845-
// create_vtable take a span argument and pass it in here?)
7846-
let span fake_span = rec(lo=0u,hi=0u);
7847-
78487844
// Create a local context that's aware of the name of the method we're
78497845
// creating.
78507846
let @local_ctxt mcx =
@@ -7857,15 +7853,15 @@ fn process_fwding_mthd(@local_ctxt cx, @ty::method m, TypeRef llself_ty,
78577853
// Get the forwarding function's type and declare it.
78587854
let TypeRef llforwarding_fn_ty =
78597855
type_of_fn_full(
7860-
cx.ccx, fake_span, m.proto,
7856+
cx.ccx, sp, m.proto,
78617857
some[TypeRef](llself_ty), m.inputs, m.output,
78627858
vec::len[ast::ty_param](ty_params));
78637859
let ValueRef llforwarding_fn =
78647860
decl_internal_fastcall_fn(cx.ccx.llmod, s, llforwarding_fn_ty);
78657861

78667862
// Create a new function context and block context for the forwarding
78677863
// function, holding onto a pointer to the first block.
7868-
auto fcx = new_fn_ctxt(cx, fake_span, llforwarding_fn);
7864+
auto fcx = new_fn_ctxt(cx, sp, llforwarding_fn);
78697865
auto bcx = new_top_block_ctxt(fcx);
78707866
auto lltop = bcx.llbb;
78717867

@@ -7926,8 +7922,7 @@ fn process_fwding_mthd(@local_ctxt cx, @ty::method m, TypeRef llself_ty,
79267922

79277923
// And cast to that type.
79287924
llself_obj_body = bcx.build.PointerCast(llself_obj_body,
7929-
T_ptr(type_of(cx.ccx,
7930-
fake_span,
7925+
T_ptr(type_of(cx.ccx, sp,
79317926
body_ty)));
79327927

79337928
// Now, reach into the body and grab the with_obj.
@@ -7950,7 +7945,7 @@ fn process_fwding_mthd(@local_ctxt cx, @ty::method m, TypeRef llself_ty,
79507945
let uint ix = 0u;
79517946
alt (ty::struct(bcx.fcx.lcx.ccx.tcx, with_obj_ty)) {
79527947
case (ty::ty_obj(?methods)) {
7953-
ix = ty::method_idx(cx.ccx.sess, fake_span, m.ident, methods);
7948+
ix = ty::method_idx(cx.ccx.sess, sp, m.ident, methods);
79547949
}
79557950
case (_) {
79567951
// Shouldn't happen.
@@ -7968,7 +7963,7 @@ fn process_fwding_mthd(@local_ctxt cx, @ty::method m, TypeRef llself_ty,
79687963
auto orig_mthd_ty = ty::method_ty_to_fn_ty(cx.ccx.tcx, *m);
79697964
auto llwith_obj_ty = val_ty(llwith_obj.val);
79707965
auto llorig_mthd_ty =
7971-
type_of_fn_full(bcx.fcx.lcx.ccx, fake_span,
7966+
type_of_fn_full(bcx.fcx.lcx.ccx, sp,
79727967
ty::ty_fn_proto(bcx.fcx.lcx.ccx.tcx, orig_mthd_ty),
79737968
some[TypeRef](llwith_obj_ty),
79747969
m.inputs,
@@ -8042,7 +8037,7 @@ fn process_normal_mthd(@local_ctxt cx, @ast::method m, TypeRef llself_ty,
80428037

80438038
// Create a vtable for an object being translated. Returns a pointer into
80448039
// read-only memory.
8045-
fn create_vtbl(@local_ctxt cx, TypeRef llself_ty, ty::t self_ty,
8040+
fn create_vtbl(@local_ctxt cx, &span sp, TypeRef llself_ty, ty::t self_ty,
80468041
&ast::_obj ob, &vec[ast::ty_param] ty_params,
80478042
option::t[ty::t] with_obj_ty,
80488043
ty::t[] additional_field_tys) -> ValueRef {
@@ -8187,7 +8182,7 @@ fn create_vtbl(@local_ctxt cx, TypeRef llself_ty, ty::t self_ty,
81878182
}
81888183
case (some(?t)) {
81898184
llmethods += [process_fwding_mthd(
8190-
cx, fm, llself_ty,
8185+
cx, sp, fm, llself_ty,
81918186
self_ty, ty_params,
81928187
t,
81938188
additional_field_tys)];
@@ -8285,7 +8280,8 @@ fn trans_obj(@local_ctxt cx, &span sp, &ast::_obj ob, ast::node_id ctor_id,
82858280
// It will be located in the read-only memory of the executable we're
82868281
// creating and will contain ValueRefs for all of this object's methods.
82878282
// create_vtbl returns a pointer to the vtable, which we store.
8288-
auto vtbl = create_vtbl(cx, llself_ty, self_ty, ob, ty_params, none, ~[]);
8283+
auto vtbl = create_vtbl(cx, sp, llself_ty, self_ty, ob, ty_params, none,
8284+
~[]);
82898285

82908286
bcx.build.Store(vtbl, pair_vtbl);
82918287

0 commit comments

Comments
 (0)