struct TranslateCtx<'a, T: Target> {
krate: &'a TranslatedCrate,
fmt: FmtCtx<'a>,
target_name: &'a TargetTriple,
target: &'a TargetInfo,
global_ids: RefCell<Generator<GlobalDeclId>>,
string_literals: RefCell<SeqHashMap<String, GlobalName>>,
mini_target: PhantomData<T>,
}Fields§
§krate: &'a TranslatedCrate§fmt: FmtCtx<'a>§target_name: &'a TargetTriple§target: &'a TargetInfo§global_ids: RefCell<Generator<GlobalDeclId>>§string_literals: RefCell<SeqHashMap<String, GlobalName>>§mini_target: PhantomData<T>Implementations§
Source§impl<T: Target> TranslateCtx<'_, T>
impl<T: Target> TranslateCtx<'_, T>
Sourcepub(super) fn lower_intrinsic(
&self,
fdecl: &FunDecl,
) -> Result<Option<Function>, Error>
pub(super) fn lower_intrinsic( &self, fdecl: &FunDecl, ) -> Result<Option<Function>, Error>
Lowers this function to an intrinsic if we recognize it as such. Otherwise return None.
Sourcefn make_intrinsic_function(
&self,
span: Span,
fdecl: &FunDecl,
intrinsic: IntrinsicOp,
) -> Result<Function, Error>
fn make_intrinsic_function( &self, span: Span, fdecl: &FunDecl, intrinsic: IntrinsicOp, ) -> Result<Function, Error>
Make a function that invokes the matching MiniRust intrinsic.
Sourcefn make_catch_unwind_function(
&self,
span: Span,
fdecl: &FunDecl,
) -> Result<Function, Error>
fn make_catch_unwind_function( &self, span: Span, fdecl: &FunDecl, ) -> Result<Function, Error>
Implement core::intrinsics::catch_unwind in MiniRust.
Sourcefn make_unwind_function(
&self,
span: Span,
fdecl: &FunDecl,
source: UnwindSource,
) -> Result<Function, Error>
fn make_unwind_function( &self, span: Span, fdecl: &FunDecl, source: UnwindSource, ) -> Result<Function, Error>
Function that starts unwinding.
Sourcefn make_layout_of_val_function(
&self,
span: Span,
fdecl: &FunDecl,
alignment: bool,
) -> Result<Function, Error>
fn make_layout_of_val_function( &self, span: Span, fdecl: &FunDecl, alignment: bool, ) -> Result<Function, Error>
Compute a DST’s layout from the metadata carried by its pointer.
Sourcefn make_cold_path_function(
&self,
span: Span,
fdecl: &FunDecl,
) -> Result<Function, Error>
fn make_cold_path_function( &self, span: Span, fdecl: &FunDecl, ) -> Result<Function, Error>
cold_path is only an optimization hint.
Source§impl<T: Target> TranslateCtx<'_, T>
impl<T: Target> TranslateCtx<'_, T>
pub(super) fn ty(&self, span: Span, ty: &Ty) -> Result<Type, Error>
fn adt_type(&self, span: Span, tref: &TypeDeclRef) -> Result<Type, Error>
fn tuple_type( &self, span: Span, fields: &IndexVec<FieldId, Field>, variant_layout: Option<&VariantLayout>, layout: &Layout, generics: &GenericArgs, ) -> Result<Type, Error>
fn discriminator( &self, span: Span, variants: &IndexVec<VariantId, Variant>, value: &Discriminator, ) -> Result<Discriminator, Error>
pub(super) fn variant_discriminant( &self, span: Span, ty: &Ty, variant: VariantId, ) -> Result<Int, Error>
pub(super) fn variant_discriminant_for_tref( &self, span: Span, tref: &TypeDeclRef, variant: VariantId, ) -> Result<Int, Error>
pub(super) fn pointee_info( &self, span: Span, ty: &Ty, ) -> Result<PointeeInfo, Error>
fn freeze_and_unpin(&self, span: Span, ty: &Ty) -> Result<(bool, bool), Error>
pub(super) fn unsafe_cell_strategy( &self, span: Span, ty: &Ty, ) -> Result<UnsafeCellStrategy, Error>
pub(super) fn size_and_align( &self, span: Span, ty: &Ty, ) -> Result<(u64, u64), Error>
pub(super) fn metadata_kind( &self, span: Span, ty: &Ty, ) -> Result<PointerMetaKind, Error>
pub(super) fn int_type(&self, ty: IntegerTy) -> IntType
pub(super) fn size(&self, span: Span, size: &Size) -> Result<u64, Error>
Source§impl<'a, T: Target> TranslateCtx<'a, T>
impl<'a, T: Target> TranslateCtx<'a, T>
fn new(krate: &'a TranslatedCrate) -> Result<Self, Error>
fn fn_name(&self, id: FunDeclId) -> FnName
fn global_name(&self, id: GlobalDeclId) -> GlobalName
fn trait_name(&self, id: TypeDeclId) -> TraitName
fn vtable_name(&self, id: GlobalDeclId) -> VTableName
fn method_name(&self, id: FieldId) -> TraitMethodName
fn local_name(&self, local: LocalId) -> LocalName
fn field_name(&self, field: FieldId) -> Int
fn block_name(&self, id: BlockId) -> BbName
fn translate(&self) -> Result<Program, Error>
Source§impl<T: Target> TranslateCtx<'_, T>
Function bodies.
impl<T: Target> TranslateCtx<'_, T>
Function bodies.
Sourcefn make_start_function(
&self,
span: Span,
main: FunDeclId,
) -> Result<Function, Error>
fn make_start_function( &self, span: Span, main: FunDeclId, ) -> Result<Function, Error>
Make a start function with the right calling convention that just calls into main().
fn function( &self, span: Span, fdecl: &FunDecl, body: &ExprBody, ) -> Result<Function, Error>
fn statement( &self, statement: &Statement, ) -> Result<SmallVec<[Statement; 1]>, Error>
fn terminator( &self, terminator: &Terminator, unwind_kind: UnwindKind, extra_blocks: &mut Map<BbName, BasicBlock>, block_id_gen: &mut Generator<BlockId>, ) -> Result<Terminator, Error>
fn start_unwind(&self, on_unwind: BlockId) -> Terminator
fn opaque_panic_payload(&self) -> ValueExpr
fn place(&self, span: Span, place: &Place) -> Result<PlaceExpr, Error>
fn operand(&self, span: Span, operand: &Operand) -> Result<ValueExpr, Error>
fn switch_value( &self, span: Span, scrutinee: &SwitchScrutinee, ) -> Result<ValueExpr, Error>
fn rvalue(&self, span: Span, value: &Rvalue) -> Result<ValueExpr, Error>
fn binop( &self, span: Span, op: BinOp, left: &Operand, right: &Operand, ) -> Result<ValueExpr, Error>
fn unop( &self, span: Span, op: &UnOp, operand: &Operand, ) -> Result<ValueExpr, Error>
fn aggregate( &self, span: Span, kind: &AggregateKind, operands: &[Operand], ) -> Result<ValueExpr, Error>
fn fn_pointer(&self, id: FunDeclId) -> ValueExpr
fn calling_convention( &self, span: Span, abi: &Abi, ) -> Result<CallingConvention, Error>
fn callee_convention( &self, span: Span, operand: &FnOperand, ) -> Result<CallingConvention, Error>
Source§impl<T: Target> TranslateCtx<'_, T>
Constants
impl<T: Target> TranslateCtx<'_, T>
Constants
pub(crate) fn global( &self, span: Span, gdecl: &GlobalDecl, ) -> Result<Global, Error>
pub(crate) fn constant( &self, span: Span, constant: &ConstantExpr, ) -> Result<ValueExpr, Error>
Sourcefn type_id_val(
&self,
span: Span,
ty: &Ty,
ptr_offset: u64,
) -> Result<u128, Error>
fn type_id_val( &self, span: Span, ty: &Ty, ptr_offset: u64, ) -> Result<u128, Error>
The value of the TypeId of ty, as a 16-byte integer, with its pointers offset by
ptr_offset. MiniRust doesn’t have TypeId provenance so we make up the values of these
pointers by hashing the type.
pub(crate) fn constant_int( &self, span: Span, constant: &ConstantExpr, ) -> Result<Int, Error>
Source§impl<T: Target> TranslateCtx<'_, T>
Traits and vtables
impl<T: Target> TranslateCtx<'_, T>
Traits and vtables
Auto Trait Implementations§
impl<'a, T> !Freeze for TranslateCtx<'a, T>
impl<'a, T> !RefUnwindSafe for TranslateCtx<'a, T>
impl<'a, T> !Sync for TranslateCtx<'a, T>
impl<'a, T> Send for TranslateCtx<'a, T>where
PhantomData<T>: Send,
impl<'a, T> Unpin for TranslateCtx<'a, T>where
PhantomData<T>: Unpin,
impl<'a, T> UnsafeUnpin for TranslateCtx<'a, T>where
PhantomData<T>: UnsafeUnpin,
impl<'a, T> UnwindSafe for TranslateCtx<'a, T>where
PhantomData<T>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more