mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Remove local_imm/local_mem since all variables are now by reference
This commit is contained in:
parent
2616581863
commit
7dfb865339
@ -140,6 +140,11 @@
|
||||
* the various values we copied explicitly. Note that guards and moves are
|
||||
* just plain incompatible.
|
||||
*
|
||||
* Some relevant helper functions that manage bindings:
|
||||
* - `create_bindings_map()`
|
||||
* - `store_non_ref_bindings()`
|
||||
* - `insert_lllocals()`
|
||||
*
|
||||
*/
|
||||
|
||||
use core::prelude::*;
|
||||
@ -1201,7 +1206,7 @@ fn insert_lllocals(bcx: block,
|
||||
debug!("binding %? to %s",
|
||||
binding_info.id,
|
||||
val_str(bcx.ccx().tn, llval));
|
||||
llmap.insert(binding_info.id, local_mem(llval));
|
||||
llmap.insert(binding_info.id, llval);
|
||||
}
|
||||
return bcx;
|
||||
}
|
||||
@ -1673,7 +1678,7 @@ pub fn trans_match_inner(scope_cx: block,
|
||||
|
||||
let mut arm_datas = ~[], matches = ~[];
|
||||
for vec::each(arms) |arm| {
|
||||
let body = scope_block(bcx, arm.body.info(), ~"case_body");
|
||||
let body = scope_block(bcx, arm.body.info(), "case_body");
|
||||
let bindings_map = create_bindings_map(bcx, arm.pats[0]);
|
||||
let arm_data = @ArmData {bodycx: body,
|
||||
arm: arm,
|
||||
@ -1765,22 +1770,20 @@ pub fn bind_irrefutable_pat(bcx: block,
|
||||
datum.copy_to_datum(bcx, INIT, scratch);
|
||||
match binding_mode {
|
||||
BindLocal => {
|
||||
bcx.fcx.lllocals.insert(pat.id,
|
||||
local_mem(scratch.val));
|
||||
bcx.fcx.lllocals.insert(pat.id, scratch.val);
|
||||
}
|
||||
BindArgument => {
|
||||
bcx.fcx.llargs.insert(pat.id,
|
||||
local_mem(scratch.val));
|
||||
bcx.fcx.llargs.insert(pat.id, scratch.val);
|
||||
}
|
||||
}
|
||||
add_clean(bcx, scratch.val, binding_ty);
|
||||
} else {
|
||||
match binding_mode {
|
||||
BindLocal => {
|
||||
bcx.fcx.lllocals.insert(pat.id, local_mem(val));
|
||||
bcx.fcx.lllocals.insert(pat.id, val);
|
||||
}
|
||||
BindArgument => {
|
||||
bcx.fcx.llargs.insert(pat.id, local_mem(val));
|
||||
bcx.fcx.llargs.insert(pat.id, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1105,8 +1105,8 @@ pub fn init_local(bcx: block, local: @ast::local) -> block {
|
||||
}
|
||||
}
|
||||
|
||||
let llptr = match bcx.fcx.lllocals.find(&local.node.id) {
|
||||
Some(&local_mem(v)) => v,
|
||||
let llptr = match bcx.fcx.lllocals.find_copy(&local.node.id) {
|
||||
Some(v) => v,
|
||||
_ => {
|
||||
bcx.tcx().sess.span_bug(local.span,
|
||||
"init_local: Someone forgot to document why it's\
|
||||
@ -1432,7 +1432,7 @@ pub fn alloc_local(cx: block, local: @ast::local) -> block {
|
||||
});
|
||||
}
|
||||
}
|
||||
cx.fcx.lllocals.insert(local.node.id, local_mem(val));
|
||||
cx.fcx.lllocals.insert(local.node.id, val);
|
||||
cx
|
||||
}
|
||||
|
||||
@ -1768,7 +1768,7 @@ pub fn copy_args_to_allocas(fcx: fn_ctxt,
|
||||
false,
|
||||
_match::BindArgument);
|
||||
|
||||
fcx.llargs.insert(arg_id, local_mem(llarg));
|
||||
fcx.llargs.insert(arg_id, llarg);
|
||||
|
||||
if fcx.ccx.sess.opts.extra_debuginfo && fcx_has_nonzero_span(fcx) {
|
||||
debuginfo::create_arg(bcx, args[arg_n], args[arg_n].ty.span);
|
||||
@ -2004,7 +2004,7 @@ pub fn trans_enum_variant(ccx: @CrateContext,
|
||||
// this function as an opaque blob due to the way that type_of()
|
||||
// works. So we have to cast to the destination's view of the type.
|
||||
let llarg = match fcx.llargs.find(&va.id) {
|
||||
Some(&local_mem(x)) => x,
|
||||
Some(&x) => x,
|
||||
_ => fail!("trans_enum_variant: how do we know this works?"),
|
||||
};
|
||||
let arg_ty = arg_tys[i];
|
||||
@ -2074,12 +2074,7 @@ pub fn trans_tuple_struct(ccx: @CrateContext,
|
||||
fcx.llretptr.get(),
|
||||
0,
|
||||
i);
|
||||
let llarg = match fcx.llargs.get_copy(&field.node.id) {
|
||||
local_mem(x) => x,
|
||||
_ => {
|
||||
ccx.tcx.sess.bug("trans_tuple_struct: llarg wasn't local_mem")
|
||||
}
|
||||
};
|
||||
let llarg = fcx.llargs.get_copy(&field.node.id);
|
||||
let arg_ty = arg_tys[i];
|
||||
memcpy_ty(bcx, lldestptr, llarg, arg_ty);
|
||||
}
|
||||
|
@ -240,8 +240,6 @@ pub struct ValSelfData {
|
||||
is_owned: bool
|
||||
}
|
||||
|
||||
pub enum local_val { local_mem(ValueRef), local_imm(ValueRef), }
|
||||
|
||||
// Here `self_ty` is the real type of the self parameter to this method. It
|
||||
// will only be set in the case of default methods.
|
||||
pub struct param_substs {
|
||||
@ -328,10 +326,10 @@ pub struct fn_ctxt_ {
|
||||
has_immediate_return_value: bool,
|
||||
|
||||
// Maps arguments to allocas created for them in llallocas.
|
||||
llargs: @mut HashMap<ast::node_id, local_val>,
|
||||
llargs: @mut HashMap<ast::node_id, ValueRef>,
|
||||
// Maps the def_ids for local variables to the allocas created for
|
||||
// them in llallocas.
|
||||
lllocals: @mut HashMap<ast::node_id, local_val>,
|
||||
lllocals: @mut HashMap<ast::node_id, ValueRef>,
|
||||
// Same as above, but for closure upvars
|
||||
llupvars: @mut HashMap<ast::node_id, ValueRef>,
|
||||
|
||||
|
@ -105,7 +105,6 @@ use middle::ty;
|
||||
use util::common::indenter;
|
||||
use util::ppaux::ty_to_str;
|
||||
|
||||
use core::to_bytes;
|
||||
use core::uint;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::span;
|
||||
|
@ -864,16 +864,13 @@ pub fn create_local_var(bcx: block, local: @ast::local)
|
||||
};
|
||||
update_cache(cache, AutoVariableTag, local_var_metadata(mdval));
|
||||
|
||||
let llptr = match bcx.fcx.lllocals.find(&local.node.id) {
|
||||
option::Some(&local_mem(v)) => v,
|
||||
option::Some(_) => {
|
||||
bcx.tcx().sess.span_bug(local.span, "local is bound to something weird");
|
||||
}
|
||||
option::None => {
|
||||
match bcx.fcx.lllocals.get_copy(&local.node.pat.id) {
|
||||
local_imm(v) => v,
|
||||
_ => bcx.tcx().sess.span_bug(local.span, "local is bound to something weird")
|
||||
}
|
||||
// NDM Should use `pat_util::pat_bindings` for pats like (a, b) etc
|
||||
let llptr = match bcx.fcx.lllocals.find_copy(&local.node.pat.id) {
|
||||
Some(v) => v,
|
||||
None => {
|
||||
bcx.tcx().sess.span_bug(
|
||||
local.span,
|
||||
fmt!("No entry in lllocals table for %?", local.node.id));
|
||||
}
|
||||
};
|
||||
let declargs = ~[llmdnode([llptr]), mdnode];
|
||||
@ -922,9 +919,7 @@ pub fn create_arg(bcx: block, arg: ast::arg, sp: span)
|
||||
};
|
||||
update_cache(cache, tg, argument_metadata(mdval));
|
||||
|
||||
let llptr = match fcx.llargs.get_copy(&arg.id) {
|
||||
local_mem(v) | local_imm(v) => v,
|
||||
};
|
||||
let llptr = fcx.llargs.get_copy(&arg.id);
|
||||
let declargs = ~[llmdnode([llptr]), mdnode];
|
||||
trans::build::Call(bcx,
|
||||
*cx.intrinsics.get(&~"llvm.dbg.declare"),
|
||||
|
@ -1058,25 +1058,22 @@ pub fn trans_local_var(bcx: block, def: ast::def) -> Datum {
|
||||
};
|
||||
|
||||
fn take_local(bcx: block,
|
||||
table: &HashMap<ast::node_id, local_val>,
|
||||
table: &HashMap<ast::node_id, ValueRef>,
|
||||
nid: ast::node_id) -> Datum {
|
||||
let (v, mode) = match table.find(&nid) {
|
||||
Some(&local_mem(v)) => (v, ByRef(ZeroMem)),
|
||||
Some(&local_imm(v)) => (v, ByValue),
|
||||
let v = match table.find(&nid) {
|
||||
Some(&v) => v,
|
||||
None => {
|
||||
bcx.sess().bug(fmt!(
|
||||
"trans_local_var: no llval for local/arg %? found", nid));
|
||||
}
|
||||
};
|
||||
let ty = node_id_type(bcx, nid);
|
||||
|
||||
debug!("take_local(nid=%?, v=%s, mode=%?, ty=%s)",
|
||||
nid, bcx.val_str(v), mode, bcx.ty_to_str(ty));
|
||||
|
||||
debug!("take_local(nid=%?, v=%s, ty=%s)",
|
||||
nid, bcx.val_str(v), bcx.ty_to_str(ty));
|
||||
Datum {
|
||||
val: v,
|
||||
ty: ty,
|
||||
mode: mode,
|
||||
mode: ByRef(ZeroMem)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user