mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 15:54:15 +00:00
rustc: de-@ adt::Repr.
This commit is contained in:
parent
344ce17036
commit
938eaaa304
@ -225,6 +225,7 @@ use util::ppaux::{Repr, vec_map_to_str};
|
|||||||
|
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
use std::rc::Rc;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::ast::Ident;
|
use syntax::ast::Ident;
|
||||||
use syntax::ast_util::path_to_ident;
|
use syntax::ast_util::path_to_ident;
|
||||||
@ -250,7 +251,7 @@ pub enum VecLenOpt {
|
|||||||
// range)
|
// range)
|
||||||
enum Opt {
|
enum Opt {
|
||||||
lit(Lit),
|
lit(Lit),
|
||||||
var(ty::Disr, @adt::Repr),
|
var(ty::Disr, Rc<adt::Repr>),
|
||||||
range(@ast::Expr, @ast::Expr),
|
range(@ast::Expr, @ast::Expr),
|
||||||
vec_len(/* length */ uint, VecLenOpt, /*range of matches*/(uint, uint))
|
vec_len(/* length */ uint, VecLenOpt, /*range of matches*/(uint, uint))
|
||||||
}
|
}
|
||||||
@ -351,8 +352,8 @@ fn trans_opt<'a>(bcx: &'a Block<'a>, o: &Opt) -> opt_result<'a> {
|
|||||||
let (llval, _) = consts::get_const_val(bcx.ccx(), lit_id);
|
let (llval, _) = consts::get_const_val(bcx.ccx(), lit_id);
|
||||||
return single_result(rslt(bcx, llval));
|
return single_result(rslt(bcx, llval));
|
||||||
}
|
}
|
||||||
var(disr_val, repr) => {
|
var(disr_val, ref repr) => {
|
||||||
return adt::trans_case(bcx, repr, disr_val);
|
return adt::trans_case(bcx, &**repr, disr_val);
|
||||||
}
|
}
|
||||||
range(l1, l2) => {
|
range(l1, l2) => {
|
||||||
let (l1, _) = consts::const_expr(ccx, l1, true);
|
let (l1, _) = consts::const_expr(ccx, l1, true);
|
||||||
@ -1561,7 +1562,7 @@ fn compile_submatch_continue<'a, 'b>(
|
|||||||
expr::with_field_tys(tcx, pat_ty, Some(pat_id), |discr, field_tys| {
|
expr::with_field_tys(tcx, pat_ty, Some(pat_id), |discr, field_tys| {
|
||||||
let rec_vals = rec_fields.iter().map(|field_name| {
|
let rec_vals = rec_fields.iter().map(|field_name| {
|
||||||
let ix = ty::field_idx_strict(tcx, field_name.name, field_tys);
|
let ix = ty::field_idx_strict(tcx, field_name.name, field_tys);
|
||||||
adt::trans_field_ptr(bcx, pat_repr, val, discr, ix)
|
adt::trans_field_ptr(bcx, &*pat_repr, val, discr, ix)
|
||||||
}).collect::<Vec<_>>();
|
}).collect::<Vec<_>>();
|
||||||
compile_submatch(
|
compile_submatch(
|
||||||
bcx,
|
bcx,
|
||||||
@ -1587,7 +1588,7 @@ fn compile_submatch_continue<'a, 'b>(
|
|||||||
_ => ccx.sess().bug("non-tuple type in tuple pattern")
|
_ => ccx.sess().bug("non-tuple type in tuple pattern")
|
||||||
};
|
};
|
||||||
let tup_vals = Vec::from_fn(n_tup_elts, |i| {
|
let tup_vals = Vec::from_fn(n_tup_elts, |i| {
|
||||||
adt::trans_field_ptr(bcx, tup_repr, val, 0, i)
|
adt::trans_field_ptr(bcx, &*tup_repr, val, 0, i)
|
||||||
});
|
});
|
||||||
compile_submatch(bcx,
|
compile_submatch(bcx,
|
||||||
enter_tup(bcx,
|
enter_tup(bcx,
|
||||||
@ -1616,7 +1617,7 @@ fn compile_submatch_continue<'a, 'b>(
|
|||||||
|
|
||||||
let struct_repr = adt::represent_type(bcx.ccx(), struct_ty);
|
let struct_repr = adt::represent_type(bcx.ccx(), struct_ty);
|
||||||
let llstructvals = Vec::from_fn(struct_element_count, |i| {
|
let llstructvals = Vec::from_fn(struct_element_count, |i| {
|
||||||
adt::trans_field_ptr(bcx, struct_repr, val, 0, i)
|
adt::trans_field_ptr(bcx, &*struct_repr, val, 0, i)
|
||||||
});
|
});
|
||||||
compile_submatch(bcx,
|
compile_submatch(bcx,
|
||||||
enter_tuple_struct(bcx, dm, m, col, val,
|
enter_tuple_struct(bcx, dm, m, col, val,
|
||||||
@ -1652,8 +1653,8 @@ fn compile_submatch_continue<'a, 'b>(
|
|||||||
debug!("test_val={}", bcx.val_to_str(test_val));
|
debug!("test_val={}", bcx.val_to_str(test_val));
|
||||||
if opts.len() > 0u {
|
if opts.len() > 0u {
|
||||||
match *opts.get(0) {
|
match *opts.get(0) {
|
||||||
var(_, repr) => {
|
var(_, ref repr) => {
|
||||||
let (the_kind, val_opt) = adt::trans_switch(bcx, repr, val);
|
let (the_kind, val_opt) = adt::trans_switch(bcx, &**repr, val);
|
||||||
kind = the_kind;
|
kind = the_kind;
|
||||||
for &tval in val_opt.iter() { test_val = tval; }
|
for &tval in val_opt.iter() { test_val = tval; }
|
||||||
}
|
}
|
||||||
@ -1799,9 +1800,9 @@ fn compile_submatch_continue<'a, 'b>(
|
|||||||
let mut size = 0u;
|
let mut size = 0u;
|
||||||
let mut unpacked = Vec::new();
|
let mut unpacked = Vec::new();
|
||||||
match *opt {
|
match *opt {
|
||||||
var(disr_val, repr) => {
|
var(disr_val, ref repr) => {
|
||||||
let ExtractedBlock {vals: argvals, bcx: new_bcx} =
|
let ExtractedBlock {vals: argvals, bcx: new_bcx} =
|
||||||
extract_variant_args(opt_cx, repr, disr_val, val);
|
extract_variant_args(opt_cx, &**repr, disr_val, val);
|
||||||
size = argvals.len();
|
size = argvals.len();
|
||||||
unpacked = argvals;
|
unpacked = argvals;
|
||||||
opt_cx = new_bcx;
|
opt_cx = new_bcx;
|
||||||
@ -2219,7 +2220,7 @@ fn bind_irrefutable_pat<'a>(
|
|||||||
enum_id,
|
enum_id,
|
||||||
var_id);
|
var_id);
|
||||||
let args = extract_variant_args(bcx,
|
let args = extract_variant_args(bcx,
|
||||||
repr,
|
&*repr,
|
||||||
vinfo.disr_val,
|
vinfo.disr_val,
|
||||||
val);
|
val);
|
||||||
for sub_pat in sub_pats.iter() {
|
for sub_pat in sub_pats.iter() {
|
||||||
@ -2240,7 +2241,7 @@ fn bind_irrefutable_pat<'a>(
|
|||||||
// This is the tuple struct case.
|
// This is the tuple struct case.
|
||||||
let repr = adt::represent_node(bcx, pat.id);
|
let repr = adt::represent_node(bcx, pat.id);
|
||||||
for (i, elem) in elems.iter().enumerate() {
|
for (i, elem) in elems.iter().enumerate() {
|
||||||
let fldptr = adt::trans_field_ptr(bcx, repr,
|
let fldptr = adt::trans_field_ptr(bcx, &*repr,
|
||||||
val, 0, i);
|
val, 0, i);
|
||||||
bcx = bind_irrefutable_pat(bcx, *elem,
|
bcx = bind_irrefutable_pat(bcx, *elem,
|
||||||
fldptr, binding_mode,
|
fldptr, binding_mode,
|
||||||
@ -2263,7 +2264,7 @@ fn bind_irrefutable_pat<'a>(
|
|||||||
expr::with_field_tys(tcx, pat_ty, Some(pat.id), |discr, field_tys| {
|
expr::with_field_tys(tcx, pat_ty, Some(pat.id), |discr, field_tys| {
|
||||||
for f in fields.iter() {
|
for f in fields.iter() {
|
||||||
let ix = ty::field_idx_strict(tcx, f.ident.name, field_tys);
|
let ix = ty::field_idx_strict(tcx, f.ident.name, field_tys);
|
||||||
let fldptr = adt::trans_field_ptr(bcx, pat_repr, val,
|
let fldptr = adt::trans_field_ptr(bcx, &*pat_repr, val,
|
||||||
discr, ix);
|
discr, ix);
|
||||||
bcx = bind_irrefutable_pat(bcx, f.pat, fldptr,
|
bcx = bind_irrefutable_pat(bcx, f.pat, fldptr,
|
||||||
binding_mode, cleanup_scope);
|
binding_mode, cleanup_scope);
|
||||||
@ -2273,7 +2274,7 @@ fn bind_irrefutable_pat<'a>(
|
|||||||
ast::PatTup(ref elems) => {
|
ast::PatTup(ref elems) => {
|
||||||
let repr = adt::represent_node(bcx, pat.id);
|
let repr = adt::represent_node(bcx, pat.id);
|
||||||
for (i, elem) in elems.iter().enumerate() {
|
for (i, elem) in elems.iter().enumerate() {
|
||||||
let fldptr = adt::trans_field_ptr(bcx, repr, val, 0, i);
|
let fldptr = adt::trans_field_ptr(bcx, &*repr, val, 0, i);
|
||||||
bcx = bind_irrefutable_pat(bcx, *elem, fldptr,
|
bcx = bind_irrefutable_pat(bcx, *elem, fldptr,
|
||||||
binding_mode, cleanup_scope);
|
binding_mode, cleanup_scope);
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,8 @@
|
|||||||
|
|
||||||
use std::container::Map;
|
use std::container::Map;
|
||||||
use libc::c_ulonglong;
|
use libc::c_ulonglong;
|
||||||
use std::option::{Option, Some, None};
|
|
||||||
use std::num::{Bitwise};
|
use std::num::{Bitwise};
|
||||||
|
use std::rc::Rc;
|
||||||
|
|
||||||
use lib::llvm::{ValueRef, True, IntEQ, IntNE};
|
use lib::llvm::{ValueRef, True, IntEQ, IntNE};
|
||||||
use middle::trans::_match;
|
use middle::trans::_match;
|
||||||
@ -115,22 +115,22 @@ pub struct Struct {
|
|||||||
* these, for places in trans where the `ty::t` isn't directly
|
* these, for places in trans where the `ty::t` isn't directly
|
||||||
* available.
|
* available.
|
||||||
*/
|
*/
|
||||||
pub fn represent_node(bcx: &Block, node: ast::NodeId) -> @Repr {
|
pub fn represent_node(bcx: &Block, node: ast::NodeId) -> Rc<Repr> {
|
||||||
represent_type(bcx.ccx(), node_id_type(bcx, node))
|
represent_type(bcx.ccx(), node_id_type(bcx, node))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Decides how to represent a given type.
|
/// Decides how to represent a given type.
|
||||||
pub fn represent_type(cx: &CrateContext, t: ty::t) -> @Repr {
|
pub fn represent_type(cx: &CrateContext, t: ty::t) -> Rc<Repr> {
|
||||||
debug!("Representing: {}", ty_to_str(cx.tcx(), t));
|
debug!("Representing: {}", ty_to_str(cx.tcx(), t));
|
||||||
match cx.adt_reprs.borrow().find(&t) {
|
match cx.adt_reprs.borrow().find(&t) {
|
||||||
Some(repr) => return *repr,
|
Some(repr) => return repr.clone(),
|
||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
let repr = @represent_type_uncached(cx, t);
|
let repr = Rc::new(represent_type_uncached(cx, t));
|
||||||
debug!("Represented as: {:?}", repr)
|
debug!("Represented as: {:?}", repr)
|
||||||
cx.adt_reprs.borrow_mut().insert(t, repr);
|
cx.adt_reprs.borrow_mut().insert(t, repr.clone());
|
||||||
return repr;
|
repr
|
||||||
}
|
}
|
||||||
|
|
||||||
fn represent_type_uncached(cx: &CrateContext, t: ty::t) -> Repr {
|
fn represent_type_uncached(cx: &CrateContext, t: ty::t) -> Repr {
|
||||||
|
@ -660,7 +660,7 @@ pub fn iter_structural_ty<'r,
|
|||||||
let repr = adt::represent_type(cx.ccx(), t);
|
let repr = adt::represent_type(cx.ccx(), t);
|
||||||
expr::with_field_tys(cx.tcx(), t, None, |discr, field_tys| {
|
expr::with_field_tys(cx.tcx(), t, None, |discr, field_tys| {
|
||||||
for (i, field_ty) in field_tys.iter().enumerate() {
|
for (i, field_ty) in field_tys.iter().enumerate() {
|
||||||
let llfld_a = adt::trans_field_ptr(cx, repr, av, discr, i);
|
let llfld_a = adt::trans_field_ptr(cx, &*repr, av, discr, i);
|
||||||
cx = f(cx, llfld_a, field_ty.mt.ty);
|
cx = f(cx, llfld_a, field_ty.mt.ty);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -678,7 +678,7 @@ pub fn iter_structural_ty<'r,
|
|||||||
ty::ty_tup(ref args) => {
|
ty::ty_tup(ref args) => {
|
||||||
let repr = adt::represent_type(cx.ccx(), t);
|
let repr = adt::represent_type(cx.ccx(), t);
|
||||||
for (i, arg) in args.iter().enumerate() {
|
for (i, arg) in args.iter().enumerate() {
|
||||||
let llfld_a = adt::trans_field_ptr(cx, repr, av, 0, i);
|
let llfld_a = adt::trans_field_ptr(cx, &*repr, av, 0, i);
|
||||||
cx = f(cx, llfld_a, *arg);
|
cx = f(cx, llfld_a, *arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -693,9 +693,9 @@ pub fn iter_structural_ty<'r,
|
|||||||
// NB: we must hit the discriminant first so that structural
|
// NB: we must hit the discriminant first so that structural
|
||||||
// comparison know not to proceed when the discriminants differ.
|
// comparison know not to proceed when the discriminants differ.
|
||||||
|
|
||||||
match adt::trans_switch(cx, repr, av) {
|
match adt::trans_switch(cx, &*repr, av) {
|
||||||
(_match::single, None) => {
|
(_match::single, None) => {
|
||||||
cx = iter_variant(cx, repr, av, &**variants.get(0),
|
cx = iter_variant(cx, &*repr, av, &**variants.get(0),
|
||||||
substs.tps.as_slice(), f);
|
substs.tps.as_slice(), f);
|
||||||
}
|
}
|
||||||
(_match::switch, Some(lldiscrim_a)) => {
|
(_match::switch, Some(lldiscrim_a)) => {
|
||||||
@ -710,7 +710,7 @@ pub fn iter_structural_ty<'r,
|
|||||||
let variant_cx =
|
let variant_cx =
|
||||||
fcx.new_temp_block("enum-iter-variant-".to_owned() +
|
fcx.new_temp_block("enum-iter-variant-".to_owned() +
|
||||||
variant.disr_val.to_str());
|
variant.disr_val.to_str());
|
||||||
match adt::trans_case(cx, repr, variant.disr_val) {
|
match adt::trans_case(cx, &*repr, variant.disr_val) {
|
||||||
_match::single_result(r) => {
|
_match::single_result(r) => {
|
||||||
AddCase(llswitch, r.val, variant_cx.llbb)
|
AddCase(llswitch, r.val, variant_cx.llbb)
|
||||||
}
|
}
|
||||||
@ -719,7 +719,7 @@ pub fn iter_structural_ty<'r,
|
|||||||
}
|
}
|
||||||
let variant_cx =
|
let variant_cx =
|
||||||
iter_variant(variant_cx,
|
iter_variant(variant_cx,
|
||||||
repr,
|
&*repr,
|
||||||
av,
|
av,
|
||||||
&**variant,
|
&**variant,
|
||||||
substs.tps.as_slice(),
|
substs.tps.as_slice(),
|
||||||
@ -1512,10 +1512,10 @@ fn trans_enum_variant_or_tuple_like_struct(ccx: &CrateContext,
|
|||||||
|
|
||||||
if !type_is_zero_size(fcx.ccx, result_ty) {
|
if !type_is_zero_size(fcx.ccx, result_ty) {
|
||||||
let repr = adt::represent_type(ccx, result_ty);
|
let repr = adt::represent_type(ccx, result_ty);
|
||||||
adt::trans_start_init(bcx, repr, fcx.llretptr.get().unwrap(), disr);
|
adt::trans_start_init(bcx, &*repr, fcx.llretptr.get().unwrap(), disr);
|
||||||
for (i, arg_datum) in arg_datums.move_iter().enumerate() {
|
for (i, arg_datum) in arg_datums.move_iter().enumerate() {
|
||||||
let lldestptr = adt::trans_field_ptr(bcx,
|
let lldestptr = adt::trans_field_ptr(bcx,
|
||||||
repr,
|
&*repr,
|
||||||
fcx.llretptr.get().unwrap(),
|
fcx.llretptr.get().unwrap(),
|
||||||
disr,
|
disr,
|
||||||
i);
|
i);
|
||||||
|
@ -130,7 +130,7 @@ fn const_deref_ptr(cx: &CrateContext, v: ValueRef) -> ValueRef {
|
|||||||
fn const_deref_newtype(cx: &CrateContext, v: ValueRef, t: ty::t)
|
fn const_deref_newtype(cx: &CrateContext, v: ValueRef, t: ty::t)
|
||||||
-> ValueRef {
|
-> ValueRef {
|
||||||
let repr = adt::represent_type(cx, t);
|
let repr = adt::represent_type(cx, t);
|
||||||
adt::const_get_field(cx, repr, v, 0, 0)
|
adt::const_get_field(cx, &*repr, v, 0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn const_deref(cx: &CrateContext, v: ValueRef, t: ty::t, explicit: bool)
|
fn const_deref(cx: &CrateContext, v: ValueRef, t: ty::t, explicit: bool)
|
||||||
@ -418,7 +418,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
|
|||||||
let (bv, inlineable) = const_expr(cx, base, is_local);
|
let (bv, inlineable) = const_expr(cx, base, is_local);
|
||||||
expr::with_field_tys(cx.tcx(), bt, None, |discr, field_tys| {
|
expr::with_field_tys(cx.tcx(), bt, None, |discr, field_tys| {
|
||||||
let ix = ty::field_idx_strict(cx.tcx(), field.name, field_tys);
|
let ix = ty::field_idx_strict(cx.tcx(), field.name, field_tys);
|
||||||
(adt::const_get_field(cx, brepr, bv, discr, ix), inlineable)
|
(adt::const_get_field(cx, &*brepr, bv, discr, ix), inlineable)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -491,7 +491,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
|
|||||||
(expr::cast_enum, expr::cast_integral) |
|
(expr::cast_enum, expr::cast_integral) |
|
||||||
(expr::cast_enum, expr::cast_float) => {
|
(expr::cast_enum, expr::cast_float) => {
|
||||||
let repr = adt::represent_type(cx, basety);
|
let repr = adt::represent_type(cx, basety);
|
||||||
let discr = adt::const_get_discrim(cx, repr, v);
|
let discr = adt::const_get_discrim(cx, &*repr, v);
|
||||||
let iv = C_integral(cx.int_type, discr, false);
|
let iv = C_integral(cx.int_type, discr, false);
|
||||||
let ety_cast = expr::cast_type_kind(ety);
|
let ety_cast = expr::cast_type_kind(ety);
|
||||||
match ety_cast {
|
match ety_cast {
|
||||||
@ -524,7 +524,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
|
|||||||
let ety = ty::expr_ty(cx.tcx(), e);
|
let ety = ty::expr_ty(cx.tcx(), e);
|
||||||
let repr = adt::represent_type(cx, ety);
|
let repr = adt::represent_type(cx, ety);
|
||||||
let (vals, inlineable) = map_list(es.as_slice());
|
let (vals, inlineable) = map_list(es.as_slice());
|
||||||
(adt::trans_const(cx, repr, 0, vals.as_slice()), inlineable)
|
(adt::trans_const(cx, &*repr, 0, vals.as_slice()), inlineable)
|
||||||
}
|
}
|
||||||
ast::ExprStruct(_, ref fs, ref base_opt) => {
|
ast::ExprStruct(_, ref fs, ref base_opt) => {
|
||||||
let ety = ty::expr_ty(cx.tcx(), e);
|
let ety = ty::expr_ty(cx.tcx(), e);
|
||||||
@ -544,7 +544,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
|
|||||||
None => {
|
None => {
|
||||||
match base_val {
|
match base_val {
|
||||||
Some((bv, inlineable)) => {
|
Some((bv, inlineable)) => {
|
||||||
(adt::const_get_field(cx, repr, bv, discr, ix),
|
(adt::const_get_field(cx, &*repr, bv, discr, ix),
|
||||||
inlineable)
|
inlineable)
|
||||||
}
|
}
|
||||||
None => cx.sess().span_bug(e.span, "missing struct field")
|
None => cx.sess().span_bug(e.span, "missing struct field")
|
||||||
@ -552,7 +552,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
(adt::trans_const(cx, repr, discr, cs),
|
(adt::trans_const(cx, &*repr, discr, cs),
|
||||||
inlineable.iter().fold(true, |a, &b| a && b))
|
inlineable.iter().fold(true, |a, &b| a && b))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -632,7 +632,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
|
|||||||
let vinfo = ty::enum_variant_with_id(cx.tcx(),
|
let vinfo = ty::enum_variant_with_id(cx.tcx(),
|
||||||
enum_did,
|
enum_did,
|
||||||
variant_did);
|
variant_did);
|
||||||
(adt::trans_const(cx, repr, vinfo.disr_val, []), true)
|
(adt::trans_const(cx, &*repr, vinfo.disr_val, []), true)
|
||||||
}
|
}
|
||||||
Some(ast::DefStruct(_)) => {
|
Some(ast::DefStruct(_)) => {
|
||||||
let ety = ty::expr_ty(cx.tcx(), e);
|
let ety = ty::expr_ty(cx.tcx(), e);
|
||||||
@ -651,7 +651,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
|
|||||||
let ety = ty::expr_ty(cx.tcx(), e);
|
let ety = ty::expr_ty(cx.tcx(), e);
|
||||||
let repr = adt::represent_type(cx, ety);
|
let repr = adt::represent_type(cx, ety);
|
||||||
let (arg_vals, inlineable) = map_list(args.as_slice());
|
let (arg_vals, inlineable) = map_list(args.as_slice());
|
||||||
(adt::trans_const(cx, repr, 0, arg_vals.as_slice()),
|
(adt::trans_const(cx, &*repr, 0, arg_vals.as_slice()),
|
||||||
inlineable)
|
inlineable)
|
||||||
}
|
}
|
||||||
Some(ast::DefVariant(enum_did, variant_did, _)) => {
|
Some(ast::DefVariant(enum_did, variant_did, _)) => {
|
||||||
@ -662,7 +662,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
|
|||||||
variant_did);
|
variant_did);
|
||||||
let (arg_vals, inlineable) = map_list(args.as_slice());
|
let (arg_vals, inlineable) = map_list(args.as_slice());
|
||||||
(adt::trans_const(cx,
|
(adt::trans_const(cx,
|
||||||
repr,
|
&*repr,
|
||||||
vinfo.disr_val,
|
vinfo.disr_val,
|
||||||
arg_vals.as_slice()), inlineable)
|
arg_vals.as_slice()), inlineable)
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ use util::nodemap::{NodeMap, NodeSet, DefIdMap};
|
|||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::c_str::ToCStr;
|
use std::c_str::ToCStr;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
use std::rc::Rc;
|
||||||
use collections::{HashMap, HashSet};
|
use collections::{HashMap, HashSet};
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::parse::token::InternedString;
|
use syntax::parse::token::InternedString;
|
||||||
@ -92,7 +93,7 @@ pub struct CrateContext {
|
|||||||
|
|
||||||
pub lltypes: RefCell<HashMap<ty::t, Type>>,
|
pub lltypes: RefCell<HashMap<ty::t, Type>>,
|
||||||
pub llsizingtypes: RefCell<HashMap<ty::t, Type>>,
|
pub llsizingtypes: RefCell<HashMap<ty::t, Type>>,
|
||||||
pub adt_reprs: RefCell<HashMap<ty::t, @adt::Repr>>,
|
pub adt_reprs: RefCell<HashMap<ty::t, Rc<adt::Repr>>>,
|
||||||
pub symbol_hasher: RefCell<Sha256>,
|
pub symbol_hasher: RefCell<Sha256>,
|
||||||
pub type_hashcodes: RefCell<HashMap<ty::t, ~str>>,
|
pub type_hashcodes: RefCell<HashMap<ty::t, ~str>>,
|
||||||
pub all_llvm_symbols: RefCell<HashSet<~str>>,
|
pub all_llvm_symbols: RefCell<HashSet<~str>>,
|
||||||
|
@ -1389,7 +1389,7 @@ fn prepare_tuple_metadata(cx: &CrateContext,
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct GeneralMemberDescriptionFactory {
|
struct GeneralMemberDescriptionFactory {
|
||||||
type_rep: @adt::Repr,
|
type_rep: Rc<adt::Repr>,
|
||||||
variants: Rc<Vec<Rc<ty::VariantInfo>>>,
|
variants: Rc<Vec<Rc<ty::VariantInfo>>>,
|
||||||
discriminant_type_metadata: ValueRef,
|
discriminant_type_metadata: ValueRef,
|
||||||
containing_scope: DIScope,
|
containing_scope: DIScope,
|
||||||
@ -1662,7 +1662,7 @@ fn prepare_enum_metadata(cx: &CrateContext,
|
|||||||
llvm_type: enum_llvm_type,
|
llvm_type: enum_llvm_type,
|
||||||
file_metadata: file_metadata,
|
file_metadata: file_metadata,
|
||||||
member_description_factory: GeneralMD(GeneralMemberDescriptionFactory {
|
member_description_factory: GeneralMD(GeneralMemberDescriptionFactory {
|
||||||
type_rep: type_rep,
|
type_rep: type_rep.clone(),
|
||||||
variants: variants,
|
variants: variants,
|
||||||
discriminant_type_metadata: discriminant_type_metadata,
|
discriminant_type_metadata: discriminant_type_metadata,
|
||||||
containing_scope: containing_scope,
|
containing_scope: containing_scope,
|
||||||
|
@ -443,7 +443,7 @@ fn trans_rec_field<'a>(bcx: &'a Block<'a>,
|
|||||||
let ix = ty::field_idx_strict(bcx.tcx(), field.name, field_tys);
|
let ix = ty::field_idx_strict(bcx.tcx(), field.name, field_tys);
|
||||||
let d = base_datum.get_element(
|
let d = base_datum.get_element(
|
||||||
field_tys[ix].mt.ty,
|
field_tys[ix].mt.ty,
|
||||||
|srcval| adt::trans_field_ptr(bcx, repr, srcval, discr, ix));
|
|srcval| adt::trans_field_ptr(bcx, &*repr, srcval, discr, ix));
|
||||||
DatumBlock { datum: d.to_expr_datum(), bcx: bcx }
|
DatumBlock { datum: d.to_expr_datum(), bcx: bcx }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -679,7 +679,7 @@ fn trans_rvalue_dps_unadjusted<'a>(bcx: &'a Block<'a>,
|
|||||||
let repr = adt::represent_type(bcx.ccx(), expr_ty(bcx, expr));
|
let repr = adt::represent_type(bcx.ccx(), expr_ty(bcx, expr));
|
||||||
let numbered_fields: Vec<(uint, @ast::Expr)> =
|
let numbered_fields: Vec<(uint, @ast::Expr)> =
|
||||||
args.iter().enumerate().map(|(i, arg)| (i, *arg)).collect();
|
args.iter().enumerate().map(|(i, arg)| (i, *arg)).collect();
|
||||||
trans_adt(bcx, repr, 0, numbered_fields.as_slice(), None, dest)
|
trans_adt(bcx, &*repr, 0, numbered_fields.as_slice(), None, dest)
|
||||||
}
|
}
|
||||||
ast::ExprLit(lit) => {
|
ast::ExprLit(lit) => {
|
||||||
match lit.node {
|
match lit.node {
|
||||||
@ -797,7 +797,7 @@ fn trans_def_dps_unadjusted<'a>(
|
|||||||
// Nullary variant.
|
// Nullary variant.
|
||||||
let ty = expr_ty(bcx, ref_expr);
|
let ty = expr_ty(bcx, ref_expr);
|
||||||
let repr = adt::represent_type(bcx.ccx(), ty);
|
let repr = adt::represent_type(bcx.ccx(), ty);
|
||||||
adt::trans_start_init(bcx, repr, lldest,
|
adt::trans_start_init(bcx, &*repr, lldest,
|
||||||
variant_info.disr_val);
|
variant_info.disr_val);
|
||||||
return bcx;
|
return bcx;
|
||||||
}
|
}
|
||||||
@ -807,7 +807,7 @@ fn trans_def_dps_unadjusted<'a>(
|
|||||||
match ty::get(ty).sty {
|
match ty::get(ty).sty {
|
||||||
ty::ty_struct(did, _) if ty::has_dtor(bcx.tcx(), did) => {
|
ty::ty_struct(did, _) if ty::has_dtor(bcx.tcx(), did) => {
|
||||||
let repr = adt::represent_type(bcx.ccx(), ty);
|
let repr = adt::represent_type(bcx.ccx(), ty);
|
||||||
adt::trans_start_init(bcx, repr, lldest, 0);
|
adt::trans_start_init(bcx, &*repr, lldest, 0);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
@ -1004,7 +1004,7 @@ fn trans_rec_or_struct<'a>(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let repr = adt::represent_type(bcx.ccx(), ty);
|
let repr = adt::represent_type(bcx.ccx(), ty);
|
||||||
trans_adt(bcx, repr, discr, numbered_fields.as_slice(), optbase, dest)
|
trans_adt(bcx, &*repr, discr, numbered_fields.as_slice(), optbase, dest)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1239,8 +1239,8 @@ fn trans_gc<'a>(mut bcx: &'a Block<'a>,
|
|||||||
SaveIn(addr) => {
|
SaveIn(addr) => {
|
||||||
let expr_ty = expr_ty(bcx, expr);
|
let expr_ty = expr_ty(bcx, expr);
|
||||||
let repr = adt::represent_type(bcx.ccx(), expr_ty);
|
let repr = adt::represent_type(bcx.ccx(), expr_ty);
|
||||||
adt::trans_start_init(bcx, repr, addr, 0);
|
adt::trans_start_init(bcx, &*repr, addr, 0);
|
||||||
let field_dest = adt::trans_field_ptr(bcx, repr, addr, 0, 0);
|
let field_dest = adt::trans_field_ptr(bcx, &*repr, addr, 0, 0);
|
||||||
contents_datum.store_to(bcx, field_dest)
|
contents_datum.store_to(bcx, field_dest)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1580,7 +1580,7 @@ fn trans_imm_cast<'a>(bcx: &'a Block<'a>,
|
|||||||
bcx, datum.to_lvalue_datum(bcx, "trans_imm_cast", expr.id));
|
bcx, datum.to_lvalue_datum(bcx, "trans_imm_cast", expr.id));
|
||||||
let llexpr_ptr = datum.to_llref();
|
let llexpr_ptr = datum.to_llref();
|
||||||
let lldiscrim_a =
|
let lldiscrim_a =
|
||||||
adt::trans_get_discr(bcx, repr, llexpr_ptr, Some(Type::i64(ccx)));
|
adt::trans_get_discr(bcx, &*repr, llexpr_ptr, Some(Type::i64(ccx)));
|
||||||
match k_out {
|
match k_out {
|
||||||
cast_integral => int_cast(bcx, ll_t_out,
|
cast_integral => int_cast(bcx, ll_t_out,
|
||||||
val_ty(lldiscrim_a),
|
val_ty(lldiscrim_a),
|
||||||
|
@ -224,7 +224,7 @@ fn trans_struct_drop_flag<'a>(bcx: &'a Block<'a>,
|
|||||||
substs: &ty::substs)
|
substs: &ty::substs)
|
||||||
-> &'a Block<'a> {
|
-> &'a Block<'a> {
|
||||||
let repr = adt::represent_type(bcx.ccx(), t);
|
let repr = adt::represent_type(bcx.ccx(), t);
|
||||||
let drop_flag = adt::trans_drop_flag_ptr(bcx, repr, v0);
|
let drop_flag = adt::trans_drop_flag_ptr(bcx, &*repr, v0);
|
||||||
with_cond(bcx, IsNotNull(bcx, Load(bcx, drop_flag)), |cx| {
|
with_cond(bcx, IsNotNull(bcx, Load(bcx, drop_flag)), |cx| {
|
||||||
trans_struct_drop(cx, t, v0, dtor_did, class_did, substs)
|
trans_struct_drop(cx, t, v0, dtor_did, class_did, substs)
|
||||||
})
|
})
|
||||||
@ -265,7 +265,7 @@ fn trans_struct_drop<'a>(bcx: &'a Block<'a>,
|
|||||||
// this scope.
|
// this scope.
|
||||||
let field_tys = ty::struct_fields(bcx.tcx(), class_did, substs);
|
let field_tys = ty::struct_fields(bcx.tcx(), class_did, substs);
|
||||||
for (i, fld) in field_tys.iter().enumerate() {
|
for (i, fld) in field_tys.iter().enumerate() {
|
||||||
let llfld_a = adt::trans_field_ptr(bcx, repr, v0, 0, i);
|
let llfld_a = adt::trans_field_ptr(bcx, &*repr, v0, 0, i);
|
||||||
bcx.fcx.schedule_drop_mem(cleanup::CustomScope(field_scope),
|
bcx.fcx.schedule_drop_mem(cleanup::CustomScope(field_scope),
|
||||||
llfld_a,
|
llfld_a,
|
||||||
fld.mt.ty);
|
fld.mt.ty);
|
||||||
|
@ -320,7 +320,7 @@ impl<'a, 'b> Reflector<'a, 'b> {
|
|||||||
};
|
};
|
||||||
let bcx = fcx.entry_bcx.borrow().clone().unwrap();
|
let bcx = fcx.entry_bcx.borrow().clone().unwrap();
|
||||||
let arg = BitCast(bcx, arg, llptrty);
|
let arg = BitCast(bcx, arg, llptrty);
|
||||||
let ret = adt::trans_get_discr(bcx, repr, arg, Some(Type::i64(ccx)));
|
let ret = adt::trans_get_discr(bcx, &*repr, arg, Some(Type::i64(ccx)));
|
||||||
Store(bcx, ret, fcx.llretptr.get().unwrap());
|
Store(bcx, ret, fcx.llretptr.get().unwrap());
|
||||||
match fcx.llreturn.get() {
|
match fcx.llreturn.get() {
|
||||||
Some(llreturn) => Br(bcx, llreturn),
|
Some(llreturn) => Br(bcx, llreturn),
|
||||||
@ -345,7 +345,7 @@ impl<'a, 'b> Reflector<'a, 'b> {
|
|||||||
for (j, a) in v.args.iter().enumerate() {
|
for (j, a) in v.args.iter().enumerate() {
|
||||||
let bcx = this.bcx;
|
let bcx = this.bcx;
|
||||||
let null = C_null(llptrty);
|
let null = C_null(llptrty);
|
||||||
let ptr = adt::trans_field_ptr(bcx, repr, null, v.disr_val, j);
|
let ptr = adt::trans_field_ptr(bcx, &*repr, null, v.disr_val, j);
|
||||||
let offset = p2i(ccx, ptr);
|
let offset = p2i(ccx, ptr);
|
||||||
let field_args = [this.c_uint(j),
|
let field_args = [this.c_uint(j),
|
||||||
offset,
|
offset,
|
||||||
|
@ -142,7 +142,7 @@ pub fn sizing_type_of(cx: &CrateContext, t: ty::t) -> Type {
|
|||||||
|
|
||||||
ty::ty_tup(..) | ty::ty_enum(..) => {
|
ty::ty_tup(..) | ty::ty_enum(..) => {
|
||||||
let repr = adt::represent_type(cx, t);
|
let repr = adt::represent_type(cx, t);
|
||||||
adt::sizing_type_of(cx, repr)
|
adt::sizing_type_of(cx, &*repr)
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::ty_struct(..) => {
|
ty::ty_struct(..) => {
|
||||||
@ -152,7 +152,7 @@ pub fn sizing_type_of(cx: &CrateContext, t: ty::t) -> Type {
|
|||||||
Type::vector(&type_of(cx, et), n as u64)
|
Type::vector(&type_of(cx, et), n as u64)
|
||||||
} else {
|
} else {
|
||||||
let repr = adt::represent_type(cx, t);
|
let repr = adt::represent_type(cx, t);
|
||||||
adt::sizing_type_of(cx, repr)
|
adt::sizing_type_of(cx, &*repr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,7 +213,7 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type {
|
|||||||
// of the enum's variants refers to the enum itself.
|
// of the enum's variants refers to the enum itself.
|
||||||
let repr = adt::represent_type(cx, t);
|
let repr = adt::represent_type(cx, t);
|
||||||
let name = llvm_type_name(cx, an_enum, did, substs.tps.as_slice());
|
let name = llvm_type_name(cx, an_enum, did, substs.tps.as_slice());
|
||||||
adt::incomplete_type_of(cx, repr, name)
|
adt::incomplete_type_of(cx, &*repr, name)
|
||||||
}
|
}
|
||||||
ty::ty_box(typ) => {
|
ty::ty_box(typ) => {
|
||||||
Type::at_box(cx, type_of(cx, typ)).ptr_to()
|
Type::at_box(cx, type_of(cx, typ)).ptr_to()
|
||||||
@ -259,7 +259,7 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type {
|
|||||||
ty::ty_trait(..) => Type::opaque_trait(cx),
|
ty::ty_trait(..) => Type::opaque_trait(cx),
|
||||||
ty::ty_tup(..) => {
|
ty::ty_tup(..) => {
|
||||||
let repr = adt::represent_type(cx, t);
|
let repr = adt::represent_type(cx, t);
|
||||||
adt::type_of(cx, repr)
|
adt::type_of(cx, &*repr)
|
||||||
}
|
}
|
||||||
ty::ty_struct(did, ref substs) => {
|
ty::ty_struct(did, ref substs) => {
|
||||||
if ty::type_is_simd(cx.tcx(), t) {
|
if ty::type_is_simd(cx.tcx(), t) {
|
||||||
@ -275,7 +275,7 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type {
|
|||||||
a_struct,
|
a_struct,
|
||||||
did,
|
did,
|
||||||
substs.tps.as_slice());
|
substs.tps.as_slice());
|
||||||
adt::incomplete_type_of(cx, repr, name)
|
adt::incomplete_type_of(cx, &*repr, name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,7 +297,7 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type {
|
|||||||
match ty::get(t).sty {
|
match ty::get(t).sty {
|
||||||
ty::ty_enum(..) | ty::ty_struct(..) if !ty::type_is_simd(cx.tcx(), t) => {
|
ty::ty_enum(..) | ty::ty_struct(..) if !ty::type_is_simd(cx.tcx(), t) => {
|
||||||
let repr = adt::represent_type(cx, t);
|
let repr = adt::represent_type(cx, t);
|
||||||
adt::finish_type_of(cx, repr, &mut llty);
|
adt::finish_type_of(cx, &*repr, &mut llty);
|
||||||
}
|
}
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user