use syntax::parse::token::{InternedString, special_idents};
use syntax::parse::token;
-pub struct Reflector<'a, 'b> {
+pub struct Reflector<'a, 'blk, 'tcx: 'blk> {
visitor_val: ValueRef,
visitor_items: &'a [ty::ImplOrTraitItem],
- final_bcx: &'b Block<'b>,
+ final_bcx: Block<'blk, 'tcx>,
tydesc_ty: Type,
- bcx: &'b Block<'b>
+ bcx: Block<'blk, 'tcx>
}
-impl<'a, 'b> Reflector<'a, 'b> {
+impl<'a, 'blk, 'tcx> Reflector<'a, 'blk, 'tcx> {
pub fn c_uint(&mut self, u: uint) -> ValueRef {
C_uint(self.bcx.ccx(), u)
}
format!("couldn't find visit method for {}", ty_name).as_slice());
let method = match self.visitor_items[mth_idx] {
ty::MethodTraitItem(ref method) => (*method).clone(),
+ ty::TypeTraitItem(_) => return,
};
let mth_ty = ty::mk_bare_fn(tcx, method.fty.clone());
debug!("Emit call visit method: visit_{}: {}", ty_name, ty_to_string(tcx, mth_ty));
// Unfortunately we can't do anything here because at runtime we
// pass around the value by pointer (*u8). But unsized pointers are
// fat and so we can't just cast them to *u8 and back. So we have
- // to work with the pointer directly (see ty_rptr/ty_uniq).
+ // to work with the pointer directly (see ty_ptr/ty_rptr/ty_uniq).
fail!("Can't reflect unsized type")
}
// FIXME(15049) Reflection for unsized structs.
self.visit("box", extra.as_slice())
}
ty::ty_ptr(ref mt) => {
- let extra = self.c_mt(mt);
- self.visit("ptr", extra.as_slice())
+ match ty::get(mt.ty).sty {
+ ty::ty_vec(ty, None) => {
+ let extra = self.c_mt(&ty::mt{ty: ty, mutbl: mt.mutbl});
+ self.visit("evec_slice", extra.as_slice())
+ }
+ ty::ty_str => self.visit("estr_slice", &[]),
+ ty::ty_trait(..) => {
+ let extra = [
+ self.c_slice(token::intern_and_get_ident(
+ ty_to_string(tcx, t).as_slice()))
+ ];
+ self.visit("trait", extra);
+ }
+ _ => {
+ let extra = self.c_mt(mt);
+ self.visit("ptr", extra.as_slice())
+ }
+ }
}
ty::ty_uniq(typ) => {
match ty::get(typ).sty {
let sym = mangle_internal_name_by_path_and_seq(
ast_map::Values([].iter()).chain(None), "get_disr");
- let fn_ty = ty::mk_ctor_fn(&ccx.tcx, ast::DUMMY_NODE_ID,
+ let fn_ty = ty::mk_ctor_fn(ccx.tcx(), ast::DUMMY_NODE_ID,
[opaqueptrty], ty::mk_u64());
let llfdecl = decl_internal_rust_fn(ccx,
fn_ty,
}
// Emit a sequence of calls to visit_ty::visit_foo
-pub fn emit_calls_to_trait_visit_ty<'a>(
- bcx: &'a Block<'a>,
- t: ty::t,
- visitor_val: ValueRef,
- visitor_trait_id: DefId)
- -> &'a Block<'a> {
+pub fn emit_calls_to_trait_visit_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
+ t: ty::t,
+ visitor_val: ValueRef,
+ visitor_trait_id: DefId)
+ -> Block<'blk, 'tcx> {
let fcx = bcx.fcx;
let final = fcx.new_temp_block("final");
let tydesc_ty = ty::get_tydesc_ty(bcx.tcx()).unwrap();