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.
This commit is contained in:
parent
2375743037
commit
d80ff126bf
@ -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);
|
||||
}
|
||||
_ => {}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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]);
|
||||
|
@ -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)
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
};
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user