pub fn const_get_discrim(ccx: &CrateContext, r: &Repr, val: ValueRef)
    -> Disr {
    match *r {
        CEnum(ity, _, _) => {
            match ity {
                attr::SignedInt(..) => const_to_int(val) as Disr,
                attr::UnsignedInt(..) => const_to_uint(val) as Disr
            }
        }
        General(ity, _) => {
            match ity {
                attr::SignedInt(..) => const_to_int(const_get_elt(ccx, val, [0])) as Disr,
                attr::UnsignedInt(..) => const_to_uint(const_get_elt(ccx, val, [0])) as Disr
            }
        }
        Univariant(..) => 0,
        NullablePointer{ nndiscr, ptrfield, .. } => {
            if is_null(const_struct_field(ccx, val, ptrfield)) {
                /* subtraction as uint is ok because nndiscr is either 0 or 1 */
                (1 - nndiscr) as Disr
            } else {
                nndiscr
            }
        }
    }
}
/// Get the discriminant of a constant value.  (Not currently used.)
Get the discriminant of a constant value.  (Not currently used.)
Get the discriminant of a constant value . ( Not currently used . )
pub fn const_get_discrim(ccx: &CrateContext, r: &Repr, val: ValueRef)
    -> Disr {
    match *r {
        CEnum(ity, _, _) => {
            match ity {
                attr::SignedInt(..) => const_to_int(val) as Disr,
                attr::UnsignedInt(..) => const_to_uint(val) as Disr
            }
        }
        General(ity, _) => {
            match ity {
                attr::SignedInt(..) => const_to_int(const_get_elt(ccx, val, [0])) as Disr,
                attr::UnsignedInt(..) => const_to_uint(const_get_elt(ccx, val, [0])) as Disr
            }
        }
        Univariant(..) => 0,
        NullablePointer{ nndiscr, ptrfield, .. } => {
            if is_null(const_struct_field(ccx, val, ptrfield)) {
                /* subtraction as uint is ok because nndiscr is either 0 or 1 */
                (1 - nndiscr) as Disr
            } else {
                nndiscr
            }
        }
    }
}
pub fn const_get_discrim ( ccx : & CrateContext , r : & Repr , val : ValueRef ) -> Disr { match * r { CEnum ( ity , _ , _ ) => { match ity { attr :: SignedInt ( .. ) => const_to_int ( val ) as Disr , attr :: UnsignedInt ( .. ) => const_to_uint ( val ) as Disr } } General ( ity , _ ) => { match ity { attr :: SignedInt ( .. ) => const_to_int ( const_get_elt ( ccx , val , [ 0 ] ) ) as Disr , attr :: UnsignedInt ( .. ) => const_to_uint ( const_get_elt ( ccx , val , [ 0 ] ) ) as Disr } } Univariant ( .. ) => 0 , NullablePointer { nndiscr , ptrfield , .. } => { if is_null ( const_struct_field ( ccx , val , ptrfield ) ) { /* subtraction as uint is ok because nndiscr is either 0 or 1 */ ( 1 - nndiscr ) as Disr } else { nndiscr } } } }
Get the discriminant of a constant value.
Get the discriminant of a constant value .
ccx
&CrateContext
r
&Repr
val
ValueRef
ccx
&CrateContext
r
&Repr
val
ValueRef