Skip to main content

TranslateCtx

Struct TranslateCtx 

Source
struct TranslateCtx<'a, T: Target> {
    krate: &'a TranslatedCrate,
    fmt: FmtCtx<'a>,
    target_name: &'a TargetTriple,
    target: &'a TargetInfo,
    mini_target: PhantomData<T>,
}

Fields§

§krate: &'a TranslatedCrate§fmt: FmtCtx<'a>§target_name: &'a TargetTriple§target: &'a TargetInfo§mini_target: PhantomData<T>

Implementations§

Source§

impl<T: Target> TranslateCtx<'_, T>

Source

pub(super) fn ty(&self, span: Span, ty: &Ty) -> Result<Type, Error>

Source

fn adt_type(&self, span: Span, tref: &TypeDeclRef) -> Result<Type, Error>

Source

fn tuple_type( &self, span: Span, fields: &IndexVec<FieldId, Field>, layout: Option<&VariantLayout>, size: Size, align: Align, ) -> Result<Type, Error>

Source

fn fields( &self, span: Span, fields: &IndexVec<FieldId, Field>, layout: Option<&VariantLayout>, ) -> Result<Fields, Error>

Source

fn discriminator( &self, span: Span, variants: &IndexVec<VariantId, Variant>, value: &Discriminator, ) -> Result<Discriminator, Error>

Source

pub(super) fn variant_discriminant( &self, span: Span, ty: &Ty, variant: VariantId, ) -> Result<Int, Error>

Source

pub(super) fn variant_discriminant_for_tref( &self, span: Span, tref: &TypeDeclRef, variant: VariantId, ) -> Result<Int, Error>

Source

pub(super) fn pointee_info( &self, span: Span, ty: &Ty, ) -> Result<PointeeInfo, Error>

Source

fn freeze_and_unpin(&self, span: Span, ty: &Ty) -> Result<(bool, bool), Error>

Source

fn unsafe_cell_strategy( &self, span: Span, ty: &Ty, ) -> Result<UnsafeCellStrategy, Error>

Source

pub(super) fn size_and_align( &self, span: Span, ty: &Ty, ) -> Result<(u64, u64), Error>

Source

pub(super) fn metadata_kind( &self, span: Span, ty: &Ty, ) -> Result<PointerMetaKind, Error>

Source

pub(super) fn int_type(&self, ty: IntegerTy) -> IntType

Source

pub(super) fn size(&self, span: Span, size: &Size) -> Result<u64, Error>

Source§

impl<'a, T: Target> TranslateCtx<'a, T>

Source

fn new(krate: &'a TranslatedCrate) -> Result<Self, Error>

Source

fn fn_name(&self, id: FunDeclId) -> FnName

Source

fn global_name(&self, id: GlobalDeclId) -> GlobalName

Source

fn local_name(&self, local: LocalId) -> LocalName

Source

fn field_name(&self, field: FieldId) -> Int

Source

fn block_name(&self, id: BlockId) -> BbName

Source

fn translate(&self) -> Result<Program, Error>

Source§

impl<T: Target> TranslateCtx<'_, T>

Function bodies.

Source

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().

Source

fn make_intrinsic_function( &self, span: Span, fdecl: &FunDecl, intrinsic: IntrinsicOp, ) -> Result<Function, Error>

Make a function that invokes the matching MiniRust intrinsic.

Source

fn make_catch_unwind_function( &self, span: Span, fdecl: &FunDecl, ) -> Result<Function, Error>

Implement core::intrinsics::catch_unwind in MiniRust.

Source

fn make_start_unwind_function( &self, span: Span, fdecl: &FunDecl, ) -> Result<Function, Error>

Give the minirust_start_unwind foreign symbol a body that starts unwinding.

Source

fn function( &self, span: Span, fdecl: &FunDecl, body: &ExprBody, ) -> Result<Function, Error>

Source

fn statement( &self, statement: &Statement, ) -> Result<SmallVec<[Statement; 1]>, Error>

Source

fn terminator( &self, terminator: &Terminator, is_cleanup: bool, extra_blocks: &mut Map<BbName, BasicBlock>, block_id_gen: &mut Generator<BlockId>, ) -> Result<Terminator, Error>

Source

fn start_unwind(&self, on_unwind: BlockId) -> Terminator

Source

fn place(&self, span: Span, place: &Place) -> Result<PlaceExpr, Error>

Source

fn operand(&self, span: Span, operand: &Operand) -> Result<ValueExpr, Error>

Source

fn switch_value( &self, span: Span, scrutinee: &SwitchScrutinee, ) -> Result<ValueExpr, Error>

Source

fn rvalue(&self, span: Span, value: &Rvalue) -> Result<ValueExpr, Error>

Source

fn binop( &self, span: Span, op: BinOp, left: &Operand, right: &Operand, ) -> Result<ValueExpr, Error>

Source

fn unop( &self, span: Span, op: &UnOp, operand: &Operand, ) -> Result<ValueExpr, Error>

Source

fn aggregate( &self, span: Span, kind: &AggregateKind, operands: &[Operand], ) -> Result<ValueExpr, Error>

Source

fn transmute(&self, value: ValueExpr, ty: Type) -> ValueExpr

Source

fn bool_to_int(&self, value: ValueExpr) -> ValueExpr

Source

fn int_to_bool(&self, value: ValueExpr) -> ValueExpr

Source

fn fn_pointer(&self, id: FunDeclId) -> ValueExpr

Source

fn calling_convention( &self, span: Span, abi: &Abi, ) -> Result<CallingConvention, Error>

Source

fn callee_convention( &self, span: Span, operand: &FnOperand, ) -> Result<CallingConvention, Error>

Source§

impl<T: Target> TranslateCtx<'_, T>

Constants

Source

pub(crate) fn global( &self, span: Span, gdecl: &GlobalDecl, ) -> Result<Global, Error>

Source

pub(crate) fn constant( &self, span: Span, constant: &ConstantExpr, ) -> Result<ValueExpr, Error>

Source

pub(crate) fn constant_int( &self, span: Span, constant: &ConstantExpr, ) -> Result<Int, Error>

Auto Trait Implementations§

§

impl<'a, T> Freeze for TranslateCtx<'a, T>
where PhantomData<T>: Freeze,

§

impl<'a, T> RefUnwindSafe for TranslateCtx<'a, T>

§

impl<'a, T> Send for TranslateCtx<'a, T>
where PhantomData<T>: Send,

§

impl<'a, T> Sync for TranslateCtx<'a, T>
where PhantomData<T>: Sync,

§

impl<'a, T> Unpin for TranslateCtx<'a, T>
where PhantomData<T>: Unpin,

§

impl<'a, T> UnsafeUnpin for TranslateCtx<'a, T>

§

impl<'a, T> UnwindSafe for TranslateCtx<'a, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Mappable for T
where T: Any + Send + Sync,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more