Skip to content

Commit 6c42ef3

Browse files
committed
De-@ trans contexts.
1 parent 869c96d commit 6c42ef3

File tree

14 files changed

+70
-72
lines changed

14 files changed

+70
-72
lines changed

src/librustc/middle/const_eval.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use middle::astencode;
1515

1616
use middle::ty;
1717
use middle::typeck::astconv;
18-
use middle;
1918
use util::nodemap::{DefIdMap, FnvHashMap, NodeMap};
2019

2120
use syntax::ast::*;
@@ -335,7 +334,6 @@ pub fn eval_const_expr(tcx: &ty::ctxt, e: &Expr) -> const_val {
335334

336335
pub fn eval_const_expr_partial<T: ty::ExprTyProvider>(tcx: &T, e: &Expr)
337336
-> Result<const_val, ~str> {
338-
use middle::ty;
339337
fn fromb(b: bool) -> Result<const_val, ~str> { Ok(const_int(b as i64)) }
340338
match e.node {
341339
ExprUnary(UnNeg, inner) => {

src/librustc/middle/trans/base.rs

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,14 @@ pub fn push_ctxt(s: &'static str) -> _InsnCtxt {
136136
}
137137

138138
pub struct StatRecorder<'a> {
139-
ccx: @CrateContext<'a>,
139+
ccx: &'a CrateContext<'a>,
140140
name: Option<~str>,
141141
start: u64,
142142
istart: uint,
143143
}
144144

145145
impl<'a> StatRecorder<'a> {
146-
pub fn new(ccx: @CrateContext<'a>, name: ~str) -> StatRecorder<'a> {
146+
pub fn new(ccx: &'a CrateContext<'a>, name: ~str) -> StatRecorder<'a> {
147147
let start = if ccx.sess().trans_stats() {
148148
time::precise_time_ns()
149149
} else {
@@ -528,7 +528,7 @@ pub fn note_unique_llvm_symbol(ccx: &CrateContext, sym: ~str) {
528528
}
529529
530530
531-
pub fn get_res_dtor(ccx: @CrateContext,
531+
pub fn get_res_dtor(ccx: &CrateContext,
532532
did: ast::DefId,
533533
parent_id: ast::DefId,
534534
substs: &[ty::t])
@@ -1225,7 +1225,7 @@ pub fn make_return_pointer(fcx: &FunctionContext, output_type: ty::t)
12251225
//
12261226
// Be warned! You must call `init_function` before doing anything with the
12271227
// returned function context.
1228-
pub fn new_fn_ctxt<'a>(ccx: @CrateContext<'a>,
1228+
pub fn new_fn_ctxt<'a>(ccx: &'a CrateContext<'a>,
12291229
llfndecl: ValueRef,
12301230
id: ast::NodeId,
12311231
has_env: bool,
@@ -1443,15 +1443,15 @@ pub fn build_return_block(fcx: &FunctionContext, ret_cx: &Block) {
14431443
// trans_closure: Builds an LLVM function out of a source function.
14441444
// If the function closes over its environment a closure will be
14451445
// returned.
1446-
pub fn trans_closure<'a>(ccx: @CrateContext,
1447-
decl: &ast::FnDecl,
1448-
body: &ast::Block,
1449-
llfndecl: ValueRef,
1450-
param_substs: Option<@param_substs>,
1451-
id: ast::NodeId,
1452-
_attributes: &[ast::Attribute],
1453-
output_type: ty::t,
1454-
maybe_load_env: <'b> |&'b Block<'b>| -> &'b Block<'b>) {
1446+
pub fn trans_closure(ccx: &CrateContext,
1447+
decl: &ast::FnDecl,
1448+
body: &ast::Block,
1449+
llfndecl: ValueRef,
1450+
param_substs: Option<@param_substs>,
1451+
id: ast::NodeId,
1452+
_attributes: &[ast::Attribute],
1453+
output_type: ty::t,
1454+
maybe_load_env: <'a> |&'a Block<'a>| -> &'a Block<'a>) {
14551455
ccx.stats.n_closures.set(ccx.stats.n_closures.get() + 1);
14561456

14571457
let _icx = push_ctxt("trans_closure");
@@ -1543,7 +1543,7 @@ pub fn trans_closure<'a>(ccx: @CrateContext,
15431543

15441544
// trans_fn: creates an LLVM function corresponding to a source language
15451545
// function.
1546-
pub fn trans_fn(ccx: @CrateContext,
1546+
pub fn trans_fn(ccx: &CrateContext,
15471547
decl: &ast::FnDecl,
15481548
body: &ast::Block,
15491549
llfndecl: ValueRef,
@@ -1558,7 +1558,7 @@ pub fn trans_fn(ccx: @CrateContext,
15581558
param_substs, id, attrs, output_type, |bcx| bcx);
15591559
}
15601560

1561-
pub fn trans_enum_variant(ccx: @CrateContext,
1561+
pub fn trans_enum_variant(ccx: &CrateContext,
15621562
_enum_id: ast::NodeId,
15631563
variant: &ast::Variant,
15641564
_args: &[ast::VariantArg],
@@ -1575,7 +1575,7 @@ pub fn trans_enum_variant(ccx: @CrateContext,
15751575
llfndecl);
15761576
}
15771577

1578-
pub fn trans_tuple_struct(ccx: @CrateContext,
1578+
pub fn trans_tuple_struct(ccx: &CrateContext,
15791579
_fields: &[ast::StructField],
15801580
ctor_id: ast::NodeId,
15811581
param_substs: Option<@param_substs>,
@@ -1590,7 +1590,7 @@ pub fn trans_tuple_struct(ccx: @CrateContext,
15901590
llfndecl);
15911591
}
15921592

1593-
fn trans_enum_variant_or_tuple_like_struct(ccx: @CrateContext,
1593+
fn trans_enum_variant_or_tuple_like_struct(ccx: &CrateContext,
15941594
ctor_id: ast::NodeId,
15951595
disr: ty::Disr,
15961596
param_substs: Option<@param_substs>,
@@ -1647,8 +1647,8 @@ fn trans_enum_variant_or_tuple_like_struct(ccx: @CrateContext,
16471647
finish_fn(&fcx, bcx);
16481648
}
16491649

1650-
pub fn trans_enum_def(ccx: @CrateContext, enum_definition: &ast::EnumDef,
1651-
id: ast::NodeId, vi: @Vec<@ty::VariantInfo> ,
1650+
pub fn trans_enum_def(ccx: &CrateContext, enum_definition: &ast::EnumDef,
1651+
id: ast::NodeId, vi: @Vec<@ty::VariantInfo>,
16521652
i: &mut uint) {
16531653
for &variant in enum_definition.variants.iter() {
16541654
let disr_val = vi.get(*i).disr_val;
@@ -1671,7 +1671,7 @@ pub fn trans_enum_def(ccx: @CrateContext, enum_definition: &ast::EnumDef,
16711671
}
16721672

16731673
pub struct TransItemVisitor<'a> {
1674-
ccx: @CrateContext<'a>,
1674+
ccx: &'a CrateContext<'a>,
16751675
}
16761676

16771677
impl<'a> Visitor<()> for TransItemVisitor<'a> {
@@ -1680,7 +1680,7 @@ impl<'a> Visitor<()> for TransItemVisitor<'a> {
16801680
}
16811681
}
16821682

1683-
pub fn trans_item(ccx: @CrateContext, item: &ast::Item) {
1683+
pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
16841684
let _icx = push_ctxt("trans_item");
16851685
match item.node {
16861686
ast::ItemFn(decl, purity, _abis, ref generics, body) => {
@@ -1757,7 +1757,7 @@ pub fn trans_item(ccx: @CrateContext, item: &ast::Item) {
17571757
}
17581758
}
17591759

1760-
pub fn trans_struct_def(ccx: @CrateContext, struct_def: @ast::StructDef) {
1760+
pub fn trans_struct_def(ccx: &CrateContext, struct_def: @ast::StructDef) {
17611761
// If this is a tuple-like struct, translate the constructor.
17621762
match struct_def.ctor_id {
17631763
// We only need to translate a constructor if there are fields;
@@ -1776,14 +1776,14 @@ pub fn trans_struct_def(ccx: @CrateContext, struct_def: @ast::StructDef) {
17761776
// separate modules in the compiled program. That's because modules exist
17771777
// only as a convenience for humans working with the code, to organize names
17781778
// and control visibility.
1779-
pub fn trans_mod(ccx: @CrateContext, m: &ast::Mod) {
1779+
pub fn trans_mod(ccx: &CrateContext, m: &ast::Mod) {
17801780
let _icx = push_ctxt("trans_mod");
17811781
for item in m.items.iter() {
17821782
trans_item(ccx, *item);
17831783
}
17841784
}
17851785

1786-
fn finish_register_fn(ccx: @CrateContext, sp: Span, sym: ~str, node_id: ast::NodeId,
1786+
fn finish_register_fn(ccx: &CrateContext, sp: Span, sym: ~str, node_id: ast::NodeId,
17871787
llfn: ValueRef) {
17881788
{
17891789
let mut item_symbols = ccx.item_symbols.borrow_mut();
@@ -1802,7 +1802,7 @@ fn finish_register_fn(ccx: @CrateContext, sp: Span, sym: ~str, node_id: ast::Nod
18021802
}
18031803
}
18041804

1805-
fn register_fn(ccx: @CrateContext,
1805+
fn register_fn(ccx: &CrateContext,
18061806
sp: Span,
18071807
sym: ~str,
18081808
node_id: ast::NodeId,
@@ -1826,7 +1826,7 @@ fn register_fn(ccx: @CrateContext,
18261826
}
18271827

18281828
// only use this for foreign function ABIs and glue, use `register_fn` for Rust functions
1829-
pub fn register_fn_llvmty(ccx: @CrateContext,
1829+
pub fn register_fn_llvmty(ccx: &CrateContext,
18301830
sp: Span,
18311831
sym: ~str,
18321832
node_id: ast::NodeId,
@@ -1849,7 +1849,7 @@ pub fn is_entry_fn(sess: &Session, node_id: ast::NodeId) -> bool {
18491849

18501850
// Create a _rust_main(args: ~[str]) function which will be called from the
18511851
// runtime rust_start function
1852-
pub fn create_entry_wrapper(ccx: @CrateContext,
1852+
pub fn create_entry_wrapper(ccx: &CrateContext,
18531853
_sp: Span,
18541854
main_llfn: ValueRef) {
18551855
let et = ccx.sess().entry_type.get().unwrap();
@@ -1861,7 +1861,7 @@ pub fn create_entry_wrapper(ccx: @CrateContext,
18611861
session::EntryNone => {} // Do nothing.
18621862
}
18631863

1864-
fn create_entry_fn(ccx: @CrateContext,
1864+
fn create_entry_fn(ccx: &CrateContext,
18651865
rust_main: ValueRef,
18661866
use_start_lang_item: bool) {
18671867
let llfty = Type::func([ccx.int_type, Type::i8().ptr_to().ptr_to()],
@@ -1941,7 +1941,7 @@ fn exported_name(ccx: &CrateContext, id: ast::NodeId,
19411941
}
19421942
}
19431943

1944-
pub fn get_item_val(ccx: @CrateContext, id: ast::NodeId) -> ValueRef {
1944+
pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
19451945
debug!("get_item_val(id=`{:?}`)", id);
19461946

19471947
let val = {
@@ -2194,7 +2194,7 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::NodeId) -> ValueRef {
21942194
}
21952195
}
21962196

2197-
fn register_method(ccx: @CrateContext, id: ast::NodeId,
2197+
fn register_method(ccx: &CrateContext, id: ast::NodeId,
21982198
m: &ast::Method) -> ValueRef {
21992199
let mty = ty::node_id_to_type(ccx.tcx, id);
22002200

@@ -2444,7 +2444,7 @@ pub fn decl_crate_map(sess: &Session, mapmeta: LinkMeta,
24442444
return (sym_name, map);
24452445
}
24462446
2447-
pub fn fill_crate_map(ccx: @CrateContext, map: ValueRef) {
2447+
pub fn fill_crate_map(ccx: &CrateContext, map: ValueRef) {
24482448
let event_loop_factory = match ccx.tcx.lang_items.event_loop_factory() {
24492449
Some(did) => unsafe {
24502450
if is_local(did) {
@@ -2551,7 +2551,7 @@ pub fn trans_crate(krate: ast::Crate,
25512551
// 1. http://llvm.org/bugs/show_bug.cgi?id=11479
25522552
let llmod_id = link_meta.crateid.name + ".rs";
25532553
2554-
let ccx = @CrateContext::new(llmod_id,
2554+
let ccx = &CrateContext::new(llmod_id,
25552555
&analysis.ty_cx,
25562556
analysis.exp_map2,
25572557
analysis.maps,

src/librustc/middle/trans/closure.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ pub fn trans_expr_fn<'a>(
409409
bcx
410410
}
411411

412-
pub fn get_wrapper_for_bare_fn(ccx: @CrateContext,
412+
pub fn get_wrapper_for_bare_fn(ccx: &CrateContext,
413413
closure_ty: ty::t,
414414
def: ast::Def,
415415
fn_ptr: ValueRef,

src/librustc/middle/trans/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ pub struct FunctionContext<'a> {
286286
block_arena: &'a TypedArena<Block<'a>>,
287287

288288
// This function's enclosing crate context.
289-
ccx: @CrateContext<'a>,
289+
ccx: &'a CrateContext<'a>,
290290

291291
// Used and maintained by the debuginfo module.
292292
debug_context: debuginfo::FunctionDebugContext,
@@ -435,7 +435,7 @@ impl<'a> Block<'a> {
435435
})
436436
}
437437

438-
pub fn ccx(&self) -> @CrateContext<'a> { self.fcx.ccx }
438+
pub fn ccx(&self) -> &'a CrateContext<'a> { self.fcx.ccx }
439439
pub fn tcx(&self) -> &'a ty::ctxt {
440440
self.fcx.ccx.tcx
441441
}

src/librustc/middle/trans/consts.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ pub fn const_ptrcast(cx: &CrateContext, a: ValueRef, t: Type) -> ValueRef {
8989
}
9090
}
9191

92-
fn const_vec(cx: @CrateContext, e: &ast::Expr,
92+
fn const_vec(cx: &CrateContext, e: &ast::Expr,
9393
es: &[@ast::Expr], is_local: bool) -> (ValueRef, Type, bool) {
9494
let vec_ty = ty::expr_ty(cx.tcx, e);
9595
let unit_ty = ty::sequence_element_type(cx.tcx, vec_ty);
@@ -160,7 +160,7 @@ fn const_deref(cx: &CrateContext, v: ValueRef, t: ty::t, explicit: bool)
160160
}
161161
}
162162

163-
pub fn get_const_val(cx: @CrateContext,
163+
pub fn get_const_val(cx: &CrateContext,
164164
mut def_id: ast::DefId) -> (ValueRef, bool) {
165165
let contains_key = {
166166
let const_values = cx.const_values.borrow();
@@ -185,7 +185,7 @@ pub fn get_const_val(cx: @CrateContext,
185185
!non_inlineable_statics.get().contains(&def_id.node))
186186
}
187187

188-
pub fn const_expr(cx: @CrateContext, e: &ast::Expr, is_local: bool) -> (ValueRef, bool) {
188+
pub fn const_expr(cx: &CrateContext, e: &ast::Expr, is_local: bool) -> (ValueRef, bool) {
189189
let (llconst, inlineable) = const_expr_unadjusted(cx, e, is_local);
190190
let mut llconst = llconst;
191191
let mut inlineable = inlineable;
@@ -298,7 +298,7 @@ pub fn const_expr(cx: @CrateContext, e: &ast::Expr, is_local: bool) -> (ValueRef
298298

299299
// the bool returned is whether this expression can be inlined into other crates
300300
// if it's assigned to a static.
301-
fn const_expr_unadjusted(cx: @CrateContext, e: &ast::Expr,
301+
fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
302302
is_local: bool) -> (ValueRef, bool) {
303303
let map_list = |exprs: &[@ast::Expr]| {
304304
exprs.iter().map(|&e| const_expr(cx, e, is_local))
@@ -694,7 +694,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: &ast::Expr,
694694
}
695695
}
696696

697-
pub fn trans_const(ccx: @CrateContext, m: ast::Mutability, id: ast::NodeId) {
697+
pub fn trans_const(ccx: &CrateContext, m: ast::Mutability, id: ast::NodeId) {
698698
unsafe {
699699
let _icx = push_ctxt("trans_const");
700700
let g = base::get_item_val(ccx, id);

src/librustc/middle/trans/datum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ impl<'a> DatumBlock<'a, Expr> {
709709
self.datum.shallow_copy(self.bcx, dst)
710710
}
711711

712-
pub fn ccx(&self) -> @CrateContext<'a> {
712+
pub fn ccx(&self) -> &'a CrateContext<'a> {
713713
self.bcx.ccx()
714714
}
715715

src/librustc/middle/trans/debuginfo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ enum VariableKind {
253253
}
254254

255255
/// Create any deferred debug metadata nodes
256-
pub fn finalize(cx: @CrateContext) {
256+
pub fn finalize(cx: &CrateContext) {
257257
if cx.dbg_cx.is_none() {
258258
return;
259259
}

src/librustc/middle/trans/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ fn trans_def<'a>(bcx: &'a Block<'a>,
548548
ast::DefStatic(did, _) => {
549549
let const_ty = expr_ty(bcx, ref_expr);
550550

551-
fn get_did(ccx: @CrateContext, did: ast::DefId)
551+
fn get_did(ccx: &CrateContext, did: ast::DefId)
552552
-> ast::DefId {
553553
if did.krate != ast::LOCAL_CRATE {
554554
inline::maybe_instantiate_inline(ccx, did)

0 commit comments

Comments
 (0)