librustc: Remove visit_tydesc intrinsic.
This commit is contained in:
parent
ce6226e6c9
commit
7a4122ac67
@ -327,8 +327,6 @@ extern "rust-intrinsic" {
|
||||
/// Returns `true` if a type is managed (will be allocated on the local heap)
|
||||
pub fn owns_managed<T>() -> bool;
|
||||
|
||||
pub fn visit_tydesc(td: *const TyDesc, tv: &mut TyVisitor);
|
||||
|
||||
/// Calculates the offset from a pointer. The offset *must* be in-bounds of
|
||||
/// the object, or one-byte-past-the-end. An arithmetic overflow is also
|
||||
/// undefined behaviour.
|
||||
|
@ -307,13 +307,6 @@ pub fn trans_intrinsic_call<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, node: ast::N
|
||||
let tp_ty = *substs.types.get(FnSpace, 0);
|
||||
C_bool(ccx, ty::type_contents(ccx.tcx(), tp_ty).owns_managed())
|
||||
}
|
||||
(_, "visit_tydesc") => {
|
||||
let td = *llargs.get(0);
|
||||
let visitor = *llargs.get(1);
|
||||
let td = PointerCast(bcx, td, ccx.tydesc_type().ptr_to());
|
||||
glue::call_visit_glue(bcx, visitor, td);
|
||||
C_nil(ccx)
|
||||
}
|
||||
(_, "offset") => {
|
||||
let ptr = *llargs.get(0);
|
||||
let offset = *llargs.get(1);
|
||||
|
@ -5578,25 +5578,6 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
|
||||
}
|
||||
}
|
||||
},
|
||||
"visit_tydesc" => {
|
||||
let tydesc_ty = match ty::get_tydesc_ty(ccx.tcx) {
|
||||
Ok(t) => t,
|
||||
Err(s) => { tcx.sess.span_fatal(it.span, s.as_slice()); }
|
||||
};
|
||||
let region0 = ty::ReLateBound(it.id, ty::BrAnon(0));
|
||||
let region1 = ty::ReLateBound(it.id, ty::BrAnon(1));
|
||||
let visitor_object_ty =
|
||||
match ty::visitor_object_ty(tcx, region0, region1) {
|
||||
Ok((_, vot)) => vot,
|
||||
Err(s) => { tcx.sess.span_fatal(it.span, s.as_slice()); }
|
||||
};
|
||||
|
||||
let td_ptr = ty::mk_ptr(ccx.tcx, ty::mt {
|
||||
ty: tydesc_ty,
|
||||
mutbl: ast::MutImmutable
|
||||
});
|
||||
(0, vec!( td_ptr, visitor_object_ty ), ty::mk_nil())
|
||||
}
|
||||
"offset" => {
|
||||
(1,
|
||||
vec!(
|
||||
|
@ -1,147 +0,0 @@
|
||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
|
||||
use std::intrinsics::{TyDesc, get_tydesc, visit_tydesc, TyVisitor, Disr, Opaque};
|
||||
|
||||
struct MyVisitor {
|
||||
types: Vec<String> ,
|
||||
}
|
||||
|
||||
impl TyVisitor for MyVisitor {
|
||||
fn visit_bot(&mut self) -> bool {
|
||||
self.types.push("bot".to_string());
|
||||
println!("visited bot type");
|
||||
true
|
||||
}
|
||||
fn visit_nil(&mut self) -> bool {
|
||||
self.types.push("nil".to_string());
|
||||
println!("visited nil type");
|
||||
true
|
||||
}
|
||||
fn visit_bool(&mut self) -> bool {
|
||||
self.types.push("bool".to_string());
|
||||
println!("visited bool type");
|
||||
true
|
||||
}
|
||||
fn visit_int(&mut self) -> bool {
|
||||
self.types.push("int".to_string());
|
||||
println!("visited int type");
|
||||
true
|
||||
}
|
||||
fn visit_i8(&mut self) -> bool {
|
||||
self.types.push("i8".to_string());
|
||||
println!("visited i8 type");
|
||||
true
|
||||
}
|
||||
fn visit_i16(&mut self) -> bool {
|
||||
self.types.push("i16".to_string());
|
||||
println!("visited i16 type");
|
||||
true
|
||||
}
|
||||
fn visit_i32(&mut self) -> bool { true }
|
||||
fn visit_i64(&mut self) -> bool { true }
|
||||
|
||||
fn visit_uint(&mut self) -> bool { true }
|
||||
fn visit_u8(&mut self) -> bool { true }
|
||||
fn visit_u16(&mut self) -> bool { true }
|
||||
fn visit_u32(&mut self) -> bool { true }
|
||||
fn visit_u64(&mut self) -> bool { true }
|
||||
|
||||
fn visit_f32(&mut self) -> bool { true }
|
||||
fn visit_f64(&mut self) -> bool { true }
|
||||
|
||||
fn visit_char(&mut self) -> bool { true }
|
||||
|
||||
fn visit_estr_slice(&mut self) -> bool { true }
|
||||
|
||||
fn visit_box(&mut self, _mtbl: uint, _inner: *const TyDesc) -> bool { true }
|
||||
fn visit_uniq(&mut self, _mtbl: uint, _inner: *const TyDesc) -> bool { true }
|
||||
fn visit_ptr(&mut self, _mtbl: uint, _inner: *const TyDesc) -> bool { true }
|
||||
fn visit_rptr(&mut self, _mtbl: uint, _inner: *const TyDesc) -> bool { true }
|
||||
|
||||
fn visit_evec_slice(&mut self, _mtbl: uint, _inner: *const TyDesc) -> bool { true }
|
||||
fn visit_evec_fixed(&mut self, _n: uint, _sz: uint, _align: uint,
|
||||
_inner: *const TyDesc) -> bool { true }
|
||||
|
||||
fn visit_enter_rec(&mut self, _n_fields: uint,
|
||||
_sz: uint, _align: uint) -> bool { true }
|
||||
fn visit_rec_field(&mut self, _i: uint, _name: &str,
|
||||
_mtbl: uint, _inner: *const TyDesc) -> bool { true }
|
||||
fn visit_leave_rec(&mut self, _n_fields: uint,
|
||||
_sz: uint, _align: uint) -> bool { true }
|
||||
|
||||
fn visit_enter_class(&mut self, _name: &str, _named_fields: bool, _n_fields: uint,
|
||||
_sz: uint, _align: uint) -> bool { true }
|
||||
fn visit_class_field(&mut self, _i: uint, _name: &str, _named: bool,
|
||||
_mtbl: uint, _inner: *const TyDesc) -> bool { true }
|
||||
fn visit_leave_class(&mut self, _name: &str, _named_fields: bool, _n_fields: uint,
|
||||
_sz: uint, _align: uint) -> bool { true }
|
||||
|
||||
fn visit_enter_tup(&mut self, _n_fields: uint,
|
||||
_sz: uint, _align: uint) -> bool { true }
|
||||
fn visit_tup_field(&mut self, _i: uint, _inner: *const TyDesc) -> bool { true }
|
||||
fn visit_leave_tup(&mut self, _n_fields: uint,
|
||||
_sz: uint, _align: uint) -> bool { true }
|
||||
|
||||
fn visit_enter_enum(&mut self, _n_variants: uint,
|
||||
_get_disr: unsafe extern fn(ptr: *const Opaque) -> Disr,
|
||||
_sz: uint, _align: uint) -> bool { true }
|
||||
fn visit_enter_enum_variant(&mut self,
|
||||
_variant: uint,
|
||||
_disr_val: Disr,
|
||||
_n_fields: uint,
|
||||
_name: &str) -> bool { true }
|
||||
fn visit_enum_variant_field(&mut self, _i: uint, _offset: uint, _inner: *const TyDesc)
|
||||
-> bool { true }
|
||||
fn visit_leave_enum_variant(&mut self,
|
||||
_variant: uint,
|
||||
_disr_val: Disr,
|
||||
_n_fields: uint,
|
||||
_name: &str) -> bool { true }
|
||||
fn visit_leave_enum(&mut self,
|
||||
_n_variants: uint,
|
||||
_get_disr: unsafe extern fn(ptr: *const Opaque) -> Disr,
|
||||
_sz: uint, _align: uint) -> bool { true }
|
||||
|
||||
fn visit_enter_fn(&mut self, _purity: uint, _proto: uint,
|
||||
_n_inputs: uint, _retstyle: uint) -> bool { true }
|
||||
fn visit_fn_input(&mut self, _i: uint, _mode: uint, _inner: *const TyDesc) -> bool { true }
|
||||
fn visit_fn_output(&mut self, _retstyle: uint, _variadic: bool, _inner: *const TyDesc)
|
||||
-> bool { true }
|
||||
fn visit_leave_fn(&mut self, _purity: uint, _proto: uint,
|
||||
_n_inputs: uint, _retstyle: uint) -> bool { true }
|
||||
|
||||
|
||||
fn visit_trait(&mut self, _name: &str) -> bool { true }
|
||||
fn visit_param(&mut self, _i: uint) -> bool { true }
|
||||
fn visit_self(&mut self) -> bool { true }
|
||||
}
|
||||
|
||||
fn visit_ty<T>(v: &mut MyVisitor) {
|
||||
unsafe { visit_tydesc(get_tydesc::<T>(), v as &mut TyVisitor) }
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let mut v = MyVisitor {types: Vec::new()};
|
||||
|
||||
visit_ty::<bool>(&mut v);
|
||||
visit_ty::<int>(&mut v);
|
||||
visit_ty::<i8>(&mut v);
|
||||
visit_ty::<i16>(&mut v);
|
||||
|
||||
for s in v.types.iter() {
|
||||
println!("type: {}", (*s).clone());
|
||||
}
|
||||
|
||||
let vec_types: Vec<String> = v.types.clone().into_iter().collect();
|
||||
assert_eq!(vec_types, vec!("bool".to_string(), "int".to_string(),
|
||||
"i8".to_string(), "i16".to_string()));
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user