librustc: Change @mut Block to @Block.

This commit is contained in:
Patrick Walton 2013-12-18 14:54:42 -08:00
parent f74b8f0d3a
commit c9432327c4
21 changed files with 605 additions and 589 deletions

View File

@ -310,7 +310,7 @@ pub enum opt_result {
lower_bound(Result),
range_result(Result, Result),
}
fn trans_opt(bcx: @mut Block, o: &Opt) -> opt_result {
fn trans_opt(bcx: @Block, o: &Opt) -> opt_result {
let _icx = push_ctxt("match::trans_opt");
let ccx = bcx.ccx();
let bcx = bcx;
@ -345,7 +345,7 @@ fn trans_opt(bcx: @mut Block, o: &Opt) -> opt_result {
}
}
fn variant_opt(bcx: @mut Block, pat_id: ast::NodeId)
fn variant_opt(bcx: @Block, pat_id: ast::NodeId)
-> Opt {
let ccx = bcx.ccx();
match ccx.tcx.def_map.get_copy(&pat_id) {
@ -396,7 +396,7 @@ type BindingsMap = HashMap<Ident, BindingInfo>;
#[deriving(Clone)]
struct ArmData<'a> {
bodycx: @mut Block,
bodycx: @Block,
arm: &'a ast::Arm,
bindings_map: @BindingsMap
}
@ -435,7 +435,7 @@ fn has_nested_bindings(m: &[Match], col: uint) -> bool {
return false;
}
fn expand_nested_bindings<'r>(bcx: @mut Block,
fn expand_nested_bindings<'r>(bcx: @Block,
m: &[Match<'r>],
col: uint,
val: ValueRef)
@ -469,7 +469,7 @@ fn expand_nested_bindings<'r>(bcx: @mut Block,
})
}
fn assert_is_binding_or_wild(bcx: @mut Block, p: @ast::Pat) {
fn assert_is_binding_or_wild(bcx: @Block, p: @ast::Pat) {
if !pat_is_binding_or_wild(bcx.tcx().def_map, p) {
bcx.sess().span_bug(
p.span,
@ -480,7 +480,7 @@ fn assert_is_binding_or_wild(bcx: @mut Block, p: @ast::Pat) {
type enter_pat<'a> = 'a |@ast::Pat| -> Option<~[@ast::Pat]>;
fn enter_match<'r>(bcx: @mut Block,
fn enter_match<'r>(bcx: @Block,
dm: DefMap,
m: &[Match<'r>],
col: uint,
@ -529,7 +529,7 @@ fn enter_match<'r>(bcx: @mut Block,
return result;
}
fn enter_default<'r>(bcx: @mut Block,
fn enter_default<'r>(bcx: @Block,
dm: DefMap,
m: &[Match<'r>],
col: uint,
@ -599,7 +599,7 @@ fn enter_default<'r>(bcx: @mut Block,
// <nmatsakis> so all patterns must either be records (resp. tuples) or
// wildcards
fn enter_opt<'r>(bcx: @mut Block,
fn enter_opt<'r>(bcx: @Block,
m: &[Match<'r>],
opt: &Opt,
col: uint,
@ -735,7 +735,7 @@ fn enter_opt<'r>(bcx: @mut Block,
})
}
fn enter_rec_or_struct<'r>(bcx: @mut Block,
fn enter_rec_or_struct<'r>(bcx: @Block,
dm: DefMap,
m: &[Match<'r>],
col: uint,
@ -770,7 +770,7 @@ fn enter_rec_or_struct<'r>(bcx: @mut Block,
})
}
fn enter_tup<'r>(bcx: @mut Block,
fn enter_tup<'r>(bcx: @Block,
dm: DefMap,
m: &[Match<'r>],
col: uint,
@ -796,7 +796,7 @@ fn enter_tup<'r>(bcx: @mut Block,
})
}
fn enter_tuple_struct<'r>(bcx: @mut Block,
fn enter_tuple_struct<'r>(bcx: @Block,
dm: DefMap,
m: &[Match<'r>],
col: uint,
@ -822,7 +822,7 @@ fn enter_tuple_struct<'r>(bcx: @mut Block,
})
}
fn enter_box<'r>(bcx: @mut Block,
fn enter_box<'r>(bcx: @Block,
dm: DefMap,
m: &[Match<'r>],
col: uint,
@ -849,7 +849,7 @@ fn enter_box<'r>(bcx: @mut Block,
})
}
fn enter_uniq<'r>(bcx: @mut Block,
fn enter_uniq<'r>(bcx: @Block,
dm: DefMap,
m: &[Match<'r>],
col: uint,
@ -876,7 +876,7 @@ fn enter_uniq<'r>(bcx: @mut Block,
})
}
fn enter_region<'r>(bcx: @mut Block,
fn enter_region<'r>(bcx: @Block,
dm: DefMap,
m: &[Match<'r>],
col: uint,
@ -906,7 +906,7 @@ fn enter_region<'r>(bcx: @mut Block,
// Returns the options in one column of matches. An option is something that
// needs to be conditionally matched at runtime; for example, the discriminant
// on a set of enum variants or a literal.
fn get_options(bcx: @mut Block, m: &[Match], col: uint) -> ~[Opt] {
fn get_options(bcx: @Block, m: &[Match], col: uint) -> ~[Opt] {
let ccx = bcx.ccx();
fn add_to_set(tcx: ty::ctxt, set: &mut ~[Opt], val: Opt) {
if set.iter().any(|l| opt_eq(tcx, l, &val)) {return;}
@ -990,10 +990,10 @@ fn get_options(bcx: @mut Block, m: &[Match], col: uint) -> ~[Opt] {
struct ExtractedBlock {
vals: ~[ValueRef],
bcx: @mut Block
bcx: @Block
}
fn extract_variant_args(bcx: @mut Block,
fn extract_variant_args(bcx: @Block,
repr: &adt::Repr,
disr_val: ty::Disr,
val: ValueRef)
@ -1006,7 +1006,7 @@ fn extract_variant_args(bcx: @mut Block,
ExtractedBlock { vals: args, bcx: bcx }
}
fn match_datum(bcx: @mut Block, val: ValueRef, pat_id: ast::NodeId) -> Datum {
fn match_datum(bcx: @Block, val: ValueRef, pat_id: ast::NodeId) -> Datum {
//! Helper for converting from the ValueRef that we pass around in
//! the match code, which is always by ref, into a Datum. Eventually
//! we should just pass around a Datum and be done with it.
@ -1016,7 +1016,7 @@ fn match_datum(bcx: @mut Block, val: ValueRef, pat_id: ast::NodeId) -> Datum {
}
fn extract_vec_elems(bcx: @mut Block,
fn extract_vec_elems(bcx: @Block,
pat_span: Span,
pat_id: ast::NodeId,
elem_count: uint,
@ -1069,7 +1069,7 @@ fn extract_vec_elems(bcx: @mut Block,
/// Function returns None if there is no struct pattern.
/// Function doesn't collect fields from struct-like enum variants.
/// Function can return empty list if there is only wildcard struct pattern.
fn collect_record_or_struct_fields(bcx: @mut Block,
fn collect_record_or_struct_fields(bcx: @Block,
m: &[Match],
col: uint)
-> Option<~[ast::Ident]> {
@ -1105,7 +1105,7 @@ fn collect_record_or_struct_fields(bcx: @mut Block,
}
}
fn pats_require_rooting(bcx: @mut Block,
fn pats_require_rooting(bcx: @Block,
m: &[Match],
col: uint)
-> bool {
@ -1116,11 +1116,11 @@ fn pats_require_rooting(bcx: @mut Block,
})
}
fn root_pats_as_necessary(mut bcx: @mut Block,
fn root_pats_as_necessary(mut bcx: @Block,
m: &[Match],
col: uint,
val: ValueRef)
-> @mut Block {
-> @Block {
for br in m.iter() {
let pat_id = br.pats[col].id;
if pat_id != 0 {
@ -1163,7 +1163,7 @@ fn any_tup_pat(m: &[Match], col: uint) -> bool {
any_pat!(m, ast::PatTup(_))
}
fn any_tuple_struct_pat(bcx: @mut Block, m: &[Match], col: uint) -> bool {
fn any_tuple_struct_pat(bcx: @Block, m: &[Match], col: uint) -> bool {
m.iter().any(|br| {
let pat = br.pats[col];
match pat.node {
@ -1184,7 +1184,7 @@ trait CustomFailureHandler {
}
struct DynamicFailureHandler {
bcx: @mut Block,
bcx: @Block,
sp: Span,
msg: @str,
finished: @mut Option<BasicBlockRef>,
@ -1271,7 +1271,7 @@ pub enum branch_kind { no_branch, single, switch, compare, compare_vec_len, }
// Compiles a comparison between two things.
//
// NB: This must produce an i1, not a Rust bool (i8).
fn compare_values(cx: @mut Block,
fn compare_values(cx: @Block,
lhs: ValueRef,
rhs: ValueRef,
rhs_t: ty::t)
@ -1314,10 +1314,10 @@ fn compare_values(cx: @mut Block,
}
}
fn store_non_ref_bindings(bcx: @mut Block,
fn store_non_ref_bindings(bcx: @Block,
bindings_map: &BindingsMap,
mut opt_temp_cleanups: Option<&mut ~[ValueRef]>)
-> @mut Block
-> @Block
{
/*!
*
@ -1348,9 +1348,9 @@ fn store_non_ref_bindings(bcx: @mut Block,
return bcx;
}
fn insert_lllocals(bcx: @mut Block,
fn insert_lllocals(bcx: @Block,
bindings_map: &BindingsMap,
add_cleans: bool) -> @mut Block {
add_cleans: bool) -> @Block {
/*!
* For each binding in `data.bindings_map`, adds an appropriate entry into
* the `fcx.lllocals` map. If add_cleans is true, then adds cleanups for
@ -1391,13 +1391,13 @@ fn insert_lllocals(bcx: @mut Block,
return bcx;
}
fn compile_guard(bcx: @mut Block,
fn compile_guard(bcx: @Block,
guard_expr: &ast::Expr,
data: &ArmData,
m: &[Match],
vals: &[ValueRef],
chk: FailureHandler)
-> @mut Block {
-> @Block {
debug!("compile_guard(bcx={}, guard_expr={}, m={}, vals={})",
bcx.to_str(),
bcx.expr_to_str(guard_expr),
@ -1432,7 +1432,7 @@ fn compile_guard(bcx: @mut Block,
bcx
});
fn drop_bindings(bcx: @mut Block, data: &ArmData) -> @mut Block {
fn drop_bindings(bcx: @Block, data: &ArmData) -> @Block {
let mut bcx = bcx;
for (_, &binding_info) in data.bindings_map.iter() {
match binding_info.trmode {
@ -1447,7 +1447,7 @@ fn compile_guard(bcx: @mut Block,
}
}
fn compile_submatch(bcx: @mut Block,
fn compile_submatch(bcx: @Block,
m: &[Match],
vals: &[ValueRef],
chk: FailureHandler) {
@ -1499,7 +1499,7 @@ fn compile_submatch(bcx: @mut Block,
}
}
fn compile_submatch_continue(mut bcx: @mut Block,
fn compile_submatch_continue(mut bcx: @Block,
m: &[Match],
vals: &[ValueRef],
chk: FailureHandler,
@ -1816,18 +1816,18 @@ fn compile_submatch_continue(mut bcx: @mut Block,
}
}
pub fn trans_match(bcx: @mut Block,
pub fn trans_match(bcx: @Block,
match_expr: &ast::Expr,
discr_expr: &ast::Expr,
arms: &[ast::Arm],
dest: Dest) -> @mut Block {
dest: Dest) -> @Block {
let _icx = push_ctxt("match::trans_match");
with_scope(bcx, match_expr.info(), "match", |bcx| {
trans_match_inner(bcx, discr_expr, arms, dest)
})
}
fn create_bindings_map(bcx: @mut Block, pat: @ast::Pat) -> BindingsMap {
fn create_bindings_map(bcx: @Block, pat: @ast::Pat) -> BindingsMap {
// Create the bindings map, which is a mapping from each binding name
// to an alloca() that will be the value for that local variable.
// Note that we use the names because each binding will have many ids
@ -1867,10 +1867,10 @@ fn create_bindings_map(bcx: @mut Block, pat: @ast::Pat) -> BindingsMap {
return bindings_map;
}
fn trans_match_inner(scope_cx: @mut Block,
fn trans_match_inner(scope_cx: @Block,
discr_expr: &ast::Expr,
arms: &[ast::Arm],
dest: Dest) -> @mut Block {
dest: Dest) -> @Block {
let _icx = push_ctxt("match::trans_match_inner");
let mut bcx = scope_cx;
let tcx = bcx.tcx();
@ -1878,7 +1878,7 @@ fn trans_match_inner(scope_cx: @mut Block,
let discr_datum = unpack_datum!(bcx, {
expr::trans_to_datum(bcx, discr_expr)
});
if bcx.unreachable {
if bcx.unreachable.get() {
return bcx;
}
@ -1952,10 +1952,10 @@ enum IrrefutablePatternBindingMode {
BindArgument
}
pub fn store_local(bcx: @mut Block,
pub fn store_local(bcx: @Block,
pat: @ast::Pat,
opt_init_expr: Option<@ast::Expr>)
-> @mut Block {
-> @Block {
/*!
* Generates code for a local variable declaration like
* `let <pat>;` or `let <pat> = <opt_init_expr>`.
@ -2006,7 +2006,7 @@ pub fn store_local(bcx: @mut Block,
}
};
fn create_dummy_locals(mut bcx: @mut Block, pat: @ast::Pat) -> @mut Block {
fn create_dummy_locals(mut bcx: @Block, pat: @ast::Pat) -> @Block {
// create dummy memory for the variables if we have no
// value to store into them immediately
let tcx = bcx.tcx();
@ -2019,10 +2019,10 @@ pub fn store_local(bcx: @mut Block,
}
}
pub fn store_arg(mut bcx: @mut Block,
pub fn store_arg(mut bcx: @Block,
pat: @ast::Pat,
llval: ValueRef)
-> @mut Block {
-> @Block {
/*!
* Generates code for argument patterns like `fn foo(<pat>: T)`.
* Creates entries in the `llargs` map for each of the bindings
@ -2066,12 +2066,12 @@ pub fn store_arg(mut bcx: @mut Block,
return bcx;
}
fn mk_binding_alloca(mut bcx: @mut Block,
fn mk_binding_alloca(mut bcx: @Block,
p_id: ast::NodeId,
path: &ast::Path,
binding_mode: IrrefutablePatternBindingMode,
populate: |@mut Block, ty::t, ValueRef| -> @mut Block)
-> @mut Block {
populate: |@Block, ty::t, ValueRef| -> @Block)
-> @Block {
let var_ty = node_id_type(bcx, p_id);
let ident = ast_util::path_to_ident(path);
let llval = alloc_ty(bcx, var_ty, bcx.ident(ident));
@ -2085,11 +2085,11 @@ fn mk_binding_alloca(mut bcx: @mut Block,
return bcx;
}
fn bind_irrefutable_pat(bcx: @mut Block,
fn bind_irrefutable_pat(bcx: @Block,
pat: @ast::Pat,
val: ValueRef,
binding_mode: IrrefutablePatternBindingMode)
-> @mut Block {
-> @Block {
/*!
* A simple version of the pattern matching code that only handles
* irrefutable patterns. This is used in let/argument patterns,

View File

@ -111,7 +111,7 @@ pub struct Struct {
* these, for places in trans where the `ty::t` isn't directly
* available.
*/
pub fn represent_node(bcx: @mut Block, node: ast::NodeId) -> @Repr {
pub fn represent_node(bcx: @Block, node: ast::NodeId) -> @Repr {
represent_type(bcx.ccx(), node_id_type(bcx, node))
}
@ -458,7 +458,7 @@ fn struct_llfields(cx: &mut CrateContext, st: &Struct, sizing: bool) -> ~[Type]
*
* This should ideally be less tightly tied to `_match`.
*/
pub fn trans_switch(bcx: @mut Block, r: &Repr, scrutinee: ValueRef)
pub fn trans_switch(bcx: @Block, r: &Repr, scrutinee: ValueRef)
-> (_match::branch_kind, Option<ValueRef>) {
match *r {
CEnum(..) | General(..) => {
@ -476,7 +476,7 @@ pub fn trans_switch(bcx: @mut Block, r: &Repr, scrutinee: ValueRef)
/// Obtain the actual discriminant of a value.
pub fn trans_get_discr(bcx: @mut Block, r: &Repr, scrutinee: ValueRef, cast_to: Option<Type>)
pub fn trans_get_discr(bcx: @Block, r: &Repr, scrutinee: ValueRef, cast_to: Option<Type>)
-> ValueRef {
let signed;
let val;
@ -505,7 +505,7 @@ pub fn trans_get_discr(bcx: @mut Block, r: &Repr, scrutinee: ValueRef, cast_to:
}
}
fn nullable_bitdiscr(bcx: @mut Block, nonnull: &Struct, nndiscr: Disr, ptrfield: uint,
fn nullable_bitdiscr(bcx: @Block, nonnull: &Struct, nndiscr: Disr, ptrfield: uint,
scrutinee: ValueRef) -> ValueRef {
let cmp = if nndiscr == 0 { IntEQ } else { IntNE };
let llptr = Load(bcx, GEPi(bcx, scrutinee, [0, ptrfield]));
@ -514,7 +514,7 @@ fn nullable_bitdiscr(bcx: @mut Block, nonnull: &Struct, nndiscr: Disr, ptrfield:
}
/// Helper for cases where the discriminant is simply loaded.
fn load_discr(bcx: @mut Block, ity: IntType, ptr: ValueRef, min: Disr, max: Disr)
fn load_discr(bcx: @Block, ity: IntType, ptr: ValueRef, min: Disr, max: Disr)
-> ValueRef {
let llty = ll_inttype(bcx.ccx(), ity);
assert_eq!(val_ty(ptr), llty.ptr_to());
@ -542,7 +542,7 @@ fn load_discr(bcx: @mut Block, ity: IntType, ptr: ValueRef, min: Disr, max: Disr
*
* This should ideally be less tightly tied to `_match`.
*/
pub fn trans_case(bcx: @mut Block, r: &Repr, discr: Disr) -> _match::opt_result {
pub fn trans_case(bcx: @Block, r: &Repr, discr: Disr) -> _match::opt_result {
match *r {
CEnum(ity, _, _) => {
_match::single_result(rslt(bcx, C_integral(ll_inttype(bcx.ccx(), ity),
@ -567,7 +567,7 @@ pub fn trans_case(bcx: @mut Block, r: &Repr, discr: Disr) -> _match::opt_result
* representation. The fields, if any, should then be initialized via
* `trans_field_ptr`.
*/
pub fn trans_start_init(bcx: @mut Block, r: &Repr, val: ValueRef, discr: Disr) {
pub fn trans_start_init(bcx: @Block, r: &Repr, val: ValueRef, discr: Disr) {
match *r {
CEnum(ity, min, max) => {
assert_discr_in_range(ity, min, max, discr);
@ -623,7 +623,7 @@ pub fn num_args(r: &Repr, discr: Disr) -> uint {
}
/// Access a field, at a point when the value's case is known.
pub fn trans_field_ptr(bcx: @mut Block, r: &Repr, val: ValueRef, discr: Disr,
pub fn trans_field_ptr(bcx: @Block, r: &Repr, val: ValueRef, discr: Disr,
ix: uint) -> ValueRef {
// Note: if this ever needs to generate conditionals (e.g., if we
// decide to do some kind of cdr-coding-like non-unique repr
@ -656,7 +656,7 @@ pub fn trans_field_ptr(bcx: @mut Block, r: &Repr, val: ValueRef, discr: Disr,
}
}
fn struct_field_ptr(bcx: @mut Block, st: &Struct, val: ValueRef, ix: uint,
fn struct_field_ptr(bcx: @Block, st: &Struct, val: ValueRef, ix: uint,
needs_cast: bool) -> ValueRef {
let ccx = bcx.ccx();
@ -672,7 +672,7 @@ fn struct_field_ptr(bcx: @mut Block, st: &Struct, val: ValueRef, ix: uint,
}
/// Access the struct drop flag, if present.
pub fn trans_drop_flag_ptr(bcx: @mut Block, r: &Repr, val: ValueRef) -> ValueRef {
pub fn trans_drop_flag_ptr(bcx: @Block, r: &Repr, val: ValueRef) -> ValueRef {
match *r {
Univariant(ref st, true) => GEPi(bcx, val, [0, st.fields.len() - 1]),
_ => bcx.ccx().sess.bug("tried to get drop flag of non-droppable type")

View File

@ -27,7 +27,7 @@ use middle::trans::type_::Type;
use syntax::ast;
// Take an inline assembly expression and splat it out via LLVM
pub fn trans_inline_asm(bcx: @mut Block, ia: &ast::inline_asm) -> @mut Block {
pub fn trans_inline_asm(bcx: @Block, ia: &ast::inline_asm) -> @Block {
let mut bcx = bcx;
let mut constraints = ~[];

View File

@ -297,7 +297,7 @@ pub fn get_extern_const(externs: &mut ExternMap, llmod: ModuleRef,
// known.
//
// The runtime equivalent is box_body() in "rust_internal.h".
pub fn opaque_box_body(bcx: @mut Block,
pub fn opaque_box_body(bcx: @Block,
body_t: ty::t,
boxptr: ValueRef) -> ValueRef {
let _icx = push_ctxt("opaque_box_body");
@ -310,14 +310,14 @@ pub fn opaque_box_body(bcx: @mut Block,
// malloc_raw_dyn: allocates a box to contain a given type, but with a
// potentially dynamic size.
pub fn malloc_raw_dyn(bcx: @mut Block,
pub fn malloc_raw_dyn(bcx: @Block,
t: ty::t,
heap: heap,
size: ValueRef) -> Result {
let _icx = push_ctxt("malloc_raw");
let ccx = bcx.ccx();
fn require_alloc_fn(bcx: @mut Block, t: ty::t, it: LangItem) -> ast::DefId {
fn require_alloc_fn(bcx: @Block, t: ty::t, it: LangItem) -> ast::DefId {
let li = &bcx.tcx().lang_items;
match li.require(it) {
Ok(id) => id,
@ -377,21 +377,21 @@ pub fn malloc_raw_dyn(bcx: @mut Block,
// malloc_raw: expects an unboxed type and returns a pointer to
// enough space for a box of that type. This includes a rust_opaque_box
// header.
pub fn malloc_raw(bcx: @mut Block, t: ty::t, heap: heap) -> Result {
pub fn malloc_raw(bcx: @Block, t: ty::t, heap: heap) -> Result {
let ty = type_of(bcx.ccx(), t);
let size = llsize_of(bcx.ccx(), ty);
malloc_raw_dyn(bcx, t, heap, size)
}
pub struct MallocResult {
bcx: @mut Block,
bcx: @Block,
smart_ptr: ValueRef,
body: ValueRef
}
// malloc_general_dyn: usefully wraps malloc_raw_dyn; allocates a smart
// pointer, and pulls out the body
pub fn malloc_general_dyn(bcx: @mut Block, t: ty::t, heap: heap, size: ValueRef)
pub fn malloc_general_dyn(bcx: @Block, t: ty::t, heap: heap, size: ValueRef)
-> MallocResult {
assert!(heap != heap_exchange);
let _icx = push_ctxt("malloc_general");
@ -405,13 +405,13 @@ pub fn malloc_general_dyn(bcx: @mut Block, t: ty::t, heap: heap, size: ValueRef)
}
}
pub fn malloc_general(bcx: @mut Block, t: ty::t, heap: heap) -> MallocResult {
pub fn malloc_general(bcx: @Block, t: ty::t, heap: heap) -> MallocResult {
let ty = type_of(bcx.ccx(), t);
assert!(heap != heap_exchange);
malloc_general_dyn(bcx, t, heap, llsize_of(bcx.ccx(), ty))
}
pub fn heap_for_unique(bcx: @mut Block, t: ty::t) -> heap {
pub fn heap_for_unique(bcx: @Block, t: ty::t) -> heap {
if ty::type_contents(bcx.tcx(), t).owns_managed() {
heap_managed_unique
} else {
@ -419,7 +419,7 @@ pub fn heap_for_unique(bcx: @mut Block, t: ty::t) -> heap {
}
}
pub fn maybe_set_managed_unique_rc(bcx: @mut Block, bx: ValueRef, heap: heap) {
pub fn maybe_set_managed_unique_rc(bcx: @Block, bx: ValueRef, heap: heap) {
assert!(heap != heap_exchange);
if heap == heap_managed_unique {
// In cases where we are looking at a unique-typed allocation in the
@ -579,7 +579,7 @@ pub fn maybe_name_value(cx: &CrateContext, v: ValueRef, s: &str) {
pub enum scalar_type { nil_type, signed_int, unsigned_int, floating_point, }
// NB: This produces an i1, not a Rust bool (i8).
pub fn compare_scalar_types(cx: @mut Block,
pub fn compare_scalar_types(cx: @Block,
lhs: ValueRef,
rhs: ValueRef,
t: ty::t,
@ -611,14 +611,14 @@ pub fn compare_scalar_types(cx: @mut Block,
// A helper function to do the actual comparison of scalar values.
pub fn compare_scalar_values(cx: @mut Block,
pub fn compare_scalar_values(cx: @Block,
lhs: ValueRef,
rhs: ValueRef,
nt: scalar_type,
op: ast::BinOp)
-> ValueRef {
let _icx = push_ctxt("compare_scalar_values");
fn die(cx: @mut Block) -> ! {
fn die(cx: @Block) -> ! {
cx.tcx().sess.bug("compare_scalar_values: must be a\
comparison operator");
}
@ -672,25 +672,25 @@ pub fn compare_scalar_values(cx: @mut Block,
}
}
pub type val_and_ty_fn<'a> = 'a |@mut Block, ValueRef, ty::t|
-> @mut Block;
pub type val_and_ty_fn<'a> = 'a |@Block, ValueRef, ty::t|
-> @Block;
pub fn load_inbounds(cx: @mut Block, p: ValueRef, idxs: &[uint]) -> ValueRef {
pub fn load_inbounds(cx: @Block, p: ValueRef, idxs: &[uint]) -> ValueRef {
return Load(cx, GEPi(cx, p, idxs));
}
pub fn store_inbounds(cx: @mut Block, v: ValueRef, p: ValueRef, idxs: &[uint]) {
pub fn store_inbounds(cx: @Block, v: ValueRef, p: ValueRef, idxs: &[uint]) {
Store(cx, v, GEPi(cx, p, idxs));
}
// Iterates through the elements of a structural type.
pub fn iter_structural_ty(cx: @mut Block, av: ValueRef, t: ty::t,
f: val_and_ty_fn) -> @mut Block {
pub fn iter_structural_ty(cx: @Block, av: ValueRef, t: ty::t,
f: val_and_ty_fn) -> @Block {
let _icx = push_ctxt("iter_structural_ty");
fn iter_variant(cx: @mut Block, repr: &adt::Repr, av: ValueRef,
fn iter_variant(cx: @Block, repr: &adt::Repr, av: ValueRef,
variant: @ty::VariantInfo,
tps: &[ty::t], f: val_and_ty_fn) -> @mut Block {
tps: &[ty::t], f: val_and_ty_fn) -> @Block {
let _icx = push_ctxt("iter_variant");
let tcx = cx.tcx();
let mut cx = cx;
@ -776,7 +776,7 @@ pub fn iter_structural_ty(cx: @mut Block, av: ValueRef, t: ty::t,
return cx;
}
pub fn cast_shift_expr_rhs(cx: @mut Block, op: ast::BinOp,
pub fn cast_shift_expr_rhs(cx: @Block, op: ast::BinOp,
lhs: ValueRef, rhs: ValueRef) -> ValueRef {
cast_shift_rhs(op, lhs, rhs,
|a,b| Trunc(cx, a, b),
@ -818,8 +818,8 @@ pub fn cast_shift_rhs(op: ast::BinOp,
}
}
pub fn fail_if_zero(cx: @mut Block, span: Span, divrem: ast::BinOp,
rhs: ValueRef, rhs_t: ty::t) -> @mut Block {
pub fn fail_if_zero(cx: @Block, span: Span, divrem: ast::BinOp,
rhs: ValueRef, rhs_t: ty::t) -> @Block {
let text = if divrem == ast::BiDiv {
@"attempted to divide by zero"
} else {
@ -875,14 +875,14 @@ pub fn trans_external_path(ccx: &mut CrateContext, did: ast::DefId, t: ty::t) ->
}
}
pub fn invoke(bcx: @mut Block,
pub fn invoke(bcx: @Block,
llfn: ValueRef,
llargs: ~[ValueRef],
attributes: &[(uint, lib::llvm::Attribute)],
call_info: Option<NodeInfo>)
-> (ValueRef, @mut Block) {
-> (ValueRef, @Block) {
let _icx = push_ctxt("invoke_");
if bcx.unreachable {
if bcx.unreachable.get() {
return (C_null(Type::i8()), bcx);
}
@ -934,7 +934,7 @@ pub fn invoke(bcx: @mut Block,
}
}
pub fn need_invoke(bcx: @mut Block) -> bool {
pub fn need_invoke(bcx: @Block) -> bool {
if bcx.ccx().sess.no_landing_pads() {
return false;
}
@ -950,7 +950,7 @@ pub fn need_invoke(bcx: @mut Block) -> bool {
// Walk the scopes to look for cleanups
let mut cur = bcx;
let mut cur_scope = cur.scope;
let mut cur_scope = cur.scope.get();
loop {
cur_scope = match cur_scope {
Some(inf) => {
@ -970,13 +970,13 @@ pub fn need_invoke(bcx: @mut Block) -> bool {
Some(next) => next,
None => return false
};
cur.scope
cur.scope.get()
}
}
}
}
pub fn have_cached_lpad(bcx: @mut Block) -> bool {
pub fn have_cached_lpad(bcx: @Block) -> bool {
let mut res = false;
in_lpad_scope_cx(bcx, |inf| {
match inf.landing_pad {
@ -987,9 +987,9 @@ pub fn have_cached_lpad(bcx: @mut Block) -> bool {
return res;
}
pub fn in_lpad_scope_cx(bcx: @mut Block, f: |si: &mut ScopeInfo|) {
pub fn in_lpad_scope_cx(bcx: @Block, f: |si: &mut ScopeInfo|) {
let mut bcx = bcx;
let mut cur_scope = bcx.scope;
let mut cur_scope = bcx.scope.get();
loop {
cur_scope = match cur_scope {
Some(inf) => {
@ -1001,13 +1001,13 @@ pub fn in_lpad_scope_cx(bcx: @mut Block, f: |si: &mut ScopeInfo|) {
}
None => {
bcx = block_parent(bcx);
bcx.scope
bcx.scope.get()
}
}
}
}
pub fn get_landing_pad(bcx: @mut Block) -> BasicBlockRef {
pub fn get_landing_pad(bcx: @Block) -> BasicBlockRef {
let _icx = push_ctxt("get_landing_pad");
let mut cached = None;
@ -1053,9 +1053,9 @@ pub fn get_landing_pad(bcx: @mut Block) -> BasicBlockRef {
return pad_bcx.llbb;
}
pub fn find_bcx_for_scope(bcx: @mut Block, scope_id: ast::NodeId) -> @mut Block {
pub fn find_bcx_for_scope(bcx: @Block, scope_id: ast::NodeId) -> @Block {
let mut bcx_sid = bcx;
let mut cur_scope = bcx_sid.scope;
let mut cur_scope = bcx_sid.scope.get();
loop {
cur_scope = match cur_scope {
Some(inf) => {
@ -1075,14 +1075,14 @@ pub fn find_bcx_for_scope(bcx: @mut Block, scope_id: ast::NodeId) -> @mut Block
None => bcx.tcx().sess.bug(format!("no enclosing scope with id {}", scope_id)),
Some(bcx_par) => bcx_par
};
bcx_sid.scope
bcx_sid.scope.get()
}
}
}
}
pub fn do_spill(bcx: @mut Block, v: ValueRef, t: ty::t) -> ValueRef {
pub fn do_spill(bcx: @Block, v: ValueRef, t: ty::t) -> ValueRef {
if ty::type_is_bot(t) {
return C_null(Type::i8p());
}
@ -1093,31 +1093,31 @@ pub fn do_spill(bcx: @mut Block, v: ValueRef, t: ty::t) -> ValueRef {
// Since this function does *not* root, it is the caller's responsibility to
// ensure that the referent is pointed to by a root.
pub fn do_spill_noroot(cx: @mut Block, v: ValueRef) -> ValueRef {
pub fn do_spill_noroot(cx: @Block, v: ValueRef) -> ValueRef {
let llptr = alloca(cx, val_ty(v), "");
Store(cx, v, llptr);
return llptr;
}
pub fn spill_if_immediate(cx: @mut Block, v: ValueRef, t: ty::t) -> ValueRef {
pub fn spill_if_immediate(cx: @Block, v: ValueRef, t: ty::t) -> ValueRef {
let _icx = push_ctxt("spill_if_immediate");
if type_is_immediate(cx.ccx(), t) { return do_spill(cx, v, t); }
return v;
}
pub fn load_if_immediate(cx: @mut Block, v: ValueRef, t: ty::t) -> ValueRef {
pub fn load_if_immediate(cx: @Block, v: ValueRef, t: ty::t) -> ValueRef {
let _icx = push_ctxt("load_if_immediate");
if type_is_immediate(cx.ccx(), t) { return Load(cx, v); }
return v;
}
pub fn ignore_lhs(_bcx: @mut Block, local: &ast::Local) -> bool {
pub fn ignore_lhs(_bcx: @Block, local: &ast::Local) -> bool {
match local.pat.node {
ast::PatWild => true, _ => false
}
}
pub fn init_local(bcx: @mut Block, local: &ast::Local) -> @mut Block {
pub fn init_local(bcx: @Block, local: &ast::Local) -> @Block {
debug!("init_local(bcx={}, local.id={:?})",
bcx.to_str(), local.id);
@ -1138,7 +1138,7 @@ pub fn init_local(bcx: @mut Block, local: &ast::Local) -> @mut Block {
_match::store_local(bcx, local.pat, local.init)
}
pub fn trans_stmt(cx: @mut Block, s: &ast::Stmt) -> @mut Block {
pub fn trans_stmt(cx: @Block, s: &ast::Stmt) -> @Block {
let _icx = push_ctxt("trans_stmt");
debug!("trans_stmt({})", stmt_to_str(s, cx.tcx().sess.intr()));
@ -1172,24 +1172,24 @@ pub fn trans_stmt(cx: @mut Block, s: &ast::Stmt) -> @mut Block {
// You probably don't want to use this one. See the
// next three functions instead.
pub fn new_block(cx: @mut FunctionContext,
parent: Option<@mut Block>,
parent: Option<@Block>,
scope: Option<@mut ScopeInfo>,
is_lpad: bool,
name: &str,
opt_node_info: Option<NodeInfo>)
-> @mut Block {
-> @Block {
unsafe {
let llbb = name.with_c_str(|buf| {
llvm::LLVMAppendBasicBlockInContext(cx.ccx.llcx, cx.llfn, buf)
});
let bcx = @mut Block::new(llbb,
let bcx = @Block::new(llbb,
parent,
is_lpad,
opt_node_info,
cx);
bcx.scope = scope;
bcx.scope.set(scope);
for cx in parent.iter() {
if cx.unreachable {
if cx.unreachable.get() {
Unreachable(bcx);
break;
}
@ -1213,23 +1213,23 @@ pub fn simple_block_scope(parent: Option<@mut ScopeInfo>,
// Use this when you're at the top block of a function or the like.
pub fn top_scope_block(fcx: @mut FunctionContext, opt_node_info: Option<NodeInfo>)
-> @mut Block {
-> @Block {
return new_block(fcx, None, Some(simple_block_scope(None, opt_node_info)), false,
"function top level", opt_node_info);
}
pub fn scope_block(bcx: @mut Block,
pub fn scope_block(bcx: @Block,
opt_node_info: Option<NodeInfo>,
n: &str) -> @mut Block {
n: &str) -> @Block {
return new_block(bcx.fcx, Some(bcx), Some(simple_block_scope(None, opt_node_info)), bcx.is_lpad,
n, opt_node_info);
}
pub fn loop_scope_block(bcx: @mut Block,
loop_break: @mut Block,
pub fn loop_scope_block(bcx: @Block,
loop_break: @Block,
loop_label: Option<Name>,
n: &str,
opt_node_info: Option<NodeInfo>) -> @mut Block {
opt_node_info: Option<NodeInfo>) -> @Block {
return new_block(bcx.fcx, Some(bcx), Some(@mut ScopeInfo {
parent: None,
loop_break: Some(loop_break),
@ -1242,17 +1242,17 @@ pub fn loop_scope_block(bcx: @mut Block,
}
// Use this when creating a block for the inside of a landing pad.
pub fn lpad_block(bcx: @mut Block, n: &str) -> @mut Block {
pub fn lpad_block(bcx: @Block, n: &str) -> @Block {
new_block(bcx.fcx, Some(bcx), None, true, n, None)
}
// Use this when you're making a general CFG BB within a scope.
pub fn sub_block(bcx: @mut Block, n: &str) -> @mut Block {
pub fn sub_block(bcx: @Block, n: &str) -> @Block {
new_block(bcx.fcx, Some(bcx), None, bcx.is_lpad, n, None)
}
pub fn raw_block(fcx: @mut FunctionContext, is_lpad: bool, llbb: BasicBlockRef) -> @mut Block {
@mut Block::new(llbb, None, is_lpad, None, fcx)
pub fn raw_block(fcx: @mut FunctionContext, is_lpad: bool, llbb: BasicBlockRef) -> @Block {
@Block::new(llbb, None, is_lpad, None, fcx)
}
@ -1263,19 +1263,21 @@ pub fn raw_block(fcx: @mut FunctionContext, is_lpad: bool, llbb: BasicBlockRef)
// need to make sure those variables go out of scope when the block ends. We
// do that by running a 'cleanup' function for each variable.
// trans_block_cleanups runs all the cleanup functions for the block.
pub fn trans_block_cleanups(bcx: @mut Block, cleanups: ~[cleanup]) -> @mut Block {
pub fn trans_block_cleanups(bcx: @Block, cleanups: ~[cleanup]) -> @Block {
trans_block_cleanups_(bcx, cleanups, false)
}
pub fn trans_block_cleanups_(bcx: @mut Block,
pub fn trans_block_cleanups_(bcx: @Block,
cleanups: &[cleanup],
/* cleanup_cx: block, */
is_lpad: bool) -> @mut Block {
is_lpad: bool) -> @Block {
let _icx = push_ctxt("trans_block_cleanups");
// NB: Don't short-circuit even if this block is unreachable because
// GC-based cleanup needs to the see that the roots are live.
let no_lpads = bcx.ccx().sess.no_landing_pads();
if bcx.unreachable && !no_lpads { return bcx; }
if bcx.unreachable.get() && !no_lpads {
return bcx
}
let mut bcx = bcx;
for cu in cleanups.rev_iter() {
match *cu {
@ -1294,7 +1296,7 @@ pub fn trans_block_cleanups_(bcx: @mut Block,
// In the last argument, Some(block) mean jump to this block, and none means
// this is a landing pad and leaving should be accomplished with a resume
// instruction.
pub fn cleanup_and_leave(bcx: @mut Block,
pub fn cleanup_and_leave(bcx: @Block,
upto: Option<BasicBlockRef>,
leave: Option<BasicBlockRef>) {
let _icx = push_ctxt("cleanup_and_leave");
@ -1304,7 +1306,7 @@ pub fn cleanup_and_leave(bcx: @mut Block,
loop {
debug!("cleanup_and_leave: leaving {}", cur.to_str());
let mut cur_scope = cur.scope;
let mut cur_scope = cur.scope.get();
loop {
cur_scope = match cur_scope {
Some (inf) if !inf.empty_cleanups() => {
@ -1365,14 +1367,14 @@ pub fn cleanup_and_leave(bcx: @mut Block,
}
}
pub fn cleanup_block(bcx: @mut Block, upto: Option<BasicBlockRef>) -> @mut Block{
pub fn cleanup_block(bcx: @Block, upto: Option<BasicBlockRef>) -> @Block{
let _icx = push_ctxt("cleanup_block");
let mut cur = bcx;
let mut bcx = bcx;
loop {
debug!("cleanup_block: {}", cur.to_str());
let mut cur_scope = cur.scope;
let mut cur_scope = cur.scope.get();
loop {
cur_scope = match cur_scope {
Some (inf) => {
@ -1395,60 +1397,62 @@ pub fn cleanup_block(bcx: @mut Block, upto: Option<BasicBlockRef>) -> @mut Block
bcx
}
pub fn cleanup_and_Br(bcx: @mut Block, upto: @mut Block, target: BasicBlockRef) {
pub fn cleanup_and_Br(bcx: @Block, upto: @Block, target: BasicBlockRef) {
let _icx = push_ctxt("cleanup_and_Br");
cleanup_and_leave(bcx, Some(upto.llbb), Some(target));
}
pub fn leave_block(bcx: @mut Block, out_of: @mut Block) -> @mut Block {
pub fn leave_block(bcx: @Block, out_of: @Block) -> @Block {
let _icx = push_ctxt("leave_block");
let next_cx = sub_block(block_parent(out_of), "next");
if bcx.unreachable { Unreachable(next_cx); }
if bcx.unreachable.get() {
Unreachable(next_cx);
}
cleanup_and_Br(bcx, out_of, next_cx.llbb);
next_cx
}
pub fn with_scope(bcx: @mut Block,
pub fn with_scope(bcx: @Block,
opt_node_info: Option<NodeInfo>,
name: &str,
f: |@mut Block| -> @mut Block)
-> @mut Block {
f: |@Block| -> @Block)
-> @Block {
let _icx = push_ctxt("with_scope");
debug!("with_scope(bcx={}, opt_node_info={:?}, name={})",
bcx.to_str(), opt_node_info, name);
let _indenter = indenter();
let scope = simple_block_scope(bcx.scope, opt_node_info);
bcx.scope = Some(scope);
let scope = simple_block_scope(bcx.scope.get(), opt_node_info);
bcx.scope.set(Some(scope));
let ret = f(bcx);
let ret = trans_block_cleanups_(ret, (scope.cleanups).clone(), false);
bcx.scope = scope.parent;
bcx.scope.set(scope.parent);
ret
}
pub fn with_scope_result(bcx: @mut Block,
pub fn with_scope_result(bcx: @Block,
opt_node_info: Option<NodeInfo>,
_name: &str,
f: |@mut Block| -> Result)
f: |@Block| -> Result)
-> Result {
let _icx = push_ctxt("with_scope_result");
let scope = simple_block_scope(bcx.scope, opt_node_info);
bcx.scope = Some(scope);
let scope = simple_block_scope(bcx.scope.get(), opt_node_info);
bcx.scope.set(Some(scope));
let Result { bcx: out_bcx, val } = f(bcx);
let out_bcx = trans_block_cleanups_(out_bcx,
(scope.cleanups).clone(),
false);
bcx.scope = scope.parent;
bcx.scope.set(scope.parent);
rslt(out_bcx, val)
}
pub fn with_scope_datumblock(bcx: @mut Block,
pub fn with_scope_datumblock(bcx: @Block,
opt_node_info: Option<NodeInfo>,
name: &str,
f: |@mut Block| -> datum::DatumBlock)
f: |@Block| -> datum::DatumBlock)
-> datum::DatumBlock {
use middle::trans::datum::DatumBlock;
@ -1473,20 +1477,22 @@ pub fn block_locals(b: &ast::Block, it: |@ast::Local|) {
}
}
pub fn with_cond(bcx: @mut Block,
pub fn with_cond(bcx: @Block,
val: ValueRef,
f: |@mut Block| -> @mut Block)
-> @mut Block {
f: |@Block| -> @Block)
-> @Block {
let _icx = push_ctxt("with_cond");
let next_cx = base::sub_block(bcx, "next");
let cond_cx = base::sub_block(bcx, "cond");
CondBr(bcx, val, cond_cx.llbb, next_cx.llbb);
let after_cx = f(cond_cx);
if !after_cx.terminated { Br(after_cx, next_cx.llbb); }
if !after_cx.terminated.get() {
Br(after_cx, next_cx.llbb);
}
next_cx
}
pub fn call_memcpy(cx: @mut Block, dst: ValueRef, src: ValueRef, n_bytes: ValueRef, align: u32) {
pub fn call_memcpy(cx: @Block, dst: ValueRef, src: ValueRef, n_bytes: ValueRef, align: u32) {
let _icx = push_ctxt("call_memcpy");
let ccx = cx.ccx();
let key = match ccx.sess.targ_cfg.arch {
@ -1502,7 +1508,7 @@ pub fn call_memcpy(cx: @mut Block, dst: ValueRef, src: ValueRef, n_bytes: ValueR
Call(cx, memcpy, [dst_ptr, src_ptr, size, align, volatile], []);
}
pub fn memcpy_ty(bcx: @mut Block, dst: ValueRef, src: ValueRef, t: ty::t) {
pub fn memcpy_ty(bcx: @Block, dst: ValueRef, src: ValueRef, t: ty::t) {
let _icx = push_ctxt("memcpy_ty");
let ccx = bcx.ccx();
if ty::type_is_structural(t) {
@ -1515,8 +1521,8 @@ pub fn memcpy_ty(bcx: @mut Block, dst: ValueRef, src: ValueRef, t: ty::t) {
}
}
pub fn zero_mem(cx: @mut Block, llptr: ValueRef, t: ty::t) {
if cx.unreachable { return; }
pub fn zero_mem(cx: @Block, llptr: ValueRef, t: ty::t) {
if cx.unreachable.get() { return; }
let _icx = push_ctxt("zero_mem");
let bcx = cx;
let ccx = cx.ccx();
@ -1547,7 +1553,7 @@ pub fn memzero(b: &Builder, llptr: ValueRef, ty: Type) {
b.call(llintrinsicfn, [llptr, llzeroval, size, align, volatile], []);
}
pub fn alloc_ty(bcx: @mut Block, t: ty::t, name: &str) -> ValueRef {
pub fn alloc_ty(bcx: @Block, t: ty::t, name: &str) -> ValueRef {
let _icx = push_ctxt("alloc_ty");
let ccx = bcx.ccx();
let ty = type_of::type_of(ccx, t);
@ -1556,13 +1562,13 @@ pub fn alloc_ty(bcx: @mut Block, t: ty::t, name: &str) -> ValueRef {
return val;
}
pub fn alloca(cx: @mut Block, ty: Type, name: &str) -> ValueRef {
pub fn alloca(cx: @Block, ty: Type, name: &str) -> ValueRef {
alloca_maybe_zeroed(cx, ty, name, false)
}
pub fn alloca_maybe_zeroed(cx: @mut Block, ty: Type, name: &str, zero: bool) -> ValueRef {
pub fn alloca_maybe_zeroed(cx: @Block, ty: Type, name: &str, zero: bool) -> ValueRef {
let _icx = push_ctxt("alloca");
if cx.unreachable {
if cx.unreachable.get() {
unsafe {
return llvm::LLVMGetUndef(ty.ptr_to().to_ref());
}
@ -1577,9 +1583,9 @@ pub fn alloca_maybe_zeroed(cx: @mut Block, ty: Type, name: &str, zero: bool) ->
p
}
pub fn arrayalloca(cx: @mut Block, ty: Type, v: ValueRef) -> ValueRef {
pub fn arrayalloca(cx: @Block, ty: Type, v: ValueRef) -> ValueRef {
let _icx = push_ctxt("arrayalloca");
if cx.unreachable {
if cx.unreachable.get() {
unsafe {
return llvm::LLVMGetUndef(ty.to_ref());
}
@ -1752,10 +1758,10 @@ pub fn create_llargs_for_fn_args(cx: @mut FunctionContext,
}
pub fn copy_args_to_allocas(fcx: @mut FunctionContext,
bcx: @mut Block,
bcx: @Block,
args: &[ast::arg],
raw_llargs: &[ValueRef],
arg_tys: &[ty::t]) -> @mut Block {
arg_tys: &[ty::t]) -> @Block {
debug!("copy_args_to_allocas: raw_llargs={} arg_tys={}",
raw_llargs.llrepr(fcx.ccx),
arg_tys.repr(fcx.ccx.tcx));
@ -1815,12 +1821,12 @@ pub fn copy_args_to_allocas(fcx: @mut FunctionContext,
// Ties up the llstaticallocas -> llloadenv -> lltop edges,
// and builds the return block.
pub fn finish_fn(fcx: @mut FunctionContext, last_bcx: @mut Block) {
pub fn finish_fn(fcx: @mut FunctionContext, last_bcx: @Block) {
let _icx = push_ctxt("finish_fn");
let ret_cx = match fcx.llreturn {
Some(llreturn) => {
if !last_bcx.terminated {
if !last_bcx.terminated.get() {
Br(last_bcx, llreturn);
}
raw_block(fcx, false, llreturn)
@ -1833,7 +1839,7 @@ pub fn finish_fn(fcx: @mut FunctionContext, last_bcx: @mut Block) {
}
// Builds the return block for a function.
pub fn build_return_block(fcx: &FunctionContext, ret_cx: @mut Block) {
pub fn build_return_block(fcx: &FunctionContext, ret_cx: @Block) {
// Return the value if this function immediate; otherwise, return void.
if fcx.llretptr.is_none() || fcx.caller_expects_out_pointer {
return RetVoid(ret_cx);
@ -1973,7 +1979,7 @@ pub fn trans_fn(ccx: @mut CrateContext,
|_fcx| { });
}
fn insert_synthetic_type_entries(bcx: @mut Block,
fn insert_synthetic_type_entries(bcx: @Block,
fn_args: &[ast::arg],
arg_tys: &[ty::t])
{
@ -2413,7 +2419,7 @@ pub fn create_entry_wrapper(ccx: @mut CrateContext,
}
}
pub fn fill_fn_pair(bcx: @mut Block, pair: ValueRef, llfn: ValueRef,
pub fn fill_fn_pair(bcx: @Block, pair: ValueRef, llfn: ValueRef,
llenvptr: ValueRef) {
let ccx = bcx.ccx();
let code_cell = GEPi(bcx, pair, [0u, abi::fn_field_code]);
@ -2705,7 +2711,7 @@ pub fn register_method(ccx: @mut CrateContext,
llfn
}
pub fn vp2i(cx: @mut Block, v: ValueRef) -> ValueRef {
pub fn vp2i(cx: @Block, v: ValueRef) -> ValueRef {
let ccx = cx.ccx();
return PtrToInt(cx, v, ccx.int_type);
}
@ -2873,7 +2879,7 @@ pub fn declare_dbg_intrinsics(llmod: ModuleRef, intrinsics: &mut HashMap<&'stati
"llvm.dbg.value", [Type::metadata(), Type::i64(), Type::metadata()], Type::void());
}
pub fn trap(bcx: @mut Block) {
pub fn trap(bcx: @Block) {
match bcx.ccx().intrinsics.find_equiv(& &"llvm.trap") {
Some(&x) => { Call(bcx, x, [], []); },
_ => bcx.sess().bug("unbound llvm.trap in trap")

View File

@ -23,12 +23,12 @@ use middle::trans::type_::Type;
use std::cast;
use std::libc::{c_uint, c_ulonglong, c_char};
pub fn terminate(cx: &mut Block, _: &str) {
cx.terminated = true;
pub fn terminate(cx: &Block, _: &str) {
cx.terminated.set(true);
}
pub fn check_not_terminated(cx: &Block) {
if cx.terminated {
if cx.terminated.get() {
fail!("already terminated!");
}
}
@ -47,45 +47,45 @@ pub fn B(cx: &Block) -> Builder {
// for (fail/break/return statements, call to diverging functions, etc), and
// further instructions to the block should simply be ignored.
pub fn RetVoid(cx: &mut Block) {
if cx.unreachable { return; }
pub fn RetVoid(cx: &Block) {
if cx.unreachable.get() { return; }
check_not_terminated(cx);
terminate(cx, "RetVoid");
B(cx).ret_void();
}
pub fn Ret(cx: @mut Block, V: ValueRef) {
if cx.unreachable { return; }
pub fn Ret(cx: @Block, V: ValueRef) {
if cx.unreachable.get() { return; }
check_not_terminated(cx);
terminate(cx, "Ret");
B(cx).ret(V);
}
pub fn AggregateRet(cx: @mut Block, RetVals: &[ValueRef]) {
if cx.unreachable { return; }
pub fn AggregateRet(cx: @Block, RetVals: &[ValueRef]) {
if cx.unreachable.get() { return; }
check_not_terminated(cx);
terminate(cx, "AggregateRet");
B(cx).aggregate_ret(RetVals);
}
pub fn Br(cx: @mut Block, Dest: BasicBlockRef) {
if cx.unreachable { return; }
pub fn Br(cx: @Block, Dest: BasicBlockRef) {
if cx.unreachable.get() { return; }
check_not_terminated(cx);
terminate(cx, "Br");
B(cx).br(Dest);
}
pub fn CondBr(cx: @mut Block, If: ValueRef, Then: BasicBlockRef,
pub fn CondBr(cx: @Block, If: ValueRef, Then: BasicBlockRef,
Else: BasicBlockRef) {
if cx.unreachable { return; }
if cx.unreachable.get() { return; }
check_not_terminated(cx);
terminate(cx, "CondBr");
B(cx).cond_br(If, Then, Else);
}
pub fn Switch(cx: &mut Block, V: ValueRef, Else: BasicBlockRef, NumCases: uint)
pub fn Switch(cx: &Block, V: ValueRef, Else: BasicBlockRef, NumCases: uint)
-> ValueRef {
if cx.unreachable { return _Undef(V); }
if cx.unreachable.get() { return _Undef(V); }
check_not_terminated(cx);
terminate(cx, "Switch");
B(cx).switch(V, Else, NumCases)
@ -98,21 +98,21 @@ pub fn AddCase(S: ValueRef, OnVal: ValueRef, Dest: BasicBlockRef) {
}
}
pub fn IndirectBr(cx: &mut Block, Addr: ValueRef, NumDests: uint) {
if cx.unreachable { return; }
pub fn IndirectBr(cx: &Block, Addr: ValueRef, NumDests: uint) {
if cx.unreachable.get() { return; }
check_not_terminated(cx);
terminate(cx, "IndirectBr");
B(cx).indirect_br(Addr, NumDests);
}
pub fn Invoke(cx: @mut Block,
pub fn Invoke(cx: @Block,
Fn: ValueRef,
Args: &[ValueRef],
Then: BasicBlockRef,
Catch: BasicBlockRef,
attributes: &[(uint, lib::llvm::Attribute)])
-> ValueRef {
if cx.unreachable {
if cx.unreachable.get() {
return C_null(Type::i8());
}
check_not_terminated(cx);
@ -123,10 +123,12 @@ pub fn Invoke(cx: @mut Block,
B(cx).invoke(Fn, Args, Then, Catch, attributes)
}
pub fn Unreachable(cx: &mut Block) {
if cx.unreachable { return; }
cx.unreachable = true;
if !cx.terminated {
pub fn Unreachable(cx: &Block) {
if cx.unreachable.get() {
return
}
cx.unreachable.set(true);
if !cx.terminated.get() {
B(cx).unreachable();
}
}
@ -139,178 +141,178 @@ pub fn _Undef(val: ValueRef) -> ValueRef {
/* Arithmetic */
pub fn Add(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); }
if cx.unreachable.get() { return _Undef(LHS); }
B(cx).add(LHS, RHS)
}
pub fn NSWAdd(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); }
if cx.unreachable.get() { return _Undef(LHS); }
B(cx).nswadd(LHS, RHS)
}
pub fn NUWAdd(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); }
if cx.unreachable.get() { return _Undef(LHS); }
B(cx).nuwadd(LHS, RHS)
}
pub fn FAdd(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); }
if cx.unreachable.get() { return _Undef(LHS); }
B(cx).fadd(LHS, RHS)
}
pub fn Sub(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); }
if cx.unreachable.get() { return _Undef(LHS); }
B(cx).sub(LHS, RHS)
}
pub fn NSWSub(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); }
if cx.unreachable.get() { return _Undef(LHS); }
B(cx).nswsub(LHS, RHS)
}
pub fn NUWSub(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); }
if cx.unreachable.get() { return _Undef(LHS); }
B(cx).nuwsub(LHS, RHS)
}
pub fn FSub(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); }
if cx.unreachable.get() { return _Undef(LHS); }
B(cx).fsub(LHS, RHS)
}
pub fn Mul(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); }
if cx.unreachable.get() { return _Undef(LHS); }
B(cx).mul(LHS, RHS)
}
pub fn NSWMul(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); }
if cx.unreachable.get() { return _Undef(LHS); }
B(cx).nswmul(LHS, RHS)
}
pub fn NUWMul(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); }
if cx.unreachable.get() { return _Undef(LHS); }
B(cx).nuwmul(LHS, RHS)
}
pub fn FMul(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); }
if cx.unreachable.get() { return _Undef(LHS); }
B(cx).fmul(LHS, RHS)
}
pub fn UDiv(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); }
if cx.unreachable.get() { return _Undef(LHS); }
B(cx).udiv(LHS, RHS)
}
pub fn SDiv(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); }
if cx.unreachable.get() { return _Undef(LHS); }
B(cx).sdiv(LHS, RHS)
}
pub fn ExactSDiv(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); }
if cx.unreachable.get() { return _Undef(LHS); }
B(cx).exactsdiv(LHS, RHS)
}
pub fn FDiv(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); }
if cx.unreachable.get() { return _Undef(LHS); }
B(cx).fdiv(LHS, RHS)
}
pub fn URem(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); }
if cx.unreachable.get() { return _Undef(LHS); }
B(cx).urem(LHS, RHS)
}
pub fn SRem(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); }
if cx.unreachable.get() { return _Undef(LHS); }
B(cx).srem(LHS, RHS)
}
pub fn FRem(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); }
if cx.unreachable.get() { return _Undef(LHS); }
B(cx).frem(LHS, RHS)
}
pub fn Shl(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); }
if cx.unreachable.get() { return _Undef(LHS); }
B(cx).shl(LHS, RHS)
}
pub fn LShr(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); }
if cx.unreachable.get() { return _Undef(LHS); }
B(cx).lshr(LHS, RHS)
}
pub fn AShr(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); }
if cx.unreachable.get() { return _Undef(LHS); }
B(cx).ashr(LHS, RHS)
}
pub fn And(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); }
if cx.unreachable.get() { return _Undef(LHS); }
B(cx).and(LHS, RHS)
}
pub fn Or(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); }
if cx.unreachable.get() { return _Undef(LHS); }
B(cx).or(LHS, RHS)
}
pub fn Xor(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(LHS); }
if cx.unreachable.get() { return _Undef(LHS); }
B(cx).xor(LHS, RHS)
}
pub fn BinOp(cx: &Block, Op: Opcode, LHS: ValueRef, RHS: ValueRef)
-> ValueRef {
if cx.unreachable { return _Undef(LHS); }
if cx.unreachable.get() { return _Undef(LHS); }
B(cx).binop(Op, LHS, RHS)
}
pub fn Neg(cx: &Block, V: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(V); }
if cx.unreachable.get() { return _Undef(V); }
B(cx).neg(V)
}
pub fn NSWNeg(cx: &Block, V: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(V); }
if cx.unreachable.get() { return _Undef(V); }
B(cx).nswneg(V)
}
pub fn NUWNeg(cx: &Block, V: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(V); }
if cx.unreachable.get() { return _Undef(V); }
B(cx).nuwneg(V)
}
pub fn FNeg(cx: &Block, V: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(V); }
if cx.unreachable.get() { return _Undef(V); }
B(cx).fneg(V)
}
pub fn Not(cx: &Block, V: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(V); }
if cx.unreachable.get() { return _Undef(V); }
B(cx).not(V)
}
/* Memory */
pub fn Malloc(cx: &Block, Ty: Type) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(Type::i8p().to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i8p().to_ref()); }
B(cx).malloc(Ty)
}
}
pub fn ArrayMalloc(cx: &Block, Ty: Type, Val: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(Type::i8p().to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i8p().to_ref()); }
B(cx).array_malloc(Ty, Val)
}
}
pub fn Alloca(cx: &Block, Ty: Type, name: &str) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(Ty.ptr_to().to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(Ty.ptr_to().to_ref()); }
let b = cx.fcx.ccx.builder();
b.position_before(cx.fcx.alloca_insert_pt.unwrap());
b.alloca(Ty, name)
@ -319,7 +321,7 @@ pub fn Alloca(cx: &Block, Ty: Type, name: &str) -> ValueRef {
pub fn ArrayAlloca(cx: &Block, Ty: Type, Val: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(Ty.ptr_to().to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(Ty.ptr_to().to_ref()); }
let b = cx.fcx.ccx.builder();
b.position_before(cx.fcx.alloca_insert_pt.unwrap());
b.array_alloca(Ty, Val)
@ -327,14 +329,14 @@ pub fn ArrayAlloca(cx: &Block, Ty: Type, Val: ValueRef) -> ValueRef {
}
pub fn Free(cx: &Block, PointerVal: ValueRef) {
if cx.unreachable { return; }
if cx.unreachable.get() { return; }
B(cx).free(PointerVal)
}
pub fn Load(cx: &Block, PointerVal: ValueRef) -> ValueRef {
unsafe {
let ccx = cx.fcx.ccx;
if cx.unreachable {
if cx.unreachable.get() {
let ty = val_ty(PointerVal);
let eltty = if ty.kind() == lib::llvm::Array {
ty.element_type()
@ -350,7 +352,7 @@ pub fn Load(cx: &Block, PointerVal: ValueRef) -> ValueRef {
pub fn AtomicLoad(cx: &Block, PointerVal: ValueRef, order: AtomicOrdering) -> ValueRef {
unsafe {
let ccx = cx.fcx.ccx;
if cx.unreachable {
if cx.unreachable.get() {
return llvm::LLVMGetUndef(ccx.int_type.to_ref());
}
B(cx).atomic_load(PointerVal, order)
@ -360,7 +362,7 @@ pub fn AtomicLoad(cx: &Block, PointerVal: ValueRef, order: AtomicOrdering) -> Va
pub fn LoadRangeAssert(cx: &Block, PointerVal: ValueRef, lo: c_ulonglong,
hi: c_ulonglong, signed: lib::llvm::Bool) -> ValueRef {
if cx.unreachable {
if cx.unreachable.get() {
let ccx = cx.fcx.ccx;
let ty = val_ty(PointerVal);
let eltty = if ty.kind() == lib::llvm::Array {
@ -377,18 +379,18 @@ pub fn LoadRangeAssert(cx: &Block, PointerVal: ValueRef, lo: c_ulonglong,
}
pub fn Store(cx: &Block, Val: ValueRef, Ptr: ValueRef) {
if cx.unreachable { return; }
if cx.unreachable.get() { return; }
B(cx).store(Val, Ptr)
}
pub fn AtomicStore(cx: &Block, Val: ValueRef, Ptr: ValueRef, order: AtomicOrdering) {
if cx.unreachable { return; }
if cx.unreachable.get() { return; }
B(cx).atomic_store(Val, Ptr, order)
}
pub fn GEP(cx: &Block, Pointer: ValueRef, Indices: &[ValueRef]) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(Type::nil().ptr_to().to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().ptr_to().to_ref()); }
B(cx).gep(Pointer, Indices)
}
}
@ -398,35 +400,35 @@ pub fn GEP(cx: &Block, Pointer: ValueRef, Indices: &[ValueRef]) -> ValueRef {
#[inline]
pub fn GEPi(cx: &Block, base: ValueRef, ixs: &[uint]) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(Type::nil().ptr_to().to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().ptr_to().to_ref()); }
B(cx).gepi(base, ixs)
}
}
pub fn InBoundsGEP(cx: &Block, Pointer: ValueRef, Indices: &[ValueRef]) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(Type::nil().ptr_to().to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().ptr_to().to_ref()); }
B(cx).inbounds_gep(Pointer, Indices)
}
}
pub fn StructGEP(cx: &Block, Pointer: ValueRef, Idx: uint) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(Type::nil().ptr_to().to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().ptr_to().to_ref()); }
B(cx).struct_gep(Pointer, Idx)
}
}
pub fn GlobalString(cx: &Block, _Str: *c_char) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(Type::i8p().to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i8p().to_ref()); }
B(cx).global_string(_Str)
}
}
pub fn GlobalStringPtr(cx: &Block, _Str: *c_char) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(Type::i8p().to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i8p().to_ref()); }
B(cx).global_string_ptr(_Str)
}
}
@ -434,105 +436,105 @@ pub fn GlobalStringPtr(cx: &Block, _Str: *c_char) -> ValueRef {
/* Casts */
pub fn Trunc(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
B(cx).trunc(Val, DestTy)
}
}
pub fn ZExt(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
B(cx).zext(Val, DestTy)
}
}
pub fn SExt(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
B(cx).sext(Val, DestTy)
}
}
pub fn FPToUI(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
B(cx).fptoui(Val, DestTy)
}
}
pub fn FPToSI(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
B(cx).fptosi(Val, DestTy)
}
}
pub fn UIToFP(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
B(cx).uitofp(Val, DestTy)
}
}
pub fn SIToFP(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
B(cx).sitofp(Val, DestTy)
}
}
pub fn FPTrunc(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
B(cx).fptrunc(Val, DestTy)
}
}
pub fn FPExt(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
B(cx).fpext(Val, DestTy)
}
}
pub fn PtrToInt(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
B(cx).ptrtoint(Val, DestTy)
}
}
pub fn IntToPtr(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
B(cx).inttoptr(Val, DestTy)
}
}
pub fn BitCast(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
B(cx).bitcast(Val, DestTy)
}
}
pub fn ZExtOrBitCast(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
B(cx).zext_or_bitcast(Val, DestTy)
}
}
pub fn SExtOrBitCast(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
B(cx).sext_or_bitcast(Val, DestTy)
}
}
pub fn TruncOrBitCast(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
B(cx).trunc_or_bitcast(Val, DestTy)
}
}
@ -540,28 +542,28 @@ pub fn TruncOrBitCast(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
pub fn Cast(cx: &Block, Op: Opcode, Val: ValueRef, DestTy: Type, _: *u8)
-> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
B(cx).cast(Op, Val, DestTy)
}
}
pub fn PointerCast(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
B(cx).pointercast(Val, DestTy)
}
}
pub fn IntCast(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
B(cx).intcast(Val, DestTy)
}
}
pub fn FPCast(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy.to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(DestTy.to_ref()); }
B(cx).fpcast(Val, DestTy)
}
}
@ -571,7 +573,7 @@ pub fn FPCast(cx: &Block, Val: ValueRef, DestTy: Type) -> ValueRef {
pub fn ICmp(cx: &Block, Op: IntPredicate, LHS: ValueRef, RHS: ValueRef)
-> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(Type::i1().to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i1().to_ref()); }
B(cx).icmp(Op, LHS, RHS)
}
}
@ -579,7 +581,7 @@ pub fn ICmp(cx: &Block, Op: IntPredicate, LHS: ValueRef, RHS: ValueRef)
pub fn FCmp(cx: &Block, Op: RealPredicate, LHS: ValueRef, RHS: ValueRef)
-> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(Type::i1().to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i1().to_ref()); }
B(cx).fcmp(Op, LHS, RHS)
}
}
@ -587,14 +589,14 @@ pub fn FCmp(cx: &Block, Op: RealPredicate, LHS: ValueRef, RHS: ValueRef)
/* Miscellaneous instructions */
pub fn EmptyPhi(cx: &Block, Ty: Type) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(Ty.to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(Ty.to_ref()); }
B(cx).empty_phi(Ty)
}
}
pub fn Phi(cx: &Block, Ty: Type, vals: &[ValueRef], bbs: &[BasicBlockRef]) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(Ty.to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(Ty.to_ref()); }
B(cx).phi(Ty, vals, bbs)
}
}
@ -639,36 +641,36 @@ pub fn InlineAsmCall(cx: &Block, asm: *c_char, cons: *c_char,
pub fn Call(cx: &Block, Fn: ValueRef, Args: &[ValueRef],
attributes: &[(uint, lib::llvm::Attribute)]) -> ValueRef {
if cx.unreachable { return _UndefReturn(cx, Fn); }
if cx.unreachable.get() { return _UndefReturn(cx, Fn); }
B(cx).call(Fn, Args, attributes)
}
pub fn CallWithConv(cx: &Block, Fn: ValueRef, Args: &[ValueRef], Conv: CallConv,
attributes: &[(uint, lib::llvm::Attribute)]) -> ValueRef {
if cx.unreachable { return _UndefReturn(cx, Fn); }
if cx.unreachable.get() { return _UndefReturn(cx, Fn); }
B(cx).call_with_conv(Fn, Args, Conv, attributes)
}
pub fn AtomicFence(cx: &Block, order: AtomicOrdering) {
if cx.unreachable { return; }
if cx.unreachable.get() { return; }
B(cx).atomic_fence(order)
}
pub fn Select(cx: &Block, If: ValueRef, Then: ValueRef, Else: ValueRef) -> ValueRef {
if cx.unreachable { return _Undef(Then); }
if cx.unreachable.get() { return _Undef(Then); }
B(cx).select(If, Then, Else)
}
pub fn VAArg(cx: &Block, list: ValueRef, Ty: Type) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(Ty.to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(Ty.to_ref()); }
B(cx).va_arg(list, Ty)
}
}
pub fn ExtractElement(cx: &Block, VecVal: ValueRef, Index: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
B(cx).extract_element(VecVal, Index)
}
}
@ -676,7 +678,7 @@ pub fn ExtractElement(cx: &Block, VecVal: ValueRef, Index: ValueRef) -> ValueRef
pub fn InsertElement(cx: &Block, VecVal: ValueRef, EltVal: ValueRef,
Index: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
B(cx).insert_element(VecVal, EltVal, Index)
}
}
@ -684,42 +686,42 @@ pub fn InsertElement(cx: &Block, VecVal: ValueRef, EltVal: ValueRef,
pub fn ShuffleVector(cx: &Block, V1: ValueRef, V2: ValueRef,
Mask: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
B(cx).shuffle_vector(V1, V2, Mask)
}
}
pub fn VectorSplat(cx: &Block, NumElts: uint, EltVal: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
B(cx).vector_splat(NumElts, EltVal)
}
}
pub fn ExtractValue(cx: &Block, AggVal: ValueRef, Index: uint) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
B(cx).extract_value(AggVal, Index)
}
}
pub fn InsertValue(cx: &Block, AggVal: ValueRef, EltVal: ValueRef, Index: uint) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::nil().to_ref()); }
B(cx).insert_value(AggVal, EltVal, Index)
}
}
pub fn IsNull(cx: &Block, Val: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(Type::i1().to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i1().to_ref()); }
B(cx).is_null(Val)
}
}
pub fn IsNotNull(cx: &Block, Val: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(Type::i1().to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(Type::i1().to_ref()); }
B(cx).is_not_null(Val)
}
}
@ -727,20 +729,20 @@ pub fn IsNotNull(cx: &Block, Val: ValueRef) -> ValueRef {
pub fn PtrDiff(cx: &Block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
unsafe {
let ccx = cx.fcx.ccx;
if cx.unreachable { return llvm::LLVMGetUndef(ccx.int_type.to_ref()); }
if cx.unreachable.get() { return llvm::LLVMGetUndef(ccx.int_type.to_ref()); }
B(cx).ptrdiff(LHS, RHS)
}
}
pub fn Trap(cx: &Block) {
if cx.unreachable { return; }
if cx.unreachable.get() { return; }
B(cx).trap();
}
pub fn LandingPad(cx: &Block, Ty: Type, PersFn: ValueRef,
NumClauses: uint) -> ValueRef {
check_not_terminated(cx);
assert!(!cx.unreachable);
assert!(!cx.unreachable.get());
B(cx).landing_pad(Ty, PersFn, NumClauses)
}
@ -748,7 +750,7 @@ pub fn SetCleanup(cx: &Block, LandingPad: ValueRef) {
B(cx).set_cleanup(LandingPad)
}
pub fn Resume(cx: @mut Block, Exn: ValueRef) -> ValueRef {
pub fn Resume(cx: @Block, Exn: ValueRef) -> ValueRef {
check_not_terminated(cx);
terminate(cx, "Resume");
B(cx).resume(Exn)

View File

@ -71,11 +71,11 @@ pub enum CalleeData {
}
pub struct Callee {
bcx: @mut Block,
bcx: @Block,
data: CalleeData
}
pub fn trans(bcx: @mut Block, expr: &ast::Expr) -> Callee {
pub fn trans(bcx: @Block, expr: &ast::Expr) -> Callee {
let _icx = push_ctxt("trans_callee");
debug!("callee::trans(expr={})", expr.repr(bcx.tcx()));
@ -90,7 +90,7 @@ pub fn trans(bcx: @mut Block, expr: &ast::Expr) -> Callee {
// any other expressions are closures:
return datum_callee(bcx, expr);
fn datum_callee(bcx: @mut Block, expr: &ast::Expr) -> Callee {
fn datum_callee(bcx: @Block, expr: &ast::Expr) -> Callee {
let DatumBlock {bcx, datum} = expr::trans_to_datum(bcx, expr);
match ty::get(datum.ty).sty {
ty::ty_bare_fn(..) => {
@ -109,11 +109,11 @@ pub fn trans(bcx: @mut Block, expr: &ast::Expr) -> Callee {
}
}
fn fn_callee(bcx: @mut Block, fd: FnData) -> Callee {
fn fn_callee(bcx: @Block, fd: FnData) -> Callee {
return Callee {bcx: bcx, data: Fn(fd)};
}
fn trans_def(bcx: @mut Block, def: ast::Def, ref_expr: &ast::Expr) -> Callee {
fn trans_def(bcx: @Block, def: ast::Def, ref_expr: &ast::Expr) -> Callee {
match def {
ast::DefFn(did, _) |
ast::DefStaticMethod(did, ast::FromImpl(_), _) => {
@ -158,14 +158,14 @@ pub fn trans(bcx: @mut Block, expr: &ast::Expr) -> Callee {
}
}
pub fn trans_fn_ref_to_callee(bcx: @mut Block,
pub fn trans_fn_ref_to_callee(bcx: @Block,
def_id: ast::DefId,
ref_id: ast::NodeId) -> Callee {
Callee {bcx: bcx,
data: Fn(trans_fn_ref(bcx, def_id, ref_id))}
}
pub fn trans_fn_ref(bcx: @mut Block,
pub fn trans_fn_ref(bcx: @Block,
def_id: ast::DefId,
ref_id: ast::NodeId) -> FnData {
/*!
@ -185,7 +185,7 @@ pub fn trans_fn_ref(bcx: @mut Block,
}
pub fn trans_fn_ref_with_vtables_to_callee(
bcx: @mut Block,
bcx: @Block,
def_id: ast::DefId,
ref_id: ast::NodeId,
type_params: &[ty::t],
@ -196,7 +196,7 @@ pub fn trans_fn_ref_with_vtables_to_callee(
type_params, vtables))}
}
fn resolve_default_method_vtables(bcx: @mut Block,
fn resolve_default_method_vtables(bcx: @Block,
impl_id: ast::DefId,
method: &ty::Method,
substs: &ty::substs,
@ -239,7 +239,7 @@ fn resolve_default_method_vtables(bcx: @mut Block,
pub fn trans_fn_ref_with_vtables(
bcx: @mut Block, //
bcx: @Block, //
def_id: ast::DefId, // def id of fn
ref_id: ast::NodeId, // node id of use of fn; may be zero if N/A
type_params: &[ty::t], // values for fn's ty params
@ -444,13 +444,13 @@ pub fn trans_fn_ref_with_vtables(
// ______________________________________________________________________
// Translating calls
pub fn trans_call(in_cx: @mut Block,
pub fn trans_call(in_cx: @Block,
call_ex: &ast::Expr,
f: &ast::Expr,
args: CallArgs,
id: ast::NodeId,
dest: expr::Dest)
-> @mut Block {
-> @Block {
let _icx = push_ctxt("trans_call");
trans_call_inner(in_cx,
call_ex.info(),
@ -462,13 +462,13 @@ pub fn trans_call(in_cx: @mut Block,
DontAutorefArg).bcx
}
pub fn trans_method_call(in_cx: @mut Block,
pub fn trans_method_call(in_cx: @Block,
call_ex: &ast::Expr,
callee_id: ast::NodeId,
rcvr: &ast::Expr,
args: CallArgs,
dest: expr::Dest)
-> @mut Block {
-> @Block {
let _icx = push_ctxt("trans_method_call");
debug!("trans_method_call(call_ex={}, rcvr={})",
call_ex.repr(in_cx.tcx()),
@ -500,7 +500,7 @@ pub fn trans_method_call(in_cx: @mut Block,
DontAutorefArg).bcx
}
pub fn trans_lang_call(bcx: @mut Block,
pub fn trans_lang_call(bcx: @Block,
did: ast::DefId,
args: &[ValueRef],
dest: Option<expr::Dest>)
@ -527,12 +527,12 @@ pub fn trans_lang_call(bcx: @mut Block,
DontAutorefArg)
}
pub fn trans_lang_call_with_type_params(bcx: @mut Block,
pub fn trans_lang_call_with_type_params(bcx: @Block,
did: ast::DefId,
args: &[ValueRef],
type_params: &[ty::t],
dest: expr::Dest)
-> @mut Block {
-> @Block {
let fty;
if did.crate == ast::LOCAL_CRATE {
fty = ty::node_id_to_type(bcx.tcx(), did.node);
@ -567,11 +567,11 @@ pub fn trans_lang_call_with_type_params(bcx: @mut Block,
ArgVals(args), Some(dest), DontAutorefArg).bcx;
}
pub fn trans_call_inner(in_cx: @mut Block,
pub fn trans_call_inner(in_cx: @Block,
call_info: Option<NodeInfo>,
callee_ty: ty::t,
ret_ty: ty::t,
get_callee: |@mut Block| -> Callee,
get_callee: |@Block| -> Callee,
args: CallArgs,
dest: Option<expr::Dest>,
autoref_arg: AutorefArg)
@ -755,11 +755,11 @@ pub enum CallArgs<'a> {
ArgVals(&'a [ValueRef])
}
pub fn trans_args(cx: @mut Block,
pub fn trans_args(cx: @Block,
args: CallArgs,
fn_ty: ty::t,
autoref_arg: AutorefArg,
llargs: &mut ~[ValueRef]) -> @mut Block
llargs: &mut ~[ValueRef]) -> @Block
{
let _icx = push_ctxt("trans_args");
let mut temp_cleanups = ~[];
@ -814,7 +814,7 @@ pub enum AutorefArg {
// temp_cleanups: cleanups that should run only if failure occurs before the
// call takes place:
pub fn trans_arg_expr(bcx: @mut Block,
pub fn trans_arg_expr(bcx: @Block,
formal_arg_ty: ty::t,
self_mode: ty::SelfMode,
arg_expr: &ast::Expr,

View File

@ -155,7 +155,7 @@ pub fn mk_closure_tys(tcx: ty::ctxt,
return cdata_ty;
}
fn heap_for_unique_closure(bcx: @mut Block, t: ty::t) -> heap {
fn heap_for_unique_closure(bcx: @Block, t: ty::t) -> heap {
if ty::type_contents(bcx.tcx(), t).owns_managed() {
heap_managed_unique
} else {
@ -163,7 +163,7 @@ fn heap_for_unique_closure(bcx: @mut Block, t: ty::t) -> heap {
}
}
pub fn allocate_cbox(bcx: @mut Block, sigil: ast::Sigil, cdata_ty: ty::t)
pub fn allocate_cbox(bcx: @Block, sigil: ast::Sigil, cdata_ty: ty::t)
-> Result {
let _icx = push_ctxt("closure::allocate_cbox");
let ccx = bcx.ccx();
@ -188,14 +188,14 @@ pub fn allocate_cbox(bcx: @mut Block, sigil: ast::Sigil, cdata_ty: ty::t)
pub struct ClosureResult {
llbox: ValueRef, // llvalue of ptr to closure
cdata_ty: ty::t, // type of the closure data
bcx: @mut Block // final bcx
bcx: @Block // final bcx
}
// Given a block context and a list of tydescs and values to bind
// construct a closure out of them. If copying is true, it is a
// heap allocated closure that copies the upvars into environment.
// Otherwise, it is stack allocated and copies pointers to the upvars.
pub fn store_environment(bcx: @mut Block,
pub fn store_environment(bcx: @Block,
bound_values: ~[EnvValue],
sigil: ast::Sigil)
-> ClosureResult {
@ -257,7 +257,7 @@ pub fn store_environment(bcx: @mut Block,
// Given a context and a list of upvars, build a closure. This just
// collects the upvars and packages them up for store_environment.
pub fn build_closure(bcx0: @mut Block,
pub fn build_closure(bcx0: @Block,
cap_vars: &[moves::CaptureVar],
sigil: ast::Sigil) -> ClosureResult {
let _icx = push_ctxt("closure::build_closure");
@ -345,13 +345,13 @@ pub fn load_environment(fcx: @mut FunctionContext,
}
}
pub fn trans_expr_fn(bcx: @mut Block,
pub fn trans_expr_fn(bcx: @Block,
sigil: ast::Sigil,
decl: &ast::fn_decl,
body: &ast::Block,
outer_id: ast::NodeId,
user_id: ast::NodeId,
dest: expr::Dest) -> @mut Block {
dest: expr::Dest) -> @Block {
/*!
*
* Translates the body of a closure expression.
@ -422,12 +422,12 @@ pub fn trans_expr_fn(bcx: @mut Block,
return bcx;
}
pub fn make_closure_glue(cx: @mut Block,
pub fn make_closure_glue(cx: @Block,
v: ValueRef,
t: ty::t,
glue_fn: |@mut Block, v: ValueRef, t: ty::t|
-> @mut Block)
-> @mut Block {
glue_fn: |@Block, v: ValueRef, t: ty::t|
-> @Block)
-> @Block {
let _icx = push_ctxt("closure::make_closure_glue");
let bcx = cx;
let tcx = cx.tcx();
@ -447,10 +447,10 @@ pub fn make_closure_glue(cx: @mut Block,
}
pub fn make_opaque_cbox_drop_glue(
bcx: @mut Block,
bcx: @Block,
sigil: ast::Sigil,
cboxptr: ValueRef) // ptr to the opaque closure
-> @mut Block {
-> @Block {
let _icx = push_ctxt("closure::make_opaque_cbox_drop_glue");
match sigil {
ast::BorrowedSigil => bcx,
@ -465,11 +465,11 @@ pub fn make_opaque_cbox_drop_glue(
}
}
pub fn make_opaque_cbox_free_glue(
bcx: @mut Block,
sigil: ast::Sigil,
cbox: ValueRef) // ptr to ptr to the opaque closure
-> @mut Block {
/// `cbox` is a pointer to a pointer to an opaque closure.
pub fn make_opaque_cbox_free_glue(bcx: @Block,
sigil: ast::Sigil,
cbox: ValueRef)
-> @Block {
let _icx = push_ctxt("closure::make_opaque_cbox_free_glue");
match sigil {
ast::BorrowedSigil => {

View File

@ -35,6 +35,7 @@ use middle::trans::type_::Type;
use std::c_str::ToCStr;
use std::cast::transmute;
use std::cast;
use std::cell::{Cell, RefCell};
use std::hashmap::HashMap;
use std::libc::{c_uint, c_longlong, c_ulonglong, c_char};
use std::vec;
@ -213,7 +214,7 @@ pub struct FunctionContext {
// always be Some.
llretptr: Option<ValueRef>,
entry_bcx: Option<@mut Block>,
entry_bcx: Option<@Block>,
// These elements: "hoisted basic blocks" containing
// administrative activities that have to happen in only one place in
@ -331,7 +332,7 @@ pub enum cleantype {
/// A cleanup function: a built-in destructor.
pub trait CleanupFunction {
fn clean(&self, block: @mut Block) -> @mut Block;
fn clean(&self, block: @Block) -> @Block;
}
/// A cleanup function that calls the "drop glue" (destructor function) on
@ -342,7 +343,7 @@ pub struct TypeDroppingCleanupFunction {
}
impl CleanupFunction for TypeDroppingCleanupFunction {
fn clean(&self, block: @mut Block) -> @mut Block {
fn clean(&self, block: @Block) -> @Block {
glue::drop_ty(block, self.val, self.t)
}
}
@ -355,7 +356,7 @@ pub struct ImmediateTypeDroppingCleanupFunction {
}
impl CleanupFunction for ImmediateTypeDroppingCleanupFunction {
fn clean(&self, block: @mut Block) -> @mut Block {
fn clean(&self, block: @Block) -> @Block {
glue::drop_ty_immediate(block, self.val, self.t)
}
}
@ -371,7 +372,7 @@ pub struct WriteGuardReleasingCleanupFunction {
}
impl CleanupFunction for WriteGuardReleasingCleanupFunction {
fn clean(&self, bcx: @mut Block) -> @mut Block {
fn clean(&self, bcx: @Block) -> @Block {
write_guard::return_to_mut(bcx,
self.root_key,
self.frozen_val_ref,
@ -387,7 +388,7 @@ pub struct GCHeapFreeingCleanupFunction {
}
impl CleanupFunction for GCHeapFreeingCleanupFunction {
fn clean(&self, bcx: @mut Block) -> @mut Block {
fn clean(&self, bcx: @Block) -> @Block {
glue::trans_free(bcx, self.ptr)
}
}
@ -398,7 +399,7 @@ pub struct ExchangeHeapFreeingCleanupFunction {
}
impl CleanupFunction for ExchangeHeapFreeingCleanupFunction {
fn clean(&self, bcx: @mut Block) -> @mut Block {
fn clean(&self, bcx: @Block) -> @Block {
glue::trans_exchange_free(bcx, self.ptr)
}
}
@ -445,7 +446,7 @@ pub fn cleanup_type(cx: ty::ctxt, ty: ty::t) -> cleantype {
}
}
pub fn add_clean(bcx: @mut Block, val: ValueRef, t: ty::t) {
pub fn add_clean(bcx: @Block, val: ValueRef, t: ty::t) {
if !ty::type_needs_drop(bcx.tcx(), t) {
return
}
@ -463,7 +464,7 @@ pub fn add_clean(bcx: @mut Block, val: ValueRef, t: ty::t) {
})
}
pub fn add_clean_temp_immediate(cx: @mut Block, val: ValueRef, ty: ty::t) {
pub fn add_clean_temp_immediate(cx: @Block, val: ValueRef, ty: ty::t) {
if !ty::type_needs_drop(cx.tcx(), ty) { return; }
debug!("add_clean_temp_immediate({}, {}, {})",
cx.to_str(), cx.val_to_str(val),
@ -480,18 +481,18 @@ pub fn add_clean_temp_immediate(cx: @mut Block, val: ValueRef, ty: ty::t) {
})
}
pub fn add_clean_temp_mem(bcx: @mut Block, val: ValueRef, t: ty::t) {
pub fn add_clean_temp_mem(bcx: @Block, val: ValueRef, t: ty::t) {
add_clean_temp_mem_in_scope_(bcx, None, val, t);
}
pub fn add_clean_temp_mem_in_scope(bcx: @mut Block,
pub fn add_clean_temp_mem_in_scope(bcx: @Block,
scope_id: ast::NodeId,
val: ValueRef,
t: ty::t) {
add_clean_temp_mem_in_scope_(bcx, Some(scope_id), val, t);
}
pub fn add_clean_temp_mem_in_scope_(bcx: @mut Block, scope_id: Option<ast::NodeId>,
pub fn add_clean_temp_mem_in_scope_(bcx: @Block, scope_id: Option<ast::NodeId>,
val: ValueRef, t: ty::t) {
if !ty::type_needs_drop(bcx.tcx(), t) { return; }
debug!("add_clean_temp_mem({}, {}, {})",
@ -508,7 +509,7 @@ pub fn add_clean_temp_mem_in_scope_(bcx: @mut Block, scope_id: Option<ast::NodeI
grow_scope_clean(scope_info);
})
}
pub fn add_clean_return_to_mut(bcx: @mut Block,
pub fn add_clean_return_to_mut(bcx: @Block,
scope_id: ast::NodeId,
root_key: root_map_key,
frozen_val_ref: ValueRef,
@ -541,7 +542,7 @@ pub fn add_clean_return_to_mut(bcx: @mut Block,
grow_scope_clean(scope_info);
})
}
pub fn add_clean_free(cx: @mut Block, ptr: ValueRef, heap: heap) {
pub fn add_clean_free(cx: @Block, ptr: ValueRef, heap: heap) {
let free_fn = match heap {
heap_managed | heap_managed_unique => {
@GCHeapFreeingCleanupFunction {
@ -566,7 +567,7 @@ pub fn add_clean_free(cx: @mut Block, ptr: ValueRef, heap: heap) {
// to a system where we can also cancel the cleanup on local variables, but
// this will be more involved. For now, we simply zero out the local, and the
// drop glue checks whether it is zero.
pub fn revoke_clean(cx: @mut Block, val: ValueRef) {
pub fn revoke_clean(cx: @Block, val: ValueRef) {
in_scope_cx(cx, None, |scope_info| {
let cleanup_pos = scope_info.cleanups.iter().position(
|cu| match *cu {
@ -583,8 +584,8 @@ pub fn revoke_clean(cx: @mut Block, val: ValueRef) {
})
}
pub fn block_cleanups(bcx: &mut Block) -> ~[cleanup] {
match bcx.scope {
pub fn block_cleanups(bcx: &Block) -> ~[cleanup] {
match bcx.scope.get() {
None => ~[],
Some(inf) => inf.cleanups.clone(),
}
@ -592,7 +593,7 @@ pub fn block_cleanups(bcx: &mut Block) -> ~[cleanup] {
pub struct ScopeInfo {
parent: Option<@mut ScopeInfo>,
loop_break: Option<@mut Block>,
loop_break: Option<@Block>,
loop_label: Option<Name>,
// A list of functions that must be run at when leaving this
// block, cleaning up any variables that were introduced in the
@ -657,11 +658,11 @@ pub struct Block {
// instructions into that block by way of this block context.
// The block pointing to this one in the function's digraph.
llbb: BasicBlockRef,
terminated: bool,
unreachable: bool,
parent: Option<@mut Block>,
terminated: Cell<bool>,
unreachable: Cell<bool>,
parent: Option<@Block>,
// The current scope within this basic block
scope: Option<@mut ScopeInfo>,
scope: RefCell<Option<@mut ScopeInfo>>,
// Is this block part of a landing pad?
is_lpad: bool,
// info about the AST node this block originated from, if any
@ -674,17 +675,17 @@ pub struct Block {
impl Block {
pub fn new(llbb: BasicBlockRef,
parent: Option<@mut Block>,
parent: Option<@Block>,
is_lpad: bool,
node_info: Option<NodeInfo>,
fcx: @mut FunctionContext)
-> Block {
Block {
llbb: llbb,
terminated: false,
unreachable: false,
terminated: Cell::new(false),
unreachable: Cell::new(false),
parent: parent,
scope: None,
scope: RefCell::new(None),
is_lpad: is_lpad,
node_info: node_info,
fcx: fcx
@ -748,16 +749,16 @@ impl Block {
}
pub struct Result {
bcx: @mut Block,
bcx: @Block,
val: ValueRef
}
pub fn rslt(bcx: @mut Block, val: ValueRef) -> Result {
pub fn rslt(bcx: @Block, val: ValueRef) -> Result {
Result {bcx: bcx, val: val}
}
impl Result {
pub fn unpack(&self, bcx: &mut @mut Block) -> ValueRef {
pub fn unpack(&self, bcx: &mut @Block) -> ValueRef {
*bcx = self.bcx;
return self.val;
}
@ -769,11 +770,11 @@ pub fn val_ty(v: ValueRef) -> Type {
}
}
pub fn in_scope_cx(cx: @mut Block,
pub fn in_scope_cx(cx: @Block,
scope_id: Option<ast::NodeId>,
f: |si: &mut ScopeInfo|) {
let mut cur = cx;
let mut cur_scope = cur.scope;
let mut cur_scope = cur.scope.get();
loop {
cur_scope = match cur_scope {
Some(inf) => match scope_id {
@ -795,13 +796,13 @@ pub fn in_scope_cx(cx: @mut Block,
},
None => {
cur = block_parent(cur);
cur.scope
cur.scope.get()
}
}
}
}
pub fn block_parent(cx: @mut Block) -> @mut Block {
pub fn block_parent(cx: @Block) -> @Block {
match cx.parent {
Some(b) => b,
None => cx.sess().bug(format!("block_parent called on root block {:?}",
@ -1070,17 +1071,17 @@ pub struct mono_id_ {
pub type mono_id = @mono_id_;
pub fn umax(cx: @mut Block, a: ValueRef, b: ValueRef) -> ValueRef {
pub fn umax(cx: @Block, a: ValueRef, b: ValueRef) -> ValueRef {
let cond = build::ICmp(cx, lib::llvm::IntULT, a, b);
return build::Select(cx, cond, b, a);
}
pub fn umin(cx: @mut Block, a: ValueRef, b: ValueRef) -> ValueRef {
pub fn umin(cx: @Block, a: ValueRef, b: ValueRef) -> ValueRef {
let cond = build::ICmp(cx, lib::llvm::IntULT, a, b);
return build::Select(cx, cond, a, b);
}
pub fn align_to(cx: @mut Block, off: ValueRef, align: ValueRef) -> ValueRef {
pub fn align_to(cx: @Block, off: ValueRef, align: ValueRef) -> ValueRef {
let mask = build::Sub(cx, align, C_int(cx.ccx(), 1));
let bumped = build::Add(cx, off, mask);
return build::And(cx, bumped, build::Not(cx, mask));
@ -1105,7 +1106,7 @@ pub fn path_str(sess: session::Session, p: &[path_elt]) -> ~str {
r
}
pub fn monomorphize_type(bcx: &mut Block, t: ty::t) -> ty::t {
pub fn monomorphize_type(bcx: &Block, t: ty::t) -> ty::t {
match bcx.fcx.param_substs {
Some(substs) => {
ty::subst_tps(bcx.tcx(), substs.tys, substs.self_ty, t)
@ -1118,23 +1119,23 @@ pub fn monomorphize_type(bcx: &mut Block, t: ty::t) -> ty::t {
}
}
pub fn node_id_type(bcx: &mut Block, id: ast::NodeId) -> ty::t {
pub fn node_id_type(bcx: &Block, id: ast::NodeId) -> ty::t {
let tcx = bcx.tcx();
let t = ty::node_id_to_type(tcx, id);
monomorphize_type(bcx, t)
}
pub fn expr_ty(bcx: &mut Block, ex: &ast::Expr) -> ty::t {
pub fn expr_ty(bcx: &Block, ex: &ast::Expr) -> ty::t {
node_id_type(bcx, ex.id)
}
pub fn expr_ty_adjusted(bcx: &mut Block, ex: &ast::Expr) -> ty::t {
pub fn expr_ty_adjusted(bcx: &Block, ex: &ast::Expr) -> ty::t {
let tcx = bcx.tcx();
let t = ty::expr_ty_adjusted(tcx, ex);
monomorphize_type(bcx, t)
}
pub fn node_id_type_params(bcx: &mut Block, id: ast::NodeId) -> ~[ty::t] {
pub fn node_id_type_params(bcx: &Block, id: ast::NodeId) -> ~[ty::t] {
let tcx = bcx.tcx();
let params = ty::node_id_to_type_params(tcx, id);
@ -1154,7 +1155,7 @@ pub fn node_id_type_params(bcx: &mut Block, id: ast::NodeId) -> ~[ty::t] {
}
}
pub fn node_vtables(bcx: @mut Block, id: ast::NodeId)
pub fn node_vtables(bcx: @Block, id: ast::NodeId)
-> Option<typeck::vtable_res> {
let raw_vtables = bcx.ccx().maps.vtable_map.find(&id);
raw_vtables.map(|vts| resolve_vtables_in_fn_ctxt(bcx.fcx, *vts))
@ -1254,7 +1255,7 @@ pub fn dummy_substs(tps: ~[ty::t]) -> ty::substs {
}
}
pub fn filename_and_line_num_from_span(bcx: @mut Block,
pub fn filename_and_line_num_from_span(bcx: @Block,
span: Span) -> (ValueRef, ValueRef) {
let loc = bcx.sess().parse_sess.cm.lookup_char_pos(span.lo);
let filename_cstr = C_cstr(bcx.ccx(), loc.file.name);
@ -1264,11 +1265,11 @@ pub fn filename_and_line_num_from_span(bcx: @mut Block,
}
// Casts a Rust bool value to an i1.
pub fn bool_to_i1(bcx: @mut Block, llval: ValueRef) -> ValueRef {
pub fn bool_to_i1(bcx: @Block, llval: ValueRef) -> ValueRef {
build::ICmp(bcx, lib::llvm::IntNE, llval, C_bool(false))
}
pub fn langcall(bcx: @mut Block, span: Option<Span>, msg: &str,
pub fn langcall(bcx: @Block, span: Option<Span>, msg: &str,
li: LangItem) -> ast::DefId {
match bcx.tcx().lang_items.require(li) {
Ok(id) => id,

View File

@ -28,7 +28,7 @@ use syntax::ast_util;
use syntax::codemap::Span;
use syntax::visit::Visitor;
pub fn trans_block(bcx: @mut Block, b: &ast::Block, dest: expr::Dest) -> @mut Block {
pub fn trans_block(bcx: @Block, b: &ast::Block, dest: expr::Dest) -> @Block {
let _icx = push_ctxt("trans_block");
let mut bcx = bcx;
for s in b.stmts.iter() {
@ -39,18 +39,18 @@ pub fn trans_block(bcx: @mut Block, b: &ast::Block, dest: expr::Dest) -> @mut Bl
bcx = expr::trans_into(bcx, e, dest);
}
None => {
assert!(dest == expr::Ignore || bcx.unreachable);
assert!(dest == expr::Ignore || bcx.unreachable.get());
}
}
return bcx;
}
pub fn trans_if(bcx: @mut Block,
pub fn trans_if(bcx: @Block,
cond: &ast::Expr,
thn: ast::P<ast::Block>,
els: Option<@ast::Expr>,
dest: expr::Dest)
-> @mut Block {
-> @Block {
debug!("trans_if(bcx={}, cond={}, thn={:?}, dest={})",
bcx.to_str(), bcx.expr_to_str(cond), thn.id,
dest.to_str(bcx.ccx()));
@ -137,8 +137,8 @@ pub fn trans_if(bcx: @mut Block,
return next_bcx;
// trans `else [ if { .. } ... | { .. } ]`
fn trans_if_else(else_bcx_in: @mut Block, elexpr: @ast::Expr,
dest: expr::Dest, cleanup: bool) -> @mut Block {
fn trans_if_else(else_bcx_in: @Block, elexpr: @ast::Expr,
dest: expr::Dest, cleanup: bool) -> @Block {
let else_bcx_out = match elexpr.node {
ast::ExprIf(_, _, _) => {
let elseif_blk = ast_util::block_from_expr(elexpr);
@ -159,11 +159,11 @@ pub fn trans_if(bcx: @mut Block,
}
}
pub fn join_blocks(parent_bcx: @mut Block, in_cxs: &[@mut Block]) -> @mut Block {
pub fn join_blocks(parent_bcx: @Block, in_cxs: &[@Block]) -> @Block {
let out = sub_block(parent_bcx, "join");
let mut reachable = false;
for bcx in in_cxs.iter() {
if !bcx.unreachable {
if !bcx.unreachable.get() {
Br(*bcx, out.llbb);
reachable = true;
}
@ -174,7 +174,7 @@ pub fn join_blocks(parent_bcx: @mut Block, in_cxs: &[@mut Block]) -> @mut Block
return out;
}
pub fn trans_while(bcx: @mut Block, cond: &ast::Expr, body: &ast::Block) -> @mut Block {
pub fn trans_while(bcx: @Block, cond: &ast::Expr, body: &ast::Block) -> @Block {
let _icx = push_ctxt("trans_while");
let next_bcx = sub_block(bcx, "while next");
@ -213,10 +213,10 @@ pub fn trans_while(bcx: @mut Block, cond: &ast::Expr, body: &ast::Block) -> @mut
return next_bcx;
}
pub fn trans_loop(bcx:@mut Block,
pub fn trans_loop(bcx:@Block,
body: &ast::Block,
opt_label: Option<Name>)
-> @mut Block {
-> @Block {
let _icx = push_ctxt("trans_loop");
let next_bcx = sub_block(bcx, "next");
let body_bcx_in = loop_scope_block(bcx, next_bcx, opt_label, "`loop`",
@ -227,14 +227,14 @@ pub fn trans_loop(bcx:@mut Block,
return next_bcx;
}
pub fn trans_break_cont(bcx: @mut Block,
pub fn trans_break_cont(bcx: @Block,
opt_label: Option<Name>,
to_end: bool)
-> @mut Block {
-> @Block {
let _icx = push_ctxt("trans_break_cont");
// Locate closest loop block, outputting cleanup as we go.
let mut unwind = bcx;
let mut cur_scope = unwind.scope;
let mut cur_scope = unwind.scope.get();
let mut target;
loop {
cur_scope = match cur_scope {
@ -272,7 +272,7 @@ pub fn trans_break_cont(bcx: @mut Block,
return bcx;
}
};
unwind.scope
unwind.scope.get()
}
}
}
@ -281,15 +281,15 @@ pub fn trans_break_cont(bcx: @mut Block,
return bcx;
}
pub fn trans_break(bcx: @mut Block, label_opt: Option<Name>) -> @mut Block {
pub fn trans_break(bcx: @Block, label_opt: Option<Name>) -> @Block {
return trans_break_cont(bcx, label_opt, true);
}
pub fn trans_cont(bcx: @mut Block, label_opt: Option<Name>) -> @mut Block {
pub fn trans_cont(bcx: @Block, label_opt: Option<Name>) -> @Block {
return trans_break_cont(bcx, label_opt, false);
}
pub fn trans_ret(bcx: @mut Block, e: Option<@ast::Expr>) -> @mut Block {
pub fn trans_ret(bcx: @Block, e: Option<@ast::Expr>) -> @Block {
let _icx = push_ctxt("trans_ret");
let mut bcx = bcx;
let dest = match bcx.fcx.llretptr {
@ -307,10 +307,10 @@ pub fn trans_ret(bcx: @mut Block, e: Option<@ast::Expr>) -> @mut Block {
return bcx;
}
pub fn trans_fail_expr(bcx: @mut Block,
pub fn trans_fail_expr(bcx: @Block,
sp_opt: Option<Span>,
fail_expr: Option<@ast::Expr>)
-> @mut Block {
-> @Block {
let _icx = push_ctxt("trans_fail_expr");
let mut bcx = bcx;
match fail_expr {
@ -323,7 +323,7 @@ pub fn trans_fail_expr(bcx: @mut Block,
if ty::type_is_str(arg_datum.ty) {
let (lldata, _) = arg_datum.get_vec_base_and_len_no_root(bcx);
return trans_fail_value(bcx, sp_opt, lldata);
} else if bcx.unreachable || ty::type_is_bot(arg_datum.ty) {
} else if bcx.unreachable.get() || ty::type_is_bot(arg_datum.ty) {
return bcx;
} else {
bcx.sess().span_bug(
@ -335,19 +335,19 @@ pub fn trans_fail_expr(bcx: @mut Block,
}
}
pub fn trans_fail(bcx: @mut Block,
pub fn trans_fail(bcx: @Block,
sp_opt: Option<Span>,
fail_str: @str)
-> @mut Block {
-> @Block {
let _icx = push_ctxt("trans_fail");
let V_fail_str = C_cstr(bcx.ccx(), fail_str);
return trans_fail_value(bcx, sp_opt, V_fail_str);
}
fn trans_fail_value(bcx: @mut Block,
fn trans_fail_value(bcx: @Block,
sp_opt: Option<Span>,
V_fail_str: ValueRef)
-> @mut Block {
-> @Block {
let _icx = push_ctxt("trans_fail_value");
let ccx = bcx.ccx();
let (V_filename, V_line) = match sp_opt {
@ -370,8 +370,8 @@ fn trans_fail_value(bcx: @mut Block,
return bcx;
}
pub fn trans_fail_bounds_check(bcx: @mut Block, sp: Span,
index: ValueRef, len: ValueRef) -> @mut Block {
pub fn trans_fail_bounds_check(bcx: @Block, sp: Span,
index: ValueRef, len: ValueRef) -> @Block {
let _icx = push_ctxt("trans_fail_bounds_check");
let (filename, line) = filename_and_line_num_from_span(bcx, sp);
let args = ~[filename, line, index, len];

View File

@ -128,7 +128,7 @@ pub struct Datum {
}
pub struct DatumBlock {
bcx: @mut Block,
bcx: @Block,
datum: Datum,
}
@ -165,14 +165,14 @@ pub fn immediate_rvalue(val: ValueRef, ty: ty::t) -> Datum {
return Datum {val: val, ty: ty, mode: ByValue};
}
pub fn immediate_rvalue_bcx(bcx: @mut Block,
pub fn immediate_rvalue_bcx(bcx: @Block,
val: ValueRef,
ty: ty::t)
-> DatumBlock {
return DatumBlock {bcx: bcx, datum: immediate_rvalue(val, ty)};
}
pub fn scratch_datum(bcx: @mut Block, ty: ty::t, name: &str, zero: bool) -> Datum {
pub fn scratch_datum(bcx: @Block, ty: ty::t, name: &str, zero: bool) -> Datum {
/*!
* Allocates temporary space on the stack using alloca() and
* returns a by-ref Datum pointing to it. If `zero` is true, the
@ -206,10 +206,10 @@ pub fn appropriate_mode(ccx: &mut CrateContext, ty: ty::t) -> DatumMode {
impl Datum {
pub fn store_to(&self,
bcx: @mut Block,
bcx: @Block,
action: CopyAction,
dst: ValueRef)
-> @mut Block {
-> @Block {
/*!
*
* Stores this value into its final home. This moves if
@ -224,9 +224,9 @@ impl Datum {
}
pub fn store_to_dest(&self,
bcx: @mut Block,
bcx: @Block,
dest: expr::Dest)
-> @mut Block {
-> @Block {
match dest {
expr::Ignore => {
return bcx;
@ -238,30 +238,30 @@ impl Datum {
}
pub fn store_to_datum(&self,
bcx: @mut Block,
bcx: @Block,
action: CopyAction,
datum: Datum)
-> @mut Block {
-> @Block {
debug!("store_to_datum(self={}, action={:?}, datum={})",
self.to_str(bcx.ccx()), action, datum.to_str(bcx.ccx()));
assert!(datum.mode.is_by_ref());
self.store_to(bcx, action, datum.val)
}
pub fn move_to_datum(&self, bcx: @mut Block, action: CopyAction, datum: Datum)
-> @mut Block {
pub fn move_to_datum(&self, bcx: @Block, action: CopyAction, datum: Datum)
-> @Block {
assert!(datum.mode.is_by_ref());
self.move_to(bcx, action, datum.val)
}
pub fn copy_to_datum(&self, bcx: @mut Block, action: CopyAction, datum: Datum)
-> @mut Block {
pub fn copy_to_datum(&self, bcx: @Block, action: CopyAction, datum: Datum)
-> @Block {
assert!(datum.mode.is_by_ref());
self.copy_to(bcx, action, datum.val)
}
pub fn copy_to(&self, bcx: @mut Block, action: CopyAction, dst: ValueRef)
-> @mut Block {
pub fn copy_to(&self, bcx: @Block, action: CopyAction, dst: ValueRef)
-> @Block {
/*!
*
* Copies the value into `dst`, which should be a pointer to a
@ -304,10 +304,10 @@ impl Datum {
}
pub fn copy_to_no_check(&self,
bcx: @mut Block,
bcx: @Block,
action: CopyAction,
dst: ValueRef)
-> @mut Block {
-> @Block {
/*!
*
* A helper for `copy_to()` which does not check to see if we
@ -335,8 +335,8 @@ impl Datum {
// This works like copy_val, except that it deinitializes the source.
// Since it needs to zero out the source, src also needs to be an lval.
//
pub fn move_to(&self, bcx: @mut Block, action: CopyAction, dst: ValueRef)
-> @mut Block {
pub fn move_to(&self, bcx: @Block, action: CopyAction, dst: ValueRef)
-> @Block {
let _icx = push_ctxt("move_to");
let mut bcx = bcx;
@ -365,7 +365,7 @@ impl Datum {
return bcx;
}
pub fn add_clean(&self, bcx: @mut Block) {
pub fn add_clean(&self, bcx: @Block) {
/*!
* Schedules this datum for cleanup in `bcx`. The datum
* must be an rvalue.
@ -385,7 +385,7 @@ impl Datum {
}
}
pub fn cancel_clean(&self, bcx: @mut Block) {
pub fn cancel_clean(&self, bcx: @Block) {
if ty::type_needs_drop(bcx.tcx(), self.ty) {
match self.mode {
ByValue |
@ -410,7 +410,7 @@ impl Datum {
self.mode)
}
pub fn to_value_datum(&self, bcx: @mut Block) -> Datum {
pub fn to_value_datum(&self, bcx: @Block) -> Datum {
/*!
*
* Yields a by-value form of this datum. This may involve
@ -427,7 +427,7 @@ impl Datum {
}
}
pub fn to_value_llval(&self, bcx: @mut Block) -> ValueRef {
pub fn to_value_llval(&self, bcx: @Block) -> ValueRef {
/*!
*
* Yields the value itself. */
@ -448,7 +448,7 @@ impl Datum {
}
}
pub fn to_ref_datum(&self, bcx: @mut Block) -> Datum {
pub fn to_ref_datum(&self, bcx: @Block) -> Datum {
/*!
* Yields a by-ref form of this datum. This may involve
* creation of a temporary stack slot. The value returned by
@ -465,7 +465,7 @@ impl Datum {
}
}
pub fn to_ref_llval(&self, bcx: @mut Block) -> ValueRef {
pub fn to_ref_llval(&self, bcx: @Block) -> ValueRef {
match self.mode {
ByRef(_) => self.val,
ByValue => {
@ -498,7 +498,7 @@ impl Datum {
appropriate_mode(ccx, self.ty)
}
pub fn to_appropriate_llval(&self, bcx: @mut Block) -> ValueRef {
pub fn to_appropriate_llval(&self, bcx: @Block) -> ValueRef {
/*!
*
* Yields an llvalue with the `appropriate_mode()`. */
@ -509,7 +509,7 @@ impl Datum {
}
}
pub fn to_appropriate_datum(&self, bcx: @mut Block) -> Datum {
pub fn to_appropriate_datum(&self, bcx: @Block) -> Datum {
/*!
*
* Yields a datum with the `appropriate_mode()`. */
@ -521,7 +521,7 @@ impl Datum {
}
pub fn get_element(&self,
bcx: @mut Block,
bcx: @Block,
ty: ty::t,
source: DatumCleanup,
gep: |ValueRef| -> ValueRef)
@ -534,7 +534,7 @@ impl Datum {
}
}
pub fn drop_val(&self, bcx: @mut Block) -> @mut Block {
pub fn drop_val(&self, bcx: @Block) -> @Block {
if !ty::type_needs_drop(bcx.tcx(), self.ty) {
return bcx;
}
@ -545,7 +545,7 @@ impl Datum {
};
}
pub fn box_body(&self, bcx: @mut Block) -> Datum {
pub fn box_body(&self, bcx: @Block) -> Datum {
/*!
*
* This datum must represent an @T or ~T box. Returns a new
@ -578,7 +578,7 @@ impl Datum {
}
}
pub fn to_rptr(&self, bcx: @mut Block) -> Datum {
pub fn to_rptr(&self, bcx: @Block) -> Datum {
//! Returns a new datum of region-pointer type containing the
//! the same ptr as this datum (after converting to by-ref
//! using `to_ref_llval()`).
@ -599,12 +599,12 @@ impl Datum {
/// derefs: Number of times deref'd already.
/// is_auto: If true, only deref if auto-derefable.
pub fn try_deref(&self,
bcx: @mut Block,
bcx: @Block,
span: Span,
expr_id: ast::NodeId,
derefs: uint,
is_auto: bool)
-> (Option<Datum>, @mut Block) {
-> (Option<Datum>, @Block) {
let ccx = bcx.ccx();
debug!("try_deref(expr_id={:?}, derefs={:?}, is_auto={}, self={:?})",
@ -703,7 +703,7 @@ impl Datum {
}
}
fn deref_ptr(bcx: @mut Block, lv: &Datum, ty: ty::t) -> Datum {
fn deref_ptr(bcx: @Block, lv: &Datum, ty: ty::t) -> Datum {
Datum {
val: lv.to_value_llval(bcx),
ty: ty,
@ -713,7 +713,7 @@ impl Datum {
}
/// expr: The deref expression.
pub fn deref(&self, bcx: @mut Block, expr: &ast::Expr, derefs: uint)
pub fn deref(&self, bcx: @Block, expr: &ast::Expr, derefs: uint)
-> DatumBlock {
match self.try_deref(bcx, expr.span, expr.id, derefs, false) {
(Some(lvres), bcx) => DatumBlock { bcx: bcx, datum: lvres },
@ -725,7 +725,7 @@ impl Datum {
}
pub fn autoderef(&self,
bcx: @mut Block,
bcx: @Block,
span: Span,
expr_id: ast::NodeId,
max: uint)
@ -758,11 +758,11 @@ impl Datum {
}
pub fn get_vec_base_and_byte_len(&self,
mut bcx: @mut Block,
mut bcx: @Block,
span: Span,
expr_id: ast::NodeId,
derefs: uint)
-> (@mut Block, ValueRef, ValueRef) {
-> (@Block, ValueRef, ValueRef) {
//! Converts a vector into the slice pair. Performs rooting
//! and write guards checks.
@ -772,7 +772,7 @@ impl Datum {
(bcx, base, len)
}
pub fn get_vec_base_and_byte_len_no_root(&self, bcx: @mut Block)
pub fn get_vec_base_and_byte_len_no_root(&self, bcx: @Block)
-> (ValueRef, ValueRef) {
//! Converts a vector into the slice pair. Des not root
//! nor perform write guard checks.
@ -782,11 +782,11 @@ impl Datum {
}
pub fn get_vec_base_and_len(&self,
mut bcx: @mut Block,
mut bcx: @Block,
span: Span,
expr_id: ast::NodeId,
derefs: uint)
-> (@mut Block, ValueRef, ValueRef) {
-> (@Block, ValueRef, ValueRef) {
//! Converts a vector into the slice pair. Performs rooting
//! and write guards checks.
@ -796,7 +796,7 @@ impl Datum {
(bcx, base, len)
}
pub fn get_vec_base_and_len_no_root(&self, bcx: @mut Block)
pub fn get_vec_base_and_len_no_root(&self, bcx: @Block)
-> (ValueRef, ValueRef) {
//! Converts a vector into the slice pair. Des not root
//! nor perform write guard checks.
@ -806,21 +806,21 @@ impl Datum {
}
pub fn root_and_write_guard(&self,
bcx: @mut Block,
bcx: @Block,
span: Span,
expr_id: ast::NodeId,
derefs: uint)
-> @mut Block {
-> @Block {
write_guard::root_and_write_guard(self, bcx, span, expr_id, derefs)
}
pub fn to_result(&self, bcx: @mut Block) -> common::Result {
pub fn to_result(&self, bcx: @Block) -> common::Result {
rslt(bcx, self.to_appropriate_llval(bcx))
}
}
impl DatumBlock {
pub fn unpack(&self, bcx: &mut @mut Block) -> Datum {
pub fn unpack(&self, bcx: &mut @Block) -> Datum {
*bcx = self.bcx;
return self.datum;
}
@ -830,22 +830,22 @@ impl DatumBlock {
*self
}
pub fn drop_val(&self) -> @mut Block {
pub fn drop_val(&self) -> @Block {
self.datum.drop_val(self.bcx)
}
pub fn store_to(&self,
action: CopyAction,
dst: ValueRef)
-> @mut Block {
-> @Block {
self.datum.store_to(self.bcx, action, dst)
}
pub fn copy_to(&self, action: CopyAction, dst: ValueRef) -> @mut Block {
pub fn copy_to(&self, action: CopyAction, dst: ValueRef) -> @Block {
self.datum.copy_to(self.bcx, action, dst)
}
pub fn move_to(&self, action: CopyAction, dst: ValueRef) -> @mut Block {
pub fn move_to(&self, action: CopyAction, dst: ValueRef) -> @Block {
self.datum.move_to(self.bcx, action, dst)
}

View File

@ -284,7 +284,7 @@ pub fn finalize(cx: @mut CrateContext) {
/// Creates debug information for the given local variable.
///
/// Adds the created metadata nodes directly to the crate's IR.
pub fn create_local_var_metadata(bcx: @mut Block,
pub fn create_local_var_metadata(bcx: @Block,
local: &ast::Local) {
if fn_should_be_ignored(bcx.fcx) {
return;
@ -320,7 +320,7 @@ pub fn create_local_var_metadata(bcx: @mut Block,
/// Creates debug information for a variable captured in a closure.
///
/// Adds the created metadata nodes directly to the crate's IR.
pub fn create_captured_var_metadata(bcx: @mut Block,
pub fn create_captured_var_metadata(bcx: @Block,
node_id: ast::NodeId,
env_data_type: ty::t,
env_pointer: ValueRef,
@ -387,7 +387,7 @@ pub fn create_captured_var_metadata(bcx: @mut Block,
/// Creates debug information for a local variable introduced in the head of a match-statement arm.
///
/// Adds the created metadata nodes directly to the crate's IR.
pub fn create_match_binding_metadata(bcx: @mut Block,
pub fn create_match_binding_metadata(bcx: @Block,
variable_ident: ast::Ident,
node_id: ast::NodeId,
variable_type: ty::t,
@ -417,7 +417,7 @@ pub fn create_match_binding_metadata(bcx: @mut Block,
/// Creates debug information for the self argument of a method.
///
/// Adds the created metadata nodes directly to the crate's IR.
pub fn create_self_argument_metadata(bcx: @mut Block,
pub fn create_self_argument_metadata(bcx: @Block,
type_of_self: ty::t,
llptr: ValueRef) {
if fn_should_be_ignored(bcx.fcx) {
@ -492,7 +492,7 @@ pub fn create_self_argument_metadata(bcx: @mut Block,
/// Creates debug information for the given function argument.
///
/// Adds the created metadata nodes directly to the crate's IR.
pub fn create_argument_metadata(bcx: @mut Block,
pub fn create_argument_metadata(bcx: @Block,
arg: &ast::arg) {
if fn_should_be_ignored(bcx.fcx) {
return;
@ -951,7 +951,7 @@ fn compile_unit_metadata(cx: @mut CrateContext) {
});
}
fn declare_local(bcx: @mut Block,
fn declare_local(bcx: @Block,
variable_ident: ast::Ident,
variable_type: ty::t,
scope_metadata: DIScope,

View File

@ -175,7 +175,7 @@ impl Dest {
}
}
pub fn trans_to_datum(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
pub fn trans_to_datum(bcx: @Block, expr: &ast::Expr) -> DatumBlock {
debug!("trans_to_datum(expr={})", bcx.expr_to_str(expr));
let mut bcx = bcx;
@ -229,11 +229,11 @@ pub fn trans_to_datum(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
debug!("after adjustments, datum={}", datum.to_str(bcx.ccx()));
return DatumBlock {bcx: bcx, datum: datum};
fn auto_ref(bcx: @mut Block, datum: Datum) -> DatumBlock {
fn auto_ref(bcx: @Block, datum: Datum) -> DatumBlock {
DatumBlock {bcx: bcx, datum: datum.to_rptr(bcx)}
}
fn auto_borrow_fn(bcx: @mut Block,
fn auto_borrow_fn(bcx: @Block,
adjusted_ty: ty::t,
datum: Datum) -> DatumBlock {
// Currently, all closure types are represented precisely the
@ -244,7 +244,7 @@ pub fn trans_to_datum(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
mode: datum.mode}}
}
fn auto_slice(bcx: @mut Block,
fn auto_slice(bcx: @Block,
autoderefs: uint,
expr: &ast::Expr,
datum: Datum) -> DatumBlock {
@ -273,7 +273,7 @@ pub fn trans_to_datum(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
DatumBlock {bcx: bcx, datum: scratch}
}
fn add_env(bcx: @mut Block, expr: &ast::Expr, datum: Datum) -> DatumBlock {
fn add_env(bcx: @Block, expr: &ast::Expr, datum: Datum) -> DatumBlock {
// This is not the most efficient thing possible; since closures
// are two words it'd be better if this were compiled in
// 'dest' mode, but I can't find a nice way to structure the
@ -292,7 +292,7 @@ pub fn trans_to_datum(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
DatumBlock {bcx: bcx, datum: scratch}
}
fn auto_slice_and_ref(bcx: @mut Block,
fn auto_slice_and_ref(bcx: @Block,
autoderefs: uint,
expr: &ast::Expr,
datum: Datum) -> DatumBlock {
@ -300,7 +300,7 @@ pub fn trans_to_datum(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
auto_ref(bcx, datum)
}
fn auto_borrow_obj(mut bcx: @mut Block,
fn auto_borrow_obj(mut bcx: @Block,
autoderefs: uint,
expr: &ast::Expr,
source_datum: Datum) -> DatumBlock {
@ -414,7 +414,7 @@ pub fn trans_to_datum(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
}
}
pub fn trans_into(bcx: @mut Block, expr: &ast::Expr, dest: Dest) -> @mut Block {
pub fn trans_into(bcx: @Block, expr: &ast::Expr, dest: Dest) -> @Block {
if bcx.tcx().adjustments.contains_key(&expr.id) {
// use trans_to_datum, which is mildly less efficient but
// which will perform the adjustments:
@ -472,7 +472,7 @@ pub fn trans_into(bcx: @mut Block, expr: &ast::Expr, dest: Dest) -> @mut Block {
};
}
fn trans_lvalue(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
fn trans_lvalue(bcx: @Block, expr: &ast::Expr) -> DatumBlock {
/*!
*
* Translates an lvalue expression, always yielding a by-ref
@ -491,7 +491,7 @@ fn trans_lvalue(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
};
}
fn trans_to_datum_unadjusted(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
fn trans_to_datum_unadjusted(bcx: @Block, expr: &ast::Expr) -> DatumBlock {
/*!
* Translates an expression into a datum. If this expression
* is an rvalue, this will result in a temporary value being
@ -551,13 +551,13 @@ fn trans_to_datum_unadjusted(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
}
}
fn nil(bcx: @mut Block, ty: ty::t) -> DatumBlock {
fn nil(bcx: @Block, ty: ty::t) -> DatumBlock {
let datum = immediate_rvalue(C_nil(), ty);
DatumBlock {bcx: bcx, datum: datum}
}
}
fn trans_rvalue_datum_unadjusted(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
fn trans_rvalue_datum_unadjusted(bcx: @Block, expr: &ast::Expr) -> DatumBlock {
let _icx = push_ctxt("trans_rvalue_datum_unadjusted");
match expr.node {
@ -608,11 +608,11 @@ fn trans_rvalue_datum_unadjusted(bcx: @mut Block, expr: &ast::Expr) -> DatumBloc
}
}
fn trans_rvalue_stmt_unadjusted(bcx: @mut Block, expr: &ast::Expr) -> @mut Block {
fn trans_rvalue_stmt_unadjusted(bcx: @Block, expr: &ast::Expr) -> @Block {
let mut bcx = bcx;
let _icx = push_ctxt("trans_rvalue_stmt");
if bcx.unreachable {
if bcx.unreachable.get() {
return bcx;
}
@ -660,8 +660,8 @@ fn trans_rvalue_stmt_unadjusted(bcx: @mut Block, expr: &ast::Expr) -> @mut Block
};
}
fn trans_rvalue_dps_unadjusted(bcx: @mut Block, expr: &ast::Expr,
dest: Dest) -> @mut Block {
fn trans_rvalue_dps_unadjusted(bcx: @Block, expr: &ast::Expr,
dest: Dest) -> @Block {
let _icx = push_ctxt("trans_rvalue_dps_unadjusted");
let tcx = bcx.tcx();
@ -785,8 +785,8 @@ fn trans_rvalue_dps_unadjusted(bcx: @mut Block, expr: &ast::Expr,
}
}
fn trans_def_dps_unadjusted(bcx: @mut Block, ref_expr: &ast::Expr,
def: ast::Def, dest: Dest) -> @mut Block {
fn trans_def_dps_unadjusted(bcx: @Block, ref_expr: &ast::Expr,
def: ast::Def, dest: Dest) -> @Block {
let _icx = push_ctxt("trans_def_dps_unadjusted");
let ccx = bcx.ccx();
@ -835,7 +835,7 @@ fn trans_def_dps_unadjusted(bcx: @mut Block, ref_expr: &ast::Expr,
}
}
fn trans_def_datum_unadjusted(bcx: @mut Block,
fn trans_def_datum_unadjusted(bcx: @Block,
ref_expr: &ast::Expr,
def: ast::Def) -> DatumBlock
{
@ -870,7 +870,7 @@ fn trans_def_datum_unadjusted(bcx: @mut Block,
}
}
fn trans_lvalue_unadjusted(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
fn trans_lvalue_unadjusted(bcx: @Block, expr: &ast::Expr) -> DatumBlock {
/*!
*
* Translates an lvalue expression, always yielding a by-ref
@ -907,7 +907,7 @@ fn trans_lvalue_unadjusted(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
}
};
fn trans_rec_field(bcx: @mut Block,
fn trans_rec_field(bcx: @Block,
base: &ast::Expr,
field: ast::Ident) -> DatumBlock {
//! Translates `base.field`.
@ -931,7 +931,7 @@ fn trans_lvalue_unadjusted(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
})
}
fn trans_index(bcx: @mut Block,
fn trans_index(bcx: @Block,
index_expr: &ast::Expr,
base: &ast::Expr,
idx: &ast::Expr) -> DatumBlock {
@ -985,7 +985,7 @@ fn trans_lvalue_unadjusted(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
};
}
fn trans_def_lvalue(bcx: @mut Block,
fn trans_def_lvalue(bcx: @Block,
ref_expr: &ast::Expr,
def: ast::Def)
-> DatumBlock
@ -1006,7 +1006,7 @@ fn trans_lvalue_unadjusted(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
}
}
fn get_val(bcx: @mut Block, did: ast::DefId, const_ty: ty::t)
fn get_val(bcx: @Block, did: ast::DefId, const_ty: ty::t)
-> ValueRef {
// For external constants, we don't inline.
if did.crate == ast::LOCAL_CRATE {
@ -1063,7 +1063,7 @@ fn trans_lvalue_unadjusted(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
}
}
pub fn trans_local_var(bcx: @mut Block, def: ast::Def) -> Datum {
pub fn trans_local_var(bcx: @Block, def: ast::Def) -> Datum {
let _icx = push_ctxt("trans_local_var");
return match def {
@ -1115,7 +1115,7 @@ pub fn trans_local_var(bcx: @mut Block, def: ast::Def) -> Datum {
}
};
fn take_local(bcx: @mut Block,
fn take_local(bcx: @Block,
table: &HashMap<ast::NodeId, ValueRef>,
nid: ast::NodeId) -> Datum {
let v = match table.find(&nid) {
@ -1184,12 +1184,12 @@ pub fn with_field_tys<R>(
}
}
fn trans_rec_or_struct(bcx: @mut Block,
fn trans_rec_or_struct(bcx: @Block,
fields: &[ast::Field],
base: Option<@ast::Expr>,
expr_span: codemap::Span,
id: ast::NodeId,
dest: Dest) -> @mut Block
dest: Dest) -> @Block
{
let _icx = push_ctxt("trans_rec");
let bcx = bcx;
@ -1263,10 +1263,10 @@ struct StructBaseInfo {
* - `optbase` contains information on the base struct (if any) from
* which remaining fields are copied; see comments on `StructBaseInfo`.
*/
fn trans_adt(bcx: @mut Block, repr: &adt::Repr, discr: ty::Disr,
fn trans_adt(bcx: @Block, repr: &adt::Repr, discr: ty::Disr,
fields: &[(uint, @ast::Expr)],
optbase: Option<StructBaseInfo>,
dest: Dest) -> @mut Block {
dest: Dest) -> @Block {
let _icx = push_ctxt("trans_adt");
let mut bcx = bcx;
let addr = match dest {
@ -1311,7 +1311,7 @@ fn trans_adt(bcx: @mut Block, repr: &adt::Repr, discr: ty::Disr,
}
fn trans_immediate_lit(bcx: @mut Block, expr: &ast::Expr,
fn trans_immediate_lit(bcx: @Block, expr: &ast::Expr,
lit: ast::lit) -> DatumBlock {
// must not be a string constant, that is a RvalueDpsExpr
let _icx = push_ctxt("trans_immediate_lit");
@ -1319,7 +1319,7 @@ fn trans_immediate_lit(bcx: @mut Block, expr: &ast::Expr,
immediate_rvalue_bcx(bcx, consts::const_lit(bcx.ccx(), expr, lit), ty)
}
fn trans_unary_datum(bcx: @mut Block,
fn trans_unary_datum(bcx: @Block,
un_expr: &ast::Expr,
op: ast::UnOp,
sub_expr: &ast::Expr) -> DatumBlock {
@ -1379,7 +1379,7 @@ fn trans_unary_datum(bcx: @mut Block,
}
};
fn trans_boxed_expr(bcx: @mut Block,
fn trans_boxed_expr(bcx: @Block,
box_ty: ty::t,
contents: &ast::Expr,
contents_ty: ty::t,
@ -1408,7 +1408,7 @@ fn trans_unary_datum(bcx: @mut Block,
}
}
fn trans_addr_of(bcx: @mut Block, expr: &ast::Expr,
fn trans_addr_of(bcx: @Block, expr: &ast::Expr,
subexpr: &ast::Expr) -> DatumBlock {
let _icx = push_ctxt("trans_addr_of");
let mut bcx = bcx;
@ -1419,7 +1419,7 @@ fn trans_addr_of(bcx: @mut Block, expr: &ast::Expr,
// Important to get types for both lhs and rhs, because one might be _|_
// and the other not.
fn trans_eager_binop(bcx: @mut Block,
fn trans_eager_binop(bcx: @Block,
binop_expr: &ast::Expr,
binop_ty: ty::t,
op: ast::BinOp,
@ -1522,7 +1522,7 @@ fn trans_eager_binop(bcx: @mut Block,
// refinement types would obviate the need for this
enum lazy_binop_ty { lazy_and, lazy_or }
fn trans_lazy_binop(bcx: @mut Block,
fn trans_lazy_binop(bcx: @Block,
binop_expr: &ast::Expr,
op: lazy_binop_ty,
a: &ast::Expr,
@ -1537,7 +1537,7 @@ fn trans_lazy_binop(bcx: @mut Block,
})
};
if past_lhs.unreachable {
if past_lhs.unreachable.get() {
return immediate_rvalue_bcx(past_lhs, lhs, binop_ty);
}
@ -1556,7 +1556,7 @@ fn trans_lazy_binop(bcx: @mut Block,
})
};
if past_rhs.unreachable {
if past_rhs.unreachable.get() {
return immediate_rvalue_bcx(join, lhs, binop_ty);
}
@ -1567,7 +1567,7 @@ fn trans_lazy_binop(bcx: @mut Block,
return immediate_rvalue_bcx(join, phi, binop_ty);
}
fn trans_binary(bcx: @mut Block,
fn trans_binary(bcx: @Block,
binop_expr: &ast::Expr,
op: ast::BinOp,
lhs: &ast::Expr,
@ -1593,14 +1593,14 @@ fn trans_binary(bcx: @mut Block,
}
}
fn trans_overloaded_op(bcx: @mut Block,
fn trans_overloaded_op(bcx: @Block,
expr: &ast::Expr,
callee_id: ast::NodeId,
rcvr: &ast::Expr,
args: ~[@ast::Expr],
ret_ty: ty::t,
dest: Dest)
-> @mut Block {
-> @Block {
let origin = bcx.ccx().maps.method_map.get_copy(&expr.id);
let fty = node_id_type(bcx, callee_id);
callee::trans_call_inner(bcx,
@ -1618,7 +1618,7 @@ fn trans_overloaded_op(bcx: @mut Block,
DoAutorefArg).bcx
}
fn int_cast(bcx: @mut Block, lldsttype: Type, llsrctype: Type,
fn int_cast(bcx: @Block, lldsttype: Type, llsrctype: Type,
llsrc: ValueRef, signed: bool) -> ValueRef {
let _icx = push_ctxt("int_cast");
unsafe {
@ -1636,7 +1636,7 @@ fn int_cast(bcx: @mut Block, lldsttype: Type, llsrctype: Type,
}
}
fn float_cast(bcx: @mut Block, lldsttype: Type, llsrctype: Type,
fn float_cast(bcx: @Block, lldsttype: Type, llsrctype: Type,
llsrc: ValueRef) -> ValueRef {
let _icx = push_ctxt("float_cast");
let srcsz = llsrctype.float_width();
@ -1672,7 +1672,7 @@ pub fn cast_type_kind(t: ty::t) -> cast_kind {
}
}
fn trans_imm_cast(bcx: @mut Block, expr: &ast::Expr,
fn trans_imm_cast(bcx: @Block, expr: &ast::Expr,
id: ast::NodeId) -> DatumBlock {
let _icx = push_ctxt("trans_cast");
let ccx = bcx.ccx();
@ -1747,12 +1747,12 @@ fn trans_imm_cast(bcx: @mut Block, expr: &ast::Expr,
return immediate_rvalue_bcx(bcx, newval, t_out);
}
fn trans_assign_op(bcx: @mut Block,
fn trans_assign_op(bcx: @Block,
expr: &ast::Expr,
callee_id: ast::NodeId,
op: ast::BinOp,
dst: &ast::Expr,
src: @ast::Expr) -> @mut Block
src: @ast::Expr) -> @Block
{
let _icx = push_ctxt("trans_assign_op");
let mut bcx = bcx;
@ -1788,7 +1788,7 @@ fn trans_assign_op(bcx: @mut Block,
return result_datum.copy_to_datum(bcx, DROP_EXISTING, dst_datum);
}
pub fn trans_log_level(bcx: @mut Block) -> DatumBlock {
pub fn trans_log_level(bcx: @Block) -> DatumBlock {
let _icx = push_ctxt("trans_log_level");
let ccx = bcx.ccx();

View File

@ -153,12 +153,12 @@ pub fn register_foreign_item_fn(ccx: @mut CrateContext,
return llfn;
}
pub fn trans_native_call(bcx: @mut Block,
pub fn trans_native_call(bcx: @Block,
callee_ty: ty::t,
llfn: ValueRef,
llretptr: ValueRef,
llargs_rust: &[ValueRef],
passed_arg_tys: ~[ty::t]) -> @mut Block {
passed_arg_tys: ~[ty::t]) -> @Block {
/*!
* Prepares a call to a native function. This requires adapting
* from the Rust argument passing rules to the native rules.

View File

@ -40,7 +40,7 @@ use std::c_str::ToCStr;
use std::libc::c_uint;
use syntax::ast;
pub fn trans_free(cx: @mut Block, v: ValueRef) -> @mut Block {
pub fn trans_free(cx: @Block, v: ValueRef) -> @Block {
let _icx = push_ctxt("trans_free");
callee::trans_lang_call(cx,
langcall(cx, None, "", FreeFnLangItem),
@ -48,7 +48,7 @@ pub fn trans_free(cx: @mut Block, v: ValueRef) -> @mut Block {
Some(expr::Ignore)).bcx
}
pub fn trans_exchange_free(cx: @mut Block, v: ValueRef) -> @mut Block {
pub fn trans_exchange_free(cx: @Block, v: ValueRef) -> @Block {
let _icx = push_ctxt("trans_exchange_free");
callee::trans_lang_call(cx,
langcall(cx, None, "", ExchangeFreeFnLangItem),
@ -56,7 +56,7 @@ pub fn trans_exchange_free(cx: @mut Block, v: ValueRef) -> @mut Block {
Some(expr::Ignore)).bcx
}
pub fn take_ty(cx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
pub fn take_ty(cx: @Block, v: ValueRef, t: ty::t) -> @Block {
// NB: v is an *alias* of type t here, not a direct value.
let _icx = push_ctxt("take_ty");
if ty::type_needs_drop(cx.tcx(), t) {
@ -65,7 +65,7 @@ pub fn take_ty(cx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
return cx;
}
pub fn drop_ty(cx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
pub fn drop_ty(cx: @Block, v: ValueRef, t: ty::t) -> @Block {
// NB: v is an *alias* of type t here, not a direct value.
let _icx = push_ctxt("drop_ty");
if ty::type_needs_drop(cx.tcx(), t) {
@ -74,14 +74,14 @@ pub fn drop_ty(cx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
return cx;
}
pub fn drop_ty_immediate(bcx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
pub fn drop_ty_immediate(bcx: @Block, v: ValueRef, t: ty::t) -> @Block {
let _icx = push_ctxt("drop_ty_immediate");
let vp = alloca(bcx, type_of(bcx.ccx(), t), "");
Store(bcx, v, vp);
drop_ty(bcx, vp, t)
}
pub fn free_ty(cx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
pub fn free_ty(cx: @Block, v: ValueRef, t: ty::t) -> @Block {
// NB: v is an *alias* of type t here, not a direct value.
let _icx = push_ctxt("free_ty");
if ty::type_needs_drop(cx.tcx(), t) {
@ -90,7 +90,7 @@ pub fn free_ty(cx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
return cx;
}
pub fn free_ty_immediate(bcx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
pub fn free_ty_immediate(bcx: @Block, v: ValueRef, t: ty::t) -> @Block {
let _icx = push_ctxt("free_ty_immediate");
match ty::get(t).sty {
ty::ty_uniq(_) |
@ -264,7 +264,7 @@ pub fn lazily_emit_tydesc_glue(ccx: @mut CrateContext,
}
// See [Note-arg-mode]
pub fn call_tydesc_glue_full(bcx: @mut Block,
pub fn call_tydesc_glue_full(bcx: @Block,
v: ValueRef,
tydesc: ValueRef,
field: uint,
@ -273,7 +273,7 @@ pub fn call_tydesc_glue_full(bcx: @mut Block,
let ccx = bcx.ccx();
// NB: Don't short-circuit even if this block is unreachable because
// GC-based cleanup needs to the see that the roots are live.
if bcx.unreachable && !ccx.sess.no_landing_pads() { return; }
if bcx.unreachable.get() && !ccx.sess.no_landing_pads() { return; }
let static_glue_fn = match static_ti {
None => None,
@ -323,15 +323,15 @@ pub fn call_tydesc_glue_full(bcx: @mut Block,
}
// See [Note-arg-mode]
pub fn call_tydesc_glue(cx: @mut Block, v: ValueRef, t: ty::t, field: uint)
-> @mut Block {
pub fn call_tydesc_glue(cx: @Block, v: ValueRef, t: ty::t, field: uint)
-> @Block {
let _icx = push_ctxt("call_tydesc_glue");
let ti = get_tydesc(cx.ccx(), t);
call_tydesc_glue_full(cx, v, ti.tydesc, field, Some(ti));
return cx;
}
pub fn make_visit_glue(bcx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
pub fn make_visit_glue(bcx: @Block, v: ValueRef, t: ty::t) -> @Block {
let _icx = push_ctxt("make_visit_glue");
with_scope(bcx, None, "visitor cleanup", |bcx| {
let mut bcx = bcx;
@ -350,7 +350,7 @@ pub fn make_visit_glue(bcx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
})
}
pub fn make_free_glue(bcx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
pub fn make_free_glue(bcx: @Block, v: ValueRef, t: ty::t) -> @Block {
// NB: v0 is an *alias* of type t here, not a direct value.
let _icx = push_ctxt("make_free_glue");
match ty::get(t).sty {
@ -387,8 +387,8 @@ pub fn make_free_glue(bcx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
}
}
pub fn trans_struct_drop_flag(bcx: @mut Block, t: ty::t, v0: ValueRef, dtor_did: ast::DefId,
class_did: ast::DefId, substs: &ty::substs) -> @mut Block {
pub fn trans_struct_drop_flag(bcx: @Block, t: ty::t, v0: ValueRef, dtor_did: ast::DefId,
class_did: ast::DefId, substs: &ty::substs) -> @Block {
let repr = adt::represent_type(bcx.ccx(), t);
let drop_flag = adt::trans_drop_flag_ptr(bcx, repr, v0);
with_cond(bcx, IsNotNull(bcx, Load(bcx, drop_flag)), |cx| {
@ -396,8 +396,8 @@ pub fn trans_struct_drop_flag(bcx: @mut Block, t: ty::t, v0: ValueRef, dtor_did:
})
}
pub fn trans_struct_drop(bcx: @mut Block, t: ty::t, v0: ValueRef, dtor_did: ast::DefId,
class_did: ast::DefId, substs: &ty::substs) -> @mut Block {
pub fn trans_struct_drop(bcx: @Block, t: ty::t, v0: ValueRef, dtor_did: ast::DefId,
class_did: ast::DefId, substs: &ty::substs) -> @Block {
let repr = adt::represent_type(bcx.ccx(), t);
// Find and call the actual destructor
@ -434,7 +434,7 @@ pub fn trans_struct_drop(bcx: @mut Block, t: ty::t, v0: ValueRef, dtor_did: ast:
})
}
pub fn make_drop_glue(bcx: @mut Block, v0: ValueRef, t: ty::t) -> @mut Block {
pub fn make_drop_glue(bcx: @Block, v0: ValueRef, t: ty::t) -> @Block {
// NB: v0 is an *alias* of type t here, not a direct value.
let _icx = push_ctxt("make_drop_glue");
let ccx = bcx.ccx();
@ -505,10 +505,10 @@ pub fn make_drop_glue(bcx: @mut Block, v0: ValueRef, t: ty::t) -> @mut Block {
}
// box_ptr_ptr is optional, it is constructed if not supplied.
pub fn decr_refcnt_maybe_free(bcx: @mut Block, box_ptr: ValueRef,
pub fn decr_refcnt_maybe_free(bcx: @Block, box_ptr: ValueRef,
box_ptr_ptr: Option<ValueRef>,
t: ty::t)
-> @mut Block {
-> @Block {
let _icx = push_ctxt("decr_refcnt_maybe_free");
let ccx = bcx.ccx();
@ -534,7 +534,7 @@ pub fn decr_refcnt_maybe_free(bcx: @mut Block, box_ptr: ValueRef,
}
pub fn make_take_glue(bcx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
pub fn make_take_glue(bcx: @Block, v: ValueRef, t: ty::t) -> @Block {
let _icx = push_ctxt("make_take_glue");
// NB: v is a *pointer* to type t here, not a direct value.
match ty::get(t).sty {
@ -575,7 +575,7 @@ pub fn make_take_glue(bcx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
}
}
pub fn incr_refcnt_of_boxed(cx: @mut Block, box_ptr: ValueRef) {
pub fn incr_refcnt_of_boxed(cx: @Block, box_ptr: ValueRef) {
let _icx = push_ctxt("incr_refcnt_of_boxed");
let ccx = cx.ccx();
let rc_ptr = GEPi(cx, box_ptr, [0u, abi::box_field_refcnt]);
@ -639,8 +639,8 @@ pub fn declare_tydesc(ccx: &mut CrateContext, t: ty::t) -> @mut tydesc_info {
return inf;
}
pub type glue_helper<'a> = 'a |@mut Block, ValueRef, ty::t|
-> @mut Block;
pub type glue_helper<'a> = 'a |@Block, ValueRef, ty::t|
-> @Block;
pub fn declare_generic_glue(ccx: &mut CrateContext, t: ty::t, llfnty: Type,
name: &str) -> ValueRef {

View File

@ -38,7 +38,7 @@ pub fn trans_intrinsic(ccx: @mut CrateContext,
ref_id: Option<ast::NodeId>) {
debug!("trans_intrinsic(item.ident={})", ccx.sess.str_of(item.ident));
fn simple_llvm_intrinsic(bcx: @mut Block, name: &'static str, num_args: uint) {
fn simple_llvm_intrinsic(bcx: @Block, name: &'static str, num_args: uint) {
assert!(num_args <= 4);
let mut args = [0 as ValueRef, ..4];
let first_real_arg = bcx.fcx.arg_pos(0u);
@ -50,7 +50,7 @@ pub fn trans_intrinsic(ccx: @mut CrateContext,
Ret(bcx, llcall);
}
fn with_overflow_instrinsic(bcx: @mut Block, name: &'static str, t: ty::t) {
fn with_overflow_instrinsic(bcx: @Block, name: &'static str, t: ty::t) {
let first_real_arg = bcx.fcx.arg_pos(0u);
let a = get_param(bcx.fcx.llfn, first_real_arg);
let b = get_param(bcx.fcx.llfn, first_real_arg + 1);
@ -73,7 +73,7 @@ pub fn trans_intrinsic(ccx: @mut CrateContext,
}
}
fn copy_intrinsic(bcx: @mut Block, allow_overlap: bool, tp_ty: ty::t) {
fn copy_intrinsic(bcx: @Block, allow_overlap: bool, tp_ty: ty::t) {
let ccx = bcx.ccx();
let lltp_ty = type_of::type_of(ccx, tp_ty);
let align = C_i32(machine::llalign_of_min(ccx, lltp_ty) as i32);
@ -104,7 +104,7 @@ pub fn trans_intrinsic(ccx: @mut CrateContext,
RetVoid(bcx);
}
fn memset_intrinsic(bcx: @mut Block, tp_ty: ty::t) {
fn memset_intrinsic(bcx: @Block, tp_ty: ty::t) {
let ccx = bcx.ccx();
let lltp_ty = type_of::type_of(ccx, tp_ty);
let align = C_i32(machine::llalign_of_min(ccx, lltp_ty) as i32);
@ -126,7 +126,7 @@ pub fn trans_intrinsic(ccx: @mut CrateContext,
RetVoid(bcx);
}
fn count_zeros_intrinsic(bcx: @mut Block, name: &'static str) {
fn count_zeros_intrinsic(bcx: @Block, name: &'static str) {
let x = get_param(bcx.fcx.llfn, bcx.fcx.arg_pos(0u));
let y = C_i1(false);
let llfn = bcx.ccx().intrinsics.get_copy(&name);

View File

@ -138,7 +138,7 @@ pub fn trans_method(ccx: @mut CrateContext,
[]);
}
pub fn trans_self_arg(bcx: @mut Block,
pub fn trans_self_arg(bcx: @Block,
base: &ast::Expr,
temp_cleanups: &mut ~[ValueRef],
mentry: typeck::method_map_entry) -> Result {
@ -154,7 +154,7 @@ pub fn trans_self_arg(bcx: @mut Block,
DontAutorefArg)
}
pub fn trans_method_callee(bcx: @mut Block,
pub fn trans_method_callee(bcx: @Block,
callee_id: ast::NodeId,
this: &ast::Expr,
mentry: typeck::method_map_entry)
@ -212,7 +212,7 @@ pub fn trans_method_callee(bcx: @mut Block,
}
}
pub fn trans_static_method_callee(bcx: @mut Block,
pub fn trans_static_method_callee(bcx: @Block,
method_id: ast::DefId,
trait_id: ast::DefId,
callee_id: ast::NodeId)
@ -311,7 +311,7 @@ pub fn method_with_name(ccx: &mut CrateContext,
meth.def_id
}
pub fn trans_monomorphized_callee(bcx: @mut Block,
pub fn trans_monomorphized_callee(bcx: @Block,
callee_id: ast::NodeId,
base: &ast::Expr,
mentry: typeck::method_map_entry,
@ -368,7 +368,7 @@ pub fn trans_monomorphized_callee(bcx: @mut Block,
}
pub fn combine_impl_and_methods_tps(bcx: @mut Block,
pub fn combine_impl_and_methods_tps(bcx: @Block,
mth_did: ast::DefId,
callee_id: ast::NodeId,
rcvr_substs: &[ty::t],
@ -417,7 +417,7 @@ pub fn combine_impl_and_methods_tps(bcx: @mut Block,
return (ty_substs, vtables);
}
pub fn trans_trait_callee(bcx: @mut Block,
pub fn trans_trait_callee(bcx: @Block,
callee_id: ast::NodeId,
n_method: uint,
self_expr: &ast::Expr)
@ -459,7 +459,7 @@ pub fn trans_trait_callee(bcx: @mut Block,
Some(self_scratch.val))
}
pub fn trans_trait_callee_from_llval(bcx: @mut Block,
pub fn trans_trait_callee_from_llval(bcx: @Block,
callee_ty: ty::t,
n_method: uint,
llpair: ValueRef,
@ -530,7 +530,7 @@ pub fn vtable_id(ccx: @mut CrateContext,
/// Creates a returns a dynamic vtable for the given type and vtable origin.
/// This is used only for objects.
pub fn get_vtable(bcx: @mut Block,
pub fn get_vtable(bcx: @Block,
self_ty: ty::t,
origins: typeck::vtable_param_res)
-> ValueRef {
@ -588,7 +588,7 @@ pub fn make_vtable(ccx: &mut CrateContext,
}
}
fn emit_vtable_methods(bcx: @mut Block,
fn emit_vtable_methods(bcx: @Block,
impl_id: ast::DefId,
substs: &[ty::t],
vtables: typeck::vtable_res)
@ -629,12 +629,12 @@ fn emit_vtable_methods(bcx: @mut Block,
})
}
pub fn trans_trait_cast(bcx: @mut Block,
pub fn trans_trait_cast(bcx: @Block,
val: &ast::Expr,
id: ast::NodeId,
dest: expr::Dest,
_store: ty::TraitStore)
-> @mut Block {
-> @Block {
let mut bcx = bcx;
let _icx = push_ctxt("impl::trans_cast");

View File

@ -37,9 +37,9 @@ use middle::trans::type_::Type;
pub struct Reflector {
visitor_val: ValueRef,
visitor_methods: @~[@ty::Method],
final_bcx: @mut Block,
final_bcx: @Block,
tydesc_ty: Type,
bcx: @mut Block
bcx: @Block
}
impl Reflector {
@ -382,11 +382,11 @@ impl Reflector {
}
// Emit a sequence of calls to visit_ty::visit_foo
pub fn emit_calls_to_trait_visit_ty(bcx: @mut Block,
pub fn emit_calls_to_trait_visit_ty(bcx: @Block,
t: ty::t,
visitor_val: ValueRef,
visitor_trait_id: DefId)
-> @mut Block {
-> @Block {
let final = sub_block(bcx, "final");
let tydesc_ty = ty::get_tydesc_ty(bcx.ccx().tcx).unwrap();
let tydesc_ty = type_of(bcx.ccx(), tydesc_ty);

View File

@ -53,18 +53,18 @@ pub fn expand_boxed_vec_ty(tcx: ty::ctxt, t: ty::t) -> ty::t {
}
}
pub fn get_fill(bcx: @mut Block, vptr: ValueRef) -> ValueRef {
pub fn get_fill(bcx: @Block, vptr: ValueRef) -> ValueRef {
let _icx = push_ctxt("tvec::get_fill");
Load(bcx, GEPi(bcx, vptr, [0u, abi::vec_elt_fill]))
}
pub fn set_fill(bcx: @mut Block, vptr: ValueRef, fill: ValueRef) {
pub fn set_fill(bcx: @Block, vptr: ValueRef, fill: ValueRef) {
Store(bcx, fill, GEPi(bcx, vptr, [0u, abi::vec_elt_fill]));
}
pub fn get_alloc(bcx: @mut Block, vptr: ValueRef) -> ValueRef {
pub fn get_alloc(bcx: @Block, vptr: ValueRef) -> ValueRef {
Load(bcx, GEPi(bcx, vptr, [0u, abi::vec_elt_alloc]))
}
pub fn get_bodyptr(bcx: @mut Block, vptr: ValueRef, t: ty::t) -> ValueRef {
pub fn get_bodyptr(bcx: @Block, vptr: ValueRef, t: ty::t) -> ValueRef {
if ty::type_contents(bcx.tcx(), t).owns_managed() {
GEPi(bcx, vptr, [0u, abi::box_field_body])
} else {
@ -72,19 +72,19 @@ pub fn get_bodyptr(bcx: @mut Block, vptr: ValueRef, t: ty::t) -> ValueRef {
}
}
pub fn get_dataptr(bcx: @mut Block, vptr: ValueRef) -> ValueRef {
pub fn get_dataptr(bcx: @Block, vptr: ValueRef) -> ValueRef {
let _icx = push_ctxt("tvec::get_dataptr");
GEPi(bcx, vptr, [0u, abi::vec_elt_elems, 0u])
}
pub fn pointer_add_byte(bcx: @mut Block, ptr: ValueRef, bytes: ValueRef) -> ValueRef {
pub fn pointer_add_byte(bcx: @Block, ptr: ValueRef, bytes: ValueRef) -> ValueRef {
let _icx = push_ctxt("tvec::pointer_add_byte");
let old_ty = val_ty(ptr);
let bptr = PointerCast(bcx, ptr, Type::i8p());
return PointerCast(bcx, InBoundsGEP(bcx, bptr, [bytes]), old_ty);
}
pub fn alloc_raw(bcx: @mut Block, unit_ty: ty::t,
pub fn alloc_raw(bcx: @Block, unit_ty: ty::t,
fill: ValueRef, alloc: ValueRef, heap: heap) -> Result {
let _icx = push_ctxt("tvec::alloc_uniq");
let ccx = bcx.ccx();
@ -107,12 +107,12 @@ pub fn alloc_raw(bcx: @mut Block, unit_ty: ty::t,
}
}
pub fn alloc_uniq_raw(bcx: @mut Block, unit_ty: ty::t,
pub fn alloc_uniq_raw(bcx: @Block, unit_ty: ty::t,
fill: ValueRef, alloc: ValueRef) -> Result {
alloc_raw(bcx, unit_ty, fill, alloc, base::heap_for_unique(bcx, unit_ty))
}
pub fn alloc_vec(bcx: @mut Block,
pub fn alloc_vec(bcx: @Block,
unit_ty: ty::t,
elts: uint,
heap: heap)
@ -130,8 +130,8 @@ pub fn alloc_vec(bcx: @mut Block,
return rslt(bcx, vptr);
}
pub fn make_drop_glue_unboxed(bcx: @mut Block, vptr: ValueRef, vec_ty: ty::t) ->
@mut Block {
pub fn make_drop_glue_unboxed(bcx: @Block, vptr: ValueRef, vec_ty: ty::t) ->
@Block {
let _icx = push_ctxt("tvec::make_drop_glue_unboxed");
let tcx = bcx.tcx();
let unit_ty = ty::sequence_element_type(tcx, vec_ty);
@ -160,11 +160,11 @@ impl VecTypes {
}
}
pub fn trans_fixed_vstore(bcx: @mut Block,
pub fn trans_fixed_vstore(bcx: @Block,
vstore_expr: &ast::Expr,
content_expr: &ast::Expr,
dest: expr::Dest)
-> @mut Block {
-> @Block {
//!
//
// [...] allocates a fixed-size array and moves it around "by value".
@ -189,11 +189,11 @@ pub fn trans_fixed_vstore(bcx: @mut Block,
};
}
pub fn trans_slice_vstore(bcx: @mut Block,
pub fn trans_slice_vstore(bcx: @Block,
vstore_expr: &ast::Expr,
content_expr: &ast::Expr,
dest: expr::Dest)
-> @mut Block {
-> @Block {
//!
//
// &[...] allocates memory on the stack and writes the values into it,
@ -247,11 +247,11 @@ pub fn trans_slice_vstore(bcx: @mut Block,
return bcx;
}
pub fn trans_lit_str(bcx: @mut Block,
pub fn trans_lit_str(bcx: @Block,
lit_expr: &ast::Expr,
str_lit: @str,
dest: Dest)
-> @mut Block {
-> @Block {
//!
//
// Literal strings translate to slices into static memory. This is
@ -282,7 +282,7 @@ pub fn trans_lit_str(bcx: @mut Block,
}
pub fn trans_uniq_or_managed_vstore(bcx: @mut Block, heap: heap, vstore_expr: &ast::Expr,
pub fn trans_uniq_or_managed_vstore(bcx: @Block, heap: heap, vstore_expr: &ast::Expr,
content_expr: &ast::Expr) -> DatumBlock {
//!
//
@ -343,12 +343,12 @@ pub fn trans_uniq_or_managed_vstore(bcx: @mut Block, heap: heap, vstore_expr: &a
return immediate_rvalue_bcx(bcx, val, vt.vec_ty);
}
pub fn write_content(bcx: @mut Block,
pub fn write_content(bcx: @Block,
vt: &VecTypes,
vstore_expr: &ast::Expr,
content_expr: &ast::Expr,
dest: Dest)
-> @mut Block {
-> @Block {
let _icx = push_ctxt("tvec::write_content");
let mut bcx = bcx;
@ -433,12 +433,12 @@ pub fn write_content(bcx: @mut Block,
}
}
pub fn vec_types_from_expr(bcx: @mut Block, vec_expr: &ast::Expr) -> VecTypes {
pub fn vec_types_from_expr(bcx: @Block, vec_expr: &ast::Expr) -> VecTypes {
let vec_ty = node_id_type(bcx, vec_expr.id);
vec_types(bcx, vec_ty)
}
pub fn vec_types(bcx: @mut Block, vec_ty: ty::t) -> VecTypes {
pub fn vec_types(bcx: @Block, vec_ty: ty::t) -> VecTypes {
let ccx = bcx.ccx();
let unit_ty = ty::sequence_element_type(bcx.tcx(), vec_ty);
let llunit_ty = type_of::type_of(ccx, unit_ty);
@ -452,7 +452,7 @@ pub fn vec_types(bcx: @mut Block, vec_ty: ty::t) -> VecTypes {
llunit_alloc_size: llunit_alloc_size}
}
pub fn elements_required(bcx: @mut Block, content_expr: &ast::Expr) -> uint {
pub fn elements_required(bcx: @Block, content_expr: &ast::Expr) -> uint {
//! Figure out the number of elements we need to store this content
match content_expr.node {
@ -468,7 +468,7 @@ pub fn elements_required(bcx: @mut Block, content_expr: &ast::Expr) -> uint {
}
}
pub fn get_base_and_byte_len(bcx: @mut Block, llval: ValueRef,
pub fn get_base_and_byte_len(bcx: @Block, llval: ValueRef,
vec_ty: ty::t) -> (ValueRef, ValueRef) {
//!
//
@ -505,7 +505,7 @@ pub fn get_base_and_byte_len(bcx: @mut Block, llval: ValueRef,
}
}
pub fn get_base_and_len(bcx: @mut Block, llval: ValueRef, vec_ty: ty::t) -> (ValueRef, ValueRef) {
pub fn get_base_and_len(bcx: @Block, llval: ValueRef, vec_ty: ty::t) -> (ValueRef, ValueRef) {
//!
//
// Converts a vector into the slice pair. The vector should be stored in
@ -539,15 +539,15 @@ pub fn get_base_and_len(bcx: @mut Block, llval: ValueRef, vec_ty: ty::t) -> (Val
}
}
pub type iter_vec_block<'a> = 'a |@mut Block, ValueRef, ty::t|
-> @mut Block;
pub type iter_vec_block<'a> = 'a |@Block, ValueRef, ty::t|
-> @Block;
pub fn iter_vec_loop(bcx: @mut Block,
pub fn iter_vec_loop(bcx: @Block,
data_ptr: ValueRef,
vt: &VecTypes,
count: ValueRef,
f: iter_vec_block
) -> @mut Block {
) -> @Block {
let _icx = push_ctxt("tvec::iter_vec_loop");
let next_bcx = sub_block(bcx, "iter_vec_loop: while next");
@ -597,8 +597,8 @@ pub fn iter_vec_loop(bcx: @mut Block,
next_bcx
}
pub fn iter_vec_raw(bcx: @mut Block, data_ptr: ValueRef, vec_ty: ty::t,
fill: ValueRef, f: iter_vec_block) -> @mut Block {
pub fn iter_vec_raw(bcx: @Block, data_ptr: ValueRef, vec_ty: ty::t,
fill: ValueRef, f: iter_vec_block) -> @Block {
let _icx = push_ctxt("tvec::iter_vec_raw");
let vt = vec_types(bcx, vec_ty);
@ -632,15 +632,15 @@ pub fn iter_vec_raw(bcx: @mut Block, data_ptr: ValueRef, vec_ty: ty::t,
}
}
pub fn iter_vec_uniq(bcx: @mut Block, vptr: ValueRef, vec_ty: ty::t,
fill: ValueRef, f: iter_vec_block) -> @mut Block {
pub fn iter_vec_uniq(bcx: @Block, vptr: ValueRef, vec_ty: ty::t,
fill: ValueRef, f: iter_vec_block) -> @Block {
let _icx = push_ctxt("tvec::iter_vec_uniq");
let data_ptr = get_dataptr(bcx, get_bodyptr(bcx, vptr, vec_ty));
iter_vec_raw(bcx, data_ptr, vec_ty, fill, f)
}
pub fn iter_vec_unboxed(bcx: @mut Block, body_ptr: ValueRef, vec_ty: ty::t,
f: iter_vec_block) -> @mut Block {
pub fn iter_vec_unboxed(bcx: @Block, body_ptr: ValueRef, vec_ty: ty::t,
f: iter_vec_block) -> @Block {
let _icx = push_ctxt("tvec::iter_vec_unboxed");
let fill = get_fill(bcx, body_ptr);
let dataptr = get_dataptr(bcx, body_ptr);

View File

@ -17,8 +17,8 @@ use middle::trans::datum::immediate_rvalue;
use middle::trans::glue;
use middle::ty;
pub fn make_free_glue(bcx: @mut Block, vptrptr: ValueRef, box_ty: ty::t)
-> @mut Block {
pub fn make_free_glue(bcx: @Block, vptrptr: ValueRef, box_ty: ty::t)
-> @Block {
let _icx = push_ctxt("uniq::make_free_glue");
let box_datum = immediate_rvalue(Load(bcx, vptrptr), box_ty);

View File

@ -49,7 +49,7 @@ impl Value {
/// This only performs a search for a trivially dominating store. The store
/// must be the only user of this value, and there must not be any conditional
/// branches between the store and the given block.
pub fn get_dominating_store(self, bcx: &mut Block) -> Option<Value> {
pub fn get_dominating_store(self, bcx: &Block) -> Option<Value> {
match self.get_single_user().and_then(|user| user.as_store_inst()) {
Some(store) => {
store.get_parent().and_then(|store_bb| {

View File

@ -34,10 +34,10 @@ use syntax::ast;
use middle::trans::type_::Type;
pub fn root_and_write_guard(datum: &Datum,
mut bcx: @mut Block,
mut bcx: @Block,
span: Span,
expr_id: ast::NodeId,
derefs: uint) -> @mut Block {
derefs: uint) -> @Block {
let key = root_map_key { id: expr_id, derefs: derefs };
debug!("write_guard::root_and_write_guard(key={:?})", key);
@ -60,12 +60,12 @@ pub fn root_and_write_guard(datum: &Datum,
}
}
pub fn return_to_mut(mut bcx: @mut Block,
pub fn return_to_mut(mut bcx: @Block,
root_key: root_map_key,
frozen_val_ref: ValueRef,
bits_val_ref: ValueRef,
filename_val: ValueRef,
line_val: ValueRef) -> @mut Block {
line_val: ValueRef) -> @Block {
debug!("write_guard::return_to_mut(root_key={:?}, {}, {}, {})",
root_key,
bcx.to_str(),
@ -102,10 +102,10 @@ pub fn return_to_mut(mut bcx: @mut Block,
}
fn root(datum: &Datum,
mut bcx: @mut Block,
mut bcx: @Block,
span: Span,
root_key: root_map_key,
root_info: RootInfo) -> @mut Block {
root_info: RootInfo) -> @Block {
//! In some cases, borrowck will decide that an @T/@[]/@str
//! value must be rooted for the program to be safe. In that
//! case, we will call this function, which will stash a copy
@ -120,7 +120,10 @@ fn root(datum: &Datum,
let scratch = scratch_datum(bcx, datum.ty, "__write_guard", true);
datum.copy_to_datum(bcx, INIT, scratch);
let cleanup_bcx = find_bcx_for_scope(bcx, root_info.scope);
add_clean_temp_mem_in_scope(cleanup_bcx, root_info.scope, scratch.val, scratch.ty);
add_clean_temp_mem_in_scope(cleanup_bcx,
root_info.scope,
scratch.val,
scratch.ty);
// Now, consider also freezing it.
match root_info.freeze {
@ -165,9 +168,13 @@ fn root(datum: &Datum,
Some(expr::Ignore)).bcx;
}
add_clean_return_to_mut(
cleanup_bcx, root_info.scope, root_key, scratch.val, scratch_bits.val,
filename, line);
add_clean_return_to_mut(cleanup_bcx,
root_info.scope,
root_key,
scratch.val,
scratch_bits.val,
filename,
line);
}
}
@ -175,8 +182,8 @@ fn root(datum: &Datum,
}
fn perform_write_guard(datum: &Datum,
bcx: @mut Block,
span: Span) -> @mut Block {
bcx: @Block,
span: Span) -> @Block {
debug!("perform_write_guard");
let llval = datum.to_value_llval(bcx);