From d80ff126bf4597fa44612abdb21d7d3ff6ecbce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Mon, 24 Aug 2015 21:50:50 +0200 Subject: [PATCH] Rename get_len() to get_meta() The functions is useful for all kinds of fat pointers, but get_len() just feels so wrong for trait object fat pointers. Let's use get_meta() because that's rather neutral. --- src/librustc_trans/trans/_match.rs | 12 ++++++------ src/librustc_trans/trans/base.rs | 8 ++++---- src/librustc_trans/trans/callee.rs | 2 +- src/librustc_trans/trans/expr.rs | 12 ++++++------ src/librustc_trans/trans/foreign.rs | 2 +- src/librustc_trans/trans/glue.rs | 2 +- src/librustc_trans/trans/intrinsic.rs | 2 +- src/librustc_trans/trans/tvec.rs | 2 +- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/librustc_trans/trans/_match.rs b/src/librustc_trans/trans/_match.rs index bd7c67fa8bb..bd3e077aa55 100644 --- a/src/librustc_trans/trans/_match.rs +++ b/src/librustc_trans/trans/_match.rs @@ -886,9 +886,9 @@ fn compare_str<'blk, 'tcx>(cx: Block<'blk, 'tcx>, &format!("comparison of `{}`", rhs_t), StrEqFnLangItem); let lhs_data = Load(cx, expr::get_dataptr(cx, lhs)); - let lhs_len = Load(cx, expr::get_len(cx, lhs)); + let lhs_len = Load(cx, expr::get_meta(cx, lhs)); let rhs_data = Load(cx, expr::get_dataptr(cx, rhs)); - let rhs_len = Load(cx, expr::get_len(cx, rhs)); + let rhs_len = Load(cx, expr::get_meta(cx, rhs)); callee::trans_lang_call(cx, did, &[lhs_data, lhs_len, rhs_data, rhs_len], None, debug_loc) } @@ -910,14 +910,14 @@ fn compare_str<'blk, 'tcx>(cx: Block<'blk, 'tcx>, let rhs_str = alloc_ty(cx, ty_str_slice, "rhs_str"); Store(cx, GEPi(cx, rhs, &[0, 0]), expr::get_dataptr(cx, rhs_str)); - Store(cx, C_uint(cx.ccx(), pat_len), expr::get_len(cx, rhs_str)); + Store(cx, C_uint(cx.ccx(), pat_len), expr::get_meta(cx, rhs_str)); let lhs_str; if val_ty(lhs) == val_ty(rhs) { // Both the discriminant and the pattern are thin pointers lhs_str = alloc_ty(cx, ty_str_slice, "lhs_str"); Store(cx, GEPi(cx, lhs, &[0, 0]), expr::get_dataptr(cx, lhs_str)); - Store(cx, C_uint(cx.ccx(), pat_len), expr::get_len(cx, lhs_str)); + Store(cx, C_uint(cx.ccx(), pat_len), expr::get_meta(cx, lhs_str)); } else { // The discriminant is a fat pointer @@ -1196,9 +1196,9 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, let llty = type_of::type_of(bcx.ccx(), unsized_ty); let scratch = alloca_no_lifetime(bcx, llty, "__struct_field_fat_ptr"); let data = adt::trans_field_ptr(bcx, &*repr, struct_val, 0, arg_count); - let len = Load(bcx, expr::get_len(bcx, val.val)); + let len = Load(bcx, expr::get_meta(bcx, val.val)); Store(bcx, data, expr::get_dataptr(bcx, scratch)); - Store(bcx, len, expr::get_len(bcx, scratch)); + Store(bcx, len, expr::get_meta(bcx, scratch)); field_vals.push(scratch); } _ => {} diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index 6be2bb08464..0f53255197e 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -835,7 +835,7 @@ pub fn store_ty<'blk, 'tcx>(cx: Block<'blk, 'tcx>, v: ValueRef, dst: ValueRef, t if common::type_is_fat_ptr(cx.tcx(), t) { Store(cx, ExtractValue(cx, v, abi::FAT_PTR_ADDR), expr::get_dataptr(cx, dst)); - Store(cx, ExtractValue(cx, v, abi::FAT_PTR_EXTRA), expr::get_len(cx, dst)); + Store(cx, ExtractValue(cx, v, abi::FAT_PTR_EXTRA), expr::get_meta(cx, dst)); } else { let store = Store(cx, from_arg_ty(cx, v, t), to_arg_ty_ptr(cx, dst, t)); unsafe { @@ -1389,7 +1389,7 @@ pub fn create_datums_for_fn_args<'a, 'tcx>(mut bcx: Block<'a, 'tcx>, arg_scope_id, (data, extra), |(data, extra), bcx, dst| { Store(bcx, data, expr::get_dataptr(bcx, dst)); - Store(bcx, extra, expr::get_len(bcx, dst)); + Store(bcx, extra, expr::get_meta(bcx, dst)); bcx })) } else { @@ -1420,7 +1420,7 @@ pub fn create_datums_for_fn_args<'a, 'tcx>(mut bcx: Block<'a, 'tcx>, let data = get_param(bcx.fcx.llfn, idx); let extra = get_param(bcx.fcx.llfn, idx + 1); Store(bcx, data, expr::get_dataptr(bcx, lldest)); - Store(bcx, extra, expr::get_len(bcx, lldest)); + Store(bcx, extra, expr::get_meta(bcx, lldest)); idx += 2; } else { let datum = datum::Datum::new( @@ -1822,7 +1822,7 @@ fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx i); if common::type_is_fat_ptr(bcx.tcx(), arg_ty) { Store(bcx, get_param(fcx.llfn, llarg_idx), expr::get_dataptr(bcx, lldestptr)); - Store(bcx, get_param(fcx.llfn, llarg_idx + 1), expr::get_len(bcx, lldestptr)); + Store(bcx, get_param(fcx.llfn, llarg_idx + 1), expr::get_meta(bcx, lldestptr)); llarg_idx += 2; } else { let arg = get_param(fcx.llfn, llarg_idx); diff --git a/src/librustc_trans/trans/callee.rs b/src/librustc_trans/trans/callee.rs index d201114fd82..92b9ed9c3fb 100644 --- a/src/librustc_trans/trans/callee.rs +++ b/src/librustc_trans/trans/callee.rs @@ -1128,7 +1128,7 @@ pub fn trans_arg_datum<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, if common::type_is_fat_ptr(bcx.tcx(), formal_arg_ty) { llargs.push(Load(bcx, expr::get_dataptr(bcx, val))); - llargs.push(Load(bcx, expr::get_len(bcx, val))); + llargs.push(Load(bcx, expr::get_meta(bcx, val))); } else { llargs.push(val); } diff --git a/src/librustc_trans/trans/expr.rs b/src/librustc_trans/trans/expr.rs index 8d1d9cb1d01..68f79dc386a 100644 --- a/src/librustc_trans/trans/expr.rs +++ b/src/librustc_trans/trans/expr.rs @@ -282,7 +282,7 @@ pub fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, return DatumBlock::new(bcx, datum); } -pub fn get_len(bcx: Block, fat_ptr: ValueRef) -> ValueRef { +pub fn get_meta(bcx: Block, fat_ptr: ValueRef) -> ValueRef { GEPi(bcx, fat_ptr, &[0, abi::FAT_PTR_EXTRA]) } @@ -292,7 +292,7 @@ pub fn get_dataptr(bcx: Block, fat_ptr: ValueRef) -> ValueRef { pub fn copy_fat_ptr(bcx: Block, src_ptr: ValueRef, dst_ptr: ValueRef) { Store(bcx, Load(bcx, get_dataptr(bcx, src_ptr)), get_dataptr(bcx, dst_ptr)); - Store(bcx, Load(bcx, get_len(bcx, src_ptr)), get_len(bcx, dst_ptr)); + Store(bcx, Load(bcx, get_meta(bcx, src_ptr)), get_meta(bcx, dst_ptr)); } /// Retrieve the information we are losing (making dynamic) in an unsizing @@ -454,7 +454,7 @@ fn coerce_unsized<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, // load out the original data pointer so we can repackage // it. (Load(bcx, get_dataptr(bcx, source.val)), - Some(Load(bcx, get_len(bcx, source.val)))) + Some(Load(bcx, get_meta(bcx, source.val)))) } else { let val = if source.kind.is_by_ref() { load_ty(bcx, source.val, source.ty) @@ -473,7 +473,7 @@ fn coerce_unsized<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let base = PointerCast(bcx, base, ptr_ty); Store(bcx, base, get_dataptr(bcx, target.val)); - Store(bcx, info, get_len(bcx, target.val)); + Store(bcx, info, get_meta(bcx, target.val)); } // This can be extended to enums and tuples in the future. @@ -729,8 +729,8 @@ fn trans_field<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>, } else { let scratch = rvalue_scratch_datum(bcx, d.ty, ""); Store(bcx, d.val, get_dataptr(bcx, scratch.val)); - let info = Load(bcx, get_len(bcx, base_datum.val)); - Store(bcx, info, get_len(bcx, scratch.val)); + let info = Load(bcx, get_meta(bcx, base_datum.val)); + Store(bcx, info, get_meta(bcx, scratch.val)); // Always generate an lvalue datum, because this pointer doesn't own // the data and cleanup is scheduled elsewhere. diff --git a/src/librustc_trans/trans/foreign.rs b/src/librustc_trans/trans/foreign.rs index b316d105d0c..929061b08b8 100644 --- a/src/librustc_trans/trans/foreign.rs +++ b/src/librustc_trans/trans/foreign.rs @@ -302,7 +302,7 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, "__arg"); if type_is_fat_ptr(ccx.tcx(), passed_arg_tys[i]) { Store(bcx, llargs_rust[i + offset], expr::get_dataptr(bcx, scratch)); - Store(bcx, llargs_rust[i + offset + 1], expr::get_len(bcx, scratch)); + Store(bcx, llargs_rust[i + offset + 1], expr::get_meta(bcx, scratch)); offset += 1; } else { base::store_ty(bcx, llarg_rust, scratch, passed_arg_tys[i]); diff --git a/src/librustc_trans/trans/glue.rs b/src/librustc_trans/trans/glue.rs index fe20ae2cf39..d049d51d085 100644 --- a/src/librustc_trans/trans/glue.rs +++ b/src/librustc_trans/trans/glue.rs @@ -389,7 +389,7 @@ fn trans_struct_drop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let (_, bcx) = if type_is_sized(bcx.tcx(), t) { invoke(bcx, dtor_addr, &[v0], dtor_ty, DebugLoc::None) } else { - let args = [Load(bcx, expr::get_dataptr(bcx, v0)), Load(bcx, expr::get_len(bcx, v0))]; + let args = [Load(bcx, expr::get_dataptr(bcx, v0)), Load(bcx, expr::get_meta(bcx, v0))]; invoke(bcx, dtor_addr, &args, dtor_ty, DebugLoc::None) }; diff --git a/src/librustc_trans/trans/intrinsic.rs b/src/librustc_trans/trans/intrinsic.rs index ded748e9894..a7f99be0762 100644 --- a/src/librustc_trans/trans/intrinsic.rs +++ b/src/librustc_trans/trans/intrinsic.rs @@ -449,7 +449,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, } else { let scratch = rvalue_scratch_datum(bcx, tp_ty, "tmp"); Store(bcx, llargs[0], expr::get_dataptr(bcx, scratch.val)); - Store(bcx, llargs[1], expr::get_len(bcx, scratch.val)); + Store(bcx, llargs[1], expr::get_meta(bcx, scratch.val)); fcx.schedule_lifetime_end(cleanup::CustomScope(cleanup_scope), scratch.val); scratch.val }; diff --git a/src/librustc_trans/trans/tvec.rs b/src/librustc_trans/trans/tvec.rs index a9abc61c274..397c9c74835 100644 --- a/src/librustc_trans/trans/tvec.rs +++ b/src/librustc_trans/trans/tvec.rs @@ -310,7 +310,7 @@ pub fn get_base_and_len<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ty::TyArray(_, n) => get_fixed_base_and_len(bcx, llval, n), ty::TySlice(_) | ty::TyStr => { let base = Load(bcx, expr::get_dataptr(bcx, llval)); - let len = Load(bcx, expr::get_len(bcx, llval)); + let len = Load(bcx, expr::get_meta(bcx, llval)); (base, len) }