Struct jit::Ty
[−]
[src]
pub struct Ty(_);
An object that represents a native system type
Each &Ty
represents a basic system type, be it a primitive, a struct, a
union, a pointer, or a function signature. The library uses this information
to lay out values in memory.
Types are not attached to a context so they are reference-counted by LibJIT,
so internally they are represented as Rc<Ty>
. This represents a reference
to the inner Ty
.
Methods
impl Ty
fn get_size(&self) -> usize
Get the size of this type in bytes.
fn get_alignment(&self) -> usize
Get the alignment of this type in bytes.
fn get_kind(&self) -> TypeKind
Get a value that indicates the kind of this type. This allows callers to quickly classify a type to determine how it should be handled further.
fn get_ref(&self) -> Option<&Ty>
Get the type that is referred to by this pointer type.
fn get_return(&self) -> Option<&Ty>
Get the type returned by this function type.
fn set_names(&mut self, names: &[&str])
Set the field or parameter names of this struct or union type.
use jit::*; let f64_t = get::<f64>(); let mut ty = Type::new_struct(&mut [&f64_t, &f64_t]); ty.set_names(&["x", "y"]); assert_eq!(ty.get_field("x").unwrap().get_type(), &f64_t as &Ty); assert_eq!(ty.get_field("y").unwrap().get_type(), &f64_t as &Ty);
fn fields(&self) -> Fields
Iterate over the type's fields
use jit::*; let pos_t = get::<(f64, f64)>(); let f64_t = get::<f64>(); for field in pos_t.fields() { assert_eq!(field.get_type(), &f64_t as &Ty); }
fn params(&self) -> Params
Iterate over the function signature's parameters
use jit::*; let sig_t = get::<fn(i32, i32) -> i32>(); let i32_t = get::<i32>(); for param in sig_t.params() { assert_eq!(param, &i32_t as &Ty); }
fn get_field(&self, name: &str) -> Option<Field>
Find the field/parameter index for a particular name.
fn is_primitive(&self) -> bool
Check if this is a primitive
use jit::*; assert!(get::<i16>().is_primitive()); assert!(!get::<(i16, i16)>().is_primitive());
fn is_float(&self) -> bool
Check if this is a floating-point number
use jit::*; assert!(get::<f64>().is_float()); assert!(!get::<i16>().is_float());
fn is_int(&self) -> bool
Check if this is an integer
use jit::*; assert!(get::<i16>().is_int()); assert!(!get::<f32>().is_int());
fn is_struct(&self) -> bool
Check if this is a struct
use jit::*; assert!(get::<(i16, i16)>().is_struct());
fn is_union(&self) -> bool
Check if this is a union
fn is_signature(&self) -> bool
Check if this is a signature
use jit::*; assert!(get::<fn(i16) -> i16>().is_signature());
fn is_pointer(&self) -> bool
Check if this is a pointer
use jit::*; assert!(get::<&'static u8>().is_pointer());
fn is_tagged(&self) -> bool
Check if this is tagged