librustc: De-export trans. rs=deexporting

This commit is contained in:
Patrick Walton 2013-01-30 11:46:19 -08:00
parent 7ad0716275
commit ba11e96289
20 changed files with 1021 additions and 1061 deletions

View file

@ -173,11 +173,14 @@ use syntax::ast_util;
use syntax::codemap::span;
use syntax::print::pprust::pat_to_str;
fn macros() { include!("macros.rs"); } // FIXME(#3114): Macro import/export.
pub fn macros() {
// FIXME(#3114): Macro import/export.
include!("macros.rs");
}
// An option identifying a literal: either a unit-like struct or an
// expression.
enum Lit {
pub enum Lit {
UnitLikeStructLit(ast::node_id), // the node ID of the pattern
ExprLit(@ast::expr),
ConstLit(ast::def_id), // the def ID of the constant
@ -185,7 +188,7 @@ enum Lit {
// An option identifying a branch (either a literal, a enum variant or a
// range)
enum Opt {
pub enum Opt {
lit(Lit),
var(/* disr val */int, /* variant dids */{enm: def_id, var: def_id}),
range(@ast::expr, @ast::expr),
@ -193,7 +196,7 @@ enum Opt {
vec_len_ge(uint)
}
fn opt_eq(tcx: ty::ctxt, a: &Opt, b: &Opt) -> bool {
pub fn opt_eq(tcx: ty::ctxt, a: &Opt, b: &Opt) -> bool {
match (*a, *b) {
(lit(a), lit(b)) => {
match (a, b) {
@ -240,12 +243,12 @@ fn opt_eq(tcx: ty::ctxt, a: &Opt, b: &Opt) -> bool {
}
}
enum opt_result {
pub enum opt_result {
single_result(Result),
lower_bound(Result),
range_result(Result, Result),
}
fn trans_opt(bcx: block, o: &Opt) -> opt_result {
pub fn trans_opt(bcx: block, o: &Opt) -> opt_result {
let _icx = bcx.insn_ctxt("match::trans_opt");
let ccx = bcx.ccx();
let mut bcx = bcx;
@ -279,7 +282,7 @@ fn trans_opt(bcx: block, o: &Opt) -> opt_result {
}
}
fn variant_opt(tcx: ty::ctxt, pat_id: ast::node_id) -> Opt {
pub fn variant_opt(tcx: ty::ctxt, pat_id: ast::node_id) -> Opt {
match tcx.def_map.get(pat_id) {
ast::def_variant(enum_id, var_id) => {
let variants = ty::enum_variants(tcx, enum_id);
@ -299,7 +302,7 @@ fn variant_opt(tcx: ty::ctxt, pat_id: ast::node_id) -> Opt {
}
}
enum TransBindingMode {
pub enum TransBindingMode {
TrByValue(/*ismove:*/ bool, /*llbinding:*/ ValueRef),
TrByRef,
TrByImplicitRef
@ -313,27 +316,27 @@ enum TransBindingMode {
* - `trmode` is the trans binding mode
* - `id` is the node id of the binding
* - `ty` is the Rust type of the binding */
struct BindingInfo {
pub struct BindingInfo {
llmatch: ValueRef,
trmode: TransBindingMode,
id: ast::node_id,
ty: ty::t,
}
type BindingsMap = HashMap<ident, BindingInfo>;
pub type BindingsMap = HashMap<ident, BindingInfo>;
struct ArmData {
pub struct ArmData {
bodycx: block,
arm: &ast::arm,
bindings_map: BindingsMap
}
struct Match {
pub struct Match {
pats: ~[@ast::pat],
data: @ArmData
}
fn match_to_str(bcx: block, m: &Match) -> ~str {
pub fn match_to_str(bcx: block, m: &Match) -> ~str {
if bcx.sess().verbose() {
// for many programs, this just take too long to serialize
fmt!("%?", m.pats.map(|p| pat_to_str(*p, bcx.sess().intr())))
@ -342,11 +345,11 @@ fn match_to_str(bcx: block, m: &Match) -> ~str {
}
}
fn matches_to_str(bcx: block, m: &[@Match]) -> ~str {
pub fn matches_to_str(bcx: block, m: &[@Match]) -> ~str {
fmt!("%?", m.map(|n| match_to_str(bcx, *n)))
}
fn has_nested_bindings(m: &[@Match], col: uint) -> bool {
pub fn has_nested_bindings(m: &[@Match], col: uint) -> bool {
for vec::each(m) |br| {
match br.pats[col].node {
ast::pat_ident(_, _, Some(_)) => return true,
@ -356,10 +359,9 @@ fn has_nested_bindings(m: &[@Match], col: uint) -> bool {
return false;
}
fn expand_nested_bindings(bcx: block, m: &[@Match/&r],
col: uint, val: ValueRef)
-> ~[@Match/&r]
{
pub fn expand_nested_bindings(bcx: block, m: &[@Match/&r],
col: uint, val: ValueRef)
-> ~[@Match/&r] {
debug!("expand_nested_bindings(bcx=%s, m=%s, col=%u, val=%?)",
bcx.to_str(),
matches_to_str(bcx, m),
@ -388,9 +390,9 @@ fn expand_nested_bindings(bcx: block, m: &[@Match/&r],
}
}
type enter_pat = fn(@ast::pat) -> Option<~[@ast::pat]>;
pub type enter_pat = fn(@ast::pat) -> Option<~[@ast::pat]>;
fn assert_is_binding_or_wild(bcx: block, p: @ast::pat) {
pub fn assert_is_binding_or_wild(bcx: block, p: @ast::pat) {
if !pat_is_binding_or_wild(bcx.tcx().def_map, p) {
bcx.sess().span_bug(
p.span,
@ -399,10 +401,9 @@ fn assert_is_binding_or_wild(bcx: block, p: @ast::pat) {
}
}
fn enter_match(bcx: block, dm: DefMap, m: &[@Match/&r],
col: uint, val: ValueRef, e: enter_pat)
-> ~[@Match/&r]
{
pub fn enter_match(bcx: block, dm: DefMap, m: &[@Match/&r],
col: uint, val: ValueRef, e: enter_pat)
-> ~[@Match/&r] {
debug!("enter_match(bcx=%s, m=%s, col=%u, val=%?)",
bcx.to_str(),
matches_to_str(bcx, m),
@ -442,10 +443,9 @@ fn enter_match(bcx: block, dm: DefMap, m: &[@Match/&r],
return result;
}
fn enter_default(bcx: block, dm: DefMap, m: &[@Match/&r],
col: uint, val: ValueRef)
-> ~[@Match/&r]
{
pub fn enter_default(bcx: block, dm: DefMap, m: &[@Match/&r],
col: uint, val: ValueRef)
-> ~[@Match/&r] {
debug!("enter_default(bcx=%s, m=%s, col=%u, val=%?)",
bcx.to_str(),
matches_to_str(bcx, m),
@ -487,10 +487,9 @@ fn enter_default(bcx: block, dm: DefMap, m: &[@Match/&r],
// <nmatsakis> so all patterns must either be records (resp. tuples) or
// wildcards
fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint,
variant_size: uint, val: ValueRef)
-> ~[@Match/&r]
{
pub fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint,
variant_size: uint, val: ValueRef)
-> ~[@Match/&r] {
debug!("enter_opt(bcx=%s, m=%s, col=%u, val=%?)",
bcx.to_str(),
matches_to_str(bcx, m),
@ -591,8 +590,13 @@ fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint,
}
}
fn enter_rec_or_struct(bcx: block, dm: DefMap, m: &[@Match/&r], col: uint,
fields: ~[ast::ident], val: ValueRef) -> ~[@Match/&r] {
pub fn enter_rec_or_struct(bcx: block,
dm: DefMap,
m: &[@Match/&r],
col: uint,
fields: ~[ast::ident],
val: ValueRef)
-> ~[@Match/&r] {
debug!("enter_rec_or_struct(bcx=%s, m=%s, col=%u, val=%?)",
bcx.to_str(),
matches_to_str(bcx, m),
@ -621,10 +625,9 @@ fn enter_rec_or_struct(bcx: block, dm: DefMap, m: &[@Match/&r], col: uint,
}
}
fn enter_tup(bcx: block, dm: DefMap, m: &[@Match/&r],
col: uint, val: ValueRef, n_elts: uint)
-> ~[@Match/&r]
{
pub fn enter_tup(bcx: block, dm: DefMap, m: &[@Match/&r],
col: uint, val: ValueRef, n_elts: uint)
-> ~[@Match/&r] {
debug!("enter_tup(bcx=%s, m=%s, col=%u, val=%?)",
bcx.to_str(),
matches_to_str(bcx, m),
@ -646,10 +649,13 @@ fn enter_tup(bcx: block, dm: DefMap, m: &[@Match/&r],
}
}
fn enter_tuple_struct(bcx: block, dm: DefMap, m: &[@Match/&r], col: uint,
val: ValueRef, n_elts: uint)
-> ~[@Match/&r]
{
pub fn enter_tuple_struct(bcx: block,
dm: DefMap,
m: &[@Match/&r],
col: uint,
val: ValueRef,
n_elts: uint)
-> ~[@Match/&r] {
debug!("enter_tuple_struct(bcx=%s, m=%s, col=%u, val=%?)",
bcx.to_str(),
matches_to_str(bcx, m),
@ -669,10 +675,12 @@ fn enter_tuple_struct(bcx: block, dm: DefMap, m: &[@Match/&r], col: uint,
}
}
fn enter_box(bcx: block, dm: DefMap, m: &[@Match/&r],
col: uint, val: ValueRef)
-> ~[@Match/&r]
{
pub fn enter_box(bcx: block,
dm: DefMap,
m: &[@Match/&r],
col: uint,
val: ValueRef)
-> ~[@Match/&r] {
debug!("enter_box(bcx=%s, m=%s, col=%u, val=%?)",
bcx.to_str(),
matches_to_str(bcx, m),
@ -694,10 +702,12 @@ fn enter_box(bcx: block, dm: DefMap, m: &[@Match/&r],
}
}
fn enter_uniq(bcx: block, dm: DefMap, m: &[@Match/&r],
col: uint, val: ValueRef)
-> ~[@Match/&r]
{
pub fn enter_uniq(bcx: block,
dm: DefMap,
m: &[@Match/&r],
col: uint,
val: ValueRef)
-> ~[@Match/&r] {
debug!("enter_uniq(bcx=%s, m=%s, col=%u, val=%?)",
bcx.to_str(),
matches_to_str(bcx, m),
@ -719,10 +729,12 @@ fn enter_uniq(bcx: block, dm: DefMap, m: &[@Match/&r],
}
}
fn enter_region(bcx: block, dm: DefMap, m: &[@Match/&r],
col: uint, val: ValueRef)
-> ~[@Match/&r]
{
pub fn enter_region(bcx: block,
dm: DefMap,
m: &[@Match/&r],
col: uint,
val: ValueRef)
-> ~[@Match/&r] {
debug!("enter_region(bcx=%s, m=%s, col=%u, val=%?)",
bcx.to_str(),
matches_to_str(bcx, m),
@ -747,7 +759,7 @@ fn enter_region(bcx: block, dm: DefMap, m: &[@Match/&r],
// Returns the options in one column of matches. An option is something that
// needs to be conditionally matched at runtime; for example, the discriminant
// on a set of enum variants or a literal.
fn get_options(ccx: @crate_ctxt, m: &[@Match], col: uint) -> ~[Opt] {
pub fn get_options(ccx: @crate_ctxt, m: &[@Match], col: uint) -> ~[Opt] {
fn add_to_set(tcx: ty::ctxt, set: &DVec<Opt>, val: Opt) {
if set.any(|l| opt_eq(tcx, l, &val)) {return;}
set.push(val);
@ -806,11 +818,11 @@ fn get_options(ccx: @crate_ctxt, m: &[@Match], col: uint) -> ~[Opt] {
return dvec::unwrap(move found);
}
fn extract_variant_args(bcx: block, pat_id: ast::node_id,
vdefs: {enm: def_id, var: def_id},
val: ValueRef)
-> {vals: ~[ValueRef], bcx: block}
{
pub fn extract_variant_args(bcx: block,
pat_id: ast::node_id,
vdefs: {enm: def_id, var: def_id},
val: ValueRef)
-> {vals: ~[ValueRef], bcx: block} {
let _icx = bcx.insn_ctxt("match::extract_variant_args");
let ccx = bcx.fcx.ccx;
let enum_ty_substs = match ty::get(node_id_type(bcx, pat_id)).sty {
@ -838,10 +850,12 @@ fn extract_variant_args(bcx: block, pat_id: ast::node_id,
return {vals: args, bcx: bcx};
}
fn extract_vec_elems(bcx: block, pat_id: ast::node_id,
elem_count: uint, tail: bool, val: ValueRef)
-> {vals: ~[ValueRef], bcx: block}
{
pub fn extract_vec_elems(bcx: block,
pat_id: ast::node_id,
elem_count: uint,
tail: bool,
val: ValueRef)
-> {vals: ~[ValueRef], bcx: block} {
let _icx = bcx.insn_ctxt("match::extract_vec_elems");
let vt = tvec::vec_types(bcx, node_id_type(bcx, pat_id));
let unboxed = load_if_immediate(bcx, val, vt.vec_ty);
@ -874,8 +888,10 @@ fn extract_vec_elems(bcx: block, pat_id: ast::node_id,
}
// NB: This function does not collect fields from struct-like enum variants.
fn collect_record_or_struct_fields(bcx: block, m: &[@Match], col: uint) ->
~[ast::ident] {
pub fn collect_record_or_struct_fields(bcx: block,
m: &[@Match],
col: uint)
-> ~[ast::ident] {
let mut fields: ~[ast::ident] = ~[];
for vec::each(m) |br| {
match /*bad*/copy br.pats[col].node {
@ -901,11 +917,11 @@ fn collect_record_or_struct_fields(bcx: block, m: &[@Match], col: uint) ->
}
}
fn root_pats_as_necessary(bcx: block,
m: &[@Match],
col: uint,
val: ValueRef)
-> block {
pub fn root_pats_as_necessary(bcx: block,
m: &[@Match],
col: uint,
val: ValueRef)
-> block {
let mut bcx = bcx;
for vec::each(m) |br| {
let pat_id = br.pats[col].id;
@ -945,23 +961,23 @@ macro_rules! any_pat (
)
)
fn any_box_pat(m: &[@Match], col: uint) -> bool {
pub fn any_box_pat(m: &[@Match], col: uint) -> bool {
any_pat!(m, ast::pat_box(_))
}
fn any_uniq_pat(m: &[@Match], col: uint) -> bool {
pub fn any_uniq_pat(m: &[@Match], col: uint) -> bool {
any_pat!(m, ast::pat_uniq(_))
}
fn any_region_pat(m: &[@Match], col: uint) -> bool {
pub fn any_region_pat(m: &[@Match], col: uint) -> bool {
any_pat!(m, ast::pat_region(_))
}
fn any_tup_pat(m: &[@Match], col: uint) -> bool {
pub fn any_tup_pat(m: &[@Match], col: uint) -> bool {
any_pat!(m, ast::pat_tup(_))
}
fn any_tuple_struct_pat(bcx: block, m: &[@Match], col: uint) -> bool {
pub fn any_tuple_struct_pat(bcx: block, m: &[@Match], col: uint) -> bool {
vec::any(m, |br| {
let pat = br.pats[col];
match pat.node {
@ -976,9 +992,9 @@ fn any_tuple_struct_pat(bcx: block, m: &[@Match], col: uint) -> bool {
})
}
type mk_fail = fn@() -> BasicBlockRef;
pub type mk_fail = fn@() -> BasicBlockRef;
fn pick_col(m: &[@Match]) -> uint {
pub fn pick_col(m: &[@Match]) -> uint {
fn score(p: @ast::pat) -> uint {
match p.node {
ast::pat_lit(_) | ast::pat_enum(_, _) | ast::pat_range(_, _) => 1u,
@ -1008,18 +1024,15 @@ fn pick_col(m: &[@Match]) -> uint {
return best_col;
}
enum branch_kind { no_branch, single, switch, compare, compare_vec_len, }
impl branch_kind : cmp::Eq {
pure fn eq(&self, other: &branch_kind) -> bool {
((*self) as uint) == ((*other) as uint)
}
pure fn ne(&self, other: &branch_kind) -> bool { !(*self).eq(other) }
}
#[deriving_eq]
pub enum branch_kind { no_branch, single, switch, compare, compare_vec_len, }
// Compiles a comparison between two things.
fn compare_values(cx: block, lhs: ValueRef, rhs: ValueRef, rhs_t: ty::t) ->
Result {
pub fn compare_values(cx: block,
lhs: ValueRef,
rhs: ValueRef,
rhs_t: ty::t)
-> Result {
let _icx = cx.insn_ctxt("compare_values");
if ty::type_is_scalar(rhs_t) {
let rs = compare_scalar_types(cx, lhs, rhs, rhs_t, ast::eq);
@ -1059,11 +1072,10 @@ fn compare_values(cx: block, lhs: ValueRef, rhs: ValueRef, rhs_t: ty::t) ->
}
}
fn store_non_ref_bindings(bcx: block,
data: &ArmData,
opt_temp_cleanups: Option<&DVec<ValueRef>>)
-> block
{
pub fn store_non_ref_bindings(bcx: block,
data: &ArmData,
opt_temp_cleanups: Option<&DVec<ValueRef>>)
-> block {
/*!
*
* For each copy/move binding, copy the value from the value
@ -1099,9 +1111,9 @@ fn store_non_ref_bindings(bcx: block,
return bcx;
}
fn insert_lllocals(bcx: block,
data: &ArmData,
add_cleans: bool) -> block {
pub fn insert_lllocals(bcx: block,
data: &ArmData,
add_cleans: bool) -> block {
/*!
*
* For each binding in `data.bindings_map`, adds an appropriate entry into
@ -1139,14 +1151,13 @@ fn insert_lllocals(bcx: block,
return bcx;
}
fn compile_guard(bcx: block,
guard_expr: @ast::expr,
data: &ArmData,
m: &[@Match],
vals: &[ValueRef],
chk: Option<mk_fail>)
-> block
{
pub fn compile_guard(bcx: block,
guard_expr: @ast::expr,
data: &ArmData,
m: &[@Match],
vals: &[ValueRef],
chk: Option<mk_fail>)
-> block {
debug!("compile_guard(bcx=%s, guard_expr=%s, m=%s, vals=%?)",
bcx.to_str(),
bcx.expr_to_str(guard_expr),
@ -1194,11 +1205,10 @@ fn compile_guard(bcx: block,
}
}
fn compile_submatch(bcx: block,
m: &[@Match],
vals: &[ValueRef],
chk: Option<mk_fail>)
{
pub fn compile_submatch(bcx: block,
m: &[@Match],
vals: &[ValueRef],
chk: Option<mk_fail>) {
debug!("compile_submatch(bcx=%s, m=%s, vals=%?)",
bcx.to_str(),
matches_to_str(bcx, m),
@ -1530,21 +1540,21 @@ fn compile_submatch(bcx: block,
}
}
fn trans_match(bcx: block,
match_expr: @ast::expr,
discr_expr: @ast::expr,
arms: ~[ast::arm],
dest: Dest) -> block {
pub fn trans_match(bcx: block,
match_expr: @ast::expr,
discr_expr: @ast::expr,
arms: ~[ast::arm],
dest: Dest) -> block {
let _icx = bcx.insn_ctxt("match::trans_match");
do with_scope(bcx, match_expr.info(), ~"match") |bcx| {
trans_match_inner(bcx, discr_expr, arms, dest)
}
}
fn trans_match_inner(scope_cx: block,
discr_expr: @ast::expr,
arms: &[ast::arm],
dest: Dest) -> block {
pub fn trans_match_inner(scope_cx: block,
discr_expr: @ast::expr,
arms: &[ast::arm],
dest: Dest) -> block {
let _icx = scope_cx.insn_ctxt("match::trans_match_inner");
let mut bcx = scope_cx;
let tcx = bcx.tcx();
@ -1659,7 +1669,7 @@ fn trans_match_inner(scope_cx: block,
}
}
enum IrrefutablePatternBindingMode {
pub enum IrrefutablePatternBindingMode {
// Stores the association between node ID and LLVM value in `lllocals`.
BindLocal,
// Stores the association between node ID and LLVM value in `llargs`.
@ -1667,12 +1677,12 @@ enum IrrefutablePatternBindingMode {
}
// Not match-related, but similar to the pattern-munging code above
fn bind_irrefutable_pat(bcx: block,
pat: @ast::pat,
val: ValueRef,
make_copy: bool,
binding_mode: IrrefutablePatternBindingMode)
-> block {
pub fn bind_irrefutable_pat(bcx: block,
pat: @ast::pat,
val: ValueRef,
make_copy: bool,
binding_mode: IrrefutablePatternBindingMode)
-> block {
let _icx = bcx.insn_ctxt("match::bind_irrefutable_pat");
let ccx = bcx.fcx.ccx;
let mut bcx = bcx;

File diff suppressed because it is too large Load diff

View file

@ -25,19 +25,19 @@ use core::vec;
use std::map::HashMap;
use syntax::codemap;
fn terminate(cx: block, _: &str) {
pub fn terminate(cx: block, _: &str) {
unsafe {
cx.terminated = true;
}
}
fn check_not_terminated(cx: block) {
pub fn check_not_terminated(cx: block) {
if cx.terminated {
fail ~"already terminated!";
}
}
fn B(cx: block) -> BuilderRef {
pub fn B(cx: block) -> BuilderRef {
unsafe {
let b = cx.fcx.ccx.builder.B;
llvm::LLVMPositionBuilderAtEnd(b, cx.llbb);
@ -45,7 +45,7 @@ fn B(cx: block) -> BuilderRef {
}
}
fn count_insn(cx: block, category: &str) {
pub fn count_insn(cx: block, category: &str) {
if cx.ccx().sess.count_llvm_insns() {
let h = cx.ccx().stats.llvm_insns;
@ -96,7 +96,7 @@ fn count_insn(cx: block, category: &str) {
// for (fail/break/return statements, call to diverging functions, etc), and
// further instructions to the block should simply be ignored.
fn RetVoid(cx: block) {
pub fn RetVoid(cx: block) {
unsafe {
if cx.unreachable { return; }
check_not_terminated(cx);
@ -106,7 +106,7 @@ fn RetVoid(cx: block) {
}
}
fn Ret(cx: block, V: ValueRef) {
pub fn Ret(cx: block, V: ValueRef) {
unsafe {
if cx.unreachable { return; }
check_not_terminated(cx);
@ -116,7 +116,7 @@ fn Ret(cx: block, V: ValueRef) {
}
}
fn AggregateRet(cx: block, RetVals: ~[ValueRef]) {
pub fn AggregateRet(cx: block, RetVals: ~[ValueRef]) {
if cx.unreachable { return; }
check_not_terminated(cx);
terminate(cx, "AggregateRet");
@ -126,7 +126,7 @@ fn AggregateRet(cx: block, RetVals: ~[ValueRef]) {
}
}
fn Br(cx: block, Dest: BasicBlockRef) {
pub fn Br(cx: block, Dest: BasicBlockRef) {
unsafe {
if cx.unreachable { return; }
check_not_terminated(cx);
@ -136,8 +136,8 @@ fn Br(cx: block, Dest: BasicBlockRef) {
}
}
fn CondBr(cx: block, If: ValueRef, Then: BasicBlockRef,
Else: BasicBlockRef) {
pub fn CondBr(cx: block, If: ValueRef, Then: BasicBlockRef,
Else: BasicBlockRef) {
unsafe {
if cx.unreachable { return; }
check_not_terminated(cx);
@ -147,7 +147,7 @@ fn CondBr(cx: block, If: ValueRef, Then: BasicBlockRef,
}
}
fn Switch(cx: block, V: ValueRef, Else: BasicBlockRef, NumCases: uint)
pub fn Switch(cx: block, V: ValueRef, Else: BasicBlockRef, NumCases: uint)
-> ValueRef {
unsafe {
if cx.unreachable { return _Undef(V); }
@ -157,14 +157,14 @@ fn Switch(cx: block, V: ValueRef, Else: BasicBlockRef, NumCases: uint)
}
}
fn AddCase(S: ValueRef, OnVal: ValueRef, Dest: BasicBlockRef) {
pub fn AddCase(S: ValueRef, OnVal: ValueRef, Dest: BasicBlockRef) {
unsafe {
if llvm::LLVMIsUndef(S) == lib::llvm::True { return; }
llvm::LLVMAddCase(S, OnVal, Dest);
}
}
fn IndirectBr(cx: block, Addr: ValueRef, NumDests: uint) {
pub fn IndirectBr(cx: block, Addr: ValueRef, NumDests: uint) {
unsafe {
if cx.unreachable { return; }
check_not_terminated(cx);
@ -176,15 +176,15 @@ fn IndirectBr(cx: block, Addr: ValueRef, NumDests: uint) {
// This is a really awful way to get a zero-length c-string, but better (and a
// lot more efficient) than doing str::as_c_str("", ...) every time.
fn noname() -> *libc::c_char {
pub fn noname() -> *libc::c_char {
unsafe {
const cnull: uint = 0u;
return cast::reinterpret_cast(&ptr::addr_of(&cnull));
}
}
fn Invoke(cx: block, Fn: ValueRef, Args: ~[ValueRef],
Then: BasicBlockRef, Catch: BasicBlockRef) {
pub fn Invoke(cx: block, Fn: ValueRef, Args: ~[ValueRef],
Then: BasicBlockRef, Catch: BasicBlockRef) {
if cx.unreachable { return; }
check_not_terminated(cx);
terminate(cx, "Invoke");
@ -201,8 +201,8 @@ fn Invoke(cx: block, Fn: ValueRef, Args: ~[ValueRef],
}
}
fn FastInvoke(cx: block, Fn: ValueRef, Args: ~[ValueRef],
Then: BasicBlockRef, Catch: BasicBlockRef) {
pub fn FastInvoke(cx: block, Fn: ValueRef, Args: ~[ValueRef],
Then: BasicBlockRef, Catch: BasicBlockRef) {
if cx.unreachable { return; }
check_not_terminated(cx);
terminate(cx, "FastInvoke");
@ -215,7 +215,7 @@ fn FastInvoke(cx: block, Fn: ValueRef, Args: ~[ValueRef],
}
}
fn Unreachable(cx: block) {
pub fn Unreachable(cx: block) {
unsafe {
if cx.unreachable { return; }
cx.unreachable = true;
@ -226,14 +226,14 @@ fn Unreachable(cx: block) {
}
}
fn _Undef(val: ValueRef) -> ValueRef {
pub fn _Undef(val: ValueRef) -> ValueRef {
unsafe {
return llvm::LLVMGetUndef(val_ty(val));
}
}
/* Arithmetic */
fn Add(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
pub fn Add(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, "add");
@ -241,7 +241,7 @@ fn Add(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
}
}
fn NSWAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
pub fn NSWAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, "nswadd");
@ -249,7 +249,7 @@ fn NSWAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
}
}
fn NUWAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
pub fn NUWAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, "nuwadd");
@ -257,7 +257,7 @@ fn NUWAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
}
}
fn FAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
pub fn FAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, "fadd");
@ -265,7 +265,7 @@ fn FAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
}
}
fn Sub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
pub fn Sub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, "sub");
@ -273,7 +273,7 @@ fn Sub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
}
}
fn NSWSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
pub fn NSWSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, "nwsub");
@ -281,7 +281,7 @@ fn NSWSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
}
}
fn NUWSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
pub fn NUWSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, "nuwsub");
@ -289,7 +289,7 @@ fn NUWSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
}
}
fn FSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
pub fn FSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, "sub");
@ -297,7 +297,7 @@ fn FSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
}
}
fn Mul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
pub fn Mul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, "mul");
@ -305,7 +305,7 @@ fn Mul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
}
}
fn NSWMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
pub fn NSWMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, "nswmul");
@ -313,7 +313,7 @@ fn NSWMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
}
}
fn NUWMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
pub fn NUWMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, "nuwmul");
@ -321,7 +321,7 @@ fn NUWMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
}
}
fn FMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
pub fn FMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, "fmul");
@ -329,7 +329,7 @@ fn FMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
}
}
fn UDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
pub fn UDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, "udiv");
@ -337,7 +337,7 @@ fn UDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
}
}
fn SDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
pub fn SDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, "sdiv");
@ -345,7 +345,7 @@ fn SDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
}
}
fn ExactSDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
pub fn ExactSDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, "extractsdiv");
@ -353,7 +353,7 @@ fn ExactSDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
}
}
fn FDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
pub fn FDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, "fdiv");
@ -361,7 +361,7 @@ fn FDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
}
}
fn URem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
pub fn URem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, "urem");
@ -369,7 +369,7 @@ fn URem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
}
}
fn SRem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
pub fn SRem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, "srem");
@ -377,7 +377,7 @@ fn SRem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
}
}
fn FRem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
pub fn FRem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, "frem");
@ -385,7 +385,7 @@ fn FRem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
}
}
fn Shl(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
pub fn Shl(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, "shl");
@ -393,7 +393,7 @@ fn Shl(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
}
}
fn LShr(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
pub fn LShr(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, "lshr");
@ -401,7 +401,7 @@ fn LShr(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
}
}
fn AShr(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
pub fn AShr(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, "ashr");
@ -409,7 +409,7 @@ fn AShr(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
}
}
fn And(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
pub fn And(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, "and");
@ -417,7 +417,7 @@ fn And(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
}
}
fn Or(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
pub fn Or(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, "or");
@ -425,7 +425,7 @@ fn Or(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
}
}
fn Xor(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
pub fn Xor(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, "xor");
@ -433,7 +433,8 @@ fn Xor(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
}
}
fn BinOp(cx: block, Op: Opcode, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
pub fn BinOp(cx: block, Op: Opcode, LHS: ValueRef, RHS: ValueRef)
-> ValueRef {
unsafe {
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, "binop");
@ -441,7 +442,7 @@ fn BinOp(cx: block, Op: Opcode, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
}
}
fn Neg(cx: block, V: ValueRef) -> ValueRef {
pub fn Neg(cx: block, V: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(V); }
count_insn(cx, "neg");
@ -449,7 +450,7 @@ fn Neg(cx: block, V: ValueRef) -> ValueRef {
}
}
fn NSWNeg(cx: block, V: ValueRef) -> ValueRef {
pub fn NSWNeg(cx: block, V: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(V); }
count_insn(cx, "nswneg");
@ -457,14 +458,14 @@ fn NSWNeg(cx: block, V: ValueRef) -> ValueRef {
}
}
fn NUWNeg(cx: block, V: ValueRef) -> ValueRef {
pub fn NUWNeg(cx: block, V: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(V); }
count_insn(cx, "nuwneg");
return llvm::LLVMBuildNUWNeg(B(cx), V, noname());
}
}
fn FNeg(cx: block, V: ValueRef) -> ValueRef {
pub fn FNeg(cx: block, V: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(V); }
count_insn(cx, "fneg");
@ -472,7 +473,7 @@ fn FNeg(cx: block, V: ValueRef) -> ValueRef {
}
}
fn Not(cx: block, V: ValueRef) -> ValueRef {
pub fn Not(cx: block, V: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return _Undef(V); }
count_insn(cx, "not");
@ -481,7 +482,7 @@ fn Not(cx: block, V: ValueRef) -> ValueRef {
}
/* Memory */
fn Malloc(cx: block, Ty: TypeRef) -> ValueRef {
pub fn Malloc(cx: block, Ty: TypeRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_i8())); }
count_insn(cx, "malloc");
@ -489,7 +490,7 @@ fn Malloc(cx: block, Ty: TypeRef) -> ValueRef {
}
}
fn ArrayMalloc(cx: block, Ty: TypeRef, Val: ValueRef) -> ValueRef {
pub fn ArrayMalloc(cx: block, Ty: TypeRef, Val: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_i8())); }
count_insn(cx, "arraymalloc");
@ -497,7 +498,7 @@ fn ArrayMalloc(cx: block, Ty: TypeRef, Val: ValueRef) -> ValueRef {
}
}
fn Alloca(cx: block, Ty: TypeRef) -> ValueRef {
pub fn Alloca(cx: block, Ty: TypeRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(Ty)); }
count_insn(cx, "alloca");
@ -505,7 +506,7 @@ fn Alloca(cx: block, Ty: TypeRef) -> ValueRef {
}
}
fn ArrayAlloca(cx: block, Ty: TypeRef, Val: ValueRef) -> ValueRef {
pub fn ArrayAlloca(cx: block, Ty: TypeRef, Val: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(Ty)); }
count_insn(cx, "arrayalloca");
@ -513,7 +514,7 @@ fn ArrayAlloca(cx: block, Ty: TypeRef, Val: ValueRef) -> ValueRef {
}
}
fn Free(cx: block, PointerVal: ValueRef) {
pub fn Free(cx: block, PointerVal: ValueRef) {
unsafe {
if cx.unreachable { return; }
count_insn(cx, "free");
@ -521,7 +522,7 @@ fn Free(cx: block, PointerVal: ValueRef) {
}
}
fn Load(cx: block, PointerVal: ValueRef) -> ValueRef {
pub fn Load(cx: block, PointerVal: ValueRef) -> ValueRef {
unsafe {
let ccx = cx.fcx.ccx;
if cx.unreachable {
@ -535,7 +536,7 @@ fn Load(cx: block, PointerVal: ValueRef) -> ValueRef {
}
}
fn Store(cx: block, Val: ValueRef, Ptr: ValueRef) {
pub fn Store(cx: block, Val: ValueRef, Ptr: ValueRef) {
unsafe {
if cx.unreachable { return; }
debug!("Store %s -> %s",
@ -546,7 +547,7 @@ fn Store(cx: block, Val: ValueRef, Ptr: ValueRef) {
}
}
fn GEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) -> ValueRef {
pub fn GEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_nil())); }
count_insn(cx, "gep");
@ -559,13 +560,13 @@ fn GEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) -> ValueRef {
// in C_i32()
//
// XXX: Use a small-vector optimization to avoid allocations here.
fn GEPi(cx: block, base: ValueRef, ixs: &[uint]) -> ValueRef {
pub fn GEPi(cx: block, base: ValueRef, ixs: &[uint]) -> ValueRef {
let v = do vec::map(ixs) |i| { C_i32(*i as i32) };
count_insn(cx, "gepi");
return InBoundsGEP(cx, base, v);
}
fn InBoundsGEP(cx: block, Pointer: ValueRef, Indices: &[ValueRef]) ->
pub fn InBoundsGEP(cx: block, Pointer: ValueRef, Indices: &[ValueRef]) ->
ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_nil())); }
@ -579,7 +580,7 @@ fn InBoundsGEP(cx: block, Pointer: ValueRef, Indices: &[ValueRef]) ->
}
}
fn StructGEP(cx: block, Pointer: ValueRef, Idx: uint) -> ValueRef {
pub fn StructGEP(cx: block, Pointer: ValueRef, Idx: uint) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_nil())); }
count_insn(cx, "structgep");
@ -590,7 +591,7 @@ fn StructGEP(cx: block, Pointer: ValueRef, Idx: uint) -> ValueRef {
}
}
fn GlobalString(cx: block, _Str: *libc::c_char) -> ValueRef {
pub fn GlobalString(cx: block, _Str: *libc::c_char) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_i8())); }
count_insn(cx, "globalstring");
@ -598,7 +599,7 @@ fn GlobalString(cx: block, _Str: *libc::c_char) -> ValueRef {
}
}
fn GlobalStringPtr(cx: block, _Str: *libc::c_char) -> ValueRef {
pub fn GlobalStringPtr(cx: block, _Str: *libc::c_char) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_i8())); }
count_insn(cx, "globalstringptr");
@ -607,7 +608,7 @@ fn GlobalStringPtr(cx: block, _Str: *libc::c_char) -> ValueRef {
}
/* Casts */
fn Trunc(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
pub fn Trunc(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, "trunc");
@ -615,7 +616,7 @@ fn Trunc(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
}
}
fn ZExt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
pub fn ZExt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, "zext");
@ -623,7 +624,7 @@ fn ZExt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
}
}
fn SExt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
pub fn SExt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, "sext");
@ -631,7 +632,7 @@ fn SExt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
}
}
fn FPToUI(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
pub fn FPToUI(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, "fptoui");
@ -639,7 +640,7 @@ fn FPToUI(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
}
}
fn FPToSI(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
pub fn FPToSI(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, "fptosi");
@ -647,7 +648,7 @@ fn FPToSI(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
}
}
fn UIToFP(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
pub fn UIToFP(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, "uitofp");
@ -655,7 +656,7 @@ fn UIToFP(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
}
}
fn SIToFP(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
pub fn SIToFP(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, "sitofp");
@ -663,7 +664,7 @@ fn SIToFP(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
}
}
fn FPTrunc(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
pub fn FPTrunc(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, "fptrunc");
@ -671,7 +672,7 @@ fn FPTrunc(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
}
}
fn FPExt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
pub fn FPExt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, "fpext");
@ -679,7 +680,7 @@ fn FPExt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
}
}
fn PtrToInt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
pub fn PtrToInt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, "ptrtoint");
@ -687,7 +688,7 @@ fn PtrToInt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
}
}
fn IntToPtr(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
pub fn IntToPtr(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, "inttoptr");
@ -695,7 +696,7 @@ fn IntToPtr(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
}
}
fn BitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
pub fn BitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, "bitcast");
@ -703,7 +704,7 @@ fn BitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
}
}
fn ZExtOrBitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
pub fn ZExtOrBitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, "zextorbitcast");
@ -711,7 +712,7 @@ fn ZExtOrBitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
}
}
fn SExtOrBitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
pub fn SExtOrBitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, "sextorbitcast");
@ -719,7 +720,7 @@ fn SExtOrBitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
}
}
fn TruncOrBitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
pub fn TruncOrBitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, "truncorbitcast");
@ -727,7 +728,7 @@ fn TruncOrBitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
}
}
fn Cast(cx: block, Op: Opcode, Val: ValueRef, DestTy: TypeRef, _: *u8)
pub fn Cast(cx: block, Op: Opcode, Val: ValueRef, DestTy: TypeRef, _: *u8)
-> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
@ -736,7 +737,7 @@ fn Cast(cx: block, Op: Opcode, Val: ValueRef, DestTy: TypeRef, _: *u8)
}
}
fn PointerCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
pub fn PointerCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, "pointercast");
@ -744,7 +745,7 @@ fn PointerCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
}
}
fn IntCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
pub fn IntCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, "intcast");
@ -752,7 +753,7 @@ fn IntCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
}
}
fn FPCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
pub fn FPCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, "fpcast");
@ -762,7 +763,7 @@ fn FPCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
/* Comparisons */
fn ICmp(cx: block, Op: IntPredicate, LHS: ValueRef, RHS: ValueRef)
pub fn ICmp(cx: block, Op: IntPredicate, LHS: ValueRef, RHS: ValueRef)
-> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(T_i1()); }
@ -771,7 +772,7 @@ fn ICmp(cx: block, Op: IntPredicate, LHS: ValueRef, RHS: ValueRef)
}
}
fn FCmp(cx: block, Op: RealPredicate, LHS: ValueRef, RHS: ValueRef)
pub fn FCmp(cx: block, Op: RealPredicate, LHS: ValueRef, RHS: ValueRef)
-> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(T_i1()); }
@ -781,7 +782,7 @@ fn FCmp(cx: block, Op: RealPredicate, LHS: ValueRef, RHS: ValueRef)
}
/* Miscellaneous instructions */
fn EmptyPhi(cx: block, Ty: TypeRef) -> ValueRef {
pub fn EmptyPhi(cx: block, Ty: TypeRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(Ty); }
count_insn(cx, "emptyphi");
@ -789,7 +790,7 @@ fn EmptyPhi(cx: block, Ty: TypeRef) -> ValueRef {
}
}
fn Phi(cx: block, Ty: TypeRef, vals: ~[ValueRef], bbs: ~[BasicBlockRef])
pub fn Phi(cx: block, Ty: TypeRef, vals: ~[ValueRef], bbs: ~[BasicBlockRef])
-> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(Ty); }
@ -803,7 +804,7 @@ fn Phi(cx: block, Ty: TypeRef, vals: ~[ValueRef], bbs: ~[BasicBlockRef])
}
}
fn AddIncomingToPhi(phi: ValueRef, val: ValueRef, bb: BasicBlockRef) {
pub fn AddIncomingToPhi(phi: ValueRef, val: ValueRef, bb: BasicBlockRef) {
unsafe {
if llvm::LLVMIsUndef(phi) == lib::llvm::True { return; }
let valptr = cast::reinterpret_cast(&ptr::addr_of(&val));
@ -812,7 +813,7 @@ fn AddIncomingToPhi(phi: ValueRef, val: ValueRef, bb: BasicBlockRef) {
}
}
fn _UndefReturn(cx: block, Fn: ValueRef) -> ValueRef {
pub fn _UndefReturn(cx: block, Fn: ValueRef) -> ValueRef {
unsafe {
let ccx = cx.fcx.ccx;
let ty = val_ty(Fn);
@ -823,7 +824,7 @@ fn _UndefReturn(cx: block, Fn: ValueRef) -> ValueRef {
}
}
fn add_span_comment(bcx: block, sp: span, text: ~str) {
pub fn add_span_comment(bcx: block, sp: span, text: ~str) {
let ccx = bcx.ccx();
if !ccx.sess.no_asm_comments() {
let s = text + ~" (" + ccx.sess.codemap.span_to_str(sp)
@ -833,7 +834,7 @@ fn add_span_comment(bcx: block, sp: span, text: ~str) {
}
}
fn add_comment(bcx: block, text: ~str) {
pub fn add_comment(bcx: block, text: ~str) {
unsafe {
let ccx = bcx.ccx();
if !ccx.sess.no_asm_comments() {
@ -852,7 +853,7 @@ fn add_comment(bcx: block, text: ~str) {
}
}
fn Call(cx: block, Fn: ValueRef, Args: &[ValueRef]) -> ValueRef {
pub fn Call(cx: block, Fn: ValueRef, Args: &[ValueRef]) -> ValueRef {
if cx.unreachable { return _UndefReturn(cx, Fn); }
unsafe {
count_insn(cx, "call");
@ -867,7 +868,7 @@ fn Call(cx: block, Fn: ValueRef, Args: &[ValueRef]) -> ValueRef {
}
}
fn FastCall(cx: block, Fn: ValueRef, Args: ~[ValueRef]) -> ValueRef {
pub fn FastCall(cx: block, Fn: ValueRef, Args: ~[ValueRef]) -> ValueRef {
if cx.unreachable { return _UndefReturn(cx, Fn); }
unsafe {
count_insn(cx, "fastcall");
@ -878,8 +879,8 @@ fn FastCall(cx: block, Fn: ValueRef, Args: ~[ValueRef]) -> ValueRef {
}
}
fn CallWithConv(cx: block, Fn: ValueRef, Args: ~[ValueRef],
Conv: CallConv) -> ValueRef {
pub fn CallWithConv(cx: block, Fn: ValueRef, Args: ~[ValueRef],
Conv: CallConv) -> ValueRef {
if cx.unreachable { return _UndefReturn(cx, Fn); }
unsafe {
count_insn(cx, "callwithconv");
@ -890,7 +891,7 @@ fn CallWithConv(cx: block, Fn: ValueRef, Args: ~[ValueRef],
}
}
fn Select(cx: block, If: ValueRef, Then: ValueRef, Else: ValueRef) ->
pub fn Select(cx: block, If: ValueRef, Then: ValueRef, Else: ValueRef) ->
ValueRef {
unsafe {
if cx.unreachable { return _Undef(Then); }
@ -899,7 +900,7 @@ fn Select(cx: block, If: ValueRef, Then: ValueRef, Else: ValueRef) ->
}
}
fn VAArg(cx: block, list: ValueRef, Ty: TypeRef) -> ValueRef {
pub fn VAArg(cx: block, list: ValueRef, Ty: TypeRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(Ty); }
count_insn(cx, "vaarg");
@ -907,7 +908,7 @@ fn VAArg(cx: block, list: ValueRef, Ty: TypeRef) -> ValueRef {
}
}
fn ExtractElement(cx: block, VecVal: ValueRef, Index: ValueRef) ->
pub fn ExtractElement(cx: block, VecVal: ValueRef, Index: ValueRef) ->
ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(T_nil()); }
@ -916,7 +917,7 @@ fn ExtractElement(cx: block, VecVal: ValueRef, Index: ValueRef) ->
}
}
fn InsertElement(cx: block, VecVal: ValueRef, EltVal: ValueRef,
pub fn InsertElement(cx: block, VecVal: ValueRef, EltVal: ValueRef,
Index: ValueRef) {
unsafe {
if cx.unreachable { return; }
@ -925,8 +926,8 @@ fn InsertElement(cx: block, VecVal: ValueRef, EltVal: ValueRef,
}
}
fn ShuffleVector(cx: block, V1: ValueRef, V2: ValueRef,
Mask: ValueRef) {
pub fn ShuffleVector(cx: block, V1: ValueRef, V2: ValueRef,
Mask: ValueRef) {
unsafe {
if cx.unreachable { return; }
count_insn(cx, "shufflevector");
@ -934,7 +935,7 @@ fn ShuffleVector(cx: block, V1: ValueRef, V2: ValueRef,
}
}
fn ExtractValue(cx: block, AggVal: ValueRef, Index: uint) -> ValueRef {
pub fn ExtractValue(cx: block, AggVal: ValueRef, Index: uint) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(T_nil()); }
count_insn(cx, "extractvalue");
@ -943,8 +944,8 @@ fn ExtractValue(cx: block, AggVal: ValueRef, Index: uint) -> ValueRef {
}
}
fn InsertValue(cx: block, AggVal: ValueRef, EltVal: ValueRef,
Index: uint) {
pub fn InsertValue(cx: block, AggVal: ValueRef, EltVal: ValueRef,
Index: uint) {
unsafe {
if cx.unreachable { return; }
count_insn(cx, "insertvalue");
@ -953,7 +954,7 @@ fn InsertValue(cx: block, AggVal: ValueRef, EltVal: ValueRef,
}
}
fn IsNull(cx: block, Val: ValueRef) -> ValueRef {
pub fn IsNull(cx: block, Val: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(T_i1()); }
count_insn(cx, "isnull");
@ -961,7 +962,7 @@ fn IsNull(cx: block, Val: ValueRef) -> ValueRef {
}
}
fn IsNotNull(cx: block, Val: ValueRef) -> ValueRef {
pub fn IsNotNull(cx: block, Val: ValueRef) -> ValueRef {
unsafe {
if cx.unreachable { return llvm::LLVMGetUndef(T_i1()); }
count_insn(cx, "isnotnull");
@ -969,7 +970,7 @@ fn IsNotNull(cx: block, Val: ValueRef) -> ValueRef {
}
}
fn PtrDiff(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
pub fn PtrDiff(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
unsafe {
let ccx = cx.fcx.ccx;
if cx.unreachable { return llvm::LLVMGetUndef(ccx.int_type); }
@ -978,7 +979,7 @@ fn PtrDiff(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
}
}
fn Trap(cx: block) {
pub fn Trap(cx: block) {
unsafe {
if cx.unreachable { return; }
let b = B(cx);
@ -998,8 +999,8 @@ fn Trap(cx: block) {
}
}
fn LandingPad(cx: block, Ty: TypeRef, PersFn: ValueRef,
NumClauses: uint) -> ValueRef {
pub fn LandingPad(cx: block, Ty: TypeRef, PersFn: ValueRef,
NumClauses: uint) -> ValueRef {
unsafe {
check_not_terminated(cx);
assert !cx.unreachable;
@ -1009,14 +1010,14 @@ fn LandingPad(cx: block, Ty: TypeRef, PersFn: ValueRef,
}
}
fn SetCleanup(cx: block, LandingPad: ValueRef) {
pub fn SetCleanup(cx: block, LandingPad: ValueRef) {
unsafe {
count_insn(cx, "setcleanup");
llvm::LLVMSetCleanup(LandingPad, lib::llvm::True);
}
}
fn Resume(cx: block, Exn: ValueRef) -> ValueRef {
pub fn Resume(cx: block, Exn: ValueRef) -> ValueRef {
unsafe {
check_not_terminated(cx);
terminate(cx, "Resume");
@ -1026,16 +1027,16 @@ fn Resume(cx: block, Exn: ValueRef) -> ValueRef {
}
// Atomic Operations
fn AtomicCmpXchg(cx: block, dst: ValueRef,
cmp: ValueRef, src: ValueRef,
order: AtomicOrdering) -> ValueRef {
pub fn AtomicCmpXchg(cx: block, dst: ValueRef,
cmp: ValueRef, src: ValueRef,
order: AtomicOrdering) -> ValueRef {
unsafe {
llvm::LLVMBuildAtomicCmpXchg(B(cx), dst, cmp, src, order)
}
}
fn AtomicRMW(cx: block, op: AtomicBinOp,
dst: ValueRef, src: ValueRef,
order: AtomicOrdering) -> ValueRef {
pub fn AtomicRMW(cx: block, op: AtomicBinOp,
dst: ValueRef, src: ValueRef,
order: AtomicOrdering) -> ValueRef {
unsafe {
llvm::LLVMBuildAtomicRMW(B(cx), op, dst, src, order)
}

View file

@ -13,29 +13,26 @@ use middle::trans::base::*;
use middle::trans::build::*;
use middle::trans::common::*;
export ABIInfo, LLVMType, FnType;
export llvm_abi_info;
trait ABIInfo {
pub trait ABIInfo {
fn compute_info(&self,
atys: &[TypeRef],
rty: TypeRef,
ret_def: bool) -> FnType;
}
struct LLVMType {
pub struct LLVMType {
cast: bool,
ty: TypeRef
}
struct FnType {
pub struct FnType {
arg_tys: ~[LLVMType],
ret_ty: LLVMType,
attrs: ~[Option<Attribute>],
sret: bool
}
impl FnType {
pub impl FnType {
fn decl_fn(&self, decl: fn(fnty: TypeRef) -> ValueRef) -> ValueRef {
let atys = vec::map(self.arg_tys, |t| t.ty);
let rty = self.ret_ty.ty;
@ -208,7 +205,7 @@ impl LLVM_ABIInfo: ABIInfo {
}
}
fn llvm_abi_info() -> ABIInfo {
pub fn llvm_abi_info() -> ABIInfo {
return LLVM_ABIInfo as ABIInfo;
}

View file

@ -17,8 +17,6 @@ use lib::llvm::{StructRetAttribute, ByValAttribute};
use middle::trans::common::*;
use middle::trans::cabi::*;
export x86_64_abi_info;
enum x86_64_reg_class {
no_class,
integer_class,
@ -412,6 +410,6 @@ impl X86_64_ABIInfo: ABIInfo {
}
}
fn x86_64_abi_info() -> ABIInfo {
pub fn x86_64_abi_info() -> ABIInfo {
return X86_64_ABIInfo as ABIInfo;
}

View file

@ -23,6 +23,7 @@ use middle::trans::common::*;
use middle::trans::datum::{Datum, INIT, ByRef, ByValue, FromLvalue};
use middle::trans::expr;
use middle::trans::glue;
use middle::trans::machine;
use middle::trans::type_of::*;
use util::ppaux::ty_to_str;
@ -103,7 +104,7 @@ use syntax::print::pprust::expr_to_str;
//
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
enum EnvAction {
pub enum EnvAction {
/// Copy the value from this llvm ValueRef into the environment.
EnvStore,
@ -114,12 +115,12 @@ enum EnvAction {
EnvRef
}
struct EnvValue {
pub struct EnvValue {
action: EnvAction,
datum: Datum
}
impl EnvAction {
pub impl EnvAction {
fn to_str() -> ~str {
match self {
EnvStore => ~"EnvStore",
@ -129,21 +130,21 @@ impl EnvAction {
}
}
impl EnvValue {
pub impl EnvValue {
fn to_str(ccx: @crate_ctxt) -> ~str {
fmt!("%s(%s)", self.action.to_str(), self.datum.to_str(ccx))
}
}
fn mk_tuplified_uniq_cbox_ty(tcx: ty::ctxt, cdata_ty: ty::t) -> ty::t {
pub fn mk_tuplified_uniq_cbox_ty(tcx: ty::ctxt, cdata_ty: ty::t) -> ty::t {
let cbox_ty = tuplify_box_ty(tcx, cdata_ty);
return ty::mk_imm_uniq(tcx, cbox_ty);
}
// Given a closure ty, emits a corresponding tuple ty
fn mk_closure_tys(tcx: ty::ctxt,
bound_values: ~[EnvValue])
-> ty::t {
pub fn mk_closure_tys(tcx: ty::ctxt,
bound_values: ~[EnvValue])
-> ty::t {
// determine the types of the values in the env. Note that this
// is the actual types that will be stored in the map, not the
// logical types as the user sees them, so by-ref upvars must be
@ -159,9 +160,8 @@ fn mk_closure_tys(tcx: ty::ctxt,
return cdata_ty;
}
fn allocate_cbox(bcx: block, proto: ast::Proto, cdata_ty: ty::t)
-> Result
{
pub fn allocate_cbox(bcx: block, proto: ast::Proto, cdata_ty: ty::t)
-> Result {
let _icx = bcx.insn_ctxt("closure::allocate_cbox");
let ccx = bcx.ccx(), tcx = ccx.tcx;
@ -196,7 +196,7 @@ fn allocate_cbox(bcx: block, proto: ast::Proto, cdata_ty: ty::t)
}
}
type closure_result = {
pub type closure_result = {
llbox: ValueRef, // llvalue of ptr to closure
cdata_ty: ty::t, // type of the closure data
bcx: block // final bcx
@ -206,9 +206,9 @@ type closure_result = {
// construct a closure out of them. If copying is true, it is a
// heap allocated closure that copies the upvars into environment.
// Otherwise, it is stack allocated and copies pointers to the upvars.
fn store_environment(bcx: block,
bound_values: ~[EnvValue],
proto: ast::Proto) -> closure_result {
pub fn store_environment(bcx: block,
bound_values: ~[EnvValue],
proto: ast::Proto) -> closure_result {
let _icx = bcx.insn_ctxt("closure::store_environment");
let ccx = bcx.ccx(), tcx = ccx.tcx;
@ -263,10 +263,10 @@ fn store_environment(bcx: block,
// Given a context and a list of upvars, build a closure. This just
// collects the upvars and packages them up for store_environment.
fn build_closure(bcx0: block,
cap_vars: ~[capture::capture_var],
proto: ast::Proto,
include_ret_handle: Option<ValueRef>) -> closure_result {
pub fn build_closure(bcx0: block,
cap_vars: ~[capture::capture_var],
proto: ast::Proto,
include_ret_handle: Option<ValueRef>) -> closure_result {
let _icx = bcx0.insn_ctxt("closure::build_closure");
// If we need to, package up the iterator body to call
let mut bcx = bcx0;;
@ -326,11 +326,11 @@ fn build_closure(bcx0: block,
// Given an enclosing block context, a new function context, a closure type,
// and a list of upvars, generate code to load and populate the environment
// with the upvars and type descriptors.
fn load_environment(fcx: fn_ctxt,
cdata_ty: ty::t,
cap_vars: ~[capture::capture_var],
load_ret_handle: bool,
proto: ast::Proto) {
pub fn load_environment(fcx: fn_ctxt,
cdata_ty: ty::t,
cap_vars: ~[capture::capture_var],
load_ret_handle: bool,
proto: ast::Proto) {
let _icx = fcx.insn_ctxt("closure::load_environment");
let llloadenv = match fcx.llloadenv {
@ -377,16 +377,15 @@ fn load_environment(fcx: fn_ctxt,
}
}
fn trans_expr_fn(bcx: block,
proto: ast::Proto,
+decl: ast::fn_decl,
+body: ast::blk,
outer_id: ast::node_id,
user_id: ast::node_id,
cap_clause: ast::capture_clause,
is_loop_body: Option<Option<ValueRef>>,
dest: expr::Dest) -> block
{
pub fn trans_expr_fn(bcx: block,
proto: ast::Proto,
+decl: ast::fn_decl,
+body: ast::blk,
outer_id: ast::node_id,
user_id: ast::node_id,
cap_clause: ast::capture_clause,
is_loop_body: Option<Option<ValueRef>>,
dest: expr::Dest) -> block {
/*!
*
* Translates the body of a closure expression.
@ -462,13 +461,11 @@ fn trans_expr_fn(bcx: block,
return bcx;
}
fn make_fn_glue(
cx: block,
v: ValueRef,
t: ty::t,
glue_fn: fn@(block, v: ValueRef, t: ty::t) -> block)
-> block
{
pub fn make_fn_glue(cx: block,
v: ValueRef,
t: ty::t,
glue_fn: fn@(block, v: ValueRef, t: ty::t) -> block)
-> block {
let _icx = cx.insn_ctxt("closure::make_fn_glue");
let bcx = cx;
let tcx = cx.tcx();
@ -487,12 +484,11 @@ fn make_fn_glue(
}
}
fn make_opaque_cbox_take_glue(
pub fn make_opaque_cbox_take_glue(
bcx: block,
proto: ast::Proto,
cboxptr: ValueRef) // ptr to ptr to the opaque closure
-> block
{
-> block {
// Easy cases:
let _icx = bcx.insn_ctxt("closure::make_opaque_cbox_take_glue");
match proto {
@ -521,7 +517,7 @@ fn make_opaque_cbox_take_glue(
let sz = Load(bcx, GEPi(bcx, tydesc, [0u, abi::tydesc_field_size]));
// Adjust sz to account for the rust_opaque_box header fields
let sz = Add(bcx, sz, shape::llsize_of(ccx, T_box_header(ccx)));
let sz = Add(bcx, sz, machine::llsize_of(ccx, T_box_header(ccx)));
// Allocate memory, update original ptr, and copy existing data
let opaque_tydesc = PointerCast(bcx, tydesc, T_ptr(T_i8()));
@ -547,7 +543,7 @@ fn make_opaque_cbox_take_glue(
}
}
fn make_opaque_cbox_drop_glue(
pub fn make_opaque_cbox_drop_glue(
bcx: block,
proto: ast::Proto,
cboxptr: ValueRef) // ptr to the opaque closure
@ -568,7 +564,7 @@ fn make_opaque_cbox_drop_glue(
}
}
fn make_opaque_cbox_free_glue(
pub fn make_opaque_cbox_free_glue(
bcx: block,
proto: ast::Proto,
cbox: ValueRef) // ptr to ptr to the opaque closure

File diff suppressed because it is too large Load diff

View file

@ -15,11 +15,12 @@ use middle::trans::base::get_insn_ctxt;
use middle::trans::common::*;
use middle::trans::consts;
use middle::trans::expr;
use middle::trans::machine;
use middle::ty;
use syntax::{ast, ast_util, codemap, ast_map};
fn const_lit(cx: @crate_ctxt, e: @ast::expr, lit: ast::lit)
pub fn const_lit(cx: @crate_ctxt, e: @ast::expr, lit: ast::lit)
-> ValueRef {
let _icx = cx.insn_ctxt("trans_lit");
match lit.node {
@ -58,7 +59,7 @@ fn const_lit(cx: @crate_ctxt, e: @ast::expr, lit: ast::lit)
}
}
fn const_ptrcast(cx: @crate_ctxt, a: ValueRef, t: TypeRef) -> ValueRef {
pub fn const_ptrcast(cx: @crate_ctxt, a: ValueRef, t: TypeRef) -> ValueRef {
unsafe {
let b = llvm::LLVMConstPointerCast(a, T_ptr(t));
assert cx.const_globals.insert(b as int, a);
@ -66,20 +67,20 @@ fn const_ptrcast(cx: @crate_ctxt, a: ValueRef, t: TypeRef) -> ValueRef {
}
}
fn const_vec(cx: @crate_ctxt, e: @ast::expr, es: &[@ast::expr])
pub fn const_vec(cx: @crate_ctxt, e: @ast::expr, es: &[@ast::expr])
-> (ValueRef, ValueRef, TypeRef) {
unsafe {
let vec_ty = ty::expr_ty(cx.tcx, e);
let unit_ty = ty::sequence_element_type(cx.tcx, vec_ty);
let llunitty = type_of::type_of(cx, unit_ty);
let v = C_array(llunitty, es.map(|e| const_expr(cx, *e)));
let unit_sz = shape::llsize_of(cx, llunitty);
let unit_sz = machine::llsize_of(cx, llunitty);
let sz = llvm::LLVMConstMul(C_uint(cx, es.len()), unit_sz);
return (v, sz, llunitty);
}
}
fn const_deref(cx: @crate_ctxt, v: ValueRef) -> ValueRef {
pub fn const_deref(cx: @crate_ctxt, v: ValueRef) -> ValueRef {
unsafe {
let v = match cx.const_globals.find(v as int) {
Some(v) => v,
@ -91,7 +92,8 @@ fn const_deref(cx: @crate_ctxt, v: ValueRef) -> ValueRef {
}
}
fn const_get_elt(cx: @crate_ctxt, v: ValueRef, us: &[c_uint]) -> ValueRef {
pub fn const_get_elt(cx: @crate_ctxt, v: ValueRef, us: &[c_uint])
-> ValueRef {
unsafe {
let r = do vec::as_imm_buf(us) |p, len| {
llvm::LLVMConstExtractValue(v, p, len as c_uint)
@ -104,7 +106,7 @@ fn const_get_elt(cx: @crate_ctxt, v: ValueRef, us: &[c_uint]) -> ValueRef {
}
}
fn const_autoderef(cx: @crate_ctxt, ty: ty::t, v: ValueRef)
pub fn const_autoderef(cx: @crate_ctxt, ty: ty::t, v: ValueRef)
-> (ty::t, ValueRef) {
let mut t1 = ty;
let mut v1 = v;
@ -120,7 +122,7 @@ fn const_autoderef(cx: @crate_ctxt, ty: ty::t, v: ValueRef)
}
}
fn get_const_val(cx: @crate_ctxt, def_id: ast::def_id) -> ValueRef {
pub fn get_const_val(cx: @crate_ctxt, def_id: ast::def_id) -> ValueRef {
if !ast_util::is_local(def_id) {
cx.tcx.sess.bug(~"cross-crate constants");
}
@ -137,7 +139,7 @@ fn get_const_val(cx: @crate_ctxt, def_id: ast::def_id) -> ValueRef {
cx.const_values.get(def_id.node)
}
fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
pub fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
unsafe {
let _icx = cx.insn_ctxt("const_expr");
return match /*bad*/copy e.node {
@ -244,7 +246,7 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
ty::vstore_slice(_) => {
let unit_ty = ty::sequence_element_type(cx.tcx, bt);
let llunitty = type_of::type_of(cx, unit_ty);
let unit_sz = shape::llsize_of(cx, llunitty);
let unit_sz = machine::llsize_of(cx, llunitty);
(const_deref(cx, const_get_elt(cx, bv, [0])),
llvm::LLVMConstUDiv(const_get_elt(cx, bv, [1]),
@ -450,7 +452,7 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
Some(ast::def_variant(tid, vid)) => {
let ety = ty::expr_ty(cx.tcx, e);
let degen = ty::enum_is_univariant(cx.tcx, tid);
let size = shape::static_size_of_enum(cx, ety);
let size = machine::static_size_of_enum(cx, ety);
let discrim = base::get_discrim_val(cx, e.span, tid, vid);
let c_args = C_struct(args.map(|a| const_expr(cx, *a)));
@ -474,7 +476,7 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
}
}
fn trans_const(ccx: @crate_ctxt, _e: @ast::expr, id: ast::node_id) {
pub fn trans_const(ccx: @crate_ctxt, _e: @ast::expr, id: ast::node_id) {
unsafe {
let _icx = ccx.insn_ctxt("trans_const");
let g = base::get_item_val(ccx, id);

View file

@ -17,7 +17,7 @@ use middle::pat_util::*;
use middle::trans::base;
use middle::trans::build::B;
use middle::trans::common::*;
use middle::trans::shape;
use middle::trans::machine;
use middle::trans::type_of;
use middle::trans;
use middle::ty;
@ -33,13 +33,6 @@ use syntax::codemap::{span, CharPos};
use syntax::parse::token::ident_interner;
use syntax::{ast, codemap, ast_util, ast_map};
export create_local_var;
export create_function;
export create_arg;
export update_source_pos;
export debug_ctxt;
export mk_ctxt;
const LLVMDebugVersion: int = (9 << 16);
const DW_LANG_RUST: int = 0x9000;
@ -111,13 +104,13 @@ fn add_named_metadata(cx: @crate_ctxt, name: ~str, val: ValueRef) {
////////////////
type debug_ctxt = {
pub type debug_ctxt = {
llmetadata: metadata_cache,
names: namegen,
crate_file: ~str
};
fn mk_ctxt(+crate: ~str, intr: @ident_interner) -> debug_ctxt {
pub fn mk_ctxt(+crate: ~str, intr: @ident_interner) -> debug_ctxt {
{llmetadata: map::HashMap(),
names: new_namegen(intr),
crate_file: crate}
@ -313,8 +306,8 @@ fn create_block(cx: block) -> @metadata<block_md> {
fn size_and_align_of(cx: @crate_ctxt, t: ty::t) -> (int, int) {
let llty = type_of::type_of(cx, t);
(shape::llsize_of_real(cx, llty) as int,
shape::llalign_of_pref(cx, llty) as int)
(machine::llsize_of_real(cx, llty) as int,
machine::llalign_of_pref(cx, llty) as int)
}
fn create_basic_type(cx: @crate_ctxt, t: ty::t, span: span)
@ -654,7 +647,7 @@ fn create_var(type_tag: int, context: ValueRef, +name: ~str, file: ValueRef,
return llmdnode(lldata);
}
fn create_local_var(bcx: block, local: @ast::local)
pub fn create_local_var(bcx: block, local: @ast::local)
-> @metadata<local_var_md> {
unsafe {
let cx = bcx.ccx();
@ -705,7 +698,7 @@ fn create_local_var(bcx: block, local: @ast::local)
}
}
fn create_arg(bcx: block, arg: ast::arg, sp: span)
pub fn create_arg(bcx: block, arg: ast::arg, sp: span)
-> Option<@metadata<argument_md>> {
unsafe {
let fcx = bcx.fcx, cx = fcx.ccx;
@ -752,7 +745,7 @@ fn create_arg(bcx: block, arg: ast::arg, sp: span)
}
}
fn update_source_pos(cx: block, s: span) {
pub fn update_source_pos(cx: block, s: span) {
if !cx.sess().opts.debuginfo {
return;
}
@ -769,7 +762,7 @@ fn update_source_pos(cx: block, s: span) {
}
}
fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> {
pub fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> {
let cx = fcx.ccx;
let dbg_cx = (/*bad*/copy cx.dbg_cx).get();

View file

@ -40,9 +40,6 @@ use syntax::{ast, ast_util};
use syntax::{attr, ast_map};
use syntax::parse::token::special_idents;
export link_name, trans_foreign_mod, register_foreign_fn, trans_foreign_fn,
trans_intrinsic;
fn abi_info(arch: session::arch) -> cabi::ABIInfo {
return match arch {
arch_x86_64 => x86_64_abi_info(),
@ -50,7 +47,7 @@ fn abi_info(arch: session::arch) -> cabi::ABIInfo {
}
}
fn link_name(ccx: @crate_ctxt, i: @ast::foreign_item) -> ~str {
pub fn link_name(ccx: @crate_ctxt, i: @ast::foreign_item) -> ~str {
match attr::first_attr_value_str_by_name(i.attrs, ~"link_name") {
None => ccx.sess.str_of(i.ident),
option::Some(ref ln) => (/*bad*/copy *ln)
@ -206,8 +203,9 @@ fn build_wrap_fn_(ccx: @crate_ctxt,
// stack pointer appropriately to avoid a round of copies. (In fact, the shim
// function itself is unnecessary). We used to do this, in fact, and will
// perhaps do so in the future.
fn trans_foreign_mod(ccx: @crate_ctxt,
foreign_mod: ast::foreign_mod, abi: ast::foreign_abi) {
pub fn trans_foreign_mod(ccx: @crate_ctxt,
foreign_mod: ast::foreign_mod,
abi: ast::foreign_abi) {
let _icx = ccx.insn_ctxt("foreign::trans_foreign_mod");
@ -332,10 +330,12 @@ fn trans_foreign_mod(ccx: @crate_ctxt,
}
}
fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item,
+path: ast_map::path, +substs: param_substs,
ref_id: Option<ast::node_id>)
{
pub fn trans_intrinsic(ccx: @crate_ctxt,
decl: ValueRef,
item: @ast::foreign_item,
+path: ast_map::path,
+substs: param_substs,
ref_id: Option<ast::node_id>) {
debug!("trans_intrinsic(item.ident=%s)", ccx.sess.str_of(item.ident));
// XXX: Bad copy.
@ -433,7 +433,7 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item,
~"size_of" => {
let tp_ty = substs.tys[0];
let lltp_ty = type_of::type_of(ccx, tp_ty);
Store(bcx, C_uint(ccx, shape::llsize_of_real(ccx, lltp_ty)),
Store(bcx, C_uint(ccx, machine::llsize_of_real(ccx, lltp_ty)),
fcx.llretptr);
}
~"move_val" => {
@ -464,13 +464,13 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item,
~"min_align_of" => {
let tp_ty = substs.tys[0];
let lltp_ty = type_of::type_of(ccx, tp_ty);
Store(bcx, C_uint(ccx, shape::llalign_of_min(ccx, lltp_ty)),
Store(bcx, C_uint(ccx, machine::llalign_of_min(ccx, lltp_ty)),
fcx.llretptr);
}
~"pref_align_of"=> {
let tp_ty = substs.tys[0];
let lltp_ty = type_of::type_of(ccx, tp_ty);
Store(bcx, C_uint(ccx, shape::llalign_of_pref(ccx, lltp_ty)),
Store(bcx, C_uint(ccx, machine::llalign_of_pref(ccx, lltp_ty)),
fcx.llretptr);
}
~"get_tydesc" => {
@ -839,9 +839,12 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item,
finish_fn(fcx, lltop);
}
fn trans_foreign_fn(ccx: @crate_ctxt, +path: ast_map::path,
decl: ast::fn_decl, body: ast::blk, llwrapfn: ValueRef,
id: ast::node_id) {
pub fn trans_foreign_fn(ccx: @crate_ctxt,
+path: ast_map::path,
decl: ast::fn_decl,
body: ast::blk,
llwrapfn: ValueRef,
id: ast::node_id) {
let _icx = ccx.insn_ctxt("foreign::build_foreign_fn");
fn build_rust_fn(ccx: @crate_ctxt, +path: ast_map::path,
@ -930,12 +933,12 @@ fn trans_foreign_fn(ccx: @crate_ctxt, +path: ast_map::path,
build_wrap_fn(ccx, llshimfn, llwrapfn, tys)
}
fn register_foreign_fn(ccx: @crate_ctxt,
sp: span,
+path: ast_map::path,
node_id: ast::node_id,
attrs: &[ast::attribute])
-> ValueRef {
pub fn register_foreign_fn(ccx: @crate_ctxt,
sp: span,
+path: ast_map::path,
node_id: ast::node_id,
attrs: &[ast::attribute])
-> ValueRef {
let _icx = ccx.insn_ctxt("foreign::register_foreign_fn");
let t = ty::node_id_to_type(ccx.tcx, node_id);
let (llargtys, llretty, ret_ty) = c_arg_and_ret_lltys(ccx, node_id);

View file

@ -39,7 +39,10 @@ use syntax::ast_util::local_def;
use syntax::print::pprust::expr_to_str;
use syntax::{ast, ast_map};
fn macros() { include!("macros.rs"); } // FIXME(#3114): Macro import/export.
pub fn macros() {
// FIXME(#3114): Macro import/export.
include!("macros.rs");
}
/**
The main "translation" pass for methods. Generates code
@ -47,9 +50,9 @@ for non-monomorphized methods only. Other methods will
be generated once they are invoked with specific type parameters,
see `trans::base::lval_static_fn()` or `trans::base::monomorphic_fn()`.
*/
fn trans_impl(ccx: @crate_ctxt, +path: path, name: ast::ident,
methods: ~[@ast::method], tps: ~[ast::ty_param],
self_ty: Option<ty::t>, id: ast::node_id) {
pub fn trans_impl(ccx: @crate_ctxt, +path: path, name: ast::ident,
methods: ~[@ast::method], tps: ~[ast::ty_param],
self_ty: Option<ty::t>, id: ast::node_id) {
let _icx = ccx.insn_ctxt("impl::trans_impl");
if tps.len() > 0u { return; }
let sub_path = vec::append_one(path, path_name(name));
@ -93,13 +96,13 @@ Translates a (possibly monomorphized) method body.
- `llfn`: the LLVM ValueRef for the method
- `impl_id`: the node ID of the impl this method is inside
*/
fn trans_method(ccx: @crate_ctxt,
+path: path,
method: &ast::method,
+param_substs: Option<param_substs>,
base_self_ty: Option<ty::t>,
llfn: ValueRef,
impl_id: ast::def_id) {
pub fn trans_method(ccx: @crate_ctxt,
+path: path,
method: &ast::method,
+param_substs: Option<param_substs>,
base_self_ty: Option<ty::t>,
llfn: ValueRef,
impl_id: ast::def_id) {
// figure out how self is being passed
let self_arg = match method.self_ty.node {
ast::sty_static => {
@ -148,9 +151,9 @@ fn trans_method(ccx: @crate_ctxt,
Some(impl_id));
}
fn trans_self_arg(bcx: block,
base: @ast::expr,
mentry: typeck::method_map_entry) -> Result {
pub fn trans_self_arg(bcx: block,
base: @ast::expr,
mentry: typeck::method_map_entry) -> Result {
let _icx = bcx.insn_ctxt("impl::trans_self_arg");
let mut temp_cleanups = ~[];
@ -172,9 +175,11 @@ fn trans_self_arg(bcx: block,
return result;
}
fn trans_method_callee(bcx: block, callee_id: ast::node_id,
self: @ast::expr, mentry: typeck::method_map_entry) ->
Callee {
pub fn trans_method_callee(bcx: block,
callee_id: ast::node_id,
self: @ast::expr,
mentry: typeck::method_map_entry)
-> Callee {
let _icx = bcx.insn_ctxt("impl::trans_method_callee");
// Replace method_self with method_static here.
@ -243,7 +248,7 @@ fn trans_method_callee(bcx: block, callee_id: ast::node_id,
}) => {
match bcx.fcx.param_substs {
Some(ref substs) => {
let vtbl = base::find_vtable(bcx.tcx(), substs, p, b);
let vtbl = find_vtable(bcx.tcx(), substs, p, b);
trans_monomorphized_callee(bcx, callee_id, self, mentry,
trait_id, off, vtbl)
}
@ -265,11 +270,11 @@ fn trans_method_callee(bcx: block, callee_id: ast::node_id,
}
}
fn trans_static_method_callee(bcx: block,
method_id: ast::def_id,
trait_id: ast::def_id,
callee_id: ast::node_id) -> FnData
{
pub fn trans_static_method_callee(bcx: block,
method_id: ast::def_id,
trait_id: ast::def_id,
callee_id: ast::node_id)
-> FnData {
let _icx = bcx.insn_ctxt("impl::trans_static_method_callee");
let ccx = bcx.ccx();
@ -348,13 +353,13 @@ fn trans_static_method_callee(bcx: block,
}
}
fn method_from_methods(ms: ~[@ast::method], name: ast::ident)
pub fn method_from_methods(ms: ~[@ast::method], name: ast::ident)
-> Option<ast::def_id> {
ms.find(|m| m.ident == name).map(|m| local_def(m.id))
}
fn method_with_name(ccx: @crate_ctxt, impl_id: ast::def_id,
name: ast::ident) -> ast::def_id {
pub fn method_with_name(ccx: @crate_ctxt, impl_id: ast::def_id,
name: ast::ident) -> ast::def_id {
if impl_id.crate == ast::local_crate {
match ccx.tcx.items.get(impl_id.node) {
ast_map::node_item(@ast::item {
@ -370,8 +375,8 @@ fn method_with_name(ccx: @crate_ctxt, impl_id: ast::def_id,
}
}
fn method_with_name_or_default(ccx: @crate_ctxt, impl_id: ast::def_id,
name: ast::ident) -> ast::def_id {
pub fn method_with_name_or_default(ccx: @crate_ctxt, impl_id: ast::def_id,
name: ast::ident) -> ast::def_id {
if impl_id.crate == ast::local_crate {
match ccx.tcx.items.get(impl_id.node) {
ast_map::node_item(@ast::item {
@ -404,8 +409,8 @@ fn method_with_name_or_default(ccx: @crate_ctxt, impl_id: ast::def_id,
}
}
fn method_ty_param_count(ccx: @crate_ctxt, m_id: ast::def_id,
i_id: ast::def_id) -> uint {
pub fn method_ty_param_count(ccx: @crate_ctxt, m_id: ast::def_id,
i_id: ast::def_id) -> uint {
debug!("method_ty_param_count: m_id: %?, i_id: %?", m_id, i_id);
if m_id.crate == ast::local_crate {
match ccx.tcx.items.find(m_id.node) {
@ -431,15 +436,14 @@ fn method_ty_param_count(ccx: @crate_ctxt, m_id: ast::def_id,
}
}
fn trans_monomorphized_callee(bcx: block,
callee_id: ast::node_id,
base: @ast::expr,
mentry: typeck::method_map_entry,
trait_id: ast::def_id,
n_method: uint,
+vtbl: typeck::vtable_origin)
-> Callee
{
pub fn trans_monomorphized_callee(bcx: block,
callee_id: ast::node_id,
base: @ast::expr,
mentry: typeck::method_map_entry,
trait_id: ast::def_id,
n_method: uint,
+vtbl: typeck::vtable_origin)
-> Callee {
let _icx = bcx.insn_ctxt("impl::trans_monomorphized_callee");
return match vtbl {
typeck::vtable_static(impl_did, rcvr_substs, rcvr_origins) => {
@ -495,13 +499,12 @@ fn trans_monomorphized_callee(bcx: block,
}
fn combine_impl_and_methods_tps(bcx: block,
mth_did: ast::def_id,
impl_did: ast::def_id,
callee_id: ast::node_id,
+rcvr_substs: ~[ty::t])
-> ~[ty::t]
{
pub fn combine_impl_and_methods_tps(bcx: block,
mth_did: ast::def_id,
impl_did: ast::def_id,
callee_id: ast::node_id,
+rcvr_substs: ~[ty::t])
-> ~[ty::t] {
/*!
*
* Creates a concatenated set of substitutions which includes
@ -534,13 +537,12 @@ fn combine_impl_and_methods_tps(bcx: block,
return ty_substs;
}
fn combine_impl_and_methods_origins(bcx: block,
mth_did: ast::def_id,
impl_did: ast::def_id,
callee_id: ast::node_id,
rcvr_origins: typeck::vtable_res)
-> typeck::vtable_res
{
pub fn combine_impl_and_methods_origins(bcx: block,
mth_did: ast::def_id,
impl_did: ast::def_id,
callee_id: ast::node_id,
rcvr_origins: typeck::vtable_res)
-> typeck::vtable_res {
/*!
*
* Similar to `combine_impl_and_methods_tps`, but for vtables.
@ -576,14 +578,13 @@ fn combine_impl_and_methods_origins(bcx: block,
}
fn trans_trait_callee(bcx: block,
callee_id: ast::node_id,
n_method: uint,
self_expr: @ast::expr,
vstore: ty::vstore,
explicit_self: ast::self_ty_)
-> Callee
{
pub fn trans_trait_callee(bcx: block,
callee_id: ast::node_id,
n_method: uint,
self_expr: @ast::expr,
vstore: ty::vstore,
explicit_self: ast::self_ty_)
-> Callee {
//!
//
// Create a method callee where the method is coming from a trait
@ -614,14 +615,13 @@ fn trans_trait_callee(bcx: block,
explicit_self)
}
fn trans_trait_callee_from_llval(bcx: block,
callee_ty: ty::t,
n_method: uint,
llpair: ValueRef,
vstore: ty::vstore,
explicit_self: ast::self_ty_)
-> Callee
{
pub fn trans_trait_callee_from_llval(bcx: block,
callee_ty: ty::t,
n_method: uint,
llpair: ValueRef,
vstore: ty::vstore,
explicit_self: ast::self_ty_)
-> Callee {
//!
//
// Same as `trans_trait_callee()` above, except that it is given
@ -743,7 +743,9 @@ fn trans_trait_callee_from_llval(bcx: block,
};
}
fn vtable_id(ccx: @crate_ctxt, +origin: typeck::vtable_origin) -> mono_id {
pub fn vtable_id(ccx: @crate_ctxt,
+origin: typeck::vtable_origin)
-> mono_id {
match origin {
typeck::vtable_static(impl_id, substs, sub_vtables) => {
monomorphize::make_mono_id(
@ -770,7 +772,9 @@ fn vtable_id(ccx: @crate_ctxt, +origin: typeck::vtable_origin) -> mono_id {
}
}
fn get_vtable(ccx: @crate_ctxt, +origin: typeck::vtable_origin) -> ValueRef {
pub fn get_vtable(ccx: @crate_ctxt,
+origin: typeck::vtable_origin)
-> ValueRef {
// XXX: Bad copy.
let hash_id = vtable_id(ccx, copy origin);
match ccx.vtables.find(hash_id) {
@ -784,7 +788,7 @@ fn get_vtable(ccx: @crate_ctxt, +origin: typeck::vtable_origin) -> ValueRef {
}
}
fn make_vtable(ccx: @crate_ctxt, ptrs: ~[ValueRef]) -> ValueRef {
pub fn make_vtable(ccx: @crate_ctxt, ptrs: ~[ValueRef]) -> ValueRef {
unsafe {
let _icx = ccx.insn_ctxt("impl::make_vtable");
let tbl = C_struct(ptrs);
@ -799,8 +803,11 @@ fn make_vtable(ccx: @crate_ctxt, ptrs: ~[ValueRef]) -> ValueRef {
}
}
fn make_impl_vtable(ccx: @crate_ctxt, impl_id: ast::def_id, substs: ~[ty::t],
vtables: typeck::vtable_res) -> ValueRef {
pub fn make_impl_vtable(ccx: @crate_ctxt,
impl_id: ast::def_id,
substs: ~[ty::t],
vtables: typeck::vtable_res)
-> ValueRef {
let _icx = ccx.insn_ctxt("impl::make_impl_vtable");
let tcx = ccx.tcx;
@ -840,13 +847,12 @@ fn make_impl_vtable(ccx: @crate_ctxt, impl_id: ast::def_id, substs: ~[ty::t],
}))
}
fn trans_trait_cast(bcx: block,
val: @ast::expr,
id: ast::node_id,
dest: expr::Dest,
vstore: ty::vstore)
-> block
{
pub fn trans_trait_cast(bcx: block,
val: @ast::expr,
id: ast::node_id,
dest: expr::Dest,
vstore: ty::vstore)
-> block {
let mut bcx = bcx;
let _icx = bcx.insn_ctxt("impl::trans_cast");

View file

@ -351,7 +351,7 @@ pub fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: ~[ty::t],
{
let llty = type_of::type_of(ccx, subst);
let size = machine::llbitsize_of_real(ccx, llty);
let align = shape::llalign_of_pref(ccx, llty);
let align = machine::llalign_of_pref(ccx, llty);
let mode = datum::appropriate_mode(subst);
// FIXME(#3547)---scalars and floats are

View file

@ -29,9 +29,7 @@ use syntax::attr;
use syntax::print::pprust::expr_to_str;
use syntax::{visit, ast_util, ast_map};
export map, find_reachable;
type map = HashMap<node_id, ()>;
pub type map = HashMap<node_id, ()>;
struct ctx {
exp_map2: resolve::ExportMap2,
@ -40,8 +38,8 @@ struct ctx {
rmap: map
}
fn find_reachable(crate_mod: _mod, exp_map2: resolve::ExportMap2,
tcx: ty::ctxt, method_map: typeck::method_map) -> map {
pub fn find_reachable(crate_mod: _mod, exp_map2: resolve::ExportMap2,
tcx: ty::ctxt, method_map: typeck::method_map) -> map {
let rmap = HashMap();
let cx = ctx {
exp_map2: exp_map2,

View file

@ -19,8 +19,8 @@ use middle::trans::common::*;
use middle::trans::datum::*;
use middle::trans::expr::SaveIn;
use middle::trans::glue;
use middle::trans::machine;
use middle::trans::meth;
use middle::trans::shape;
use middle::trans::type_of::*;
use util::ppaux::ty_to_str;
@ -28,7 +28,7 @@ use std::map::HashMap;
use syntax::ast::def_id;
use syntax::ast;
enum reflector = {
pub enum reflector = {
visitor_val: ValueRef,
visitor_methods: @~[ty::method],
final_bcx: block,
@ -36,7 +36,7 @@ enum reflector = {
mut bcx: block
};
impl reflector {
pub impl reflector {
fn c_uint(u: uint) -> ValueRef {
C_uint(self.bcx.ccx(), u)
@ -62,8 +62,8 @@ impl reflector {
fn c_size_and_align(t: ty::t) -> ~[ValueRef] {
let tr = type_of::type_of(self.bcx.ccx(), t);
let s = shape::llsize_of_real(self.bcx.ccx(), tr);
let a = shape::llalign_of_min(self.bcx.ccx(), tr);
let s = machine::llsize_of_real(self.bcx.ccx(), tr);
let a = machine::llalign_of_min(self.bcx.ccx(), tr);
return ~[self.c_uint(s),
self.c_uint(a)];
}
@ -310,9 +310,11 @@ impl reflector {
}
// Emit a sequence of calls to visit_ty::visit_foo
fn emit_calls_to_trait_visit_ty(bcx: block, t: ty::t,
visitor_val: ValueRef,
visitor_trait_id: def_id) -> block {
pub fn emit_calls_to_trait_visit_ty(bcx: block,
t: ty::t,
visitor_val: ValueRef,
visitor_trait_id: def_id)
-> block {
use syntax::parse::token::special_idents::tydesc;
let final = sub_block(bcx, ~"final");
assert bcx.ccx().tcx.intrinsic_defs.contains_key(tydesc);
@ -330,7 +332,7 @@ fn emit_calls_to_trait_visit_ty(bcx: block, t: ty::t,
return final;
}
fn ast_proto_constant(proto: ast::Proto) -> uint {
pub fn ast_proto_constant(proto: ast::Proto) -> uint {
match proto {
ast::ProtoBare => 0u,
ast::ProtoUniq => 2u,
@ -338,3 +340,4 @@ fn ast_proto_constant(proto: ast::Proto) -> uint {
ast::ProtoBorrowed => 4u,
}
}

View file

@ -34,10 +34,13 @@ use syntax::util::interner;
use ty_ctxt = middle::ty::ctxt;
type ctxt = {mut next_tag_id: u16, pad: u16, pad2: u32};
pub type ctxt = {mut next_tag_id: u16, pad: u16, pad2: u32};
fn mk_global(ccx: @crate_ctxt, name: ~str, llval: ValueRef, internal: bool) ->
ValueRef {
pub fn mk_global(ccx: @crate_ctxt,
name: ~str,
llval: ValueRef,
internal: bool)
-> ValueRef {
unsafe {
let llglobal = do str::as_c_str(name) |buf| {
llvm::LLVMAddGlobal(ccx.llmod, val_ty(llval), buf)
@ -54,7 +57,7 @@ fn mk_global(ccx: @crate_ctxt, name: ~str, llval: ValueRef, internal: bool) ->
}
}
fn mk_ctxt(llmod: ModuleRef) -> ctxt {
pub fn mk_ctxt(llmod: ModuleRef) -> ctxt {
unsafe {
let llshapetablesty = trans::common::T_named_struct(~"shapes");
let _llshapetables = str::as_c_str(~"shapes", |buf| {
@ -69,11 +72,11 @@ fn mk_ctxt(llmod: ModuleRef) -> ctxt {
Although these two functions are never called, they are here
for a VERY GOOD REASON. See #3670
*/
fn add_u16(dest: &mut ~[u8], val: u16) {
pub fn add_u16(dest: &mut ~[u8], val: u16) {
*dest += ~[(val & 0xffu16) as u8, (val >> 8u16) as u8];
}
fn add_substr(dest: &mut ~[u8], src: ~[u8]) {
pub fn add_substr(dest: &mut ~[u8], src: ~[u8]) {
add_u16(&mut *dest, vec::len(src) as u16);
*dest += src;
}

View file

@ -31,7 +31,7 @@ use syntax::print::pprust::{expr_to_str};
// containing an unboxed vector. This expands a boxed vector type into such an
// expanded type. It doesn't respect mutability, but that doesn't matter at
// this point.
fn expand_boxed_vec_ty(tcx: ty::ctxt, t: ty::t) -> ty::t {
pub fn expand_boxed_vec_ty(tcx: ty::ctxt, t: ty::t) -> ty::t {
let unit_ty = ty::sequence_element_type(tcx, t);
let unboxed_vec_ty = ty::mk_mut_unboxed_vec(tcx, unit_ty);
match ty::get(t).sty {
@ -46,35 +46,35 @@ fn expand_boxed_vec_ty(tcx: ty::ctxt, t: ty::t) -> ty::t {
}
}
fn get_fill(bcx: block, vptr: ValueRef) -> ValueRef {
pub fn get_fill(bcx: block, vptr: ValueRef) -> ValueRef {
let _icx = bcx.insn_ctxt("tvec::get_fill");
Load(bcx, GEPi(bcx, vptr, [0u, abi::vec_elt_fill]))
}
fn set_fill(bcx: block, vptr: ValueRef, fill: ValueRef) {
pub fn set_fill(bcx: block, vptr: ValueRef, fill: ValueRef) {
Store(bcx, fill, GEPi(bcx, vptr, [0u, abi::vec_elt_fill]));
}
fn get_alloc(bcx: block, vptr: ValueRef) -> ValueRef {
pub fn get_alloc(bcx: block, vptr: ValueRef) -> ValueRef {
Load(bcx, GEPi(bcx, vptr, [0u, abi::vec_elt_alloc]))
}
fn get_bodyptr(bcx: block, vptr: ValueRef) -> ValueRef {
pub fn get_bodyptr(bcx: block, vptr: ValueRef) -> ValueRef {
base::non_gc_box_cast(bcx, GEPi(bcx, vptr, [0u, abi::box_field_body]))
}
fn get_dataptr(bcx: block, vptr: ValueRef) -> ValueRef {
pub fn get_dataptr(bcx: block, vptr: ValueRef) -> ValueRef {
let _icx = bcx.insn_ctxt("tvec::get_dataptr");
GEPi(bcx, vptr, [0u, abi::vec_elt_elems, 0u])
}
fn pointer_add(bcx: block, ptr: ValueRef, bytes: ValueRef) -> ValueRef {
pub fn pointer_add(bcx: block, ptr: ValueRef, bytes: ValueRef) -> ValueRef {
let _icx = bcx.insn_ctxt("tvec::pointer_add");
let old_ty = val_ty(ptr);
let bptr = PointerCast(bcx, ptr, T_ptr(T_i8()));
return PointerCast(bcx, InBoundsGEP(bcx, bptr, ~[bytes]), old_ty);
}
fn alloc_raw(bcx: block, unit_ty: ty::t,
fill: ValueRef, alloc: ValueRef, heap: heap) -> Result {
pub fn alloc_raw(bcx: block, unit_ty: ty::t,
fill: ValueRef, alloc: ValueRef, heap: heap) -> Result {
let _icx = bcx.insn_ctxt("tvec::alloc_uniq");
let ccx = bcx.ccx();
@ -87,12 +87,16 @@ fn alloc_raw(bcx: block, unit_ty: ty::t,
Store(bcx, alloc, GEPi(bcx, body, [0u, abi::vec_elt_alloc]));
return rslt(bcx, box);
}
fn alloc_uniq_raw(bcx: block, unit_ty: ty::t,
fill: ValueRef, alloc: ValueRef) -> Result {
pub fn alloc_uniq_raw(bcx: block, unit_ty: ty::t,
fill: ValueRef, alloc: ValueRef) -> Result {
alloc_raw(bcx, unit_ty, fill, alloc, heap_exchange)
}
fn alloc_vec(bcx: block, unit_ty: ty::t, elts: uint, heap: heap) -> Result {
pub fn alloc_vec(bcx: block,
unit_ty: ty::t,
elts: uint,
heap: heap)
-> Result {
let _icx = bcx.insn_ctxt("tvec::alloc_uniq");
let ccx = bcx.ccx();
let llunitty = type_of::type_of(ccx, unit_ty);
@ -106,7 +110,7 @@ fn alloc_vec(bcx: block, unit_ty: ty::t, elts: uint, heap: heap) -> Result {
return rslt(bcx, vptr);
}
fn duplicate_uniq(bcx: block, vptr: ValueRef, vec_ty: ty::t) -> Result {
pub fn duplicate_uniq(bcx: block, vptr: ValueRef, vec_ty: ty::t) -> Result {
let _icx = bcx.insn_ctxt("tvec::duplicate_uniq");
let fill = get_fill(bcx, get_bodyptr(bcx, vptr));
@ -123,7 +127,7 @@ fn duplicate_uniq(bcx: block, vptr: ValueRef, vec_ty: ty::t) -> Result {
return rslt(bcx, newptr);
}
fn make_drop_glue_unboxed(bcx: block, vptr: ValueRef, vec_ty: ty::t) ->
pub fn make_drop_glue_unboxed(bcx: block, vptr: ValueRef, vec_ty: ty::t) ->
block {
let _icx = bcx.insn_ctxt("tvec::make_drop_glue_unboxed");
let tcx = bcx.tcx(), unit_ty = ty::sequence_element_type(tcx, vec_ty);
@ -132,14 +136,14 @@ fn make_drop_glue_unboxed(bcx: block, vptr: ValueRef, vec_ty: ty::t) ->
} else { bcx }
}
struct VecTypes {
pub struct VecTypes {
vec_ty: ty::t,
unit_ty: ty::t,
llunit_ty: TypeRef,
llunit_size: ValueRef
}
impl VecTypes {
pub impl VecTypes {
fn to_str(ccx: @crate_ctxt) -> ~str {
fmt!("VecTypes {vec_ty=%s, unit_ty=%s, llunit_ty=%s, llunit_size=%s}",
ty_to_str(ccx.tcx, self.vec_ty),
@ -149,11 +153,11 @@ impl VecTypes {
}
}
fn trans_fixed_vstore(bcx: block,
vstore_expr: @ast::expr,
content_expr: @ast::expr,
dest: expr::Dest) -> block
{
pub fn trans_fixed_vstore(bcx: block,
vstore_expr: @ast::expr,
content_expr: @ast::expr,
dest: expr::Dest)
-> block {
//!
//
// [...] allocates a fixed-size array and moves it around "by value".
@ -178,11 +182,11 @@ fn trans_fixed_vstore(bcx: block,
};
}
fn trans_slice_vstore(bcx: block,
vstore_expr: @ast::expr,
content_expr: @ast::expr,
dest: expr::Dest) -> block
{
pub fn trans_slice_vstore(bcx: block,
vstore_expr: @ast::expr,
content_expr: @ast::expr,
dest: expr::Dest)
-> block {
//!
//
// &[...] allocates memory on the stack and writes the values into it,
@ -237,11 +241,11 @@ fn trans_slice_vstore(bcx: block,
return bcx;
}
fn trans_lit_str(bcx: block,
lit_expr: @ast::expr,
lit_str: @~str,
dest: Dest) -> block
{
pub fn trans_lit_str(bcx: block,
lit_expr: @ast::expr,
lit_str: @~str,
dest: Dest)
-> block {
//!
//
// Literal strings translate to slices into static memory. This is
@ -275,10 +279,10 @@ fn trans_lit_str(bcx: block,
}
fn trans_uniq_or_managed_vstore(bcx: block,
heap: heap,
vstore_expr: @ast::expr,
content_expr: @ast::expr) -> DatumBlock {
pub fn trans_uniq_or_managed_vstore(bcx: block,
heap: heap,
vstore_expr: @ast::expr,
content_expr: @ast::expr) -> DatumBlock {
//!
//
// @[...] or ~[...] (also @"..." or ~"...") allocate boxes in the
@ -334,12 +338,12 @@ fn trans_uniq_or_managed_vstore(bcx: block,
return immediate_rvalue_bcx(bcx, val, vt.vec_ty);
}
fn write_content(bcx: block,
vt: &VecTypes,
vstore_expr: @ast::expr,
content_expr: @ast::expr,
dest: Dest) -> block
{
pub fn write_content(bcx: block,
vt: &VecTypes,
vstore_expr: @ast::expr,
content_expr: @ast::expr,
dest: Dest)
-> block {
let _icx = bcx.insn_ctxt("tvec::write_content");
let mut bcx = bcx;
@ -436,12 +440,12 @@ fn write_content(bcx: block,
}
}
fn vec_types_from_expr(bcx: block, vec_expr: @ast::expr) -> VecTypes {
pub fn vec_types_from_expr(bcx: block, vec_expr: @ast::expr) -> VecTypes {
let vec_ty = node_id_type(bcx, vec_expr.id);
vec_types(bcx, vec_ty)
}
fn vec_types(bcx: block, vec_ty: ty::t) -> VecTypes {
pub fn vec_types(bcx: block, vec_ty: ty::t) -> VecTypes {
let ccx = bcx.ccx();
let unit_ty = ty::sequence_element_type(bcx.tcx(), vec_ty);
let llunit_ty = type_of::type_of(ccx, unit_ty);
@ -453,7 +457,7 @@ fn vec_types(bcx: block, vec_ty: ty::t) -> VecTypes {
llunit_size: llunit_size}
}
fn elements_required(bcx: block, content_expr: @ast::expr) -> uint {
pub fn elements_required(bcx: block, content_expr: @ast::expr) -> uint {
//! Figure out the number of elements we need to store this content
match /*bad*/copy content_expr.node {
@ -469,9 +473,9 @@ fn elements_required(bcx: block, content_expr: @ast::expr) -> uint {
}
}
fn get_base_and_len(bcx: block,
llval: ValueRef,
vec_ty: ty::t) -> (ValueRef, ValueRef) {
pub fn get_base_and_len(bcx: block,
llval: ValueRef,
vec_ty: ty::t) -> (ValueRef, ValueRef) {
//!
//
// Converts a vector into the slice pair. The vector should be stored in
@ -507,12 +511,12 @@ fn get_base_and_len(bcx: block,
}
}
type val_and_ty_fn = fn@(block, ValueRef, ty::t) -> Result;
pub type val_and_ty_fn = fn@(block, ValueRef, ty::t) -> Result;
type iter_vec_block = fn(block, ValueRef, ty::t) -> block;
pub type iter_vec_block = fn(block, ValueRef, ty::t) -> block;
fn iter_vec_raw(bcx: block, data_ptr: ValueRef, vec_ty: ty::t,
fill: ValueRef, f: iter_vec_block) -> block {
pub fn iter_vec_raw(bcx: block, data_ptr: ValueRef, vec_ty: ty::t,
fill: ValueRef, f: iter_vec_block) -> block {
let _icx = bcx.insn_ctxt("tvec::iter_vec_raw");
let unit_ty = ty::sequence_element_type(bcx.tcx(), vec_ty);
@ -542,15 +546,15 @@ fn iter_vec_raw(bcx: block, data_ptr: ValueRef, vec_ty: ty::t,
}
fn iter_vec_uniq(bcx: block, vptr: ValueRef, vec_ty: ty::t,
fill: ValueRef, f: iter_vec_block) -> block {
pub fn iter_vec_uniq(bcx: block, vptr: ValueRef, vec_ty: ty::t,
fill: ValueRef, f: iter_vec_block) -> block {
let _icx = bcx.insn_ctxt("tvec::iter_vec_uniq");
let data_ptr = get_dataptr(bcx, get_bodyptr(bcx, vptr));
iter_vec_raw(bcx, data_ptr, vec_ty, fill, f)
}
fn iter_vec_unboxed(bcx: block, body_ptr: ValueRef, vec_ty: ty::t,
f: iter_vec_block) -> block {
pub fn iter_vec_unboxed(bcx: block, body_ptr: ValueRef, vec_ty: ty::t,
f: iter_vec_block) -> block {
let _icx = bcx.insn_ctxt("tvec::iter_vec_unboxed");
let fill = get_fill(bcx, body_ptr);
let dataptr = get_dataptr(bcx, body_ptr);

View file

@ -14,6 +14,7 @@ use lib::llvm::{TypeRef};
use middle::trans::common::*;
use middle::trans::common;
use middle::trans::expr;
use middle::trans::machine;
use util::ppaux;
use std::map::HashMap;
@ -29,7 +30,7 @@ export type_of_glue_fn;
export type_of_non_gc_box;
export type_of_rooted;
fn type_of_explicit_arg(ccx: @crate_ctxt, arg: ty::arg) -> TypeRef {
pub fn type_of_explicit_arg(ccx: @crate_ctxt, arg: ty::arg) -> TypeRef {
let llty = type_of(ccx, arg.ty);
match ty::resolved_mode(ccx.tcx, arg.mode) {
ast::by_val => llty,
@ -44,12 +45,13 @@ fn type_of_explicit_arg(ccx: @crate_ctxt, arg: ty::arg) -> TypeRef {
}
}
fn type_of_explicit_args(ccx: @crate_ctxt, inputs: ~[ty::arg]) -> ~[TypeRef] {
pub fn type_of_explicit_args(ccx: @crate_ctxt, inputs: ~[ty::arg])
-> ~[TypeRef] {
inputs.map(|arg| type_of_explicit_arg(ccx, *arg))
}
fn type_of_fn(cx: @crate_ctxt, inputs: ~[ty::arg],
output: ty::t) -> TypeRef {
pub fn type_of_fn(cx: @crate_ctxt, inputs: ~[ty::arg],
output: ty::t) -> TypeRef {
unsafe {
let mut atys: ~[TypeRef] = ~[];
@ -66,11 +68,11 @@ fn type_of_fn(cx: @crate_ctxt, inputs: ~[ty::arg],
}
// Given a function type and a count of ty params, construct an llvm type
fn type_of_fn_from_ty(cx: @crate_ctxt, fty: ty::t) -> TypeRef {
pub fn type_of_fn_from_ty(cx: @crate_ctxt, fty: ty::t) -> TypeRef {
type_of_fn(cx, ty::ty_fn_args(fty), ty::ty_fn_ret(fty))
}
fn type_of_non_gc_box(cx: @crate_ctxt, t: ty::t) -> TypeRef {
pub fn type_of_non_gc_box(cx: @crate_ctxt, t: ty::t) -> TypeRef {
assert !ty::type_needs_infer(t);
let t_norm = ty::normalize_ty(cx.tcx, t);
@ -91,7 +93,7 @@ fn type_of_non_gc_box(cx: @crate_ctxt, t: ty::t) -> TypeRef {
}
}
fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
pub fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
debug!("type_of %?: %?", t, ty::get(t));
// Check the cache.
@ -234,14 +236,14 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
return llty;
}
fn fill_type_of_enum(cx: @crate_ctxt, did: ast::def_id, t: ty::t,
llty: TypeRef) {
pub fn fill_type_of_enum(cx: @crate_ctxt, did: ast::def_id, t: ty::t,
llty: TypeRef) {
debug!("type_of_enum %?: %?", t, ty::get(t));
let lltys = {
let degen = ty::enum_is_univariant(cx.tcx, did);
let size = shape::static_size_of_enum(cx, t);
let size = machine::static_size_of_enum(cx, t);
if !degen {
~[T_enum_discrim(cx), T_array(T_i8(), size)]
}
@ -257,13 +259,12 @@ fn fill_type_of_enum(cx: @crate_ctxt, did: ast::def_id, t: ty::t,
}
// Want refinements! (Or case classes, I guess
enum named_ty { a_struct, an_enum }
pub enum named_ty { a_struct, an_enum }
fn llvm_type_name(cx: @crate_ctxt,
what: named_ty,
did: ast::def_id,
tps: ~[ty::t]
) -> ~str {
pub fn llvm_type_name(cx: @crate_ctxt,
what: named_ty,
did: ast::def_id,
tps: ~[ty::t]) -> ~str {
let name = match what {
a_struct => { "~struct" }
an_enum => { "~enum" }
@ -280,7 +281,7 @@ fn llvm_type_name(cx: @crate_ctxt,
);
}
fn type_of_dtor(ccx: @crate_ctxt, self_ty: ty::t) -> TypeRef {
pub fn type_of_dtor(ccx: @crate_ctxt, self_ty: ty::t) -> TypeRef {
unsafe {
T_fn(~[T_ptr(type_of(ccx, ty::mk_nil(ccx.tcx))), // output pointer
T_ptr(type_of(ccx, self_ty))], // self arg
@ -288,14 +289,14 @@ fn type_of_dtor(ccx: @crate_ctxt, self_ty: ty::t) -> TypeRef {
}
}
fn type_of_rooted(ccx: @crate_ctxt, t: ty::t) -> TypeRef {
pub fn type_of_rooted(ccx: @crate_ctxt, t: ty::t) -> TypeRef {
let addrspace = base::get_tydesc(ccx, t).addrspace;
debug!("type_of_rooted %s in addrspace %u",
ty_to_str(ccx.tcx, t), addrspace as uint);
return T_root(type_of(ccx, t), addrspace);
}
fn type_of_glue_fn(ccx: @crate_ctxt, t: ty::t) -> TypeRef {
pub fn type_of_glue_fn(ccx: @crate_ctxt, t: ty::t) -> TypeRef {
let tydescpp = T_ptr(T_ptr(ccx.tydesc_type));
let llty = T_ptr(type_of(ccx, t));
return T_fn(~[T_ptr(T_nil()), T_ptr(T_nil()), tydescpp, llty],

View file

@ -44,15 +44,14 @@ use syntax::ast_map;
use syntax::ast_util;
use syntax::visit;
type type_uses = uint; // Bitmask
const use_repr: uint = 1u; /* Dependency on size/alignment/mode and
take/drop glue */
const use_tydesc: uint = 2u; /* Takes the tydesc, or compares */
pub type type_uses = uint; // Bitmask
pub const use_repr: uint = 1u; /* Dependency on size/alignment/mode and
take/drop glue */
pub const use_tydesc: uint = 2u; /* Takes the tydesc, or compares */
type ctx = {ccx: @crate_ctxt,
uses: ~[mut type_uses]};
pub type ctx = {ccx: @crate_ctxt, uses: ~[mut type_uses]};
fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
pub fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
-> ~[type_uses] {
match ccx.type_use_cache.find(fn_id) {
Some(uses) => return uses,
@ -175,7 +174,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
uses
}
fn type_needs(cx: ctx, use_: uint, ty: ty::t) {
pub fn type_needs(cx: ctx, use_: uint, ty: ty::t) {
// Optimization -- don't descend type if all params already have this use
for vec::each_mut(cx.uses) |u| {
if *u & use_ != use_ {
@ -185,8 +184,10 @@ fn type_needs(cx: ctx, use_: uint, ty: ty::t) {
}
}
fn type_needs_inner(cx: ctx, use_: uint, ty: ty::t,
enums_seen: @List<def_id>) {
pub fn type_needs_inner(cx: ctx,
use_: uint,
ty: ty::t,
enums_seen: @List<def_id>) {
do ty::maybe_walk_ty(ty) |ty| {
if ty::type_has_params(ty) {
match ty::get(ty).sty {
@ -220,11 +221,11 @@ fn type_needs_inner(cx: ctx, use_: uint, ty: ty::t,
}
}
fn node_type_needs(cx: ctx, use_: uint, id: node_id) {
pub fn node_type_needs(cx: ctx, use_: uint, id: node_id) {
type_needs(cx, use_, ty::node_id_to_type(cx.ccx.tcx, id));
}
fn mark_for_method_call(cx: ctx, e_id: node_id, callee_id: node_id) {
pub fn mark_for_method_call(cx: ctx, e_id: node_id, callee_id: node_id) {
do option::iter(&cx.ccx.maps.method_map.find(e_id)) |mth| {
match mth.origin {
typeck::method_static(did) => {
@ -247,7 +248,7 @@ fn mark_for_method_call(cx: ctx, e_id: node_id, callee_id: node_id) {
}
}
fn mark_for_expr(cx: ctx, e: @expr) {
pub fn mark_for_expr(cx: ctx, e: @expr) {
match e.node {
expr_vstore(_, _) |
expr_vec(_, _) |
@ -347,7 +348,7 @@ fn mark_for_expr(cx: ctx, e: @expr) {
}
}
fn handle_body(cx: ctx, body: blk) {
pub fn handle_body(cx: ctx, body: blk) {
let v = visit::mk_vt(@visit::Visitor {
visit_expr: |e, cx, v| {
visit::visit_expr(e, cx, v);
@ -372,3 +373,4 @@ fn handle_body(cx: ctx, body: blk) {
});
(v.visit_block)(body, cx, v);
}

View file

@ -20,9 +20,7 @@ use middle::trans::glue;
use syntax::ast;
export make_free_glue, autoderef, duplicate;
fn make_free_glue(bcx: block, vptrptr: ValueRef, box_ty: ty::t)
pub fn make_free_glue(bcx: block, vptrptr: ValueRef, box_ty: ty::t)
-> block {
let _icx = bcx.insn_ctxt("uniq::make_free_glue");
let box_datum = immediate_rvalue(Load(bcx, vptrptr), box_ty);
@ -36,7 +34,7 @@ fn make_free_glue(bcx: block, vptrptr: ValueRef, box_ty: ty::t)
}
}
fn duplicate(bcx: block, src_box: ValueRef, src_ty: ty::t) -> Result {
pub fn duplicate(bcx: block, src_box: ValueRef, src_ty: ty::t) -> Result {
let _icx = bcx.insn_ctxt("uniq::duplicate");
// Load the body of the source (*src)

View file

@ -57,41 +57,23 @@ pub mod middle {
pub mod datum;
pub mod callee;
pub mod expr;
#[legacy_exports]
pub mod common;
#[legacy_exports]
pub mod consts;
#[legacy_exports]
pub mod type_of;
#[legacy_exports]
pub mod build;
#[legacy_exports]
pub mod base;
#[legacy_exports]
pub mod _match;
#[legacy_exports]
pub mod uniq;
#[legacy_exports]
pub mod closure;
#[legacy_exports]
pub mod tvec;
#[legacy_exports]
pub mod meth;
#[legacy_exports]
pub mod cabi;
#[legacy_exports]
pub mod cabi_x86_64;
#[legacy_exports]
pub mod foreign;
#[legacy_exports]
pub mod reflect;
#[legacy_exports]
pub mod shape;
#[legacy_exports]
pub mod debuginfo;
#[legacy_exports]
pub mod type_use;
#[legacy_exports]
pub mod reachable;
pub mod machine;
}