Skip to content

Commit bc79e1f

Browse files
committed
---
yaml --- r: 153932 b: refs/heads/try2 c: 8cda74c h: refs/heads/master v: v3
1 parent 78ed4fd commit bc79e1f

File tree

17 files changed

+217
-68
lines changed

17 files changed

+217
-68
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 491bd29945c26a0ff3f03e1d25e9ba635c40713e
8+
refs/heads/try2: 8cda74c4b5e7244a0ef045af941de313ad84caac
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/middle/trans/base.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,7 +1235,8 @@ pub fn new_fn_ctxt<'a>(ccx: &'a CrateContext,
12351235
output_type: ty::t,
12361236
param_substs: &'a param_substs,
12371237
sp: Option<Span>,
1238-
block_arena: &'a TypedArena<Block<'a>>)
1238+
block_arena: &'a TypedArena<Block<'a>>,
1239+
handle_items: HandleItemsFlag)
12391240
-> FunctionContext<'a> {
12401241
param_substs.validate();
12411242

@@ -1268,7 +1269,8 @@ pub fn new_fn_ctxt<'a>(ccx: &'a CrateContext,
12681269
block_arena: block_arena,
12691270
ccx: ccx,
12701271
debug_context: debug_context,
1271-
scopes: RefCell::new(Vec::new())
1272+
scopes: RefCell::new(Vec::new()),
1273+
handle_items: handle_items,
12721274
};
12731275

12741276
if has_env {
@@ -1579,7 +1581,8 @@ pub fn trans_closure(ccx: &CrateContext,
15791581
abi: Abi,
15801582
has_env: bool,
15811583
is_unboxed_closure: IsUnboxedClosureFlag,
1582-
maybe_load_env: <'a> |&'a Block<'a>| -> &'a Block<'a>) {
1584+
maybe_load_env: <'a> |&'a Block<'a>| -> &'a Block<'a>,
1585+
handle_items: HandleItemsFlag) {
15831586
ccx.stats.n_closures.set(ccx.stats.n_closures.get() + 1);
15841587

15851588
let _icx = push_ctxt("trans_closure");
@@ -1596,7 +1599,8 @@ pub fn trans_closure(ccx: &CrateContext,
15961599
output_type,
15971600
param_substs,
15981601
Some(body.span),
1599-
&arena);
1602+
&arena,
1603+
handle_items);
16001604
let mut bcx = init_function(&fcx, false, output_type);
16011605

16021606
// cleanup scope for the incoming arguments
@@ -1698,7 +1702,8 @@ pub fn trans_fn(ccx: &CrateContext,
16981702
llfndecl: ValueRef,
16991703
param_substs: &param_substs,
17001704
id: ast::NodeId,
1701-
attrs: &[ast::Attribute]) {
1705+
attrs: &[ast::Attribute],
1706+
handle_items: HandleItemsFlag) {
17021707
let _s = StatRecorder::new(ccx, ccx.tcx.map.path_to_string(id).to_string());
17031708
debug!("trans_fn(param_substs={})", param_substs.repr(ccx.tcx()));
17041709
let _icx = push_ctxt("trans_fn");
@@ -1718,7 +1723,8 @@ pub fn trans_fn(ccx: &CrateContext,
17181723
abi,
17191724
false,
17201725
NotUnboxedClosure,
1721-
|bcx| bcx);
1726+
|bcx| bcx,
1727+
handle_items);
17221728
}
17231729

17241730
pub fn trans_enum_variant(ccx: &CrateContext,
@@ -1824,7 +1830,7 @@ fn trans_enum_variant_or_tuple_like_struct(ccx: &CrateContext,
18241830

18251831
let arena = TypedArena::new();
18261832
let fcx = new_fn_ctxt(ccx, llfndecl, ctor_id, false, result_ty,
1827-
param_substs, None, &arena);
1833+
param_substs, None, &arena, TranslateItems);
18281834
let bcx = init_function(&fcx, false, result_ty);
18291835

18301836
let arg_tys = ty::ty_fn_args(ctor_ty);
@@ -1925,7 +1931,8 @@ pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
19251931
llfn,
19261932
&param_substs::empty(),
19271933
item.id,
1928-
item.attrs.as_slice());
1934+
item.attrs.as_slice(),
1935+
TranslateItems);
19291936
} else {
19301937
// Be sure to travel more than just one layer deep to catch nested
19311938
// items in blocks and such.

branches/try2/src/librustc/middle/trans/callee.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,8 @@ pub fn trans_unboxing_shim(bcx: &Block,
339339
return_type,
340340
&empty_param_substs,
341341
None,
342-
&block_arena);
342+
&block_arena,
343+
TranslateItems);
343344
let mut bcx = init_function(&fcx, false, return_type);
344345

345346
// Create the substituted versions of the self type.

branches/try2/src/librustc/middle/trans/closure.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,8 @@ pub fn trans_expr_fn<'a>(
394394
ty::ty_fn_abi(fty),
395395
true,
396396
NotUnboxedClosure,
397-
|bcx| load_environment(bcx, cdata_ty, &freevars, store));
397+
|bcx| load_environment(bcx, cdata_ty, &freevars, store),
398+
bcx.fcx.handle_items);
398399
fill_fn_pair(bcx, dest_addr, llfn, llbox);
399400
bcx
400401
}
@@ -486,7 +487,8 @@ pub fn trans_unboxed_closure<'a>(
486487
ty::ty_fn_abi(function_type),
487488
true,
488489
IsUnboxedClosure,
489-
|bcx| load_unboxed_closure_environment(bcx, freevars_ptr));
490+
|bcx| load_unboxed_closure_environment(bcx, freevars_ptr),
491+
bcx.fcx.handle_items);
490492

491493
// Don't hoist this to the top of the function. It's perfectly legitimate
492494
// to have a zero-size unboxed closure (in which case dest will be
@@ -573,7 +575,7 @@ pub fn get_wrapper_for_bare_fn(ccx: &CrateContext,
573575
let arena = TypedArena::new();
574576
let empty_param_substs = param_substs::empty();
575577
let fcx = new_fn_ctxt(ccx, llfn, -1, true, f.sig.output,
576-
&empty_param_substs, None, &arena);
578+
&empty_param_substs, None, &arena, TranslateItems);
577579
let bcx = init_function(&fcx, true, f.sig.output);
578580

579581
let args = create_datums_for_fn_args(&fcx,

branches/try2/src/librustc/middle/trans/common.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,12 @@ impl<T:Subst+Clone> SubstP for T {
221221
pub type RvalueDatum = datum::Datum<datum::Rvalue>;
222222
pub type LvalueDatum = datum::Datum<datum::Lvalue>;
223223

224+
#[deriving(Clone, Eq, PartialEq)]
225+
pub enum HandleItemsFlag {
226+
IgnoreItems,
227+
TranslateItems,
228+
}
229+
224230
// Function context. Every LLVM function we create will have one of
225231
// these.
226232
pub struct FunctionContext<'a> {
@@ -289,6 +295,9 @@ pub struct FunctionContext<'a> {
289295

290296
// Cleanup scopes.
291297
pub scopes: RefCell<Vec<cleanup::CleanupScope<'a>> >,
298+
299+
// How to handle items encountered during translation of this function.
300+
pub handle_items: HandleItemsFlag,
292301
}
293302

294303
impl<'a> FunctionContext<'a> {

branches/try2/src/librustc/middle/trans/controlflow.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ pub fn trans_stmt<'a>(cx: &'a Block<'a>,
6868
debuginfo::create_local_var_metadata(bcx, &**local);
6969
}
7070
}
71-
ast::DeclItem(ref i) => trans_item(cx.fcx.ccx, &**i)
71+
ast::DeclItem(ref i) => {
72+
match fcx.handle_items {
73+
TranslateItems => trans_item(cx.fcx.ccx, &**i),
74+
IgnoreItems => {}
75+
}
76+
}
7277
}
7378
}
7479
ast::StmtMac(..) => cx.tcx().sess.bug("unexpanded macro")

branches/try2/src/librustc/middle/trans/foreign.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,8 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext,
601601

602602
let llfn = base::decl_internal_rust_fn(ccx, t, ps.as_slice());
603603
base::set_llvm_fn_attrs(attrs, llfn);
604-
base::trans_fn(ccx, decl, body, llfn, &param_substs::empty(), id, []);
604+
base::trans_fn(ccx, decl, body, llfn, &param_substs::empty(), id, [],
605+
TranslateItems);
605606
llfn
606607
}
607608

branches/try2/src/librustc/middle/trans/glue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ fn make_generic_glue(ccx: &CrateContext,
468468
let arena = TypedArena::new();
469469
let empty_param_substs = param_substs::empty();
470470
let fcx = new_fn_ctxt(ccx, llfn, -1, false, ty::mk_nil(),
471-
&empty_param_substs, None, &arena);
471+
&empty_param_substs, None, &arena, TranslateItems);
472472

473473
let bcx = init_function(&fcx, false, ty::mk_nil());
474474

branches/try2/src/librustc/middle/trans/inline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ pub fn maybe_instantiate_inline(ccx: &CrateContext, fn_id: ast::DefId)
133133
if unparameterized {
134134
let llfn = get_item_val(ccx, mth.id);
135135
trans_fn(ccx, &*mth.pe_fn_decl(), &*mth.pe_body(), llfn,
136-
&param_substs::empty(), mth.id, []);
136+
&param_substs::empty(), mth.id, [], TranslateItems);
137137
}
138138
local_def(mth.id)
139139
}

branches/try2/src/librustc/middle/trans/meth.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ pub fn trans_impl(ccx: &CrateContext,
7575
llfn,
7676
&param_substs::empty(),
7777
method.id,
78-
[]);
78+
[],
79+
TranslateItems);
7980
} else {
8081
let mut v = TransItemVisitor{ ccx: ccx };
8182
visit::walk_method_helper(&mut v, &**method, ());

branches/try2/src/librustc/middle/trans/monomorphize.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ pub fn monomorphic_fn(ccx: &CrateContext,
149149
} => {
150150
let d = mk_lldecl();
151151
set_llvm_fn_attrs(i.attrs.as_slice(), d);
152-
trans_fn(ccx, &**decl, &**body, d, &psubsts, fn_id.node, []);
152+
trans_fn(ccx, &**decl, &**body, d, &psubsts, fn_id.node, [],
153+
IgnoreItems);
153154
d
154155
}
155156
_ => {
@@ -181,7 +182,8 @@ pub fn monomorphic_fn(ccx: &CrateContext,
181182
ast_map::NodeMethod(mth) => {
182183
let d = mk_lldecl();
183184
set_llvm_fn_attrs(mth.attrs.as_slice(), d);
184-
trans_fn(ccx, &*mth.pe_fn_decl(), &*mth.pe_body(), d, &psubsts, mth.id, []);
185+
trans_fn(ccx, &*mth.pe_fn_decl(), &*mth.pe_body(), d, &psubsts, mth.id, [],
186+
IgnoreItems);
185187
d
186188
}
187189
ast_map::NodeTraitMethod(method) => {
@@ -190,7 +192,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
190192
let d = mk_lldecl();
191193
set_llvm_fn_attrs(mth.attrs.as_slice(), d);
192194
trans_fn(ccx, &*mth.pe_fn_decl(), &*mth.pe_body(), d,
193-
&psubsts, mth.id, []);
195+
&psubsts, mth.id, [], IgnoreItems);
194196
d
195197
}
196198
_ => {

branches/try2/src/librustc/middle/trans/reflect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ impl<'a, 'b> Reflector<'a, 'b> {
312312
let empty_param_substs = param_substs::empty();
313313
let fcx = new_fn_ctxt(ccx, llfdecl, -1, false,
314314
ty::mk_u64(), &empty_param_substs,
315-
None, &arena);
315+
None, &arena, TranslateItems);
316316
let bcx = init_function(&fcx, false, ty::mk_u64());
317317

318318
// we know the return type of llfdecl is an int here, so

0 commit comments

Comments
 (0)