use util::ppaux::{Repr, ty_to_string};
use std::c_str::ToCStr;
-use std::gc::Gc;
use std::vec;
use libc::c_uint;
use syntax::{ast, ast_util};
+use syntax::ptr::P;
-pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: ast::Lit)
+pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: &ast::Lit)
-> ValueRef {
let _icx = push_ctxt("trans_lit");
debug!("const_lit: {}", lit);
}
fn const_vec(cx: &CrateContext, e: &ast::Expr,
- es: &[Gc<ast::Expr>], is_local: bool) -> (ValueRef, Type, bool) {
+ es: &[P<ast::Expr>], is_local: bool) -> (ValueRef, Type, bool) {
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);
None => { }
Some(adj) => {
match adj {
- ty::AutoAddEnv(ty::RegionTraitStore(ty::ReStatic, _)) => {
+ ty::AdjustAddEnv(ty::RegionTraitStore(ty::ReStatic, _)) => {
let def = ty::resolve_expr(cx.tcx(), e);
let wrapper = closure::get_wrapper_for_bare_fn(cx,
ety_adjusted,
is_local);
llconst = C_struct(cx, [wrapper, C_null(Type::i8p(cx))], false)
}
- ty::AutoAddEnv(store) => {
+ ty::AdjustAddEnv(store) => {
cx.sess()
.span_bug(e.span,
format!("unexpected static function: {:?}",
store).as_slice())
}
- ty::AutoDerefRef(ref adj) => {
+ ty::AdjustDerefRef(ref adj) => {
let mut ty = ety;
// Save the last autoderef in case we can avoid it.
if adj.autoderefs > 0 {
// if it's assigned to a static.
fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
is_local: bool) -> (ValueRef, bool) {
- let map_list = |exprs: &[Gc<ast::Expr>]| {
+ let map_list = |exprs: &[P<ast::Expr>]| {
exprs.iter().map(|e| first_two(const_expr(cx, &**e, is_local)))
.fold((Vec::new(), true),
|(l, all_inlineable), (val, inlineable)| {
let _icx = push_ctxt("const_expr");
return match e.node {
ast::ExprLit(ref lit) => {
- (consts::const_lit(cx, e, (**lit).clone()), true)
+ (consts::const_lit(cx, e, &**lit), true)
}
ast::ExprBinary(b, ref e1, ref e2) => {
let (te1, _, _) = const_expr(cx, &**e1, is_local);
(adt::const_get_field(cx, &*brepr, bv, discr, ix), inlineable)
})
}
+ ast::ExprTupField(ref base, idx, _) => {
+ let (bv, inlineable, bt) = const_expr(cx, &**base, is_local);
+ let brepr = adt::represent_type(cx, bt);
+ expr::with_field_tys(cx.tcx(), bt, None, |discr, _| {
+ (adt::const_get_field(cx, &*brepr, bv, discr, idx.node), inlineable)
+ })
+ }
ast::ExprIndex(ref base, ref index) => {
let (bv, inlineable, bt) = const_expr(cx, &**base, is_local);
}
}
}
- ast::ExprCall(callee, ref args) => {
+ ast::ExprCall(ref callee, ref args) => {
let opt_def = cx.tcx().def_map.borrow().find_copy(&callee.id);
match opt_def {
Some(def::DefStruct(_)) => {