Struct rustc::middle::trans::datum::Datum[src]
pub struct Datum<K> {
pub val: ValueRef,
pub ty: t,
pub kind: K,
}A Datum encapsulates the result of evaluating an expression. It
describes where the value is stored, what Rust type the value has,
whether it is addressed by reference, and so forth. Please refer
the section on datums in doc.rs for more details.
Fields
val | The llvm value. This is either a pointer to the Rust value or
the value itself, depending on |
ty | The rust type of the value. |
kind | Indicates whether this is by-ref or by-value. |
Methods
impl Datum<Rvalue>
fn add_clean(self, fcx: &FunctionContext, scope: ScopeId) -> ValueRef
Schedules a cleanup for this datum in the given scope. That means that this datum is no longer an rvalue datum; hence, this function consumes the datum and returns the contained ValueRef.
fn to_lvalue_datum_in_scope<'a>(self, bcx: &'a Block<'a>, name: &str, scope: ScopeId) -> DatumBlock<'a, Lvalue>
Returns an lvalue datum (that is, a by ref datum with
cleanup scheduled). If self is not already an lvalue,
cleanup will be scheduled in the temporary scope for expr_id.
fn to_ref_datum<'a>(self, bcx: &'a Block<'a>) -> DatumBlock<'a, Rvalue>
fn to_appropriate_datum<'a>(self, bcx: &'a Block<'a>) -> DatumBlock<'a, Rvalue>
impl Datum<Expr>
Methods suitable for "expr" datums that could be either lvalues or
rvalues. These include coercions into lvalues/rvalues but also a number
of more general operations. (Some of those operations could be moved to
the more general impl<K> Datum<K>, but it's convenient to have them
here since we can match self.kind rather than having to implement
generic methods in KindOps.)
fn assert_lvalue(self, bcx: &Block) -> Datum<Lvalue>
Asserts that this datum is an lvalue and returns it.
fn assert_rvalue(self, bcx: &Block) -> Datum<Rvalue>
Asserts that this datum is an lvalue and returns it.
fn store_to_dest<'a>(self, bcx: &'a Block<'a>, dest: Dest, expr_id: NodeId) -> &'a Block<'a>
fn add_clean_if_rvalue<'a>(self, bcx: &'a Block<'a>, expr_id: NodeId)
Arranges cleanup for self if it is an rvalue. Use when
you are done working with a value that may need drop.
fn clean<'a>(self, bcx: &'a Block<'a>, name: &'static str, expr_id: NodeId) -> &'a Block<'a>
Ensures that self will get cleaned up, if it is not an lvalue
already.
fn to_lvalue_datum<'a>(self, bcx: &'a Block<'a>, name: &str, expr_id: NodeId) -> DatumBlock<'a, Lvalue>
fn to_rvalue_datum<'a>(self, bcx: &'a Block<'a>, name: &'static str) -> DatumBlock<'a, Rvalue>
Ensures that we have an rvalue datum (that is, a datum with no cleanup scheduled).
impl Datum<Lvalue>
Methods suitable only for lvalues. These include the various operations to extract components out of compound data structures, such as extracting the field from a struct or a particular element from an array.
fn to_llref(self) -> ValueRef
Converts a datum into a by-ref value. The datum type must be one which is always passed by reference.
fn get_element(&self, ty: t, gep: |ValueRef| -> ValueRef) -> Datum<Lvalue>
fn get_vec_base_and_len<'a>(&self, bcx: &'a Block<'a>) -> (ValueRef, ValueRef)
Converts a vector into the slice pair.
impl<K: KindOps> Datum<K>
Generic methods applicable to any sort of datum.
fn new(val: ValueRef, ty: t, kind: K) -> Datum<K>
fn to_expr_datum(self) -> Datum<Expr>
fn store_to<'a>(self, bcx: &'a Block<'a>, dst: ValueRef) -> &'a Block<'a>
Moves or copies this value into a new home, as appropriate depending on the type of the datum. This method consumes the datum, since it would be incorrect to go on using the datum if the value represented is affine (and hence the value is moved).
fn shallow_copy_and_take<'a>(&self, bcx: &'a Block<'a>, dst: ValueRef) -> &'a Block<'a>
Copies the value into a new location and runs any necessary
take glue on the new location. This function always
preserves the existing datum as a valid value. Therefore,
it does not consume self and, also, cannot be applied to
affine values (since they must never be duplicated).
fn to_str(&self, ccx: &CrateContext) -> String
fn appropriate_rvalue_mode(&self, ccx: &CrateContext) -> RvalueMode
See the appropriate_rvalue_mode() function
fn to_llscalarish<'a>(self, bcx: &'a Block<'a>) -> ValueRef
Converts self into a by-value ValueRef. Consumes this
datum (i.e., absolves you of responsibility to cleanup the
value). For this to work, the value must be something
scalar-ish (like an int or a pointer) which (1) does not
require drop glue and (2) is naturally passed around by
value, and not by reference.