pub fn trans_get_discr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, r: &Repr<'tcx>,
                                   scrutinee: ValueRef, cast_to: Option<Type>,
                                   range_assert: bool)
    -> ValueRef {
    debug!("trans_get_discr r: {:?}", r);
    let val = match *r {
        CEnum(ity, min, max) => {
            load_discr(bcx, ity, scrutinee, min, max, range_assert)
        }
        General(ity, ref cases) => {
            let ptr = StructGEP(bcx, scrutinee, 0);
            load_discr(bcx, ity, ptr, Disr(0), Disr(cases.len() as u64 - 1),
                       range_assert)
        }
        Univariant(..) | UntaggedUnion(..) => C_u8(bcx.ccx(), 0),
        RawNullablePointer { nndiscr, nnty, .. } =>  {
            let cmp = if nndiscr == Disr(0) { IntEQ } else { IntNE };
            let llptrty = type_of::sizing_type_of(bcx.ccx(), nnty);
            ICmp(bcx, cmp, Load(bcx, scrutinee), C_null(llptrty), DebugLoc::None)
        }
        StructWrappedNullablePointer { nndiscr, ref discrfield, .. } => {
            struct_wrapped_nullable_bitdiscr(bcx, nndiscr, discrfield, scrutinee)
        }
    };
    match cast_to {
        None => val,
        Some(llty) => if is_discr_signed(r) { 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<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, r: &Repr<'tcx>,
                                   scrutinee: ValueRef, cast_to: Option<Type>,
                                   range_assert: bool)
    -> ValueRef {
    debug!("trans_get_discr r: {:?}", r);
    let val = match *r {
        CEnum(ity, min, max) => {
            load_discr(bcx, ity, scrutinee, min, max, range_assert)
        }
        General(ity, ref cases) => {
            let ptr = StructGEP(bcx, scrutinee, 0);
            load_discr(bcx, ity, ptr, Disr(0), Disr(cases.len() as u64 - 1),
                       range_assert)
        }
        Univariant(..) | UntaggedUnion(..) => C_u8(bcx.ccx(), 0),
        RawNullablePointer { nndiscr, nnty, .. } =>  {
            let cmp = if nndiscr == Disr(0) { IntEQ } else { IntNE };
            let llptrty = type_of::sizing_type_of(bcx.ccx(), nnty);
            ICmp(bcx, cmp, Load(bcx, scrutinee), C_null(llptrty), DebugLoc::None)
        }
        StructWrappedNullablePointer { nndiscr, ref discrfield, .. } => {
            struct_wrapped_nullable_bitdiscr(bcx, nndiscr, discrfield, scrutinee)
        }
    };
    match cast_to {
        None => val,
        Some(llty) => if is_discr_signed(r) { SExt(bcx, val, llty) } else { ZExt(bcx, val, llty) }
    }
}
pub fn trans_get_discr < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > , r : & Repr < ' tcx > , scrutinee : ValueRef , cast_to : Option < Type > , range_assert : bool ) -> ValueRef { debug ! ( " " r ) ; let val = match * r { CEnum ( ity , min , max ) => { load_discr ( bcx , ity , scrutinee , min , max , range_assert ) } General ( ity , ref cases ) => { let ptr = StructGEP ( bcx , scrutinee , 0 ) ; load_discr ( bcx , ity , ptr , Disr ( 0 ) , Disr ( cases . len ( ) as u64 - 1 ) , range_assert ) } Univariant ( .. ) | UntaggedUnion ( .. ) => C_u8 ( bcx . ccx ( ) , 0 ) , RawNullablePointer { nndiscr , nnty , .. } => { let cmp = if nndiscr == Disr ( 0 ) { IntEQ } else { IntNE } ; let llptrty = type_of :: sizing_type_of ( bcx . ccx ( ) , nnty ) ; ICmp ( bcx , cmp , Load ( bcx , scrutinee ) , C_null ( llptrty ) , DebugLoc :: None ) } StructWrappedNullablePointer { nndiscr , ref discrfield , .. } => { struct_wrapped_nullable_bitdiscr ( bcx , nndiscr , discrfield , scrutinee ) } } ; match cast_to { None => val , Some ( llty ) => if is_discr_signed ( r ) { 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<'blk, 'tcx>
r
&Repr<'tcx>
scrutinee
ValueRef
cast_to
Option<Type>
range_assert
bool
bcx
Block<'blk, 'tcx>
r
&Repr<'tcx>
scrutinee
ValueRef
cast_to
Option<Type>
range_assert
bool