librustc: De-mut trans. rs=demuting
This commit is contained in:
parent
553c27c515
commit
9c71249b9d
|
@ -831,7 +831,7 @@ pub fn extract_variant_args(bcx: block,
|
||||||
-> ExtractedBlock {
|
-> ExtractedBlock {
|
||||||
let (enm, evar) = vdefs;
|
let (enm, evar) = vdefs;
|
||||||
let _icx = bcx.insn_ctxt("match::extract_variant_args");
|
let _icx = bcx.insn_ctxt("match::extract_variant_args");
|
||||||
let ccx = bcx.fcx.ccx;
|
let ccx = *bcx.fcx.ccx;
|
||||||
let enum_ty_substs = match ty::get(node_id_type(bcx, pat_id)).sty {
|
let enum_ty_substs = match ty::get(node_id_type(bcx, pat_id)).sty {
|
||||||
ty::ty_enum(id, ref substs) => {
|
ty::ty_enum(id, ref substs) => {
|
||||||
assert id == enm;
|
assert id == enm;
|
||||||
|
@ -1272,7 +1272,7 @@ pub fn compile_submatch(bcx: block,
|
||||||
|
|
||||||
let vals_left = vec::append(vec::slice(vals, 0u, col).to_vec(),
|
let vals_left = vec::append(vec::slice(vals, 0u, col).to_vec(),
|
||||||
vec::slice(vals, col + 1u, vals.len()));
|
vec::slice(vals, col + 1u, vals.len()));
|
||||||
let ccx = bcx.fcx.ccx;
|
let ccx = *bcx.fcx.ccx;
|
||||||
let mut pat_id = 0;
|
let mut pat_id = 0;
|
||||||
for vec::each(m) |br| {
|
for vec::each(m) |br| {
|
||||||
// Find a real id (we're adding placeholder wildcard patterns, but
|
// Find a real id (we're adding placeholder wildcard patterns, but
|
||||||
|
@ -1710,7 +1710,7 @@ pub fn bind_irrefutable_pat(bcx: block,
|
||||||
binding_mode: IrrefutablePatternBindingMode)
|
binding_mode: IrrefutablePatternBindingMode)
|
||||||
-> block {
|
-> block {
|
||||||
let _icx = bcx.insn_ctxt("match::bind_irrefutable_pat");
|
let _icx = bcx.insn_ctxt("match::bind_irrefutable_pat");
|
||||||
let ccx = bcx.fcx.ccx;
|
let ccx = *bcx.fcx.ccx;
|
||||||
let mut bcx = bcx;
|
let mut bcx = bcx;
|
||||||
|
|
||||||
// Necessary since bind_irrefutable_pat is called outside trans_match
|
// Necessary since bind_irrefutable_pat is called outside trans_match
|
||||||
|
|
|
@ -1162,7 +1162,7 @@ pub fn trans_stmt(cx: block, s: ast::stmt) -> block {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast::decl_item(i) => trans_item(cx.fcx.ccx, *i)
|
ast::decl_item(i) => trans_item(*cx.fcx.ccx, *i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast::stmt_mac(*) => cx.tcx().sess.bug(~"unexpanded macro")
|
ast::stmt_mac(*) => cx.tcx().sess.bug(~"unexpanded macro")
|
||||||
|
@ -1584,25 +1584,25 @@ pub fn new_fn_ctxt_w_id(ccx: @CrateContext,
|
||||||
param_substs: Option<@param_substs>,
|
param_substs: Option<@param_substs>,
|
||||||
sp: Option<span>) -> fn_ctxt {
|
sp: Option<span>) -> fn_ctxt {
|
||||||
let llbbs = mk_standard_basic_blocks(llfndecl);
|
let llbbs = mk_standard_basic_blocks(llfndecl);
|
||||||
return @fn_ctxt_ {
|
return @mut fn_ctxt_ {
|
||||||
llfn: llfndecl,
|
llfn: llfndecl,
|
||||||
llenv: unsafe { llvm::LLVMGetParam(llfndecl, 1u as c_uint) },
|
llenv: unsafe { llvm::LLVMGetParam(llfndecl, 1u as c_uint) },
|
||||||
llretptr: unsafe { llvm::LLVMGetParam(llfndecl, 0u as c_uint) },
|
llretptr: unsafe { llvm::LLVMGetParam(llfndecl, 0u as c_uint) },
|
||||||
mut llstaticallocas: llbbs.sa,
|
llstaticallocas: llbbs.sa,
|
||||||
mut llloadenv: None,
|
llloadenv: None,
|
||||||
mut llreturn: llbbs.rt,
|
llreturn: llbbs.rt,
|
||||||
mut llself: None,
|
llself: None,
|
||||||
mut personality: None,
|
personality: None,
|
||||||
mut loop_ret: None,
|
loop_ret: None,
|
||||||
llargs: HashMap(),
|
llargs: @HashMap(),
|
||||||
lllocals: HashMap(),
|
lllocals: @HashMap(),
|
||||||
llupvars: HashMap(),
|
llupvars: @HashMap(),
|
||||||
id: id,
|
id: id,
|
||||||
impl_id: impl_id,
|
impl_id: impl_id,
|
||||||
param_substs: param_substs,
|
param_substs: param_substs,
|
||||||
span: sp,
|
span: sp,
|
||||||
path: path,
|
path: path,
|
||||||
ccx: ccx
|
ccx: @ccx
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1792,7 +1792,7 @@ pub fn trans_closure(ccx: @CrateContext,
|
||||||
llvm::LLVMSetGC(fcx.llfn, strategy);
|
llvm::LLVMSetGC(fcx.llfn, strategy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ccx.uses_gc = true;
|
*ccx.uses_gc = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the first basic block in the function and keep a handle on it to
|
// Create the first basic block in the function and keep a handle on it to
|
||||||
|
@ -2815,7 +2815,7 @@ pub fn trap(bcx: block) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn decl_gc_metadata(ccx: @CrateContext, llmod_id: ~str) {
|
pub fn decl_gc_metadata(ccx: @CrateContext, llmod_id: ~str) {
|
||||||
if !ccx.sess.opts.gc || !ccx.uses_gc {
|
if !ccx.sess.opts.gc || !*ccx.uses_gc {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3050,7 +3050,7 @@ pub fn trans_crate(sess: session::Session,
|
||||||
discrims: HashMap(),
|
discrims: HashMap(),
|
||||||
discrim_symbols: HashMap(),
|
discrim_symbols: HashMap(),
|
||||||
tydescs: ty::new_ty_hash(),
|
tydescs: ty::new_ty_hash(),
|
||||||
mut finished_tydescs: false,
|
finished_tydescs: @mut false,
|
||||||
external: HashMap(),
|
external: HashMap(),
|
||||||
monomorphized: HashMap(),
|
monomorphized: HashMap(),
|
||||||
monomorphizing: HashMap(),
|
monomorphizing: HashMap(),
|
||||||
|
@ -3092,9 +3092,9 @@ pub fn trans_crate(sess: session::Session,
|
||||||
builder: BuilderRef_res(unsafe { llvm::LLVMCreateBuilder() }),
|
builder: BuilderRef_res(unsafe { llvm::LLVMCreateBuilder() }),
|
||||||
shape_cx: mk_ctxt(llmod),
|
shape_cx: mk_ctxt(llmod),
|
||||||
crate_map: crate_map,
|
crate_map: crate_map,
|
||||||
mut uses_gc: false,
|
uses_gc: @mut false,
|
||||||
dbg_cx: dbg_cx,
|
dbg_cx: dbg_cx,
|
||||||
mut do_not_commit_warning_issued: false
|
do_not_commit_warning_issued: @mut false
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -175,7 +175,7 @@ pub struct CrateContext {
|
||||||
tydescs: HashMap<ty::t, @mut tydesc_info>,
|
tydescs: HashMap<ty::t, @mut tydesc_info>,
|
||||||
// Set when running emit_tydescs to enforce that no more tydescs are
|
// Set when running emit_tydescs to enforce that no more tydescs are
|
||||||
// created.
|
// created.
|
||||||
mut finished_tydescs: bool,
|
finished_tydescs: @mut bool,
|
||||||
// Track mapping of external ids to local items imported for inlining
|
// Track mapping of external ids to local items imported for inlining
|
||||||
external: HashMap<ast::def_id, Option<ast::node_id>>,
|
external: HashMap<ast::def_id, Option<ast::node_id>>,
|
||||||
// Cache instances of monomorphized functions
|
// Cache instances of monomorphized functions
|
||||||
|
@ -224,9 +224,9 @@ pub struct CrateContext {
|
||||||
// Set when at least one function uses GC. Needed so that
|
// Set when at least one function uses GC. Needed so that
|
||||||
// decl_gc_metadata knows whether to link to the module metadata, which
|
// decl_gc_metadata knows whether to link to the module metadata, which
|
||||||
// is not emitted by LLVM's GC pass when no functions use GC.
|
// is not emitted by LLVM's GC pass when no functions use GC.
|
||||||
mut uses_gc: bool,
|
uses_gc: @mut bool,
|
||||||
dbg_cx: Option<debuginfo::DebugContext>,
|
dbg_cx: Option<debuginfo::DebugContext>,
|
||||||
mut do_not_commit_warning_issued: bool
|
do_not_commit_warning_issued: @mut bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Types used for llself.
|
// Types used for llself.
|
||||||
|
@ -273,34 +273,34 @@ pub struct fn_ctxt_ {
|
||||||
// the function, due to LLVM's quirks.
|
// the function, due to LLVM's quirks.
|
||||||
// A block for all the function's static allocas, so that LLVM
|
// A block for all the function's static allocas, so that LLVM
|
||||||
// will coalesce them into a single alloca call.
|
// will coalesce them into a single alloca call.
|
||||||
mut llstaticallocas: BasicBlockRef,
|
llstaticallocas: BasicBlockRef,
|
||||||
// A block containing code that copies incoming arguments to space
|
// A block containing code that copies incoming arguments to space
|
||||||
// already allocated by code in one of the llallocas blocks.
|
// already allocated by code in one of the llallocas blocks.
|
||||||
// (LLVM requires that arguments be copied to local allocas before
|
// (LLVM requires that arguments be copied to local allocas before
|
||||||
// allowing most any operation to be performed on them.)
|
// allowing most any operation to be performed on them.)
|
||||||
mut llloadenv: Option<BasicBlockRef>,
|
llloadenv: Option<BasicBlockRef>,
|
||||||
mut llreturn: BasicBlockRef,
|
llreturn: BasicBlockRef,
|
||||||
// The 'self' value currently in use in this function, if there
|
// The 'self' value currently in use in this function, if there
|
||||||
// is one.
|
// is one.
|
||||||
//
|
//
|
||||||
// NB: This is the type of the self *variable*, not the self *type*. The
|
// NB: This is the type of the self *variable*, not the self *type*. The
|
||||||
// self type is set only for default methods, while the self variable is
|
// self type is set only for default methods, while the self variable is
|
||||||
// set for all methods.
|
// set for all methods.
|
||||||
mut llself: Option<ValSelfData>,
|
llself: Option<ValSelfData>,
|
||||||
// The a value alloca'd for calls to upcalls.rust_personality. Used when
|
// The a value alloca'd for calls to upcalls.rust_personality. Used when
|
||||||
// outputting the resume instruction.
|
// outputting the resume instruction.
|
||||||
mut personality: Option<ValueRef>,
|
personality: Option<ValueRef>,
|
||||||
// If this is a for-loop body that returns, this holds the pointers needed
|
// If this is a for-loop body that returns, this holds the pointers needed
|
||||||
// for that (flagptr, retptr)
|
// for that (flagptr, retptr)
|
||||||
mut loop_ret: Option<(ValueRef, ValueRef)>,
|
loop_ret: Option<(ValueRef, ValueRef)>,
|
||||||
|
|
||||||
// Maps arguments to allocas created for them in llallocas.
|
// Maps arguments to allocas created for them in llallocas.
|
||||||
llargs: HashMap<ast::node_id, local_val>,
|
llargs: @HashMap<ast::node_id, local_val>,
|
||||||
// Maps the def_ids for local variables to the allocas created for
|
// Maps the def_ids for local variables to the allocas created for
|
||||||
// them in llallocas.
|
// them in llallocas.
|
||||||
lllocals: HashMap<ast::node_id, local_val>,
|
lllocals: @HashMap<ast::node_id, local_val>,
|
||||||
// Same as above, but for closure upvars
|
// Same as above, but for closure upvars
|
||||||
llupvars: HashMap<ast::node_id, ValueRef>,
|
llupvars: @HashMap<ast::node_id, ValueRef>,
|
||||||
|
|
||||||
// The node_id of the function, or -1 if it doesn't correspond to
|
// The node_id of the function, or -1 if it doesn't correspond to
|
||||||
// a user-defined function.
|
// a user-defined function.
|
||||||
|
@ -319,14 +319,14 @@ pub struct fn_ctxt_ {
|
||||||
path: path,
|
path: path,
|
||||||
|
|
||||||
// This function's enclosing crate context.
|
// This function's enclosing crate context.
|
||||||
ccx: @CrateContext
|
ccx: @@CrateContext
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type fn_ctxt = @fn_ctxt_;
|
pub type fn_ctxt = @mut fn_ctxt_;
|
||||||
|
|
||||||
pub fn warn_not_to_commit(ccx: @CrateContext, msg: ~str) {
|
pub fn warn_not_to_commit(ccx: @CrateContext, msg: ~str) {
|
||||||
if !ccx.do_not_commit_warning_issued {
|
if !*ccx.do_not_commit_warning_issued {
|
||||||
ccx.do_not_commit_warning_issued = true;
|
*ccx.do_not_commit_warning_issued = true;
|
||||||
ccx.sess.warn(msg + ~" -- do not commit like this!");
|
ccx.sess.warn(msg + ~" -- do not commit like this!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -689,7 +689,7 @@ pub fn block_parent(cx: block) -> block {
|
||||||
// Accessors
|
// Accessors
|
||||||
|
|
||||||
pub impl block {
|
pub impl block {
|
||||||
pure fn ccx() -> @CrateContext { self.fcx.ccx }
|
pure fn ccx() -> @CrateContext { *self.fcx.ccx }
|
||||||
pure fn tcx() -> ty::ctxt { self.fcx.ccx.tcx }
|
pure fn tcx() -> ty::ctxt { self.fcx.ccx.tcx }
|
||||||
pure fn sess() -> Session { self.fcx.ccx.sess }
|
pure fn sess() -> Session { self.fcx.ccx.sess }
|
||||||
|
|
||||||
|
|
|
@ -778,7 +778,7 @@ pub fn create_local_var(bcx: block, local: @ast::local)
|
||||||
pub fn create_arg(bcx: block, arg: ast::arg, sp: span)
|
pub fn create_arg(bcx: block, arg: ast::arg, sp: span)
|
||||||
-> Option<@Metadata<ArgumentMetadata>> {
|
-> Option<@Metadata<ArgumentMetadata>> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let fcx = bcx.fcx, cx = fcx.ccx;
|
let fcx = bcx.fcx, cx = *fcx.ccx;
|
||||||
let cache = get_cache(cx);
|
let cache = get_cache(cx);
|
||||||
let tg = ArgVariableTag;
|
let tg = ArgVariableTag;
|
||||||
match cached_metadata::<@Metadata<ArgumentMetadata>>(
|
match cached_metadata::<@Metadata<ArgumentMetadata>>(
|
||||||
|
@ -845,7 +845,7 @@ pub fn update_source_pos(cx: block, s: span) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_function(fcx: fn_ctxt) -> @Metadata<SubProgramMetadata> {
|
pub fn create_function(fcx: fn_ctxt) -> @Metadata<SubProgramMetadata> {
|
||||||
let cx = fcx.ccx;
|
let cx = *fcx.ccx;
|
||||||
let dbg_cx = (/*bad*/copy cx.dbg_cx).get();
|
let dbg_cx = (/*bad*/copy cx.dbg_cx).get();
|
||||||
|
|
||||||
debug!("~~");
|
debug!("~~");
|
||||||
|
|
|
@ -944,10 +944,10 @@ pub fn trans_local_var(bcx: block, def: ast::def) -> Datum {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast::def_arg(nid, _, _) => {
|
ast::def_arg(nid, _, _) => {
|
||||||
take_local(bcx, bcx.fcx.llargs, nid)
|
take_local(bcx, *bcx.fcx.llargs, nid)
|
||||||
}
|
}
|
||||||
ast::def_local(nid, _) | ast::def_binding(nid, _) => {
|
ast::def_local(nid, _) | ast::def_binding(nid, _) => {
|
||||||
take_local(bcx, bcx.fcx.lllocals, nid)
|
take_local(bcx, *bcx.fcx.lllocals, nid)
|
||||||
}
|
}
|
||||||
ast::def_self(nid, _) => {
|
ast::def_self(nid, _) => {
|
||||||
let self_info: ValSelfData = match bcx.fcx.llself {
|
let self_info: ValSelfData = match bcx.fcx.llself {
|
||||||
|
|
|
@ -654,7 +654,7 @@ pub fn declare_tydesc(ccx: @CrateContext, t: ty::t) -> @mut tydesc_info {
|
||||||
let _icx = ccx.insn_ctxt("declare_tydesc");
|
let _icx = ccx.insn_ctxt("declare_tydesc");
|
||||||
// If emit_tydescs already ran, then we shouldn't be creating any new
|
// If emit_tydescs already ran, then we shouldn't be creating any new
|
||||||
// tydescs.
|
// tydescs.
|
||||||
assert !ccx.finished_tydescs;
|
assert !*ccx.finished_tydescs;
|
||||||
|
|
||||||
let llty = type_of(ccx, t);
|
let llty = type_of(ccx, t);
|
||||||
|
|
||||||
|
@ -761,7 +761,7 @@ pub fn make_generic_glue(ccx: @CrateContext, t: ty::t, llfn: ValueRef,
|
||||||
pub fn emit_tydescs(ccx: @CrateContext) {
|
pub fn emit_tydescs(ccx: @CrateContext) {
|
||||||
let _icx = ccx.insn_ctxt("emit_tydescs");
|
let _icx = ccx.insn_ctxt("emit_tydescs");
|
||||||
// As of this point, allow no more tydescs to be created.
|
// As of this point, allow no more tydescs to be created.
|
||||||
ccx.finished_tydescs = true;
|
*ccx.finished_tydescs = true;
|
||||||
for ccx.tydescs.each_value |&val| {
|
for ccx.tydescs.each_value |&val| {
|
||||||
let glue_fn_ty = T_ptr(T_generic_glue_fn(ccx));
|
let glue_fn_ty = T_ptr(T_generic_glue_fn(ccx));
|
||||||
let ti = val;
|
let ti = val;
|
||||||
|
|
Loading…
Reference in New Issue