pub fn trans_set_discr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, r: &Repr<'tcx>,
                                   val: ValueRef, discr: Disr) {
    match *r {
        CEnum(ity, min, max) => {
            assert_discr_in_range(ity, min, max, discr);
            Store(bcx, C_integral(ll_inttype(bcx.ccx(), ity), discr.0, true),
                  val);
        }
        General(ity, _) => {
            Store(bcx, C_integral(ll_inttype(bcx.ccx(), ity), discr.0, true),
                  StructGEP(bcx, val, 0));
        }
        Univariant(_) => {
            assert_eq!(discr, Disr(0));
        }
        UntaggedUnion(..) => {
            assert_eq!(discr, Disr(0));
        }
        RawNullablePointer { nndiscr, nnty, ..} => {
            if discr != nndiscr {
                let llptrty = type_of::sizing_type_of(bcx.ccx(), nnty);
                Store(bcx, C_null(llptrty), val);
            }
        }
        StructWrappedNullablePointer { nndiscr, ref discrfield, .. } => {
            if discr != nndiscr {
                let llptrptr = GEPi(bcx, val, &discrfield[..]);
                let llptrty = val_ty(llptrptr).element_type();
                Store(bcx, C_null(llptrty), llptrptr);
            }
        }
    }
}
/// Set the discriminant for a new value of the given case of the given
/// representation.
Set the discriminant for a new value of the given case of the given
representation.
Set the discriminant for a new value of the given case of the given representation .
pub fn trans_set_discr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, r: &Repr<'tcx>,
                                   val: ValueRef, discr: Disr) {
    match *r {
        CEnum(ity, min, max) => {
            assert_discr_in_range(ity, min, max, discr);
            Store(bcx, C_integral(ll_inttype(bcx.ccx(), ity), discr.0, true),
                  val);
        }
        General(ity, _) => {
            Store(bcx, C_integral(ll_inttype(bcx.ccx(), ity), discr.0, true),
                  StructGEP(bcx, val, 0));
        }
        Univariant(_) => {
            assert_eq!(discr, Disr(0));
        }
        UntaggedUnion(..) => {
            assert_eq!(discr, Disr(0));
        }
        RawNullablePointer { nndiscr, nnty, ..} => {
            if discr != nndiscr {
                let llptrty = type_of::sizing_type_of(bcx.ccx(), nnty);
                Store(bcx, C_null(llptrty), val);
            }
        }
        StructWrappedNullablePointer { nndiscr, ref discrfield, .. } => {
            if discr != nndiscr {
                let llptrptr = GEPi(bcx, val, &discrfield[..]);
                let llptrty = val_ty(llptrptr).element_type();
                Store(bcx, C_null(llptrty), llptrptr);
            }
        }
    }
}
pub fn trans_set_discr < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > , r : & Repr < ' tcx > , val : ValueRef , discr : Disr ) { match * r { CEnum ( ity , min , max ) => { assert_discr_in_range ( ity , min , max , discr ) ; Store ( bcx , C_integral ( ll_inttype ( bcx . ccx ( ) , ity ) , discr . 0 , true ) , val ) ; } General ( ity , _ ) => { Store ( bcx , C_integral ( ll_inttype ( bcx . ccx ( ) , ity ) , discr . 0 , true ) , StructGEP ( bcx , val , 0 ) ) ; } Univariant ( _ ) => { assert_eq ! ( discr Disr ( 0 ) ) ; } UntaggedUnion ( .. ) => { assert_eq ! ( discr Disr ( 0 ) ) ; } RawNullablePointer { nndiscr , nnty , .. } => { if discr != nndiscr { let llptrty = type_of :: sizing_type_of ( bcx . ccx ( ) , nnty ) ; Store ( bcx , C_null ( llptrty ) , val ) ; } } StructWrappedNullablePointer { nndiscr , ref discrfield , .. } => { if discr != nndiscr { let llptrptr = GEPi ( bcx , val , & discrfield [ .. ] ) ; let llptrty = val_ty ( llptrptr ) . element_type ( ) ; Store ( bcx , C_null ( llptrty ) , llptrptr ) ; } } } }
Set the discriminant for a new value of the given case of the given
representation.
Set the discriminant for a new value of the given case of the given representation .
bcx
Block<'blk, 'tcx>
r
&Repr<'tcx>
val
ValueRef
discr
Disr
bcx
Block<'blk, 'tcx>
r
&Repr<'tcx>
val
ValueRef
discr
Disr