Struct debris_mir::mir_builder::MirBuilder
source · 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>
impl<'ctx, 'hir> MirBuilder<'ctx, 'hir>
pub fn new(ctx: &'ctx CompileContext, hir: &'hir Hir) -> Self
pub fn build(self) -> Result<Mir>
fn emit(&mut self, node: impl Into<MirNode>)
fn insert_object(&mut self) -> MirObjectId
fn get_context(&self, id: MirContextId) -> &MirContext
fn get_local_namespace(&mut self, id: MirContextId) -> &mut MirLocalNamespace
fn get_variable_opt(&mut self, ident: &Ident) -> Option<MirObjectId>
sourcefn variable_get_or_insert(
&mut self,
ident: Ident,
definition_span: Span
) -> MirObjectId
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
fn get_ident(&self, spanned_ident: &SpannedIdentifier) -> Ident
fn get_object_property( &mut self, obj_id: Option<MirObjectId>, ident: Ident, span: Span ) -> MirObjectId
sourcefn resolve_path(&mut self, path: &IdentifierPath) -> MirObjectId
fn resolve_path(&mut self, path: &IdentifierPath) -> MirObjectId
Returns the object specified by the path
sourcefn resolve_path_without_last(
&mut self,
path: &IdentifierPath
) -> (Option<MirObjectId>, Ident)
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
sourcefn next_context_with_return_data(
&mut self,
kind: MirContextKind,
super_ctx_id: Option<MirContextId>,
local_namespace_id: MirLocalNamespaceId,
return_context: ReturnContext
) -> MirContextId
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
sourcefn 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
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
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
fn return_value( &mut self, context_id: MirContextId, value: MirObjectId, span: Span )
fn promote(&mut self, value: MirObjectId, span: Span) -> MirObjectId
fn copy(&mut self, value: MirObjectId, span: Span) -> MirObjectId
sourcefn get_return_context(
&self,
kind: HirControlKind,
context_id: MirContextId
) -> ReturnContext
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
sourcefn target_context_for(
&self,
control_flow: HirControlKind
) -> Option<&MirContext>
fn target_context_for( &self, control_flow: HirControlKind ) -> Option<&MirContext>
Finds the context to return to using control_flow
fn is_comptime_call_allowed(&self) -> bool
source§impl MirBuilder<'_, '_>
impl MirBuilder<'_, '_>
pub fn handle_block( &mut self, block: &HirBlock, kind: MirContextKind ) -> Result<()>
sourcefn handle_nested_block(
&mut self,
block: &HirBlock,
kind: MirContextKind,
return_context_behavior: ReturnContextBehavior,
return_value_id: Option<(MirObjectId, Span)>
) -> Result<MirContextId>
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
fn handle_block_keep_context(&mut self, block: &HirBlock) -> Result<()>
fn handle_hir_block(&mut self, block: &HirBlock) -> Result<MirObjectId>
fn register_object_name( &mut self, spanned_ident: SpannedIdentifier ) -> MirObjectId
fn handle_context_objects(&mut self, objects: &[HirObject]) -> Result<()>
fn handle_module(&mut self, module: &HirModule) -> Result<()>
fn handle_function(&mut self, function: &HirFunction) -> Result<MirObjectId>
sourcefn apply_function_attributes(
&mut self,
function_id: MirObjectId,
attributes: &[Attribute]
) -> Result<()>
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
fn handle_struct(&mut self, strukt: &HirStruct) -> Result<()>
fn handle_statement(&mut self, statement: &HirStatement) -> Result<()>
fn handle_variable_declaration( &mut self, variable_decl: &HirVariableInitialization ) -> Result<()>
fn handle_variable_update( &mut self, variable_update: &HirVariableUpdate ) -> Result<()>
fn handle_expression( &mut self, expression: &HirExpression ) -> Result<MirObjectId>
sourcefn handle_expression_and_base(
&mut self,
expr: &HirExpression
) -> Result<(MirObjectId, Option<MirObjectId>)>
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