pub struct MirBuilder<'ctx, 'hir> {
    compile_context: &'ctx CompileContext,
    hir: &'hir Hir,
    current_context: MirContext,
    singletons: MirSingletons,
    entry_context: MirContextId,
    contexts: FxHashMap<MirContextId, MirContext>,
    return_values_arena: ReturnValuesArena,
    namespace: MirNamespace,
    extern_items: FxHashMap<Ident, MirExternItem>,
    next_context_id: u32,
}

Fields§

§compile_context: &'ctx CompileContext§hir: &'hir Hir§current_context: MirContext§singletons: MirSingletons§entry_context: MirContextId§contexts: FxHashMap<MirContextId, MirContext>§return_values_arena: ReturnValuesArena§namespace: MirNamespace§extern_items: FxHashMap<Ident, MirExternItem>§next_context_id: u32

Implementations§

source§

impl<'ctx, 'hir> MirBuilder<'ctx, 'hir>

source

pub fn new(ctx: &'ctx CompileContext, hir: &'hir Hir) -> Self

source

pub fn build(self) -> Result<Mir>

source

fn emit(&mut self, node: impl Into<MirNode>)

source

fn insert_object(&mut self) -> MirObjectId

source

fn get_context(&self, id: MirContextId) -> &MirContext

source

fn get_local_namespace(&mut self, id: MirContextId) -> &mut MirLocalNamespace

source

fn get_variable_opt(&mut self, ident: &Ident) -> Option<MirObjectId>

source

fn variable_get_or_insert( &mut self, ident: Ident, definition_span: Span ) -> MirObjectId

Traverses the namespaces stack until it finds ident. If ident cannot be found, it will be inserted at the lowest namespace

source

fn get_ident(&self, spanned_ident: &SpannedIdentifier) -> Ident

source

fn get_object_property( &mut self, obj_id: Option<MirObjectId>, ident: Ident, span: Span ) -> MirObjectId

source

fn resolve_path(&mut self, path: &IdentifierPath) -> MirObjectId

Returns the object specified by the path

source

fn resolve_path_without_last( &mut self, path: &IdentifierPath ) -> (Option<MirObjectId>, Ident)

Resolves the path up to the last ident, so that the attribute can be set manually

source

fn next_context_with_return_data( &mut self, kind: MirContextKind, super_ctx_id: Option<MirContextId>, local_namespace_id: MirLocalNamespaceId, return_context: ReturnContext ) -> MirContextId

Creates a new context with default return new return values data. returns the previous context id

source

fn next_context( &mut self, kind: MirContextKind, super_ctx_id: Option<MirContextId>, local_namespace_id: MirLocalNamespaceId, return_values_data_id: ReturnValuesDataId, return_context_behavior: ReturnContextBehavior ) -> MirContextId

Creates a new context and returns the previous one

source

fn create_context( &mut self, kind: MirContextKind, super_ctx_id: Option<MirContextId>, local_namespace_id: MirLocalNamespaceId, return_values_data_id: ReturnValuesDataId, return_context_behavior: ReturnContextBehavior ) -> MirContext

source

fn return_value( &mut self, context_id: MirContextId, value: MirObjectId, span: Span )

source

fn promote(&mut self, value: MirObjectId, span: Span) -> MirObjectId

source

fn copy(&mut self, value: MirObjectId, span: Span) -> MirObjectId

source

fn get_return_context( &self, kind: HirControlKind, context_id: MirContextId ) -> ReturnContext

Calculates the ReturnContext to use for a context with control flow, where kind is the kind of control flow and context_id is the context that is targeted by the control flow

source

fn target_context_for( &self, control_flow: HirControlKind ) -> Option<&MirContext>

Finds the context to return to using control_flow

source

fn is_comptime_call_allowed(&self) -> bool

source§

impl MirBuilder<'_, '_>

source

pub fn handle_block( &mut self, block: &HirBlock, kind: MirContextKind ) -> Result<()>

source

fn handle_nested_block( &mut self, block: &HirBlock, kind: MirContextKind, return_context_behavior: ReturnContextBehavior, return_value_id: Option<(MirObjectId, Span)> ) -> Result<MirContextId>

Handles a nested block and returns its id

source

fn handle_block_keep_context(&mut self, block: &HirBlock) -> Result<()>

source

fn handle_hir_block(&mut self, block: &HirBlock) -> Result<MirObjectId>

source

fn register_object_name( &mut self, spanned_ident: SpannedIdentifier ) -> MirObjectId

source

fn handle_context_objects(&mut self, objects: &[HirObject]) -> Result<()>

source

fn handle_module(&mut self, module: &HirModule) -> Result<()>

source

fn handle_function(&mut self, function: &HirFunction) -> Result<MirObjectId>

source

fn apply_function_attributes( &mut self, function_id: MirObjectId, attributes: &[Attribute] ) -> Result<()>

Treats the function attributes as functions and calls these with this function as parameter

source

fn handle_struct(&mut self, strukt: &HirStruct) -> Result<()>

source

fn handle_statement(&mut self, statement: &HirStatement) -> Result<()>

source

fn handle_variable_declaration( &mut self, variable_decl: &HirVariableInitialization ) -> Result<()>

source

fn handle_variable_update( &mut self, variable_update: &HirVariableUpdate ) -> Result<()>

source

fn handle_expression( &mut self, expression: &HirExpression ) -> Result<MirObjectId>

source

fn handle_expression_and_base( &mut self, expr: &HirExpression ) -> Result<(MirObjectId, Option<MirObjectId>)>

If the expression accesses a value on an object, this method returns both the parent and the accessed value

source

fn handle_literal_value(&mut self, value: &HirConstValue) -> Result<MirObjectId>

source

fn handle_function_call( &mut self, function_call: &HirFunctionCall ) -> Result<MirObjectId>

source

fn handle_type_pattern(&mut self, param: &HirTypePattern) -> Result<MirObjectId>

source

fn handle_branch( &mut self, branch: &HirConditionalBranch ) -> Result<MirObjectId>

source

fn handle_control_flow( &mut self, control_flow: &HirControlFlow ) -> Result<MirObjectId>

source

fn handle_import(&mut self, import: &HirImport) -> Result<()>

source

fn handle_tuple_initialization( &mut self, tuple_initialization: &HirTupleInitialization ) -> Result<MirObjectId>

source

fn handle_struct_initialization( &mut self, struct_initialization: &HirStructInitialization ) -> Result<MirObjectId>

source

fn handle_infinite_loop( &mut self, infinite_loop: &HirInfiniteLoop ) -> Result<MirObjectId>

Auto Trait Implementations§

§

impl<'ctx, 'hir> !RefUnwindSafe for MirBuilder<'ctx, 'hir>

§

impl<'ctx, 'hir> !Send for MirBuilder<'ctx, 'hir>

§

impl<'ctx, 'hir> !Sync for MirBuilder<'ctx, 'hir>

§

impl<'ctx, 'hir> Unpin for MirBuilder<'ctx, 'hir>

§

impl<'ctx, 'hir> !UnwindSafe for MirBuilder<'ctx, 'hir>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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.

source§

impl<T, U> Into<U> for Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.