pub fn trans_get_discr(bcx: &Block, r: &Repr, scrutinee: ValueRef, cast_to: Option<Type>)
    -> ValueRef {
    let signed;
    let val;
    match *r {
        CEnum(ity, min, max) => {
            val = load_discr(bcx, ity, scrutinee, min, max);
            signed = ity.is_signed();
        }
        General(ity, ref cases) => {
            let ptr = GEPi(bcx, scrutinee, [0, 0]);
            val = load_discr(bcx, ity, ptr, 0, (cases.len() - 1) as Disr);
            signed = ity.is_signed();
        }
        Univariant(..) => {
            val = C_u8(0);
            signed = false;
        }
        NullablePointer{ nonnull: ref nonnull, nndiscr, ptrfield, .. } => {
            val = nullable_bitdiscr(bcx, nonnull, nndiscr, ptrfield, scrutinee);
            signed = false;
        }
    }
    match cast_to {
        None => val,
        Some(llty) => if signed { SExt(bcx, val, llty) } else { ZExt(bcx, val, llty) }
    }
}
/// Obtain the actual discriminant of a value.
Obtain the actual discriminant of a value.
Obtain the actual discriminant of a value .
pub fn trans_get_discr(bcx: &Block, r: &Repr, scrutinee: ValueRef, cast_to: Option<Type>)
    -> ValueRef {
    let signed;
    let val;
    match *r {
        CEnum(ity, min, max) => {
            val = load_discr(bcx, ity, scrutinee, min, max);
            signed = ity.is_signed();
        }
        General(ity, ref cases) => {
            let ptr = GEPi(bcx, scrutinee, [0, 0]);
            val = load_discr(bcx, ity, ptr, 0, (cases.len() - 1) as Disr);
            signed = ity.is_signed();
        }
        Univariant(..) => {
            val = C_u8(0);
            signed = false;
        }
        NullablePointer{ nonnull: ref nonnull, nndiscr, ptrfield, .. } => {
            val = nullable_bitdiscr(bcx, nonnull, nndiscr, ptrfield, scrutinee);
            signed = false;
        }
    }
    match cast_to {
        None => val,
        Some(llty) => if signed { SExt(bcx, val, llty) } else { ZExt(bcx, val, llty) }
    }
}
pub fn trans_get_discr ( bcx : & Block , r : & Repr , scrutinee : ValueRef , cast_to : Option < Type > ) -> ValueRef { let signed ; let val ; match * r { CEnum ( ity , min , max ) => { val = load_discr ( bcx , ity , scrutinee , min , max ) ; signed = ity . is_signed ( ) ; } General ( ity , ref cases ) => { let ptr = GEPi ( bcx , scrutinee , [ 0 , 0 ] ) ; val = load_discr ( bcx , ity , ptr , 0 , ( cases . len ( ) - 1 ) as Disr ) ; signed = ity . is_signed ( ) ; } Univariant ( .. ) => { val = C_u8 ( 0 ) ; signed = false ; } NullablePointer { nonnull : ref nonnull , nndiscr , ptrfield , .. } => { val = nullable_bitdiscr ( bcx , nonnull , nndiscr , ptrfield , scrutinee ) ; signed = false ; } } match cast_to { None => val , Some ( llty ) => if signed { SExt ( bcx , val , llty ) } else { ZExt ( bcx , val , llty ) } } }
Obtain the actual discriminant of a value.
Obtain the actual discriminant of a value .
bcx
&Block
r
&Repr
scrutinee
ValueRef
cast_to
Option<Type>
bcx
&Block
r
&Repr
scrutinee
ValueRef
cast_to
Option<Type>