librustc: De-export some of trans. rs=deexporting

This commit is contained in:
Patrick Walton 2013-01-29 17:57:02 -08:00
parent 4b8dfad5cd
commit a47fa9b32f
8 changed files with 218 additions and 215 deletions

View File

@ -39,29 +39,29 @@ use syntax::visit;
// Represents a (possibly monomorphized) top-level fn item or method // Represents a (possibly monomorphized) top-level fn item or method
// item. Note that this is just the fn-ptr and is not a Rust closure // item. Note that this is just the fn-ptr and is not a Rust closure
// value (which is a pair). // value (which is a pair).
struct FnData { pub struct FnData {
llfn: ValueRef, llfn: ValueRef,
} }
struct MethodData { pub struct MethodData {
llfn: ValueRef, llfn: ValueRef,
llself: ValueRef, llself: ValueRef,
self_ty: ty::t, self_ty: ty::t,
self_mode: ast::rmode self_mode: ast::rmode
} }
enum CalleeData { pub enum CalleeData {
Closure(Datum), Closure(Datum),
Fn(FnData), Fn(FnData),
Method(MethodData) Method(MethodData)
} }
struct Callee { pub struct Callee {
bcx: block, bcx: block,
data: CalleeData data: CalleeData
} }
fn trans(bcx: block, expr: @ast::expr) -> Callee { pub fn trans(bcx: block, expr: @ast::expr) -> Callee {
let _icx = bcx.insn_ctxt("trans_callee"); let _icx = bcx.insn_ctxt("trans_callee");
// pick out special kinds of expressions that can be called: // pick out special kinds of expressions that can be called:
@ -133,17 +133,16 @@ fn trans(bcx: block, expr: @ast::expr) -> Callee {
} }
} }
fn trans_fn_ref_to_callee(bcx: block, pub fn trans_fn_ref_to_callee(bcx: block,
def_id: ast::def_id, def_id: ast::def_id,
ref_id: ast::node_id) -> Callee ref_id: ast::node_id) -> Callee {
{
Callee {bcx: bcx, Callee {bcx: bcx,
data: Fn(trans_fn_ref(bcx, def_id, ref_id))} data: Fn(trans_fn_ref(bcx, def_id, ref_id))}
} }
fn trans_fn_ref(bcx: block, pub fn trans_fn_ref(bcx: block,
def_id: ast::def_id, def_id: ast::def_id,
ref_id: ast::node_id) -> FnData { ref_id: ast::node_id) -> FnData {
/*! /*!
* *
* Translates a reference (with id `ref_id`) to the fn/method * Translates a reference (with id `ref_id`) to the fn/method
@ -158,26 +157,25 @@ fn trans_fn_ref(bcx: block,
trans_fn_ref_with_vtables(bcx, def_id, ref_id, type_params, vtables) trans_fn_ref_with_vtables(bcx, def_id, ref_id, type_params, vtables)
} }
fn trans_fn_ref_with_vtables_to_callee(bcx: block, pub fn trans_fn_ref_with_vtables_to_callee(
def_id: ast::def_id, bcx: block,
ref_id: ast::node_id, def_id: ast::def_id,
+type_params: ~[ty::t], ref_id: ast::node_id,
vtables: Option<typeck::vtable_res>) +type_params: ~[ty::t],
-> Callee vtables: Option<typeck::vtable_res>)
{ -> Callee {
Callee {bcx: bcx, Callee {bcx: bcx,
data: Fn(trans_fn_ref_with_vtables(bcx, def_id, ref_id, data: Fn(trans_fn_ref_with_vtables(bcx, def_id, ref_id,
type_params, vtables))} type_params, vtables))}
} }
fn trans_fn_ref_with_vtables( pub fn trans_fn_ref_with_vtables(
bcx: block, // bcx: block, //
def_id: ast::def_id, // def id of fn def_id: ast::def_id, // def id of fn
ref_id: ast::node_id, // node id of use of fn; may be zero if N/A ref_id: ast::node_id, // node id of use of fn; may be zero if N/A
+type_params: ~[ty::t], // values for fn's ty params +type_params: ~[ty::t], // values for fn's ty params
vtables: Option<typeck::vtable_res>) vtables: Option<typeck::vtable_res>)
-> FnData -> FnData {
{
//! //!
// //
// Translates a reference to a fn/method item, monomorphizing and // Translates a reference to a fn/method item, monomorphizing and
@ -289,26 +287,25 @@ fn trans_fn_ref_with_vtables(
// ______________________________________________________________________ // ______________________________________________________________________
// Translating calls // Translating calls
fn trans_call(in_cx: block, pub fn trans_call(in_cx: block,
call_ex: @ast::expr, call_ex: @ast::expr,
f: @ast::expr, f: @ast::expr,
args: CallArgs, args: CallArgs,
id: ast::node_id, id: ast::node_id,
dest: expr::Dest) dest: expr::Dest)
-> block -> block {
{
let _icx = in_cx.insn_ctxt("trans_call"); let _icx = in_cx.insn_ctxt("trans_call");
trans_call_inner( trans_call_inner(
in_cx, call_ex.info(), expr_ty(in_cx, f), node_id_type(in_cx, id), in_cx, call_ex.info(), expr_ty(in_cx, f), node_id_type(in_cx, id),
|cx| trans(cx, f), args, dest, DontAutorefArg) |cx| trans(cx, f), args, dest, DontAutorefArg)
} }
fn trans_method_call(in_cx: block, pub fn trans_method_call(in_cx: block,
call_ex: @ast::expr, call_ex: @ast::expr,
rcvr: @ast::expr, rcvr: @ast::expr,
args: CallArgs, args: CallArgs,
dest: expr::Dest) dest: expr::Dest)
-> block { -> block {
let _icx = in_cx.insn_ctxt("trans_method_call"); let _icx = in_cx.insn_ctxt("trans_method_call");
trans_call_inner( trans_call_inner(
in_cx, in_cx,
@ -335,8 +332,11 @@ fn trans_method_call(in_cx: block,
DontAutorefArg) DontAutorefArg)
} }
fn trans_rtcall_or_lang_call(bcx: block, did: ast::def_id, args: ~[ValueRef], pub fn trans_rtcall_or_lang_call(bcx: block,
dest: expr::Dest) -> block { did: ast::def_id,
args: ~[ValueRef],
dest: expr::Dest)
-> block {
let fty = if did.crate == ast::local_crate { let fty = if did.crate == ast::local_crate {
ty::node_id_to_type(bcx.ccx().tcx, did.node) ty::node_id_to_type(bcx.ccx().tcx, did.node)
} else { } else {
@ -349,11 +349,12 @@ fn trans_rtcall_or_lang_call(bcx: block, did: ast::def_id, args: ~[ValueRef],
ArgVals(args), dest, DontAutorefArg); ArgVals(args), dest, DontAutorefArg);
} }
fn trans_rtcall_or_lang_call_with_type_params(bcx: block, pub fn trans_rtcall_or_lang_call_with_type_params(bcx: block,
did: ast::def_id, did: ast::def_id,
args: ~[ValueRef], args: ~[ValueRef],
type_params: ~[ty::t], type_params: ~[ty::t],
dest: expr::Dest) -> block { dest: expr::Dest)
-> block {
let fty; let fty;
if did.crate == ast::local_crate { if did.crate == ast::local_crate {
fty = ty::node_id_to_type(bcx.tcx(), did.node); fty = ty::node_id_to_type(bcx.tcx(), did.node);
@ -389,7 +390,7 @@ fn trans_rtcall_or_lang_call_with_type_params(bcx: block,
ArgVals(args), dest, DontAutorefArg); ArgVals(args), dest, DontAutorefArg);
} }
fn body_contains_ret(body: ast::blk) -> bool { pub fn body_contains_ret(body: ast::blk) -> bool {
let cx = {mut found: false}; let cx = {mut found: false};
visit::visit_block(body, cx, visit::mk_vt(@visit::Visitor { visit::visit_block(body, cx, visit::mk_vt(@visit::Visitor {
visit_item: |_i, _cx, _v| { }, visit_item: |_i, _cx, _v| { },
@ -407,7 +408,7 @@ fn body_contains_ret(body: ast::blk) -> bool {
} }
// See [Note-arg-mode] // See [Note-arg-mode]
fn trans_call_inner( pub fn trans_call_inner(
++in_cx: block, ++in_cx: block,
call_info: Option<node_info>, call_info: Option<node_info>,
fn_expr_ty: ty::t, fn_expr_ty: ty::t,
@ -415,8 +416,7 @@ fn trans_call_inner(
get_callee: fn(block) -> Callee, get_callee: fn(block) -> Callee,
args: CallArgs, args: CallArgs,
dest: expr::Dest, dest: expr::Dest,
autoref_arg: AutorefArg) -> block autoref_arg: AutorefArg) -> block {
{
do base::with_scope(in_cx, call_info, ~"call") |cx| { do base::with_scope(in_cx, call_info, ~"call") |cx| {
let ret_in_loop = match /*bad*/copy args { let ret_in_loop = match /*bad*/copy args {
ArgExprs(args) => { ArgExprs(args) => {
@ -520,21 +520,19 @@ fn trans_call_inner(
} }
} }
pub enum CallArgs {
enum CallArgs {
ArgExprs(~[@ast::expr]), ArgExprs(~[@ast::expr]),
ArgVals(~[ValueRef]) ArgVals(~[ValueRef])
} }
fn trans_args(cx: block, pub fn trans_args(cx: block,
llenv: ValueRef, llenv: ValueRef,
+args: CallArgs, +args: CallArgs,
fn_ty: ty::t, fn_ty: ty::t,
dest: expr::Dest, dest: expr::Dest,
ret_flag: Option<ValueRef>, ret_flag: Option<ValueRef>,
+autoref_arg: AutorefArg) +autoref_arg: AutorefArg)
-> {bcx: block, args: ~[ValueRef], retslot: ValueRef} -> {bcx: block, args: ~[ValueRef], retslot: ValueRef} {
{
let _icx = cx.insn_ctxt("trans_args"); let _icx = cx.insn_ctxt("trans_args");
let mut temp_cleanups = ~[]; let mut temp_cleanups = ~[];
let arg_tys = ty::ty_fn_args(fn_ty); let arg_tys = ty::ty_fn_args(fn_ty);
@ -594,21 +592,19 @@ fn trans_args(cx: block,
return {bcx: bcx, args: llargs, retslot: llretslot}; return {bcx: bcx, args: llargs, retslot: llretslot};
} }
enum AutorefArg { pub enum AutorefArg {
DontAutorefArg, DontAutorefArg,
DoAutorefArg DoAutorefArg
} }
// temp_cleanups: cleanups that should run only if failure occurs before the // temp_cleanups: cleanups that should run only if failure occurs before the
// call takes place: // call takes place:
fn trans_arg_expr(bcx: block, pub fn trans_arg_expr(bcx: block,
formal_ty: ty::arg, formal_ty: ty::arg,
arg_expr: @ast::expr, arg_expr: @ast::expr,
temp_cleanups: &mut ~[ValueRef], temp_cleanups: &mut ~[ValueRef],
ret_flag: Option<ValueRef>, ret_flag: Option<ValueRef>,
+autoref_arg: AutorefArg) +autoref_arg: AutorefArg) -> Result {
-> Result
{
let _icx = bcx.insn_ctxt("trans_arg_expr"); let _icx = bcx.insn_ctxt("trans_arg_expr");
let ccx = bcx.ccx(); let ccx = bcx.ccx();

View File

@ -18,9 +18,12 @@ use middle::trans::datum::*;
use core::str; use core::str;
fn macros() { include!("macros.rs"); } // FIXME(#3114): Macro import/export. pub fn macros() {
// FIXME(#3114): Macro import/export.
include!("macros.rs");
}
fn trans_block(bcx: block, b: ast::blk, dest: expr::Dest) -> block { pub fn trans_block(bcx: block, b: ast::blk, dest: expr::Dest) -> block {
let _icx = bcx.insn_ctxt("trans_block"); let _icx = bcx.insn_ctxt("trans_block");
let mut bcx = bcx; let mut bcx = bcx;
do block_locals(b) |local| { do block_locals(b) |local| {
@ -42,13 +45,12 @@ fn trans_block(bcx: block, b: ast::blk, dest: expr::Dest) -> block {
return bcx; return bcx;
} }
fn trans_if(bcx: block, pub fn trans_if(bcx: block,
cond: @ast::expr, cond: @ast::expr,
thn: ast::blk, thn: ast::blk,
els: Option<@ast::expr>, els: Option<@ast::expr>,
dest: expr::Dest) dest: expr::Dest)
-> block -> block {
{
debug!("trans_if(bcx=%s, cond=%s, thn=%?, dest=%s)", debug!("trans_if(bcx=%s, cond=%s, thn=%?, dest=%s)",
bcx.to_str(), bcx.expr_to_str(cond), thn.node.id, bcx.to_str(), bcx.expr_to_str(cond), thn.node.id,
dest.to_str(bcx.ccx())); dest.to_str(bcx.ccx()));
@ -95,7 +97,7 @@ fn trans_if(bcx: block,
} }
fn join_blocks(parent_bcx: block, in_cxs: ~[block]) -> block { pub fn join_blocks(parent_bcx: block, in_cxs: ~[block]) -> block {
let out = sub_block(parent_bcx, ~"join"); let out = sub_block(parent_bcx, ~"join");
let mut reachable = false; let mut reachable = false;
for vec::each(in_cxs) |bcx| { for vec::each(in_cxs) |bcx| {
@ -110,8 +112,7 @@ fn join_blocks(parent_bcx: block, in_cxs: ~[block]) -> block {
return out; return out;
} }
fn trans_while(bcx: block, cond: @ast::expr, body: ast::blk) pub fn trans_while(bcx: block, cond: @ast::expr, body: ast::blk) -> block {
-> block {
let _icx = bcx.insn_ctxt("trans_while"); let _icx = bcx.insn_ctxt("trans_while");
let next_bcx = sub_block(bcx, ~"while next"); let next_bcx = sub_block(bcx, ~"while next");
@ -149,7 +150,10 @@ fn trans_while(bcx: block, cond: @ast::expr, body: ast::blk)
return next_bcx; return next_bcx;
} }
fn trans_loop(bcx:block, body: ast::blk, opt_label: Option<ident>) -> block { pub fn trans_loop(bcx:block,
body: ast::blk,
opt_label: Option<ident>)
-> block {
let _icx = bcx.insn_ctxt("trans_loop"); let _icx = bcx.insn_ctxt("trans_loop");
let next_bcx = sub_block(bcx, ~"next"); let next_bcx = sub_block(bcx, ~"next");
let body_bcx_in = loop_scope_block(bcx, next_bcx, opt_label, ~"`loop`", let body_bcx_in = loop_scope_block(bcx, next_bcx, opt_label, ~"`loop`",
@ -160,11 +164,10 @@ fn trans_loop(bcx:block, body: ast::blk, opt_label: Option<ident>) -> block {
return next_bcx; return next_bcx;
} }
fn trans_log(log_ex: @ast::expr, pub fn trans_log(log_ex: @ast::expr,
lvl: @ast::expr, lvl: @ast::expr,
bcx: block, bcx: block,
e: @ast::expr) -> block e: @ast::expr) -> block {
{
let _icx = bcx.insn_ctxt("trans_log"); let _icx = bcx.insn_ctxt("trans_log");
let ccx = bcx.ccx(); let ccx = bcx.ccx();
let mut bcx = bcx; let mut bcx = bcx;
@ -223,8 +226,10 @@ fn trans_log(log_ex: @ast::expr,
} }
} }
fn trans_break_cont(bcx: block, opt_label: Option<ident>, to_end: bool) pub fn trans_break_cont(bcx: block,
-> block { opt_label: Option<ident>,
to_end: bool)
-> block {
let _icx = bcx.insn_ctxt("trans_break_cont"); let _icx = bcx.insn_ctxt("trans_break_cont");
// Locate closest loop block, outputting cleanup as we go. // Locate closest loop block, outputting cleanup as we go.
let mut unwind = bcx; let mut unwind = bcx;
@ -270,15 +275,15 @@ fn trans_break_cont(bcx: block, opt_label: Option<ident>, to_end: bool)
return bcx; return bcx;
} }
fn trans_break(bcx: block, label_opt: Option<ident>) -> block { pub fn trans_break(bcx: block, label_opt: Option<ident>) -> block {
return trans_break_cont(bcx, label_opt, true); return trans_break_cont(bcx, label_opt, true);
} }
fn trans_cont(bcx: block, label_opt: Option<ident>) -> block { pub fn trans_cont(bcx: block, label_opt: Option<ident>) -> block {
return trans_break_cont(bcx, label_opt, false); return trans_break_cont(bcx, label_opt, false);
} }
fn trans_ret(bcx: block, e: Option<@ast::expr>) -> block { pub fn trans_ret(bcx: block, e: Option<@ast::expr>) -> block {
let _icx = bcx.insn_ctxt("trans_ret"); let _icx = bcx.insn_ctxt("trans_ret");
let mut bcx = bcx; let mut bcx = bcx;
let retptr = match copy bcx.fcx.loop_ret { let retptr = match copy bcx.fcx.loop_ret {
@ -306,8 +311,12 @@ fn trans_ret(bcx: block, e: Option<@ast::expr>) -> block {
Unreachable(bcx); Unreachable(bcx);
return bcx; return bcx;
} }
fn trans_check_expr(bcx: block, chk_expr: @ast::expr,
pred_expr: @ast::expr, s: ~str) -> block { pub fn trans_check_expr(bcx: block,
chk_expr: @ast::expr,
pred_expr: @ast::expr,
s: ~str)
-> block {
let _icx = bcx.insn_ctxt("trans_check_expr"); let _icx = bcx.insn_ctxt("trans_check_expr");
let expr_str = s + ~" " + expr_to_str(pred_expr, bcx.ccx().sess.intr()) let expr_str = s + ~" " + expr_to_str(pred_expr, bcx.ccx().sess.intr())
+ ~" failed"; + ~" failed";
@ -321,9 +330,10 @@ fn trans_check_expr(bcx: block, chk_expr: @ast::expr,
} }
} }
fn trans_fail_expr(bcx: block, pub fn trans_fail_expr(bcx: block,
sp_opt: Option<span>, sp_opt: Option<span>,
fail_expr: Option<@ast::expr>) -> block { fail_expr: Option<@ast::expr>)
-> block {
let _icx = bcx.insn_ctxt("trans_fail_expr"); let _icx = bcx.insn_ctxt("trans_fail_expr");
let mut bcx = bcx; let mut bcx = bcx;
match fail_expr { match fail_expr {
@ -347,17 +357,19 @@ fn trans_fail_expr(bcx: block,
} }
} }
fn trans_fail(bcx: block, sp_opt: Option<span>, +fail_str: ~str) pub fn trans_fail(bcx: block,
-> block sp_opt: Option<span>,
{ +fail_str: ~str)
-> block {
let _icx = bcx.insn_ctxt("trans_fail"); let _icx = bcx.insn_ctxt("trans_fail");
let V_fail_str = C_cstr(bcx.ccx(), fail_str); let V_fail_str = C_cstr(bcx.ccx(), fail_str);
return trans_fail_value(bcx, sp_opt, V_fail_str); return trans_fail_value(bcx, sp_opt, V_fail_str);
} }
fn trans_fail_value(bcx: block, sp_opt: Option<span>, V_fail_str: ValueRef) fn trans_fail_value(bcx: block,
-> block sp_opt: Option<span>,
{ V_fail_str: ValueRef)
-> block {
let _icx = bcx.insn_ctxt("trans_fail_value"); let _icx = bcx.insn_ctxt("trans_fail_value");
let ccx = bcx.ccx(); let ccx = bcx.ccx();
let {V_filename, V_line} = match sp_opt { let {V_filename, V_line} = match sp_opt {
@ -381,8 +393,8 @@ fn trans_fail_value(bcx: block, sp_opt: Option<span>, V_fail_str: ValueRef)
return bcx; return bcx;
} }
fn trans_fail_bounds_check(bcx: block, sp: span, pub fn trans_fail_bounds_check(bcx: block, sp: span,
index: ValueRef, len: ValueRef) -> block { index: ValueRef, len: ValueRef) -> block {
let _icx = bcx.insn_ctxt("trans_fail_bounds_check"); let _icx = bcx.insn_ctxt("trans_fail_bounds_check");
let ccx = bcx.ccx(); let ccx = bcx.ccx();

View File

@ -114,12 +114,12 @@ use core::uint;
use core::vec; use core::vec;
use syntax::parse::token::special_idents; use syntax::parse::token::special_idents;
enum CopyAction { pub enum CopyAction {
INIT, INIT,
DROP_EXISTING DROP_EXISTING
} }
struct Datum { pub struct Datum {
/// The llvm value. This is either a pointer to the Rust value or /// The llvm value. This is either a pointer to the Rust value or
/// the value itself, depending on `mode` below. /// the value itself, depending on `mode` below.
val: ValueRef, val: ValueRef,
@ -137,12 +137,12 @@ struct Datum {
source: DatumSource source: DatumSource
} }
struct DatumBlock { pub struct DatumBlock {
bcx: block, bcx: block,
datum: Datum, datum: Datum,
} }
enum DatumMode { pub enum DatumMode {
/// `val` is a pointer to the actual value (and thus has type *T) /// `val` is a pointer to the actual value (and thus has type *T)
ByRef, ByRef,
@ -150,7 +150,7 @@ enum DatumMode {
ByValue, ByValue,
} }
impl DatumMode { pub impl DatumMode {
fn is_by_ref() -> bool { fn is_by_ref() -> bool {
match self { ByRef => true, ByValue => false } match self { ByRef => true, ByValue => false }
} }
@ -160,27 +160,27 @@ impl DatumMode {
} }
} }
impl DatumMode: cmp::Eq { pub impl DatumMode: cmp::Eq {
pure fn eq(&self, other: &DatumMode) -> bool { pure fn eq(&self, other: &DatumMode) -> bool {
(*self) as uint == (*other as uint) (*self) as uint == (*other as uint)
} }
pure fn ne(&self, other: &DatumMode) -> bool { !(*self).eq(other) } pure fn ne(&self, other: &DatumMode) -> bool { !(*self).eq(other) }
} }
impl DatumMode: to_bytes::IterBytes { pub impl DatumMode: to_bytes::IterBytes {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as uint).iter_bytes(lsb0, f) (*self as uint).iter_bytes(lsb0, f)
} }
} }
/// See `Datum Sources` section at the head of this module. /// See `Datum Sources` section at the head of this module.
enum DatumSource { pub enum DatumSource {
FromRvalue, FromRvalue,
FromLvalue, FromLvalue,
FromLastUseLvalue, FromLastUseLvalue,
} }
impl DatumSource { pub impl DatumSource {
fn is_rvalue() -> bool { fn is_rvalue() -> bool {
match self { match self {
FromRvalue => true, FromRvalue => true,
@ -196,16 +196,19 @@ impl DatumSource {
} }
} }
fn immediate_rvalue(val: ValueRef, ty: ty::t) -> Datum { pub fn immediate_rvalue(val: ValueRef, ty: ty::t) -> Datum {
return Datum {val: val, ty: ty, return Datum {val: val, ty: ty,
mode: ByValue, source: FromRvalue}; mode: ByValue, source: FromRvalue};
} }
fn immediate_rvalue_bcx(bcx: block, val: ValueRef, ty: ty::t) -> DatumBlock { pub fn immediate_rvalue_bcx(bcx: block,
val: ValueRef,
ty: ty::t)
-> DatumBlock {
return DatumBlock {bcx: bcx, datum: immediate_rvalue(val, ty)}; return DatumBlock {bcx: bcx, datum: immediate_rvalue(val, ty)};
} }
fn scratch_datum(bcx: block, ty: ty::t, zero: bool) -> Datum { pub fn scratch_datum(bcx: block, ty: ty::t, zero: bool) -> Datum {
/*! /*!
* *
* Allocates temporary space on the stack using alloca() and * Allocates temporary space on the stack using alloca() and
@ -221,7 +224,7 @@ fn scratch_datum(bcx: block, ty: ty::t, zero: bool) -> Datum {
Datum { val: scratch, ty: ty, mode: ByRef, source: FromRvalue } Datum { val: scratch, ty: ty, mode: ByRef, source: FromRvalue }
} }
fn appropriate_mode(ty: ty::t) -> DatumMode { pub fn appropriate_mode(ty: ty::t) -> DatumMode {
/*! /*!
* *
* Indicates the "appropriate" mode for this value, * Indicates the "appropriate" mode for this value,
@ -237,7 +240,7 @@ fn appropriate_mode(ty: ty::t) -> DatumMode {
} }
} }
impl Datum { pub impl Datum {
fn store_will_move() -> bool { fn store_will_move() -> bool {
match self.source { match self.source {
FromRvalue | FromLastUseLvalue => true, FromRvalue | FromLastUseLvalue => true,
@ -348,7 +351,7 @@ impl Datum {
Store(bcx, self.val, dst); Store(bcx, self.val, dst);
} }
ByRef => { ByRef => {
memcpy_ty(bcx, dst, self.val, self.ty); base::memcpy_ty(bcx, dst, self.val, self.ty);
} }
} }
@ -375,7 +378,7 @@ impl Datum {
match self.mode { match self.mode {
ByRef => { ByRef => {
glue::memcpy_ty(bcx, dst, self.val, self.ty); base::memcpy_ty(bcx, dst, self.val, self.ty);
} }
ByValue => { ByValue => {
Store(bcx, self.val, dst); Store(bcx, self.val, dst);
@ -823,7 +826,7 @@ impl Datum {
} }
} }
impl DatumBlock { pub impl DatumBlock {
fn unpack(bcx: &mut block) -> Datum { fn unpack(bcx: &mut block) -> Datum {
*bcx = self.bcx; *bcx = self.bcx;
return self.datum; return self.datum;
@ -871,7 +874,7 @@ impl DatumBlock {
} }
} }
impl CopyAction : cmp::Eq { pub impl CopyAction : cmp::Eq {
pure fn eq(&self, other: &CopyAction) -> bool { pure fn eq(&self, other: &CopyAction) -> bool {
match ((*self), (*other)) { match ((*self), (*other)) {
(INIT, INIT) => true, (INIT, INIT) => true,

View File

@ -137,20 +137,6 @@ use syntax::print::pprust::{expr_to_str};
use syntax::ast; use syntax::ast;
use syntax::ast::spanned; use syntax::ast::spanned;
// The primary two functions for translating expressions:
export trans_to_datum, trans_into;
// More specific variants than trans_to_datum/trans_into that are useful
// in some scenarios:
export trans_local_var;
// Other helpers, types, and so forth:
export with_field_tys;
export Dest, SaveIn, Ignore;
export cast_type_kind;
export cast_kind, cast_pointer, cast_integral, cast_float;
export cast_enum, cast_other;
// Destinations // Destinations
// These are passed around by the code generating functions to track the // These are passed around by the code generating functions to track the
@ -158,7 +144,7 @@ export cast_enum, cast_other;
fn macros() { include!("macros.rs"); } // FIXME(#3114): Macro import/export. fn macros() { include!("macros.rs"); } // FIXME(#3114): Macro import/export.
enum Dest { pub enum Dest {
SaveIn(ValueRef), SaveIn(ValueRef),
Ignore, Ignore,
} }
@ -190,7 +176,7 @@ fn drop_and_cancel_clean(bcx: block, dat: Datum) -> block {
return bcx; return bcx;
} }
fn trans_to_datum(bcx: block, expr: @ast::expr) -> DatumBlock { pub fn trans_to_datum(bcx: block, expr: @ast::expr) -> DatumBlock {
debug!("trans_to_datum(expr=%s)", bcx.expr_to_str(expr)); debug!("trans_to_datum(expr=%s)", bcx.expr_to_str(expr));
return match bcx.tcx().adjustments.find(expr.id) { return match bcx.tcx().adjustments.find(expr.id) {
None => { None => {
@ -271,7 +257,7 @@ fn trans_to_datum(bcx: block, expr: @ast::expr) -> DatumBlock {
} }
} }
fn trans_into(bcx: block, expr: @ast::expr, dest: Dest) -> block { pub fn trans_into(bcx: block, expr: @ast::expr, dest: Dest) -> block {
return match bcx.tcx().adjustments.find(expr.id) { return match bcx.tcx().adjustments.find(expr.id) {
None => trans_into_unadjusted(bcx, expr, dest), None => trans_into_unadjusted(bcx, expr, dest),
Some(_) => { Some(_) => {
@ -830,10 +816,10 @@ fn trans_def_lvalue(bcx: block,
} }
} }
fn trans_local_var(bcx: block, pub fn trans_local_var(bcx: block,
def: ast::def, def: ast::def,
expr_id_opt: Option<ast::node_id>) expr_id_opt: Option<ast::node_id>)
-> Datum { -> Datum {
let _icx = bcx.insn_ctxt("trans_local_var"); let _icx = bcx.insn_ctxt("trans_local_var");
return match def { return match def {
@ -949,10 +935,10 @@ fn fn_data_to_datum(bcx: block,
// The optional node ID here is the node ID of the path identifying the enum // The optional node ID here is the node ID of the path identifying the enum
// variant in use. If none, this cannot possibly an enum variant (so, if it // variant in use. If none, this cannot possibly an enum variant (so, if it
// is and `node_id_opt` is none, this function fails). // is and `node_id_opt` is none, this function fails).
fn with_field_tys<R>(tcx: ty::ctxt, pub fn with_field_tys<R>(tcx: ty::ctxt,
ty: ty::t, ty: ty::t,
node_id_opt: Option<ast::node_id>, node_id_opt: Option<ast::node_id>,
op: fn(bool, (&[ty::field])) -> R) -> R { op: fn(bool, (&[ty::field])) -> R) -> R {
match ty::get(ty).sty { match ty::get(ty).sty {
ty::ty_rec(ref fields) => { ty::ty_rec(ref fields) => {
op(false, *fields) op(false, *fields)
@ -1521,7 +1507,7 @@ fn float_cast(bcx: block, lldsttype: TypeRef, llsrctype: TypeRef,
} else { llsrc }; } else { llsrc };
} }
enum cast_kind { pub enum cast_kind {
cast_pointer, cast_pointer,
cast_integral, cast_integral,
cast_float, cast_float,
@ -1547,7 +1533,7 @@ impl cast_kind : cmp::Eq {
pure fn ne(&self, other: &cast_kind) -> bool { !(*self).eq(other) } pure fn ne(&self, other: &cast_kind) -> bool { !(*self).eq(other) }
} }
fn cast_type_kind(t: ty::t) -> cast_kind { pub fn cast_type_kind(t: ty::t) -> cast_kind {
match ty::get(t).sty { match ty::get(t).sty {
ty::ty_float(*) => cast_float, ty::ty_float(*) => cast_float,
ty::ty_ptr(*) => cast_pointer, ty::ty_ptr(*) => cast_pointer,

View File

@ -28,7 +28,7 @@ use middle::trans::uniq;
use core::io; use core::io;
use core::str; use core::str;
fn trans_free(cx: block, v: ValueRef) -> block { pub fn trans_free(cx: block, v: ValueRef) -> block {
let _icx = cx.insn_ctxt("trans_free"); let _icx = cx.insn_ctxt("trans_free");
callee::trans_rtcall_or_lang_call( callee::trans_rtcall_or_lang_call(
cx, cx,
@ -37,7 +37,7 @@ fn trans_free(cx: block, v: ValueRef) -> block {
expr::Ignore) expr::Ignore)
} }
fn trans_unique_free(cx: block, v: ValueRef) -> block { pub fn trans_unique_free(cx: block, v: ValueRef) -> block {
let _icx = cx.insn_ctxt("trans_unique_free"); let _icx = cx.insn_ctxt("trans_unique_free");
callee::trans_rtcall_or_lang_call( callee::trans_rtcall_or_lang_call(
cx, cx,
@ -46,7 +46,7 @@ fn trans_unique_free(cx: block, v: ValueRef) -> block {
expr::Ignore) expr::Ignore)
} }
fn take_ty(cx: block, v: ValueRef, t: ty::t) -> 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. // NB: v is an *alias* of type t here, not a direct value.
let _icx = cx.insn_ctxt("take_ty"); let _icx = cx.insn_ctxt("take_ty");
if ty::type_needs_drop(cx.tcx(), t) { if ty::type_needs_drop(cx.tcx(), t) {
@ -55,7 +55,7 @@ fn take_ty(cx: block, v: ValueRef, t: ty::t) -> block {
return cx; return cx;
} }
fn drop_ty(cx: block, v: ValueRef, t: ty::t) -> 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. // NB: v is an *alias* of type t here, not a direct value.
let _icx = cx.insn_ctxt("drop_ty"); let _icx = cx.insn_ctxt("drop_ty");
if ty::type_needs_drop(cx.tcx(), t) { if ty::type_needs_drop(cx.tcx(), t) {
@ -64,7 +64,11 @@ fn drop_ty(cx: block, v: ValueRef, t: ty::t) -> block {
return cx; return cx;
} }
fn drop_ty_root(bcx: block, v: ValueRef, rooted: bool, t: ty::t) -> block { pub fn drop_ty_root(bcx: block,
v: ValueRef,
rooted: bool,
t: ty::t)
-> block {
if rooted { if rooted {
// NB: v is a raw ptr to an addrspace'd ptr to the value. // NB: v is a raw ptr to an addrspace'd ptr to the value.
let v = PointerCast(bcx, Load(bcx, v), T_ptr(type_of(bcx.ccx(), t))); let v = PointerCast(bcx, Load(bcx, v), T_ptr(type_of(bcx.ccx(), t)));
@ -74,7 +78,7 @@ fn drop_ty_root(bcx: block, v: ValueRef, rooted: bool, t: ty::t) -> block {
} }
} }
fn drop_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> block { pub fn drop_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> block {
let _icx = bcx.insn_ctxt("drop_ty_immediate"); let _icx = bcx.insn_ctxt("drop_ty_immediate");
match ty::get(t).sty { match ty::get(t).sty {
ty::ty_uniq(_) | ty::ty_uniq(_) |
@ -91,7 +95,7 @@ fn drop_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> block {
} }
} }
fn take_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> Result { pub fn take_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> Result {
let _icx = bcx.insn_ctxt("take_ty_immediate"); let _icx = bcx.insn_ctxt("take_ty_immediate");
match ty::get(t).sty { match ty::get(t).sty {
ty::ty_box(_) | ty::ty_opaque_box | ty::ty_box(_) | ty::ty_opaque_box |
@ -111,7 +115,7 @@ fn take_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> Result {
} }
} }
fn free_ty(cx: block, v: ValueRef, t: ty::t) -> 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. // NB: v is an *alias* of type t here, not a direct value.
let _icx = cx.insn_ctxt("free_ty"); let _icx = cx.insn_ctxt("free_ty");
if ty::type_needs_drop(cx.tcx(), t) { if ty::type_needs_drop(cx.tcx(), t) {
@ -120,7 +124,7 @@ fn free_ty(cx: block, v: ValueRef, t: ty::t) -> block {
return cx; return cx;
} }
fn free_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> block { pub fn free_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> block {
let _icx = bcx.insn_ctxt("free_ty_immediate"); let _icx = bcx.insn_ctxt("free_ty_immediate");
match ty::get(t).sty { match ty::get(t).sty {
ty::ty_uniq(_) | ty::ty_uniq(_) |
@ -138,16 +142,15 @@ fn free_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> block {
} }
} }
fn lazily_emit_all_tydesc_glue(ccx: @crate_ctxt, pub fn lazily_emit_all_tydesc_glue(ccx: @crate_ctxt,
static_ti: @tydesc_info) { static_ti: @tydesc_info) {
lazily_emit_tydesc_glue(ccx, abi::tydesc_field_take_glue, static_ti); lazily_emit_tydesc_glue(ccx, abi::tydesc_field_take_glue, static_ti);
lazily_emit_tydesc_glue(ccx, abi::tydesc_field_drop_glue, static_ti); lazily_emit_tydesc_glue(ccx, abi::tydesc_field_drop_glue, static_ti);
lazily_emit_tydesc_glue(ccx, abi::tydesc_field_free_glue, static_ti); lazily_emit_tydesc_glue(ccx, abi::tydesc_field_free_glue, static_ti);
lazily_emit_tydesc_glue(ccx, abi::tydesc_field_visit_glue, static_ti); lazily_emit_tydesc_glue(ccx, abi::tydesc_field_visit_glue, static_ti);
} }
fn simplified_glue_type(tcx: ty::ctxt, field: uint, t: ty::t) -> ty::t { pub fn simplified_glue_type(tcx: ty::ctxt, field: uint, t: ty::t) -> ty::t {
if (field == abi::tydesc_field_take_glue || if (field == abi::tydesc_field_take_glue ||
field == abi::tydesc_field_drop_glue || field == abi::tydesc_field_drop_glue ||
field == abi::tydesc_field_free_glue) && field == abi::tydesc_field_free_glue) &&
@ -200,16 +203,17 @@ fn simplified_glue_type(tcx: ty::ctxt, field: uint, t: ty::t) -> ty::t {
return t; return t;
} }
pure fn cast_glue(ccx: @crate_ctxt, ti: @tydesc_info, v: ValueRef) pub pure fn cast_glue(ccx: @crate_ctxt, ti: @tydesc_info, v: ValueRef)
-> ValueRef { -> ValueRef {
unsafe { unsafe {
let llfnty = type_of_glue_fn(ccx, ti.ty); let llfnty = type_of_glue_fn(ccx, ti.ty);
llvm::LLVMConstPointerCast(v, T_ptr(llfnty)) llvm::LLVMConstPointerCast(v, T_ptr(llfnty))
} }
} }
fn lazily_emit_simplified_tydesc_glue(ccx: @crate_ctxt, field: uint, pub fn lazily_emit_simplified_tydesc_glue(ccx: @crate_ctxt,
ti: @tydesc_info) -> bool { field: uint,
ti: @tydesc_info) -> bool {
let _icx = ccx.insn_ctxt("lazily_emit_simplified_tydesc_glue"); let _icx = ccx.insn_ctxt("lazily_emit_simplified_tydesc_glue");
let simpl = simplified_glue_type(ccx.tcx, field, ti.ty); let simpl = simplified_glue_type(ccx.tcx, field, ti.ty);
if simpl != ti.ty { if simpl != ti.ty {
@ -234,8 +238,9 @@ fn lazily_emit_simplified_tydesc_glue(ccx: @crate_ctxt, field: uint,
} }
fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint, pub fn lazily_emit_tydesc_glue(ccx: @crate_ctxt,
ti: @tydesc_info) { field: uint,
ti: @tydesc_info) {
let _icx = ccx.insn_ctxt("lazily_emit_tydesc_glue"); let _icx = ccx.insn_ctxt("lazily_emit_tydesc_glue");
let llfnty = type_of_glue_fn(ccx, ti.ty); let llfnty = type_of_glue_fn(ccx, ti.ty);
@ -299,8 +304,8 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint,
} }
// See [Note-arg-mode] // See [Note-arg-mode]
fn call_tydesc_glue_full(++bcx: block, v: ValueRef, tydesc: ValueRef, pub fn call_tydesc_glue_full(++bcx: block, v: ValueRef, tydesc: ValueRef,
field: uint, static_ti: Option<@tydesc_info>) { field: uint, static_ti: Option<@tydesc_info>) {
let _icx = bcx.insn_ctxt("call_tydesc_glue_full"); let _icx = bcx.insn_ctxt("call_tydesc_glue_full");
let ccx = bcx.ccx(); let ccx = bcx.ccx();
// NB: Don't short-circuit even if this block is unreachable because // NB: Don't short-circuit even if this block is unreachable because
@ -363,7 +368,7 @@ fn call_tydesc_glue_full(++bcx: block, v: ValueRef, tydesc: ValueRef,
} }
// See [Note-arg-mode] // See [Note-arg-mode]
fn call_tydesc_glue(++cx: block, v: ValueRef, t: ty::t, field: uint) pub fn call_tydesc_glue(++cx: block, v: ValueRef, t: ty::t, field: uint)
-> block { -> block {
let _icx = cx.insn_ctxt("call_tydesc_glue"); let _icx = cx.insn_ctxt("call_tydesc_glue");
let ti = get_tydesc(cx.ccx(), t); let ti = get_tydesc(cx.ccx(), t);
@ -371,7 +376,7 @@ fn call_tydesc_glue(++cx: block, v: ValueRef, t: ty::t, field: uint)
return cx; return cx;
} }
fn make_visit_glue(bcx: block, v: ValueRef, t: ty::t) { pub fn make_visit_glue(bcx: block, v: ValueRef, t: ty::t) {
let _icx = bcx.insn_ctxt("make_visit_glue"); let _icx = bcx.insn_ctxt("make_visit_glue");
let mut bcx = bcx; let mut bcx = bcx;
let ty_visitor_name = special_idents::ty_visitor; let ty_visitor_name = special_idents::ty_visitor;
@ -382,7 +387,7 @@ fn make_visit_glue(bcx: block, v: ValueRef, t: ty::t) {
build_return(bcx); build_return(bcx);
} }
fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) { pub fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) {
// NB: v0 is an *alias* of type t here, not a direct value. // NB: v0 is an *alias* of type t here, not a direct value.
let _icx = bcx.insn_ctxt("make_free_glue"); let _icx = bcx.insn_ctxt("make_free_glue");
let ccx = bcx.ccx(); let ccx = bcx.ccx();
@ -437,12 +442,13 @@ fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) {
build_return(bcx); build_return(bcx);
} }
fn trans_struct_drop(bcx: block, pub fn trans_struct_drop(bcx: block,
v0: ValueRef, v0: ValueRef,
dtor_did: ast::def_id, dtor_did: ast::def_id,
class_did: ast::def_id, class_did: ast::def_id,
substs: &ty::substs, substs: &ty::substs,
take_ref: bool) -> block { take_ref: bool)
-> block {
let drop_flag = GEPi(bcx, v0, struct_dtor()); let drop_flag = GEPi(bcx, v0, struct_dtor());
do with_cond(bcx, IsNotNull(bcx, Load(bcx, drop_flag))) |cx| { do with_cond(bcx, IsNotNull(bcx, Load(bcx, drop_flag))) |cx| {
let mut bcx = cx; let mut bcx = cx;
@ -491,7 +497,7 @@ fn trans_struct_drop(bcx: block,
} }
fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) { pub fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) {
// NB: v0 is an *alias* of type t here, not a direct value. // NB: v0 is an *alias* of type t here, not a direct value.
let _icx = bcx.insn_ctxt("make_drop_glue"); let _icx = bcx.insn_ctxt("make_drop_glue");
let ccx = bcx.ccx(); let ccx = bcx.ccx();
@ -549,7 +555,10 @@ fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) {
build_return(bcx); build_return(bcx);
} }
fn decr_refcnt_maybe_free(bcx: block, box_ptr: ValueRef, t: ty::t) -> block { pub fn decr_refcnt_maybe_free(bcx: block,
box_ptr: ValueRef,
t: ty::t)
-> block {
let _icx = bcx.insn_ctxt("decr_refcnt_maybe_free"); let _icx = bcx.insn_ctxt("decr_refcnt_maybe_free");
let ccx = bcx.ccx(); let ccx = bcx.ccx();
@ -563,7 +572,7 @@ fn decr_refcnt_maybe_free(bcx: block, box_ptr: ValueRef, t: ty::t) -> block {
} }
fn make_take_glue(bcx: block, v: ValueRef, t: ty::t) { pub fn make_take_glue(bcx: block, v: ValueRef, t: ty::t) {
let _icx = bcx.insn_ctxt("make_take_glue"); let _icx = bcx.insn_ctxt("make_take_glue");
// NB: v is a *pointer* to type t here, not a direct value. // NB: v is a *pointer* to type t here, not a direct value.
let bcx = match ty::get(t).sty { let bcx = match ty::get(t).sty {
@ -612,7 +621,7 @@ fn make_take_glue(bcx: block, v: ValueRef, t: ty::t) {
build_return(bcx); build_return(bcx);
} }
fn incr_refcnt_of_boxed(cx: block, box_ptr: ValueRef) { pub fn incr_refcnt_of_boxed(cx: block, box_ptr: ValueRef) {
let _icx = cx.insn_ctxt("incr_refcnt_of_boxed"); let _icx = cx.insn_ctxt("incr_refcnt_of_boxed");
let ccx = cx.ccx(); let ccx = cx.ccx();
let rc_ptr = GEPi(cx, box_ptr, [0u, abi::box_field_refcnt]); let rc_ptr = GEPi(cx, box_ptr, [0u, abi::box_field_refcnt]);
@ -623,7 +632,7 @@ fn incr_refcnt_of_boxed(cx: block, box_ptr: ValueRef) {
// Chooses the addrspace for newly declared types. // Chooses the addrspace for newly declared types.
fn declare_tydesc_addrspace(ccx: @crate_ctxt, t: ty::t) -> addrspace { pub fn declare_tydesc_addrspace(ccx: @crate_ctxt, t: ty::t) -> addrspace {
if !ty::type_needs_drop(ccx.tcx, t) { if !ty::type_needs_drop(ccx.tcx, t) {
return default_addrspace; return default_addrspace;
} else if ty::type_is_immediate(t) { } else if ty::type_is_immediate(t) {
@ -637,7 +646,7 @@ fn declare_tydesc_addrspace(ccx: @crate_ctxt, t: ty::t) -> addrspace {
} }
// Generates the declaration for (but doesn't emit) a type descriptor. // Generates the declaration for (but doesn't emit) a type descriptor.
fn declare_tydesc(ccx: @crate_ctxt, t: ty::t) -> @tydesc_info { pub fn declare_tydesc(ccx: @crate_ctxt, t: ty::t) -> @tydesc_info {
let _icx = ccx.insn_ctxt("declare_tydesc"); let _icx = ccx.insn_ctxt("declare_tydesc");
// If emit_tydescs already ran, then we shouldn't be creating any new // If emit_tydescs already ran, then we shouldn't be creating any new
// tydescs. // tydescs.
@ -682,10 +691,10 @@ fn declare_tydesc(ccx: @crate_ctxt, t: ty::t) -> @tydesc_info {
return inf; return inf;
} }
type glue_helper = fn@(block, ValueRef, ty::t); pub type glue_helper = fn@(block, ValueRef, ty::t);
fn declare_generic_glue(ccx: @crate_ctxt, t: ty::t, llfnty: TypeRef, pub fn declare_generic_glue(ccx: @crate_ctxt, t: ty::t, llfnty: TypeRef,
+name: ~str) -> ValueRef { +name: ~str) -> ValueRef {
let _icx = ccx.insn_ctxt("declare_generic_glue"); let _icx = ccx.insn_ctxt("declare_generic_glue");
let name = name; let name = name;
let mut fn_nm; let mut fn_nm;
@ -703,8 +712,11 @@ fn declare_generic_glue(ccx: @crate_ctxt, t: ty::t, llfnty: TypeRef,
return llfn; return llfn;
} }
fn make_generic_glue_inner(ccx: @crate_ctxt, t: ty::t, pub fn make_generic_glue_inner(ccx: @crate_ctxt,
llfn: ValueRef, helper: glue_helper) -> ValueRef { t: ty::t,
llfn: ValueRef,
helper: glue_helper)
-> ValueRef {
let _icx = ccx.insn_ctxt("make_generic_glue_inner"); let _icx = ccx.insn_ctxt("make_generic_glue_inner");
let fcx = new_fn_ctxt(ccx, ~[], llfn, None); let fcx = new_fn_ctxt(ccx, ~[], llfn, None);
lib::llvm::SetLinkage(llfn, lib::llvm::InternalLinkage); lib::llvm::SetLinkage(llfn, lib::llvm::InternalLinkage);
@ -725,9 +737,9 @@ fn make_generic_glue_inner(ccx: @crate_ctxt, t: ty::t,
return llfn; return llfn;
} }
fn make_generic_glue(ccx: @crate_ctxt, t: ty::t, llfn: ValueRef, pub fn make_generic_glue(ccx: @crate_ctxt, t: ty::t, llfn: ValueRef,
helper: glue_helper, name: ~str) helper: glue_helper, name: ~str)
-> ValueRef { -> ValueRef {
let _icx = ccx.insn_ctxt("make_generic_glue"); let _icx = ccx.insn_ctxt("make_generic_glue");
if !ccx.sess.trans_stats() { if !ccx.sess.trans_stats() {
return make_generic_glue_inner(ccx, t, llfn, helper); return make_generic_glue_inner(ccx, t, llfn, helper);
@ -741,7 +753,7 @@ fn make_generic_glue(ccx: @crate_ctxt, t: ty::t, llfn: ValueRef,
return llval; return llval;
} }
fn emit_tydescs(ccx: @crate_ctxt) { pub fn emit_tydescs(ccx: @crate_ctxt) {
let _icx = ccx.insn_ctxt("emit_tydescs"); let _icx = ccx.insn_ctxt("emit_tydescs");
// As of this point, allow no more tydescs to be created. // As of this point, allow no more tydescs to be created.
ccx.finished_tydescs = true; ccx.finished_tydescs = true;

View File

@ -27,8 +27,8 @@ use syntax::ast_util::local_def;
// `translate` will be true if this function is allowed to translate the // `translate` will be true if this function is allowed to translate the
// item and false otherwise. Currently, this parameter is set to false when // item and false otherwise. Currently, this parameter is set to false when
// translating default methods. // translating default methods.
fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id, pub fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id,
translate: bool) translate: bool)
-> ast::def_id { -> ast::def_id {
let _icx = ccx.insn_ctxt("maybe_instantiate_inline"); let _icx = ccx.insn_ctxt("maybe_instantiate_inline");
match ccx.external.find(fn_id) { match ccx.external.find(fn_id) {

View File

@ -36,13 +36,13 @@ use syntax::ast_map::{path, path_mod, path_name};
use syntax::ast_util::local_def; use syntax::ast_util::local_def;
use syntax::parse::token::special_idents; use syntax::parse::token::special_idents;
fn monomorphic_fn(ccx: @crate_ctxt, pub fn monomorphic_fn(ccx: @crate_ctxt,
fn_id: ast::def_id, fn_id: ast::def_id,
real_substs: ~[ty::t], real_substs: ~[ty::t],
vtables: Option<typeck::vtable_res>, vtables: Option<typeck::vtable_res>,
impl_did_opt: Option<ast::def_id>, impl_did_opt: Option<ast::def_id>,
ref_id: Option<ast::node_id>) -> ref_id: Option<ast::node_id>) ->
{val: ValueRef, must_cast: bool} { {val: ValueRef, must_cast: bool} {
let _icx = ccx.insn_ctxt("monomorphic_fn"); let _icx = ccx.insn_ctxt("monomorphic_fn");
let mut must_cast = false; let mut must_cast = false;
let substs = vec::map(real_substs, |t| { let substs = vec::map(real_substs, |t| {
@ -268,7 +268,8 @@ fn monomorphic_fn(ccx: @crate_ctxt,
{val: lldecl, must_cast: must_cast} {val: lldecl, must_cast: must_cast}
} }
fn normalize_for_monomorphization(tcx: ty::ctxt, ty: ty::t) -> Option<ty::t> { pub fn normalize_for_monomorphization(tcx: ty::ctxt,
ty: ty::t) -> Option<ty::t> {
// FIXME[mono] could do this recursively. is that worthwhile? (#2529) // FIXME[mono] could do this recursively. is that worthwhile? (#2529)
match ty::get(ty).sty { match ty::get(ty).sty {
ty::ty_box(*) => { ty::ty_box(*) => {
@ -305,10 +306,10 @@ fn normalize_for_monomorphization(tcx: ty::ctxt, ty: ty::t) -> Option<ty::t> {
} }
} }
fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: ~[ty::t], pub fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: ~[ty::t],
vtables: Option<typeck::vtable_res>, vtables: Option<typeck::vtable_res>,
impl_did_opt: Option<ast::def_id>, impl_did_opt: Option<ast::def_id>,
param_uses: Option<~[type_use::type_uses]>) -> mono_id { param_uses: Option<~[type_use::type_uses]>) -> mono_id {
let precise_param_ids = match vtables { let precise_param_ids = match vtables {
Some(vts) => { Some(vts) => {
let bounds = ty::lookup_item_type(ccx.tcx, item).bounds; let bounds = ty::lookup_item_type(ccx.tcx, item).bounds;

View File

@ -50,19 +50,12 @@ use back_ = back;
pub mod middle { pub mod middle {
pub mod trans { pub mod trans {
#[legacy_exports]
pub mod inline; pub mod inline;
#[legacy_exports]
pub mod monomorphize; pub mod monomorphize;
#[legacy_exports]
pub mod controlflow; pub mod controlflow;
#[legacy_exports]
pub mod glue; pub mod glue;
#[legacy_exports]
pub mod datum; pub mod datum;
#[legacy_exports]
pub mod callee; pub mod callee;
#[legacy_exports]
pub mod expr; pub mod expr;
#[legacy_exports] #[legacy_exports]
pub mod common; pub mod common;