Move various trans_ modules under a trans:: umbrella module
Closes #1304
This commit is contained in:
parent
b3f06c7d54
commit
03e9dac09a
16 changed files with 203 additions and 212 deletions
|
@ -5,7 +5,7 @@ import lib::llvm::llvm;
|
|||
import front::attr;
|
||||
import middle::ty;
|
||||
import metadata::{encoder, cstore};
|
||||
import middle::trans_common::crate_ctxt;
|
||||
import middle::trans::common::crate_ctxt;
|
||||
import str;
|
||||
import std::fs;
|
||||
import vec;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
|
||||
import driver::session;
|
||||
import middle::trans;
|
||||
import middle::trans_common::{T_fn, T_i1, T_i8, T_i32,
|
||||
T_int, T_nil, T_dict,
|
||||
T_opaque_vec, T_ptr,
|
||||
T_size_t, T_void};
|
||||
import middle::trans::base;
|
||||
import middle::trans::common::{T_fn, T_i1, T_i8, T_i32,
|
||||
T_int, T_nil, T_dict,
|
||||
T_opaque_vec, T_ptr,
|
||||
T_size_t, T_void};
|
||||
import lib::llvm::type_names;
|
||||
import lib::llvm::llvm::ModuleRef;
|
||||
import lib::llvm::llvm::ValueRef;
|
||||
|
@ -42,7 +42,7 @@ fn declare_upcalls(targ_cfg: @session::config,
|
|||
let arg_tys: [TypeRef] = [];
|
||||
for t: TypeRef in tys { arg_tys += [t]; }
|
||||
let fn_ty = T_fn(arg_tys, rv);
|
||||
ret trans::decl_cdecl_fn(llmod, "upcall_" + name, fn_ty);
|
||||
ret base::decl_cdecl_fn(llmod, "upcall_" + name, fn_ty);
|
||||
}
|
||||
let d = bind decl(llmod, _, _, _);
|
||||
let dv = bind decl(llmod, _, _, T_void());
|
||||
|
|
|
@ -177,10 +177,10 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg,
|
|||
|
||||
let (llmod, link_meta) =
|
||||
time(time_passes, "translation",
|
||||
bind trans::trans_crate(sess, crate, ty_cx,
|
||||
outputs.obj_filename, exp_map, ast_map,
|
||||
mut_map, copy_map, last_uses, impl_map,
|
||||
method_map, dict_map));
|
||||
bind trans::base::trans_crate(
|
||||
sess, crate, ty_cx, outputs.obj_filename, exp_map, ast_map,
|
||||
mut_map, copy_map, last_uses, impl_map, method_map,
|
||||
dict_map));
|
||||
time(time_passes, "LLVM passes",
|
||||
bind link::write::run_passes(sess, llmod, outputs.obj_filename));
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import syntax::ast::*;
|
|||
import syntax::ast_util;
|
||||
import syntax::ast_util::local_def;
|
||||
import common::*;
|
||||
import middle::trans_common::crate_ctxt;
|
||||
import middle::trans::common::crate_ctxt;
|
||||
import middle::ty;
|
||||
import middle::ty::node_id_to_monotype;
|
||||
import front::attr;
|
||||
|
|
|
@ -3,8 +3,9 @@ import std::fs;
|
|||
import std::map::hashmap;
|
||||
import lib::llvm::llvm;
|
||||
import lib::llvm::llvm::ValueRef;
|
||||
import middle::trans_common::*;
|
||||
import middle::trans_build::B;
|
||||
import trans::common::*;
|
||||
import trans::base;
|
||||
import trans::build::B;
|
||||
import middle::ty;
|
||||
import syntax::{ast, codemap};
|
||||
import codemap::span;
|
||||
|
@ -84,7 +85,7 @@ fn add_named_metadata(cx: @crate_ctxt, name: str, val: ValueRef) {
|
|||
|
||||
type debug_ctxt = {
|
||||
llmetadata: metadata_cache,
|
||||
names: trans_common::namegen
|
||||
names: namegen
|
||||
};
|
||||
|
||||
fn update_cache(cache: metadata_cache, mdtag: int, val: debug_metadata) {
|
||||
|
@ -239,8 +240,8 @@ fn create_block(cx: @block_ctxt, sp: span) -> @metadata<block_md> {
|
|||
}
|
||||
|
||||
let parent = alt cx.parent {
|
||||
trans_common::parent_none { create_function(cx.fcx, sp).node }
|
||||
trans_common::parent_some(bcx) { create_block(cx, sp).node }
|
||||
parent_none { create_function(cx.fcx, sp).node }
|
||||
parent_some(bcx) { create_block(cx, sp).node }
|
||||
};
|
||||
let file_node = create_file(bcx_ccx(cx), fname);
|
||||
let unique_id = alt cache.find(LexicalBlockTag) {
|
||||
|
@ -637,12 +638,12 @@ fn create_local_var(bcx: @block_ctxt, local: @ast::local)
|
|||
});
|
||||
let loc = codemap::lookup_char_pos(cx.sess.codemap,
|
||||
local.span.lo);
|
||||
let ty = trans::node_id_type(cx, local.node.id);
|
||||
let ty = base::node_id_type(cx, local.node.id);
|
||||
let tymd = create_ty(cx, ty, local.node.ty);
|
||||
let filemd = create_file(cx, loc.filename);
|
||||
let context = alt bcx.parent {
|
||||
trans_common::parent_none { create_function(bcx.fcx, local.span).node }
|
||||
trans_common::parent_some(_) { create_block(bcx, local.span).node }
|
||||
parent_none { create_function(bcx.fcx, local.span).node }
|
||||
parent_some(_) { create_block(bcx, local.span).node }
|
||||
};
|
||||
let mdnode = create_var(tg, context, name, filemd.node,
|
||||
loc.line as int, tymd.node);
|
||||
|
@ -658,8 +659,8 @@ fn create_local_var(bcx: @block_ctxt, local: @ast::local)
|
|||
}
|
||||
};
|
||||
let declargs = [llmdnode([llptr]), mdnode];
|
||||
trans_build::Call(bcx, cx.intrinsics.get("llvm.dbg.declare"),
|
||||
declargs);
|
||||
trans::build::Call(bcx, cx.intrinsics.get("llvm.dbg.declare"),
|
||||
declargs);
|
||||
ret mdval;
|
||||
}
|
||||
|
||||
|
@ -680,7 +681,7 @@ fn create_arg(bcx: @block_ctxt, arg: ast::arg, sp: span)
|
|||
};*/
|
||||
let loc = codemap::lookup_char_pos(cx.sess.codemap,
|
||||
sp.lo);
|
||||
let ty = trans::node_id_type(cx, arg.id);
|
||||
let ty = base::node_id_type(cx, arg.id);
|
||||
let tymd = create_ty(cx, ty, arg.ty);
|
||||
let filemd = create_file(cx, loc.filename);
|
||||
let context = create_function(bcx.fcx, sp);
|
||||
|
@ -693,8 +694,8 @@ fn create_arg(bcx: @block_ctxt, arg: ast::arg, sp: span)
|
|||
local_mem(v) | local_imm(v) { v }
|
||||
};
|
||||
let declargs = [llmdnode([llptr]), mdnode];
|
||||
trans_build::Call(bcx, cx.intrinsics.get("llvm.dbg.declare"),
|
||||
declargs);
|
||||
trans::build::Call(bcx, cx.intrinsics.get("llvm.dbg.declare"),
|
||||
declargs);
|
||||
ret mdval;
|
||||
}
|
||||
|
||||
|
@ -710,7 +711,7 @@ fn update_source_pos(cx: @block_ctxt, s: span) {
|
|||
blockmd.node,
|
||||
llnull()];
|
||||
let dbgscope = llmdnode(scopedata);
|
||||
llvm::LLVMSetCurrentDebugLocation(trans_build::B(cx), dbgscope);
|
||||
llvm::LLVMSetCurrentDebugLocation(trans::build::B(cx), dbgscope);
|
||||
}
|
||||
|
||||
fn create_function(fcx: @fn_ctxt, sp: span) -> @metadata<subprogram_md> {
|
||||
|
|
|
@ -2,16 +2,15 @@
|
|||
|
||||
import lib::llvm::True;
|
||||
import lib::llvm::llvm::ValueRef;
|
||||
import middle::trans;
|
||||
import middle::trans::get_tydesc;
|
||||
import middle::trans_common::*;
|
||||
import middle::ty;
|
||||
import trans::base::get_tydesc;
|
||||
import trans::common::*;
|
||||
import trans::base;
|
||||
import option::none;
|
||||
import str;
|
||||
import driver::session::session;
|
||||
|
||||
import lll = lib::llvm::llvm;
|
||||
import bld = trans_build;
|
||||
import bld = trans::build;
|
||||
|
||||
type ctxt = @{mutable next_tydesc_num: uint};
|
||||
|
||||
|
@ -40,7 +39,7 @@ fn add_gc_root(cx: @block_ctxt, llval: ValueRef, ty: ty::t) -> @block_ctxt {
|
|||
|
||||
// FIXME (issue #839): For now, we are unconditionally zeroing out all
|
||||
// GC-relevant types. Eventually we should use typestate for this.
|
||||
bcx = trans::zero_alloca(bcx, llval, ty);
|
||||
bcx = base::zero_alloca(bcx, llval, ty);
|
||||
|
||||
let ti = none;
|
||||
let td_r = get_tydesc(bcx, ty, false, ti);
|
||||
|
@ -53,10 +52,10 @@ fn add_gc_root(cx: @block_ctxt, llval: ValueRef, ty: ty::t) -> @block_ctxt {
|
|||
alt td_r.kind {
|
||||
tk_derived {
|
||||
// It's a derived type descriptor. First, spill it.
|
||||
let lltydescptr = trans::alloca(bcx, val_ty(lltydesc));
|
||||
let lltydescptr = base::alloca(bcx, val_ty(lltydesc));
|
||||
|
||||
let llderivedtydescs =
|
||||
trans::llderivedtydescs_block_ctxt(bcx_fcx(bcx));
|
||||
base::llderivedtydescs_block_ctxt(bcx_fcx(bcx));
|
||||
bld::Store(llderivedtydescs, lltydesc, lltydescptr);
|
||||
|
||||
let number = gc_cx.next_tydesc_num;
|
||||
|
|
|
@ -6,12 +6,12 @@ import lib::llvm::{True, False};
|
|||
import lib::llvm::llvm::{ModuleRef, TypeRef, ValueRef};
|
||||
import driver::session;
|
||||
import driver::session::session;
|
||||
import middle::{trans, trans_common};
|
||||
import middle::trans_common::{crate_ctxt, val_ty, C_bytes, C_int,
|
||||
C_named_struct, C_struct, T_enum_variant,
|
||||
block_ctxt, result, rslt, bcx_ccx, bcx_tcx,
|
||||
type_has_static_size, umax, umin, align_to,
|
||||
tydesc_info};
|
||||
import trans::base;
|
||||
import middle::trans::common::{crate_ctxt, val_ty, C_bytes, C_int,
|
||||
C_named_struct, C_struct, T_enum_variant,
|
||||
block_ctxt, result, rslt, bcx_ccx, bcx_tcx,
|
||||
type_has_static_size, umax, umin, align_to,
|
||||
tydesc_info};
|
||||
import back::abi;
|
||||
import middle::ty;
|
||||
import middle::ty::field;
|
||||
|
@ -19,7 +19,7 @@ import syntax::ast;
|
|||
import syntax::ast_util::dummy_sp;
|
||||
import syntax::util::interner;
|
||||
import util::common;
|
||||
import trans_build::{Load, Store, Add, GEPi};
|
||||
import trans::build::{Load, Store, Add, GEPi};
|
||||
import syntax::codemap::span;
|
||||
|
||||
import core::{vec, str};
|
||||
|
@ -68,7 +68,7 @@ const shape_tydesc: u8 = 28u8;
|
|||
const shape_send_tydesc: u8 = 29u8;
|
||||
|
||||
// FIXME: This is a bad API in trans_common.
|
||||
fn C_u8(n: u8) -> ValueRef { ret trans_common::C_u8(n as uint); }
|
||||
fn C_u8(n: u8) -> ValueRef { ret trans::common::C_u8(n as uint); }
|
||||
|
||||
fn hash_res_info(ri: res_info) -> uint {
|
||||
let h = 5381u;
|
||||
|
@ -134,8 +134,8 @@ fn largest_variants(ccx: @crate_ctxt, tag_id: ast::def_id) -> [uint] {
|
|||
// follow from how elem_t doesn't contain params.
|
||||
// (Could add a postcondition to type_contains_params,
|
||||
// once we implement Issue #586.)
|
||||
check (trans_common::type_has_static_size(ccx, elem_t));
|
||||
let llty = trans::type_of(ccx, elem_t);
|
||||
check (trans::common::type_has_static_size(ccx, elem_t));
|
||||
let llty = base::type_of(ccx, elem_t);
|
||||
min_size += llsize_of_real(ccx, llty);
|
||||
min_align += llalign_of_real(ccx, llty);
|
||||
}
|
||||
|
@ -213,11 +213,11 @@ fn compute_static_enum_size(ccx: @crate_ctxt, largest_variants: [uint],
|
|||
// FIXME: there should really be a postcondition
|
||||
// on enum_variants that would obviate the need for
|
||||
// this check. (Issue #586)
|
||||
check (trans_common::type_has_static_size(ccx, typ));
|
||||
lltys += [trans::type_of(ccx, typ)];
|
||||
check (trans::common::type_has_static_size(ccx, typ));
|
||||
lltys += [base::type_of(ccx, typ)];
|
||||
}
|
||||
|
||||
let llty = trans_common::T_struct(lltys);
|
||||
let llty = trans::common::T_struct(lltys);
|
||||
let dp = llsize_of_real(ccx, llty) as u16;
|
||||
let variant_align = llalign_of_real(ccx, llty) as u8;
|
||||
|
||||
|
@ -294,13 +294,10 @@ fn s_send_tydesc(_tcx: ty_ctxt) -> u8 {
|
|||
}
|
||||
|
||||
fn mk_ctxt(llmod: ModuleRef) -> ctxt {
|
||||
let llshapetablesty = trans_common::T_named_struct("shapes");
|
||||
let llshapetables =
|
||||
str::as_buf("shapes",
|
||||
{|buf|
|
||||
lib::llvm::llvm::LLVMAddGlobal(llmod, llshapetablesty,
|
||||
buf)
|
||||
});
|
||||
let llshapetablesty = trans::common::T_named_struct("shapes");
|
||||
let llshapetables = str::as_buf("shapes", {|buf|
|
||||
lib::llvm::llvm::LLVMAddGlobal(llmod, llshapetablesty, buf)
|
||||
});
|
||||
|
||||
ret {mutable next_tag_id: 0u16,
|
||||
pad: 0u16,
|
||||
|
@ -584,7 +581,7 @@ fn gen_resource_shapes(ccx: @crate_ctxt) -> ValueRef {
|
|||
let len = interner::len(ccx.shape_cx.resources);
|
||||
while i < len {
|
||||
let ri = interner::get(ccx.shape_cx.resources, i);
|
||||
dtors += [trans_common::get_res_dtor(ccx, ri.did, ri.t)];
|
||||
dtors += [trans::common::get_res_dtor(ccx, ri.did, ri.t)];
|
||||
i += 1u;
|
||||
}
|
||||
|
||||
|
@ -594,9 +591,9 @@ fn gen_resource_shapes(ccx: @crate_ctxt) -> ValueRef {
|
|||
fn gen_shape_tables(ccx: @crate_ctxt) {
|
||||
let lltagstable = gen_enum_shapes(ccx);
|
||||
let llresourcestable = gen_resource_shapes(ccx);
|
||||
trans_common::set_struct_body(ccx.shape_cx.llshapetablesty,
|
||||
[val_ty(lltagstable),
|
||||
val_ty(llresourcestable)]);
|
||||
trans::common::set_struct_body(ccx.shape_cx.llshapetablesty,
|
||||
[val_ty(lltagstable),
|
||||
val_ty(llresourcestable)]);
|
||||
|
||||
let lltables =
|
||||
C_named_struct(ccx.shape_cx.llshapetablesty,
|
||||
|
@ -627,7 +624,7 @@ type tag_metrics = {
|
|||
fn size_of(bcx: @block_ctxt, t: ty::t) -> result {
|
||||
let ccx = bcx_ccx(bcx);
|
||||
if check type_has_static_size(ccx, t) {
|
||||
rslt(bcx, llsize_of(ccx, trans::type_of(ccx, t)))
|
||||
rslt(bcx, llsize_of(ccx, base::type_of(ccx, t)))
|
||||
} else {
|
||||
let { bcx, sz, align: _ } = dynamic_metrics(bcx, t);
|
||||
rslt(bcx, sz)
|
||||
|
@ -637,7 +634,7 @@ fn size_of(bcx: @block_ctxt, t: ty::t) -> result {
|
|||
fn align_of(bcx: @block_ctxt, t: ty::t) -> result {
|
||||
let ccx = bcx_ccx(bcx);
|
||||
if check type_has_static_size(ccx, t) {
|
||||
rslt(bcx, llalign_of(ccx, trans::type_of(ccx, t)))
|
||||
rslt(bcx, llalign_of(ccx, base::type_of(ccx, t)))
|
||||
} else {
|
||||
let { bcx, sz: _, align } = dynamic_metrics(bcx, t);
|
||||
rslt(bcx, align)
|
||||
|
@ -647,7 +644,7 @@ fn align_of(bcx: @block_ctxt, t: ty::t) -> result {
|
|||
fn metrics(bcx: @block_ctxt, t: ty::t) -> metrics {
|
||||
let ccx = bcx_ccx(bcx);
|
||||
if check type_has_static_size(ccx, t) {
|
||||
let llty = trans::type_of(ccx, t);
|
||||
let llty = base::type_of(ccx, t);
|
||||
{ bcx: bcx, sz: llsize_of(ccx, llty), align: llalign_of(ccx, llty) }
|
||||
} else {
|
||||
dynamic_metrics(bcx, t)
|
||||
|
@ -696,7 +693,7 @@ fn static_size_of_enum(cx: @crate_ctxt, t: ty::t)
|
|||
// express that with constrained types.
|
||||
check (type_has_static_size(cx, tup_ty));
|
||||
let this_size =
|
||||
llsize_of_real(cx, trans::type_of(cx, tup_ty));
|
||||
llsize_of_real(cx, base::type_of(cx, tup_ty));
|
||||
if max_size < this_size { max_size = this_size; }
|
||||
}
|
||||
cx.enum_sizes.insert(t, max_size);
|
||||
|
@ -735,7 +732,7 @@ fn dynamic_metrics(cx: @block_ctxt, t: ty::t) -> metrics {
|
|||
alt ty::struct(bcx_tcx(cx), t) {
|
||||
ty::ty_param(p, _) {
|
||||
let ti = none::<@tydesc_info>;
|
||||
let {bcx, val: tydesc} = trans::get_tydesc(cx, t, false, ti).result;
|
||||
let {bcx, val: tydesc} = base::get_tydesc(cx, t, false, ti).result;
|
||||
let szptr = GEPi(bcx, tydesc, [0, abi::tydesc_field_size]);
|
||||
let aptr = GEPi(bcx, tydesc, [0, abi::tydesc_field_align]);
|
||||
{bcx: bcx, sz: Load(bcx, szptr), align: Load(bcx, aptr)}
|
||||
|
|
|
@ -5,8 +5,8 @@ import driver::session::session;
|
|||
import lib::llvm::llvm;
|
||||
import lib::llvm::llvm::{ValueRef, BasicBlockRef};
|
||||
import pat_util::*;
|
||||
import trans_build::*;
|
||||
import trans::{new_sub_block_ctxt, new_scope_block_ctxt, load_if_immediate};
|
||||
import build::*;
|
||||
import base::{new_sub_block_ctxt, new_scope_block_ctxt, load_if_immediate};
|
||||
import syntax::ast;
|
||||
import syntax::ast_util;
|
||||
import syntax::ast_util::{dummy_sp};
|
||||
|
@ -14,7 +14,7 @@ import syntax::ast::def_id;
|
|||
import syntax::codemap::span;
|
||||
import syntax::print::pprust::pat_to_str;
|
||||
|
||||
import trans_common::*;
|
||||
import common::*;
|
||||
|
||||
// An option identifying a branch (either a literal, a enum variant or a
|
||||
// range)
|
||||
|
@ -46,21 +46,21 @@ fn trans_opt(bcx: @block_ctxt, o: opt) -> opt_result {
|
|||
alt l.node {
|
||||
ast::expr_lit(@{node: ast::lit_str(s), _}) {
|
||||
let strty = ty::mk_str(bcx_tcx(bcx));
|
||||
let cell = trans::empty_dest_cell();
|
||||
bcx = trans_vec::trans_str(bcx, s, trans::by_val(cell));
|
||||
let cell = base::empty_dest_cell();
|
||||
bcx = tvec::trans_str(bcx, s, base::by_val(cell));
|
||||
add_clean_temp(bcx, *cell, strty);
|
||||
ret single_result(rslt(bcx, *cell));
|
||||
}
|
||||
_ {
|
||||
ret single_result(
|
||||
rslt(bcx, trans::trans_const_expr(ccx, l)));
|
||||
rslt(bcx, base::trans_const_expr(ccx, l)));
|
||||
}
|
||||
}
|
||||
}
|
||||
var(disr_val, _) { ret single_result(rslt(bcx, C_int(ccx, disr_val))); }
|
||||
range(l1, l2) {
|
||||
ret range_result(rslt(bcx, trans::trans_const_expr(ccx, l1)),
|
||||
rslt(bcx, trans::trans_const_expr(ccx, l2)));
|
||||
ret range_result(rslt(bcx, base::trans_const_expr(ccx, l1)),
|
||||
rslt(bcx, base::trans_const_expr(ccx, l2)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -274,7 +274,7 @@ fn extract_variant_args(bcx: @block_ctxt, pat_id: ast::node_id,
|
|||
vec::len(ty::enum_variant_with_id(ccx.tcx, vdefs.tg, vdefs.var).args);
|
||||
if size > 0u && vec::len(*variants) != 1u {
|
||||
let enumptr =
|
||||
PointerCast(bcx, val, trans_common::T_opaque_enum_ptr(ccx));
|
||||
PointerCast(bcx, val, T_opaque_enum_ptr(ccx));
|
||||
blobptr = GEPi(bcx, enumptr, [0, 1]);
|
||||
}
|
||||
let i = 0u;
|
||||
|
@ -286,7 +286,7 @@ fn extract_variant_args(bcx: @block_ctxt, pat_id: ast::node_id,
|
|||
// invariant needed:
|
||||
// how do we know it even makes sense to pass in ty_param_substs
|
||||
// here? What if it's [] and the enum type has variables in it?
|
||||
trans::GEP_enum(bcx, blobptr, vdefs_tg, vdefs_var,
|
||||
base::GEP_enum(bcx, blobptr, vdefs_tg, vdefs_var,
|
||||
ty_param_substs, i);
|
||||
bcx = r.bcx;
|
||||
args += [r.val];
|
||||
|
@ -381,8 +381,8 @@ fn compile_submatch(bcx: @block_ctxt, m: match, vals: [ValueRef], f: mk_fail,
|
|||
bcx.fcx.lllocals.insert(val, local);
|
||||
};
|
||||
let {bcx: guard_bcx, val: guard_val} =
|
||||
trans::trans_temp_expr(guard_cx, e);
|
||||
guard_bcx = trans::trans_block_cleanups(guard_bcx, guard_cx);
|
||||
base::trans_temp_expr(guard_cx, e);
|
||||
guard_bcx = base::trans_block_cleanups(guard_bcx, guard_cx);
|
||||
let next_cx = new_sub_block_ctxt(guard_cx, "submatch_next");
|
||||
let else_cx = new_sub_block_ctxt(guard_cx, "submatch_else");
|
||||
CondBr(guard_bcx, guard_val, next_cx.llbb, else_cx.llbb);
|
||||
|
@ -426,7 +426,7 @@ fn compile_submatch(bcx: @block_ctxt, m: match, vals: [ValueRef], f: mk_fail,
|
|||
let ix = option::get(ty::field_idx(field_name, fields));
|
||||
// not sure how to get rid of this check
|
||||
check type_is_tup_like(bcx, rec_ty);
|
||||
let r = trans::GEP_tup_like(bcx, rec_ty, val, [0, ix as int]);
|
||||
let r = base::GEP_tup_like(bcx, rec_ty, val, [0, ix as int]);
|
||||
rec_vals += [r.val];
|
||||
bcx = r.bcx;
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ fn compile_submatch(bcx: @block_ctxt, m: match, vals: [ValueRef], f: mk_fail,
|
|||
while i < n_tup_elts {
|
||||
// how to get rid of this check?
|
||||
check type_is_tup_like(bcx, tup_ty);
|
||||
let r = trans::GEP_tup_like(bcx, tup_ty, val, [0, i as int]);
|
||||
let r = base::GEP_tup_like(bcx, tup_ty, val, [0, i as int]);
|
||||
tup_vals += [r.val];
|
||||
bcx = r.bcx;
|
||||
i += 1u;
|
||||
|
@ -483,8 +483,7 @@ fn compile_submatch(bcx: @block_ctxt, m: match, vals: [ValueRef], f: mk_fail,
|
|||
kind = single;
|
||||
} else {
|
||||
let enumptr =
|
||||
PointerCast(bcx, val,
|
||||
trans_common::T_opaque_enum_ptr(ccx));
|
||||
PointerCast(bcx, val, T_opaque_enum_ptr(ccx));
|
||||
let discrimptr = GEPi(bcx, enumptr, [0, 0]);
|
||||
test_val = Load(bcx, discrimptr);
|
||||
kind = switch;
|
||||
|
@ -546,22 +545,22 @@ fn compile_submatch(bcx: @block_ctxt, m: match, vals: [ValueRef], f: mk_fail,
|
|||
single_result(r) {
|
||||
bcx = r.bcx;
|
||||
let eq =
|
||||
trans::trans_compare(bcx, ast::eq, test_val, t, r.val, t);
|
||||
let cleanup_cx = trans::trans_block_cleanups(
|
||||
base::trans_compare(bcx, ast::eq, test_val, t, r.val, t);
|
||||
let cleanup_cx = base::trans_block_cleanups(
|
||||
eq.bcx, compare_cx);
|
||||
bcx = new_sub_block_ctxt(bcx, "compare_next");
|
||||
CondBr(cleanup_cx, eq.val, opt_cx.llbb, bcx.llbb);
|
||||
}
|
||||
range_result(rbegin, rend) {
|
||||
bcx = rend.bcx;
|
||||
let ge = trans::trans_compare(bcx, ast::ge, test_val, t,
|
||||
let ge = base::trans_compare(bcx, ast::ge, test_val, t,
|
||||
rbegin.val, t);
|
||||
let le = trans::trans_compare(ge.bcx, ast::le, test_val, t,
|
||||
let le = base::trans_compare(ge.bcx, ast::le, test_val, t,
|
||||
rend.val, t);
|
||||
let in_range = rslt(le.bcx, And(le.bcx, ge.val, le.val));
|
||||
bcx = in_range.bcx;
|
||||
let cleanup_cx =
|
||||
trans::trans_block_cleanups(bcx, compare_cx);
|
||||
base::trans_block_cleanups(bcx, compare_cx);
|
||||
bcx = new_sub_block_ctxt(bcx, "compare_next");
|
||||
CondBr(cleanup_cx, in_range.val, opt_cx.llbb, bcx.llbb);
|
||||
}
|
||||
|
@ -621,8 +620,8 @@ fn make_phi_bindings(bcx: @block_ctxt, map: [exit_node],
|
|||
local_mem(x) { x }
|
||||
};
|
||||
let e_ty = ty::node_id_to_type(bcx_tcx(bcx), node_id);
|
||||
let {bcx: abcx, val: alloc} = trans::alloc_ty(bcx, e_ty);
|
||||
bcx = trans::copy_val(abcx, trans::INIT, alloc,
|
||||
let {bcx: abcx, val: alloc} = base::alloc_ty(bcx, e_ty);
|
||||
bcx = base::copy_val(abcx, base::INIT, alloc,
|
||||
load_if_immediate(abcx, local, e_ty),
|
||||
e_ty);
|
||||
add_clean(bcx, alloc, e_ty);
|
||||
|
@ -636,13 +635,13 @@ fn make_phi_bindings(bcx: @block_ctxt, map: [exit_node],
|
|||
}
|
||||
|
||||
fn trans_alt(cx: @block_ctxt, expr: @ast::expr, arms_: [ast::arm],
|
||||
dest: trans::dest) -> @block_ctxt {
|
||||
dest: base::dest) -> @block_ctxt {
|
||||
let bodies = [];
|
||||
let match: match = [];
|
||||
let alt_cx = new_scope_block_ctxt(cx, "alt");
|
||||
Br(cx, alt_cx.llbb);
|
||||
|
||||
let er = trans::trans_temp_expr(alt_cx, expr);
|
||||
let er = base::trans_temp_expr(alt_cx, expr);
|
||||
if er.bcx.unreachable { ret er.bcx; }
|
||||
|
||||
/*
|
||||
|
@ -669,14 +668,14 @@ fn trans_alt(cx: @block_ctxt, expr: @ast::expr, arms_: [ast::arm],
|
|||
done: @mutable option::t<BasicBlockRef>) -> BasicBlockRef {
|
||||
alt *done { some(bb) { ret bb; } _ { } }
|
||||
let fail_cx = new_sub_block_ctxt(cx, "case_fallthrough");
|
||||
trans::trans_fail(fail_cx, some(sp), "non-exhaustive match failure");;
|
||||
base::trans_fail(fail_cx, some(sp), "non-exhaustive match failure");;
|
||||
*done = some(fail_cx.llbb);
|
||||
ret fail_cx.llbb;
|
||||
}
|
||||
|
||||
let exit_map = [];
|
||||
let t = trans::node_id_type(cx.fcx.lcx.ccx, expr.id);
|
||||
let vr = trans::spill_if_immediate(er.bcx, er.val, t);
|
||||
let t = base::node_id_type(cx.fcx.lcx.ccx, expr.id);
|
||||
let vr = base::spill_if_immediate(er.bcx, er.val, t);
|
||||
compile_submatch(vr.bcx, match, [vr.val],
|
||||
bind mk_fail(alt_cx, expr.span, fail_cx), exit_map);
|
||||
|
||||
|
@ -686,14 +685,14 @@ fn trans_alt(cx: @block_ctxt, expr: @ast::expr, arms_: [ast::arm],
|
|||
if make_phi_bindings(body_cx, exit_map,
|
||||
pat_util::pat_id_map(bcx_tcx(cx),
|
||||
a.pats[0])) {
|
||||
let arm_dest = trans::dup_for_join(dest);
|
||||
let arm_dest = base::dup_for_join(dest);
|
||||
arm_dests += [arm_dest];
|
||||
arm_cxs += [trans::trans_block_dps(body_cx, a.body, arm_dest)];
|
||||
arm_cxs += [base::trans_block_dps(body_cx, a.body, arm_dest)];
|
||||
}
|
||||
i += 1u;
|
||||
}
|
||||
let after_cx = trans::join_returns(cx, arm_cxs, arm_dests, dest);
|
||||
after_cx = trans::trans_block_cleanups(after_cx, alt_cx);
|
||||
let after_cx = base::join_returns(cx, arm_cxs, arm_dests, dest);
|
||||
after_cx = base::trans_block_cleanups(after_cx, alt_cx);
|
||||
let next_cx = new_sub_block_ctxt(after_cx, "next");
|
||||
Br(after_cx, next_cx.llbb);
|
||||
ret next_cx;
|
||||
|
@ -713,12 +712,12 @@ fn bind_irrefutable_pat(bcx: @block_ctxt, pat: @ast::pat, val: ValueRef,
|
|||
// check unnecessary.
|
||||
check (type_has_static_size(ccx, ty));
|
||||
check non_ty_var(ccx, ty);
|
||||
let llty = trans::type_of(ccx, ty);
|
||||
let alloc = trans::alloca(bcx, llty);
|
||||
bcx = trans::copy_val(bcx, trans::INIT, alloc,
|
||||
trans::load_if_immediate(bcx, val, ty), ty);
|
||||
let llty = base::type_of(ccx, ty);
|
||||
let alloc = base::alloca(bcx, llty);
|
||||
bcx = base::copy_val(bcx, base::INIT, alloc,
|
||||
base::load_if_immediate(bcx, val, ty), ty);
|
||||
bcx.fcx.lllocals.insert(pat.id, local_mem(alloc));
|
||||
trans_common::add_clean(bcx, alloc, ty);
|
||||
add_clean(bcx, alloc, ty);
|
||||
} else { bcx.fcx.lllocals.insert(pat.id, local_mem(val)); }
|
||||
alt inner {
|
||||
some(pat) { bcx = bind_irrefutable_pat(bcx, pat, val, true); }
|
||||
|
@ -743,7 +742,7 @@ fn bind_irrefutable_pat(bcx: @block_ctxt, pat: @ast::pat, val: ValueRef,
|
|||
let ix = option::get(ty::field_idx(f.ident, rec_fields));
|
||||
// how to get rid of this check?
|
||||
check type_is_tup_like(bcx, rec_ty);
|
||||
let r = trans::GEP_tup_like(bcx, rec_ty, val, [0, ix as int]);
|
||||
let r = base::GEP_tup_like(bcx, rec_ty, val, [0, ix as int]);
|
||||
bcx = bind_irrefutable_pat(r.bcx, f.pat, r.val, make_copy);
|
||||
}
|
||||
}
|
||||
|
@ -753,7 +752,7 @@ fn bind_irrefutable_pat(bcx: @block_ctxt, pat: @ast::pat, val: ValueRef,
|
|||
for elem in elems {
|
||||
// how to get rid of this check?
|
||||
check type_is_tup_like(bcx, tup_ty);
|
||||
let r = trans::GEP_tup_like(bcx, tup_ty, val, [0, i as int]);
|
||||
let r = base::GEP_tup_like(bcx, tup_ty, val, [0, i as int]);
|
||||
bcx = bind_irrefutable_pat(r.bcx, elem, r.val, make_copy);
|
||||
i += 1u;
|
||||
}
|
|
@ -42,9 +42,8 @@ import link::{mangle_internal_name_by_type_only,
|
|||
import metadata::{csearch, cstore};
|
||||
import util::ppaux::{ty_to_str, ty_to_short_str};
|
||||
|
||||
import trans_common::*;
|
||||
import trans_build::*;
|
||||
import tvec = trans_vec;
|
||||
import common::*;
|
||||
import build::*;
|
||||
|
||||
fn type_of_1(bcx: @block_ctxt, t: ty::t) -> TypeRef {
|
||||
let cx = bcx_ccx(bcx);
|
||||
|
@ -1243,8 +1242,8 @@ fn make_take_glue(cx: @block_ctxt, v: ValueRef, t: ty::t) {
|
|||
incr_refcnt_of_boxed(bcx, Load(bcx, v))
|
||||
}
|
||||
ty::ty_uniq(_) {
|
||||
check trans_uniq::type_is_unique_box(bcx, t);
|
||||
let r = trans_uniq::duplicate(bcx, Load(bcx, v), t);
|
||||
check uniq::type_is_unique_box(bcx, t);
|
||||
let r = uniq::duplicate(bcx, Load(bcx, v), t);
|
||||
Store(r.bcx, r.val, v);
|
||||
r.bcx
|
||||
}
|
||||
|
@ -1262,10 +1261,10 @@ fn make_take_glue(cx: @block_ctxt, v: ValueRef, t: ty::t) {
|
|||
bcx
|
||||
}
|
||||
ty::ty_fn(_) {
|
||||
trans_closure::make_fn_glue(bcx, v, t, take_ty)
|
||||
closure::make_fn_glue(bcx, v, t, take_ty)
|
||||
}
|
||||
ty::ty_opaque_closure_ptr(ck) {
|
||||
trans_closure::make_opaque_cbox_take_glue(bcx, ck, v)
|
||||
closure::make_opaque_cbox_take_glue(bcx, ck, v)
|
||||
}
|
||||
_ if ty::type_is_structural(bcx_tcx(bcx), t) {
|
||||
iter_structural_ty(bcx, v, t, take_ty)
|
||||
|
@ -1308,9 +1307,9 @@ fn make_free_glue(bcx: @block_ctxt, v: ValueRef, t: ty::t) {
|
|||
free_box(bcx, v, t)
|
||||
}
|
||||
ty::ty_uniq(content_mt) {
|
||||
check trans_uniq::type_is_unique_box(bcx, t);
|
||||
check uniq::type_is_unique_box(bcx, t);
|
||||
let v = PointerCast(bcx, v, type_of_1(bcx, t));
|
||||
trans_uniq::make_free_glue(bcx, v, t)
|
||||
uniq::make_free_glue(bcx, v, t)
|
||||
}
|
||||
ty::ty_vec(_) | ty::ty_str {
|
||||
tvec::make_free_glue(bcx, PointerCast(bcx, v, type_of_1(bcx, t)), t)
|
||||
|
@ -1338,10 +1337,10 @@ fn make_free_glue(bcx: @block_ctxt, v: ValueRef, t: ty::t) {
|
|||
bcx
|
||||
}
|
||||
ty::ty_fn(_) {
|
||||
trans_closure::make_fn_glue(bcx, v, t, free_ty)
|
||||
closure::make_fn_glue(bcx, v, t, free_ty)
|
||||
}
|
||||
ty::ty_opaque_closure_ptr(ck) {
|
||||
trans_closure::make_opaque_cbox_free_glue(bcx, ck, v)
|
||||
closure::make_opaque_cbox_free_glue(bcx, ck, v)
|
||||
}
|
||||
_ { bcx }
|
||||
};
|
||||
|
@ -1363,10 +1362,10 @@ fn make_drop_glue(bcx: @block_ctxt, v0: ValueRef, t: ty::t) {
|
|||
trans_res_drop(bcx, v0, did, inner, tps)
|
||||
}
|
||||
ty::ty_fn(_) {
|
||||
trans_closure::make_fn_glue(bcx, v0, t, drop_ty)
|
||||
closure::make_fn_glue(bcx, v0, t, drop_ty)
|
||||
}
|
||||
ty::ty_opaque_closure_ptr(ck) {
|
||||
trans_closure::make_opaque_cbox_drop_glue(bcx, ck, v0)
|
||||
closure::make_opaque_cbox_drop_glue(bcx, ck, v0)
|
||||
}
|
||||
_ {
|
||||
if ty::type_needs_drop(ccx.tcx, t) &&
|
||||
|
@ -1398,7 +1397,7 @@ fn trans_res_drop(cx: @block_ctxt, rs: ValueRef, did: ast::def_id,
|
|||
let val = GEP_tup_like(cx, tup_ty, rs, [0, 1]);
|
||||
cx = val.bcx;
|
||||
// Find and call the actual destructor.
|
||||
let dtor_addr = trans_common::get_res_dtor(ccx, did, inner_t);
|
||||
let dtor_addr = common::get_res_dtor(ccx, did, inner_t);
|
||||
let args = [cx.fcx.llretptr, null_env_ptr(cx)];
|
||||
for tp: ty::t in tps {
|
||||
let ti: option::t<@tydesc_info> = none;
|
||||
|
@ -1865,8 +1864,8 @@ fn take_ty_immediate(bcx: @block_ctxt, v: ValueRef, t: ty::t) -> result {
|
|||
rslt(incr_refcnt_of_boxed(bcx, v), v)
|
||||
}
|
||||
ty::ty_uniq(_) {
|
||||
check trans_uniq::type_is_unique_box(bcx, t);
|
||||
trans_uniq::duplicate(bcx, v, t)
|
||||
check uniq::type_is_unique_box(bcx, t);
|
||||
uniq::duplicate(bcx, v, t)
|
||||
}
|
||||
ty::ty_str | ty::ty_vec(_) { tvec::duplicate(bcx, v, t) }
|
||||
_ { rslt(bcx, v) }
|
||||
|
@ -2060,7 +2059,7 @@ fn trans_unary(bcx: @block_ctxt, op: ast::unop, e: @ast::expr,
|
|||
let callee_id = ast_util::op_expr_callee_id(un_expr);
|
||||
let fty = ty::node_id_to_monotype(bcx_tcx(bcx), callee_id);
|
||||
ret trans_call_inner(bcx, fty, {|bcx|
|
||||
trans_impl::trans_method_callee(bcx, callee_id, e, origin)
|
||||
impl::trans_method_callee(bcx, callee_id, e, origin)
|
||||
}, [], un_expr.id, dest);
|
||||
}
|
||||
_ {}
|
||||
|
@ -2096,7 +2095,7 @@ fn trans_unary(bcx: @block_ctxt, op: ast::unop, e: @ast::expr,
|
|||
ret store_in_dest(bcx, box, dest);
|
||||
}
|
||||
ast::uniq(_) {
|
||||
ret trans_uniq::trans_uniq(bcx, e, un_expr.id, dest);
|
||||
ret uniq::trans_uniq(bcx, e, un_expr.id, dest);
|
||||
}
|
||||
ast::deref {
|
||||
bcx_ccx(bcx).sess.bug("deref expressions should have been \
|
||||
|
@ -2199,7 +2198,7 @@ fn trans_assign_op(bcx: @block_ctxt, ex: @ast::expr, op: ast::binop,
|
|||
let fty = ty::node_id_to_monotype(bcx_tcx(bcx), callee_id);
|
||||
ret trans_call_inner(bcx, fty, {|bcx|
|
||||
// FIXME provide the already-computed address, not the expr
|
||||
trans_impl::trans_method_callee(bcx, callee_id, dst, origin)
|
||||
impl::trans_method_callee(bcx, callee_id, dst, origin)
|
||||
}, [src], ex.id, save_in(lhs_res.val));
|
||||
}
|
||||
_ {}
|
||||
|
@ -2251,8 +2250,8 @@ fn autoderef(cx: @block_ctxt, v: ValueRef, t: ty::t) -> result_t {
|
|||
} else { v1 = body; }
|
||||
}
|
||||
ty::ty_uniq(_) {
|
||||
check trans_uniq::type_is_unique_box(cx, t1);
|
||||
let derefed = trans_uniq::autoderef(cx, v1, t1);
|
||||
check uniq::type_is_unique_box(cx, t1);
|
||||
let derefed = uniq::autoderef(cx, v1, t1);
|
||||
t1 = derefed.t;
|
||||
v1 = derefed.v;
|
||||
}
|
||||
|
@ -2320,7 +2319,7 @@ fn trans_binary(bcx: @block_ctxt, op: ast::binop, lhs: @ast::expr,
|
|||
let callee_id = ast_util::op_expr_callee_id(ex);
|
||||
let fty = ty::node_id_to_monotype(bcx_tcx(bcx), callee_id);
|
||||
ret trans_call_inner(bcx, fty, {|bcx|
|
||||
trans_impl::trans_method_callee(bcx, callee_id, lhs, origin)
|
||||
impl::trans_method_callee(bcx, callee_id, lhs, origin)
|
||||
}, [rhs], ex.id, dest);
|
||||
}
|
||||
_ {}
|
||||
|
@ -2446,7 +2445,7 @@ fn trans_for(cx: @block_ctxt, local: @ast::local, seq: @ast::expr,
|
|||
outer_next_cx, "for loop scope");
|
||||
Br(bcx, scope_cx.llbb);
|
||||
let curr = PointerCast(bcx, curr, T_ptr(type_of_or_i8(bcx, t)));
|
||||
let bcx = trans_alt::bind_irrefutable_pat(scope_cx, local.node.pat,
|
||||
let bcx = alt::bind_irrefutable_pat(scope_cx, local.node.pat,
|
||||
curr, false);
|
||||
bcx = trans_block_dps(bcx, body, ignore);
|
||||
Br(bcx, next_cx.llbb);
|
||||
|
@ -2764,7 +2763,7 @@ fn trans_callee(bcx: @block_ctxt, e: @ast::expr) -> lval_maybe_callee {
|
|||
if !expr_is_lval(bcx, e) {
|
||||
alt bcx_ccx(bcx).method_map.find(e.id) {
|
||||
some(origin) { // An impl method
|
||||
ret trans_impl::trans_method_callee(bcx, e.id, base, origin);
|
||||
ret impl::trans_method_callee(bcx, e.id, base, origin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2846,7 +2845,7 @@ fn lval_maybe_callee_to_lval(c: lval_maybe_callee, ty: ty::t) -> lval_result {
|
|||
let n_args = vec::len(ty::ty_fn_args(bcx_tcx(c.bcx), ty));
|
||||
let args = vec::init_elt(n_args, none::<@ast::expr>);
|
||||
let space = alloc_ty(c.bcx, ty);
|
||||
let bcx = trans_closure::trans_bind_1(space.bcx, ty, c, args, ty,
|
||||
let bcx = closure::trans_bind_1(space.bcx, ty, c, args, ty,
|
||||
save_in(space.val));
|
||||
add_clean_temp(bcx, space.val, ty);
|
||||
ret {bcx: bcx, val: space.val, kind: temporary};
|
||||
|
@ -2887,7 +2886,7 @@ fn trans_cast(cx: @block_ctxt, e: @ast::expr, id: ast::node_id,
|
|||
let ccx = bcx_ccx(cx);
|
||||
let t_out = node_id_type(ccx, id);
|
||||
alt ty::struct(ccx.tcx, t_out) {
|
||||
ty::ty_iface(_, _) { ret trans_impl::trans_cast(cx, e, id, dest); }
|
||||
ty::ty_iface(_, _) { ret impl::trans_cast(cx, e, id, dest); }
|
||||
_ {}
|
||||
}
|
||||
let e_res = trans_temp_expr(cx, e);
|
||||
|
@ -3065,7 +3064,7 @@ fn trans_args(cx: @block_ctxt, llenv: ValueRef,
|
|||
for bound in *param {
|
||||
alt bound {
|
||||
ty::bound_iface(_) {
|
||||
let res = trans_impl::get_dict(
|
||||
let res = impl::get_dict(
|
||||
bcx, option::get(g.origins)[n_orig]);
|
||||
lltydescs += [res.val];
|
||||
bcx = res.bcx;
|
||||
|
@ -3477,7 +3476,7 @@ fn trans_expr(bcx: @block_ctxt, e: @ast::expr, dest: dest) -> @block_ctxt {
|
|||
}
|
||||
ast::expr_alt(expr, arms) {
|
||||
// tcx.sess.span_note(e.span, "about to call trans_alt");
|
||||
ret trans_alt::trans_alt(bcx, expr, arms, dest);
|
||||
ret alt::trans_alt(bcx, expr, arms, dest);
|
||||
}
|
||||
ast::expr_block(blk) {
|
||||
let sub_cx = new_scope_block_ctxt(bcx, "block-expr body");
|
||||
|
@ -3502,7 +3501,7 @@ fn trans_expr(bcx: @block_ctxt, e: @ast::expr, dest: dest) -> @block_ctxt {
|
|||
ret trans_unary(bcx, op, x, e, dest);
|
||||
}
|
||||
ast::expr_fn(proto, decl, body, cap_clause) {
|
||||
ret trans_closure::trans_expr_fn(
|
||||
ret closure::trans_expr_fn(
|
||||
bcx, proto, decl, body, e.span, e.id, *cap_clause, dest);
|
||||
}
|
||||
ast::expr_fn_block(decl, body) {
|
||||
|
@ -3511,7 +3510,7 @@ fn trans_expr(bcx: @block_ctxt, e: @ast::expr, dest: dest) -> @block_ctxt {
|
|||
#debug("translating fn_block %s with type %s",
|
||||
expr_to_str(e), ty_to_str(tcx, ty::expr_ty(tcx, e)));
|
||||
let cap_clause = { copies: [], moves: [] };
|
||||
ret trans_closure::trans_expr_fn(
|
||||
ret closure::trans_expr_fn(
|
||||
bcx, proto, decl, body, e.span, e.id, cap_clause, dest);
|
||||
}
|
||||
_ {
|
||||
|
@ -3520,7 +3519,7 @@ fn trans_expr(bcx: @block_ctxt, e: @ast::expr, dest: dest) -> @block_ctxt {
|
|||
}
|
||||
}
|
||||
ast::expr_bind(f, args) {
|
||||
ret trans_closure::trans_bind(
|
||||
ret closure::trans_bind(
|
||||
bcx, f, args, e.id, dest);
|
||||
}
|
||||
ast::expr_copy(a) {
|
||||
|
@ -3542,7 +3541,7 @@ fn trans_expr(bcx: @block_ctxt, e: @ast::expr, dest: dest) -> @block_ctxt {
|
|||
let callee_id = ast_util::op_expr_callee_id(e);
|
||||
let fty = ty::node_id_to_monotype(tcx, callee_id);
|
||||
ret trans_call_inner(bcx, fty, {|bcx|
|
||||
trans_impl::trans_method_callee(bcx, callee_id, base, origin)
|
||||
impl::trans_method_callee(bcx, callee_id, base, origin)
|
||||
}, [idx], e.id, dest);
|
||||
}
|
||||
|
||||
|
@ -3948,7 +3947,7 @@ fn init_local(bcx: @block_ctxt, local: @ast::local) -> @block_ctxt {
|
|||
}
|
||||
// Make a note to drop this slot on the way out.
|
||||
add_clean(bcx, llptr, ty);
|
||||
ret trans_alt::bind_irrefutable_pat(bcx, local.node.pat, llptr, false);
|
||||
ret alt::bind_irrefutable_pat(bcx, local.node.pat, llptr, false);
|
||||
}
|
||||
|
||||
fn init_ref_local(bcx: @block_ctxt, local: @ast::local) -> @block_ctxt {
|
||||
|
@ -3958,7 +3957,7 @@ fn init_ref_local(bcx: @block_ctxt, local: @ast::local) -> @block_ctxt {
|
|||
owned_imm { val = do_spill_noroot(bcx, val); }
|
||||
owned {}
|
||||
}
|
||||
ret trans_alt::bind_irrefutable_pat(bcx, local.node.pat, val, false);
|
||||
ret alt::bind_irrefutable_pat(bcx, local.node.pat, val, false);
|
||||
}
|
||||
|
||||
fn zero_alloca(cx: @block_ctxt, llptr: ValueRef, t: ty::t)
|
||||
|
@ -4888,7 +4887,7 @@ fn trans_item(cx: @local_ctxt, item: ast::item) {
|
|||
}
|
||||
}
|
||||
ast::item_impl(tps, _, _, ms) {
|
||||
trans_impl::trans_impl(cx, item.ident, ms, item.id, tps);
|
||||
impl::trans_impl(cx, item.ident, ms, item.id, tps);
|
||||
}
|
||||
ast::item_res(decl, tps, body, dtor_id, ctor_id) {
|
||||
trans_res_ctor(cx, decl, ctor_id, tps);
|
||||
|
@ -5267,10 +5266,10 @@ fn trans_constant(ccx: @crate_ctxt, it: @ast::item, &&pt: [str],
|
|||
}
|
||||
ast::item_impl(tps, some(@{node: ast::ty_path(_, id), _}), _, ms) {
|
||||
let i_did = ast_util::def_id_of_def(ccx.tcx.def_map.get(id));
|
||||
trans_impl::trans_impl_vtable(ccx, pt, i_did, ms, tps, it);
|
||||
impl::trans_impl_vtable(ccx, pt, i_did, ms, tps, it);
|
||||
}
|
||||
ast::item_iface(_, _) {
|
||||
trans_impl::trans_iface_vtable(ccx, pt, it);
|
||||
impl::trans_iface_vtable(ccx, pt, it);
|
||||
}
|
||||
_ { }
|
||||
}
|
||||
|
@ -5414,16 +5413,14 @@ fn fill_crate_map(ccx: @crate_ctxt, map: ValueRef) {
|
|||
fn write_metadata(cx: @crate_ctxt, crate: @ast::crate) {
|
||||
if !cx.sess.building_library { ret; }
|
||||
let llmeta = C_postr(metadata::encoder::encode_metadata(cx, crate));
|
||||
let llconst = trans_common::C_struct([llmeta]);
|
||||
let llglobal =
|
||||
str::as_buf("rust_metadata",
|
||||
{|buf|
|
||||
llvm::LLVMAddGlobal(cx.llmod, val_ty(llconst), buf)
|
||||
});
|
||||
let llconst = C_struct([llmeta]);
|
||||
let llglobal = str::as_buf("rust_metadata", {|buf|
|
||||
llvm::LLVMAddGlobal(cx.llmod, val_ty(llconst), buf)
|
||||
});
|
||||
llvm::LLVMSetInitializer(llglobal, llconst);
|
||||
let _: () =
|
||||
str::as_buf(cx.sess.targ_cfg.target_strs.meta_sect_name,
|
||||
{|buf| llvm::LLVMSetSection(llglobal, buf) });
|
||||
str::as_buf(cx.sess.targ_cfg.target_strs.meta_sect_name, {|buf|
|
||||
llvm::LLVMSetSection(llglobal, buf)
|
||||
});
|
||||
llvm::LLVMSetLinkage(llglobal,
|
||||
lib::llvm::LLVMInternalLinkage as llvm::Linkage);
|
||||
|
|
@ -6,8 +6,8 @@ import syntax::codemap;
|
|||
import codemap::span;
|
||||
import llvm::{ValueRef, TypeRef, BasicBlockRef, BuilderRef, Opcode,
|
||||
ModuleRef};
|
||||
import trans_common::{block_ctxt, T_ptr, T_nil, T_i8, T_i1, T_void,
|
||||
T_fn, val_ty, bcx_ccx, C_i32};
|
||||
import common::{block_ctxt, T_ptr, T_nil, T_i8, T_i1, T_void,
|
||||
T_fn, val_ty, bcx_ccx, C_i32};
|
||||
|
||||
fn B(cx: @block_ctxt) -> BuilderRef {
|
||||
let b = *cx.fcx.lcx.ccx.builder;
|
|
@ -3,9 +3,9 @@ import syntax::ast;
|
|||
import syntax::ast_util;
|
||||
import lib::llvm::llvm;
|
||||
import llvm::{ValueRef, TypeRef};
|
||||
import trans_common::*;
|
||||
import trans_build::*;
|
||||
import trans::*;
|
||||
import common::*;
|
||||
import build::*;
|
||||
import base::*;
|
||||
import middle::freevars::{get_freevars, freevar_info};
|
||||
import option::{some, none};
|
||||
import back::abi;
|
||||
|
@ -15,7 +15,7 @@ import back::link::{
|
|||
mangle_internal_name_by_path,
|
||||
mangle_internal_name_by_path_and_seq};
|
||||
import util::ppaux::ty_to_str;
|
||||
import trans::{
|
||||
import base::{
|
||||
trans_shared_malloc,
|
||||
type_of_inner,
|
||||
node_id_type,
|
||||
|
@ -70,7 +70,7 @@ import shape::{size_of};
|
|||
// closure".
|
||||
//
|
||||
// Typically an opaque closure suffices because I only manipulate it
|
||||
// by ptr. The routine trans_common::T_opaque_cbox_ptr() returns an
|
||||
// by ptr. The routine common::T_opaque_cbox_ptr() returns an
|
||||
// appropriate type for such an opaque closure; it allows access to the
|
||||
// first two fields, but not the others.
|
||||
//
|
||||
|
@ -246,7 +246,7 @@ fn allocate_cbox(bcx: @block_ctxt,
|
|||
(bcx, box, 0x12345678) // use arbitrary value for debugging
|
||||
}
|
||||
ty::ck_block {
|
||||
let {bcx, val: box} = trans::alloc_ty(bcx, cbox_ty);
|
||||
let {bcx, val: box} = base::alloc_ty(bcx, cbox_ty);
|
||||
(bcx, box, 0x12345678) // use arbitrary value for debugging
|
||||
}
|
||||
};
|
||||
|
@ -316,10 +316,10 @@ fn store_environment(
|
|||
let ti = none;
|
||||
|
||||
let {result:closure_td, _} =
|
||||
trans::get_tydesc(bcx, cbox_ty, true, ti);
|
||||
trans::lazily_emit_tydesc_glue(bcx, abi::tydesc_field_take_glue, ti);
|
||||
trans::lazily_emit_tydesc_glue(bcx, abi::tydesc_field_drop_glue, ti);
|
||||
trans::lazily_emit_tydesc_glue(bcx, abi::tydesc_field_free_glue, ti);
|
||||
base::get_tydesc(bcx, cbox_ty, true, ti);
|
||||
base::lazily_emit_tydesc_glue(bcx, abi::tydesc_field_take_glue, ti);
|
||||
base::lazily_emit_tydesc_glue(bcx, abi::tydesc_field_drop_glue, ti);
|
||||
base::lazily_emit_tydesc_glue(bcx, abi::tydesc_field_free_glue, ti);
|
||||
bcx = closure_td.bcx;
|
||||
let td = maybe_clone_tydesc(bcx, ck, closure_td.val);
|
||||
Store(bcx, td, bound_tydesc);
|
||||
|
@ -367,16 +367,16 @@ fn store_environment(
|
|||
let bound_data = bound_data.val;
|
||||
alt bv {
|
||||
env_expr(e) {
|
||||
bcx = trans::trans_expr_save_in(bcx, e, bound_data);
|
||||
bcx = base::trans_expr_save_in(bcx, e, bound_data);
|
||||
add_clean_temp_mem(bcx, bound_data, bound_tys[i]);
|
||||
temp_cleanups += [bound_data];
|
||||
}
|
||||
env_copy(val, ty, owned) {
|
||||
let val1 = load_if_immediate(bcx, val, ty);
|
||||
bcx = trans::copy_val(bcx, INIT, bound_data, val1, ty);
|
||||
bcx = base::copy_val(bcx, INIT, bound_data, val1, ty);
|
||||
}
|
||||
env_copy(val, ty, owned_imm) {
|
||||
bcx = trans::copy_val(bcx, INIT, bound_data, val, ty);
|
||||
bcx = base::copy_val(bcx, INIT, bound_data, val, ty);
|
||||
}
|
||||
env_copy(_, _, temporary) {
|
||||
fail "Cannot capture temporary upvar";
|
||||
|
@ -572,7 +572,7 @@ fn trans_bind_1(cx: @block_ctxt, outgoing_fty: ty::t,
|
|||
for bound in *bounds {
|
||||
alt bound {
|
||||
ty::bound_iface(_) {
|
||||
let dict = trans_impl::get_dict(
|
||||
let dict = impl::get_dict(
|
||||
bcx, option::get(ginfo.origins)[orig]);
|
||||
tds += [PointerCast(bcx, dict.val, val_ty(td))];
|
||||
orig += 1u;
|
|
@ -22,7 +22,7 @@ import lib::llvm::{True, False, Bool};
|
|||
import metadata::{csearch};
|
||||
|
||||
// FIXME: These should probably be pulled in here too.
|
||||
import trans::{type_of_fn, drop_ty};
|
||||
import base::{type_of_fn, drop_ty};
|
||||
|
||||
type namegen = fn@(str) -> str;
|
||||
fn new_namegen() -> namegen {
|
||||
|
@ -258,7 +258,7 @@ fn add_clean_temp(cx: @block_ctxt, val: ValueRef, ty: ty::t) {
|
|||
fn do_drop(bcx: @block_ctxt, val: ValueRef, ty: ty::t) ->
|
||||
@block_ctxt {
|
||||
if ty::type_is_immediate(bcx_tcx(bcx), ty) {
|
||||
ret trans::drop_ty_immediate(bcx, val, ty);
|
||||
ret base::drop_ty_immediate(bcx, val, ty);
|
||||
} else {
|
||||
ret drop_ty(bcx, val, ty);
|
||||
}
|
||||
|
@ -276,8 +276,8 @@ fn add_clean_temp_mem(cx: @block_ctxt, val: ValueRef, ty: ty::t) {
|
|||
}
|
||||
fn add_clean_free(cx: @block_ctxt, ptr: ValueRef, shared: bool) {
|
||||
let scope_cx = find_scope_cx(cx);
|
||||
let free_fn = if shared { bind trans::trans_shared_free(_, ptr) }
|
||||
else { bind trans::trans_free_if_not_gc(_, ptr) };
|
||||
let free_fn = if shared { bind base::trans_shared_free(_, ptr) }
|
||||
else { bind base::trans_free_if_not_gc(_, ptr) };
|
||||
scope_cx.cleanups += [clean_temp(ptr, free_fn)];
|
||||
scope_cx.lpad_dirty = true;
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ fn get_res_dtor(ccx: @crate_ctxt, did: ast::def_id, inner_t: ty::t)
|
|||
check non_ty_var(ccx, nil_res);
|
||||
let f_t = type_of_fn(ccx, [{mode: ast::by_ref, ty: inner_t}],
|
||||
nil_res, *param_bounds);
|
||||
ret trans::get_extern_const(ccx.externs, ccx.llmod,
|
||||
ret base::get_extern_const(ccx.externs, ccx.llmod,
|
||||
csearch::get_symbol(ccx.sess.cstore,
|
||||
did), f_t);
|
||||
}
|
||||
|
@ -420,10 +420,6 @@ fn find_scope_cx(cx: @block_ctxt) -> @block_ctxt {
|
|||
if cx.kind != NON_SCOPE_BLOCK { ret cx; }
|
||||
alt cx.parent {
|
||||
parent_some(b) { ret find_scope_cx(b); }
|
||||
parent_none {
|
||||
cx.fcx.lcx.ccx.sess.bug("trans::find_scope_cx() " +
|
||||
"called on parentless block_ctxt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -901,19 +897,19 @@ fn hash_dict_id(&&dp: dict_id) -> uint {
|
|||
}
|
||||
|
||||
fn umax(cx: @block_ctxt, a: ValueRef, b: ValueRef) -> ValueRef {
|
||||
let cond = trans_build::ICmp(cx, lib::llvm::LLVMIntULT, a, b);
|
||||
ret trans_build::Select(cx, cond, b, a);
|
||||
let cond = build::ICmp(cx, lib::llvm::LLVMIntULT, a, b);
|
||||
ret build::Select(cx, cond, b, a);
|
||||
}
|
||||
|
||||
fn umin(cx: @block_ctxt, a: ValueRef, b: ValueRef) -> ValueRef {
|
||||
let cond = trans_build::ICmp(cx, lib::llvm::LLVMIntULT, a, b);
|
||||
ret trans_build::Select(cx, cond, a, b);
|
||||
let cond = build::ICmp(cx, lib::llvm::LLVMIntULT, a, b);
|
||||
ret build::Select(cx, cond, a, b);
|
||||
}
|
||||
|
||||
fn align_to(cx: @block_ctxt, off: ValueRef, align: ValueRef) -> ValueRef {
|
||||
let mask = trans_build::Sub(cx, align, C_int(bcx_ccx(cx), 1));
|
||||
let bumped = trans_build::Add(cx, off, mask);
|
||||
ret trans_build::And(cx, bumped, trans_build::Not(cx, mask));
|
||||
let mask = build::Sub(cx, align, C_int(bcx_ccx(cx), 1));
|
||||
let bumped = build::Add(cx, off, mask);
|
||||
ret build::And(cx, bumped, build::Not(cx, mask));
|
||||
}
|
||||
|
||||
//
|
|
@ -1,7 +1,7 @@
|
|||
import core::ctypes::c_uint;
|
||||
import trans::*;
|
||||
import trans_common::*;
|
||||
import trans_build::*;
|
||||
import base::*;
|
||||
import common::*;
|
||||
import build::*;
|
||||
import option::{some, none};
|
||||
import syntax::{ast, ast_util};
|
||||
import metadata::csearch;
|
|
@ -3,13 +3,13 @@ import option::none;
|
|||
import syntax::ast;
|
||||
import lib::llvm::llvm::{ValueRef, TypeRef};
|
||||
import back::abi;
|
||||
import trans::{call_memmove, trans_shared_malloc, type_of_or_i8,
|
||||
import base::{call_memmove, trans_shared_malloc, type_of_or_i8,
|
||||
INIT, copy_val, load_if_immediate, get_tydesc,
|
||||
node_id_type, new_sub_block_ctxt, do_spill_noroot,
|
||||
dest};
|
||||
import shape::{llsize_of, size_of};
|
||||
import trans_build::*;
|
||||
import trans_common::*;
|
||||
import build::*;
|
||||
import common::*;
|
||||
|
||||
fn get_fill(bcx: @block_ctxt, vptr: ValueRef) -> ValueRef {
|
||||
Load(bcx, GEPi(bcx, vptr, [0, abi::vec_elt_fill]))
|
||||
|
@ -77,7 +77,7 @@ fn duplicate(bcx: @block_ctxt, vptr: ValueRef, vec_ty: ty::t) -> result {
|
|||
let unit_ty = ty::sequence_element_type(bcx_tcx(bcx), vec_ty);
|
||||
Store(bcx, fill, GEPi(bcx, newptr, [0, abi::vec_elt_alloc]));
|
||||
if ty::type_needs_drop(bcx_tcx(bcx), unit_ty) {
|
||||
bcx = iter_vec(bcx, newptr, vec_ty, trans::take_ty);
|
||||
bcx = iter_vec(bcx, newptr, vec_ty, base::take_ty);
|
||||
}
|
||||
ret rslt(bcx, newptr);
|
||||
}
|
||||
|
@ -89,9 +89,9 @@ fn make_free_glue(bcx: @block_ctxt, vptr: ValueRef, vec_ty: ty::t) ->
|
|||
let null_test = IsNull(bcx, vptr);
|
||||
CondBr(bcx, null_test, next_cx.llbb, drop_cx.llbb);
|
||||
if ty::type_needs_drop(bcx_tcx(bcx), unit_ty) {
|
||||
drop_cx = iter_vec(drop_cx, vptr, vec_ty, trans::drop_ty);
|
||||
drop_cx = iter_vec(drop_cx, vptr, vec_ty, base::drop_ty);
|
||||
}
|
||||
drop_cx = trans::trans_shared_free(drop_cx, vptr);
|
||||
drop_cx = base::trans_shared_free(drop_cx, vptr);
|
||||
Br(drop_cx, next_cx.llbb);
|
||||
ret next_cx;
|
||||
}
|
||||
|
@ -99,9 +99,9 @@ fn make_free_glue(bcx: @block_ctxt, vptr: ValueRef, vec_ty: ty::t) ->
|
|||
fn trans_vec(bcx: @block_ctxt, args: [@ast::expr], id: ast::node_id,
|
||||
dest: dest) -> @block_ctxt {
|
||||
let ccx = bcx_ccx(bcx), bcx = bcx;
|
||||
if dest == trans::ignore {
|
||||
if dest == base::ignore {
|
||||
for arg in args {
|
||||
bcx = trans::trans_expr(bcx, arg, trans::ignore);
|
||||
bcx = base::trans_expr(bcx, arg, base::ignore);
|
||||
}
|
||||
ret bcx;
|
||||
}
|
||||
|
@ -121,13 +121,13 @@ fn trans_vec(bcx: @block_ctxt, args: [@ast::expr], id: ast::node_id,
|
|||
let lleltptr = if ty::type_has_dynamic_size(bcx_tcx(bcx), unit_ty) {
|
||||
InBoundsGEP(bcx, dataptr, [Mul(bcx, C_uint(ccx, i), llunitsz)])
|
||||
} else { InBoundsGEP(bcx, dataptr, [C_uint(ccx, i)]) };
|
||||
bcx = trans::trans_expr_save_in(bcx, e, lleltptr);
|
||||
bcx = base::trans_expr_save_in(bcx, e, lleltptr);
|
||||
add_clean_temp_mem(bcx, lleltptr, unit_ty);
|
||||
temp_cleanups += [lleltptr];
|
||||
i += 1u;
|
||||
}
|
||||
for cln in temp_cleanups { revoke_clean(bcx, cln); }
|
||||
ret trans::store_in_dest(bcx, vptr, dest);
|
||||
ret base::store_in_dest(bcx, vptr, dest);
|
||||
}
|
||||
|
||||
fn trans_str(bcx: @block_ctxt, s: str, dest: dest) -> @block_ctxt {
|
||||
|
@ -140,7 +140,7 @@ fn trans_str(bcx: @block_ctxt, s: str, dest: dest) -> @block_ctxt {
|
|||
let bcx =
|
||||
call_memmove(bcx, get_dataptr(bcx, sptr, T_i8()), llcstr,
|
||||
C_uint(ccx, veclen)).bcx;
|
||||
ret trans::store_in_dest(bcx, sptr, dest);
|
||||
ret base::store_in_dest(bcx, sptr, dest);
|
||||
}
|
||||
|
||||
fn trans_append(cx: @block_ctxt, vec_ty: ty::t, lhsptr: ValueRef,
|
||||
|
@ -202,13 +202,13 @@ fn trans_append_literal(bcx: @block_ctxt, vptrptr: ValueRef, vec_ty: ty::t,
|
|||
let ti = none;
|
||||
let {bcx: bcx, val: td} =
|
||||
get_tydesc(bcx, elt_ty, false, ti).result;
|
||||
trans::lazily_emit_tydesc_glue(bcx, abi::tydesc_field_take_glue, ti);
|
||||
base::lazily_emit_tydesc_glue(bcx, abi::tydesc_field_take_glue, ti);
|
||||
let opaque_v = PointerCast(bcx, vptrptr,
|
||||
T_ptr(T_ptr(ccx.opaque_vec_type)));
|
||||
for val in vals {
|
||||
let {bcx: e_bcx, val: elt} = trans::trans_temp_expr(bcx, val);
|
||||
let {bcx: e_bcx, val: elt} = base::trans_temp_expr(bcx, val);
|
||||
bcx = e_bcx;
|
||||
let r = trans::spill_if_immediate(bcx, elt, elt_ty);
|
||||
let r = base::spill_if_immediate(bcx, elt, elt_ty);
|
||||
let spilled = r.val;
|
||||
bcx = r.bcx;
|
||||
Call(bcx, bcx_ccx(bcx).upcalls.vec_push,
|
||||
|
@ -253,7 +253,7 @@ fn trans_add(bcx: @block_ctxt, vec_ty: ty::t, lhs: ValueRef,
|
|||
|
||||
let bcx = iter_vec_raw(bcx, lhs, vec_ty, lhs_fill, copy_fn);
|
||||
bcx = iter_vec_raw(bcx, rhs, vec_ty, rhs_fill, copy_fn);
|
||||
ret trans::store_in_dest(bcx, new_vec_ptr, dest);
|
||||
ret base::store_in_dest(bcx, new_vec_ptr, dest);
|
||||
}
|
||||
|
||||
type val_and_ty_fn = fn@(@block_ctxt, ValueRef, ty::t) -> result;
|
|
@ -1,8 +1,8 @@
|
|||
import syntax::ast;
|
||||
import lib::llvm::llvm::ValueRef;
|
||||
import trans_common::*;
|
||||
import trans_build::*;
|
||||
import trans::{
|
||||
import common::*;
|
||||
import build::*;
|
||||
import base::{
|
||||
trans_shared_malloc,
|
||||
type_of_inner,
|
||||
node_id_type,
|
||||
|
@ -28,9 +28,9 @@ fn trans_uniq(bcx: @block_ctxt, contents: @ast::expr,
|
|||
check type_is_unique_box(bcx, uniq_ty);
|
||||
let {bcx, val: llptr} = alloc_uniq(bcx, uniq_ty);
|
||||
add_clean_free(bcx, llptr, true);
|
||||
bcx = trans::trans_expr_save_in(bcx, contents, llptr);
|
||||
bcx = base::trans_expr_save_in(bcx, contents, llptr);
|
||||
revoke_clean(bcx, llptr);
|
||||
ret trans::store_in_dest(bcx, llptr, dest);
|
||||
ret base::store_in_dest(bcx, llptr, dest);
|
||||
}
|
||||
|
||||
fn alloc_uniq(cx: @block_ctxt, uniq_ty: ty::t)
|
||||
|
@ -92,6 +92,6 @@ fn duplicate(bcx: @block_ctxt, v: ValueRef, t: ty::t)
|
|||
|
||||
let src = load_if_immediate(bcx, v, content_ty);
|
||||
let dst = llptr;
|
||||
let bcx = trans::copy_val(bcx, INIT, dst, src, content_ty);
|
||||
let bcx = base::copy_val(bcx, INIT, dst, src, content_ty);
|
||||
ret rslt(bcx, dst);
|
||||
}
|
|
@ -14,14 +14,16 @@ use std (name = "std",
|
|||
url = "http://rust-lang.org/src/std");
|
||||
|
||||
mod middle {
|
||||
mod trans_common;
|
||||
mod trans_build;
|
||||
mod trans;
|
||||
mod trans_alt;
|
||||
mod trans_uniq;
|
||||
mod trans_closure;
|
||||
mod trans_vec;
|
||||
mod trans_impl;
|
||||
mod trans {
|
||||
mod common;
|
||||
mod build;
|
||||
mod base;
|
||||
mod alt;
|
||||
mod uniq;
|
||||
mod closure;
|
||||
mod tvec;
|
||||
mod impl;
|
||||
}
|
||||
mod ty;
|
||||
mod ast_map;
|
||||
mod resolve;
|
||||
|
|
Loading…
Add table
Reference in a new issue