pub fn trans_field_ptr_builder<'blk, 'tcx>(bcx: &BlockAndBuilder<'blk, 'tcx>,
                                           r: &Repr<'tcx>,
                                           val: MaybeSizedValue,
                                           discr: Disr, ix: usize)
                                           -> ValueRef {
    // Note: if this ever needs to generate conditionals (e.g., if we
    // decide to do some kind of cdr-coding-like non-unique repr
    // someday), it will need to return a possibly-new bcx as well.
    match *r {
        CEnum(..) => {
            bug!("element access in C-like enum")
        }
        Univariant(ref st) => {
            assert_eq!(discr, Disr(0));
            struct_field_ptr(bcx, st, val, ix, false)
        }
        General(_, ref cases) => {
            struct_field_ptr(bcx, &cases[discr.0 as usize], val, ix + 1, true)
        }
        UntaggedUnion(ref un) => {
            let ty = type_of::in_memory_type_of(bcx.ccx(), un.fields[ix]);
            if bcx.is_unreachable() { return C_undef(ty.ptr_to()); }
            bcx.pointercast(val.value, ty.ptr_to())
        }
        RawNullablePointer { nndiscr, ref nullfields, .. } |
        StructWrappedNullablePointer { nndiscr, ref nullfields, .. } if discr != nndiscr => {
            // The unit-like case might have a nonzero number of unit-like fields.
            // (e.d., Result of Either with (), as one side.)
            let ty = type_of::type_of(bcx.ccx(), nullfields[ix]);
            assert_eq!(machine::llsize_of_alloc(bcx.ccx(), ty), 0);
            // The contents of memory at this pointer can't matter, but use
            // the value that's "reasonable" in case of pointer comparison.
            if bcx.is_unreachable() { return C_undef(ty.ptr_to()); }
            bcx.pointercast(val.value, ty.ptr_to())
        }
        RawNullablePointer { nndiscr, nnty, .. } => {
            assert_eq!(ix, 0);
            assert_eq!(discr, nndiscr);
            let ty = type_of::type_of(bcx.ccx(), nnty);
            if bcx.is_unreachable() { return C_undef(ty.ptr_to()); }
            bcx.pointercast(val.value, ty.ptr_to())
        }
        StructWrappedNullablePointer { ref nonnull, nndiscr, .. } => {
            assert_eq!(discr, nndiscr);
            struct_field_ptr(bcx, nonnull, val, ix, false)
        }
    }
}
/// Access a field, at a point when the value's case is known.
Access a field, at a point when the value's case is known.
Access a field at a point when the value ' s case is known .
pub fn trans_field_ptr_builder<'blk, 'tcx>(bcx: &BlockAndBuilder<'blk, 'tcx>,
                                           r: &Repr<'tcx>,
                                           val: MaybeSizedValue,
                                           discr: Disr, ix: usize)
                                           -> ValueRef {
    // Note: if this ever needs to generate conditionals (e.g., if we
    // decide to do some kind of cdr-coding-like non-unique repr
    // someday), it will need to return a possibly-new bcx as well.
    match *r {
        CEnum(..) => {
            bug!("element access in C-like enum")
        }
        Univariant(ref st) => {
            assert_eq!(discr, Disr(0));
            struct_field_ptr(bcx, st, val, ix, false)
        }
        General(_, ref cases) => {
            struct_field_ptr(bcx, &cases[discr.0 as usize], val, ix + 1, true)
        }
        UntaggedUnion(ref un) => {
            let ty = type_of::in_memory_type_of(bcx.ccx(), un.fields[ix]);
            if bcx.is_unreachable() { return C_undef(ty.ptr_to()); }
            bcx.pointercast(val.value, ty.ptr_to())
        }
        RawNullablePointer { nndiscr, ref nullfields, .. } |
        StructWrappedNullablePointer { nndiscr, ref nullfields, .. } if discr != nndiscr => {
            // The unit-like case might have a nonzero number of unit-like fields.
            // (e.d., Result of Either with (), as one side.)
            let ty = type_of::type_of(bcx.ccx(), nullfields[ix]);
            assert_eq!(machine::llsize_of_alloc(bcx.ccx(), ty), 0);
            // The contents of memory at this pointer can't matter, but use
            // the value that's "reasonable" in case of pointer comparison.
            if bcx.is_unreachable() { return C_undef(ty.ptr_to()); }
            bcx.pointercast(val.value, ty.ptr_to())
        }
        RawNullablePointer { nndiscr, nnty, .. } => {
            assert_eq!(ix, 0);
            assert_eq!(discr, nndiscr);
            let ty = type_of::type_of(bcx.ccx(), nnty);
            if bcx.is_unreachable() { return C_undef(ty.ptr_to()); }
            bcx.pointercast(val.value, ty.ptr_to())
        }
        StructWrappedNullablePointer { ref nonnull, nndiscr, .. } => {
            assert_eq!(discr, nndiscr);
            struct_field_ptr(bcx, nonnull, val, ix, false)
        }
    }
}
pub fn trans_field_ptr_builder < ' blk , ' tcx > ( bcx : & BlockAndBuilder < ' blk , ' tcx > , r : & Repr < ' tcx > , val : MaybeSizedValue , discr : Disr , ix : usize ) -> ValueRef { // Note: if this ever needs to generate conditionals (e.g., if we // decide to do some kind of cdr-coding-like non-unique repr // someday), it will need to return a possibly-new bcx as well. match * r { CEnum ( .. ) => { bug ! ( " " ) } Univariant ( ref st ) => { assert_eq ! ( discr Disr ( 0 ) ) ; struct_field_ptr ( bcx , st , val , ix , false ) } General ( _ , ref cases ) => { struct_field_ptr ( bcx , & cases [ discr . 0 as usize ] , val , ix + 1 , true ) } UntaggedUnion ( ref un ) => { let ty = type_of :: in_memory_type_of ( bcx . ccx ( ) , un . fields [ ix ] ) ; if bcx . is_unreachable ( ) { return C_undef ( ty . ptr_to ( ) ) ; } bcx . pointercast ( val . value , ty . ptr_to ( ) ) } RawNullablePointer { nndiscr , ref nullfields , .. } | StructWrappedNullablePointer { nndiscr , ref nullfields , .. } if discr != nndiscr => { // The unit-like case might have a nonzero number of unit-like fields. // (e.d., Result of Either with (), as one side.) let ty = type_of :: type_of ( bcx . ccx ( ) , nullfields [ ix ] ) ; assert_eq ! ( machine llsize_of_alloc ( bcx ccx ( ) ty ) 0 ) ; // The contents of memory at this pointer can't matter, but use // the value that's "reasonable" in case of pointer comparison. if bcx . is_unreachable ( ) { return C_undef ( ty . ptr_to ( ) ) ; } bcx . pointercast ( val . value , ty . ptr_to ( ) ) } RawNullablePointer { nndiscr , nnty , .. } => { assert_eq ! ( ix 0 ) ; assert_eq ! ( discr nndiscr ) ; let ty = type_of :: type_of ( bcx . ccx ( ) , nnty ) ; if bcx . is_unreachable ( ) { return C_undef ( ty . ptr_to ( ) ) ; } bcx . pointercast ( val . value , ty . ptr_to ( ) ) } StructWrappedNullablePointer { ref nonnull , nndiscr , .. } => { assert_eq ! ( discr nndiscr ) ; struct_field_ptr ( bcx , nonnull , val , ix , false ) } } }
Access a field, at a point when the value's case is known.
Access a field at a point when the value ' s case is known .
bcx
&BlockAndBuilder<'blk, 'tcx>
r
&Repr<'tcx>
val
MaybeSizedValue
discr
Disr
ix
usize
bcx
&BlockAndBuilder<'blk, 'tcx>
r
&Repr<'tcx>
val
MaybeSizedValue
discr
Disr
ix
usize