/// Emit the code for an indexing operation on an already emitted rvalue.
Emit the code for an indexing operation on an already emitted rvalue.
Emit the code for an indexing operation on an already emitted rvalue .
fn emit_rvalue_index(
        &mut self,
        ty: &'gcx UnpackedType<'gcx>,
        value: HybridValue,
        base: &'gcx mir::Rvalue<'gcx>,
        length: usize,
    ) -> Result<HybridValue> {
        let base = self.emit_mir_rvalue(base)?;
        let hidden = self.emit_zero_for_type_both(self.value_type(value));
        // TODO(fschuiki): make the above a constant of all `x`.
        let shifted = self.mk_shr(value, hidden, base);
        if ty.coalesces_to_llhd_scalar() {
            let length = std::cmp::max(1, length);
            Ok(self.mk_ext_slice(shifted, 0, length))
        } else {
            if length == 0 {
                Ok(self.mk_ext_field(shifted, 0))
            } else {
                Ok(self.mk_ext_slice(shifted, 0, length))
            }
        }
    }
fn emit_rvalue_index ( & mut self , ty : & ' gcx UnpackedType < ' gcx > , value : HybridValue , base : & ' gcx mir :: Rvalue < ' gcx > , length : usize , ) -> Result < HybridValue > { let base = self . emit_mir_rvalue ( base ) ? ; let hidden = self . emit_zero_for_type_both ( self . value_type ( value ) ) ; // TODO(fschuiki): make the above a constant of all `x`. let shifted = self . mk_shr ( value , hidden , base ) ; if ty . coalesces_to_llhd_scalar ( ) { let length = std :: cmp :: max ( 1 , length ) ; Ok ( self . mk_ext_slice ( shifted , 0 , length ) ) } else { if length == 0 { Ok ( self . mk_ext_field ( shifted , 0 ) ) } else { Ok ( self . mk_ext_slice ( shifted , 0 , length ) ) } } }
Emit the code for an indexing operation on an already emitted rvalue.
Emit the code for an indexing operation on an already emitted rvalue .
&mut self
ty
&'gcx UnpackedType<'gcx>
value
HybridValue
base
&'gcx mir::Rvalue<'gcx>
length
usize