CompileCtxt

Struct CompileCtxt 

Source
pub struct CompileCtxt<'tcx> {
    pub arena: Arena<'tcx>,
    pub interner: InternPool,
    pub files: Vec<File>,
    pub unit_metas: Vec<UnitMeta>,
    pub parse_trees: Vec<Option<Box<dyn ParseTree>>>,
    pub hir_root_ids: RwLock<Vec<Option<HirId>>>,
    pub block_arena: BlockArena<'tcx>,
    pub related_map: BlockRelationMap,
    pub block_indexes: BlockIndexMaps,
    pub build_metrics: BuildMetrics,
}

Fields§

§arena: Arena<'tcx>§interner: InternPool§files: Vec<File>§unit_metas: Vec<UnitMeta>

Per-file metadata: package/module/file names and roots.

§parse_trees: Vec<Option<Box<dyn ParseTree>>>

Generic parse trees from language-specific parsers

§hir_root_ids: RwLock<Vec<Option<HirId>>>§block_arena: BlockArena<'tcx>§related_map: BlockRelationMap§block_indexes: BlockIndexMaps

Index maps for efficient block lookups by name, kind, unit, and id Uses DashMap internally for concurrent access

§build_metrics: BuildMetrics

Metrics collected while building the compilation context

Implementations§

Source§

impl<'tcx> CompileCtxt<'tcx>

Source

pub const GLOBAL_SCOPE_OWNER: HirId

Sentinel owner id reserved for the global scope so that file-level scopes (whose HIR id often defaults to 0) do not reuse the same Scope instance.

Source

pub fn from_sources<L: LanguageTrait>(sources: &[Vec<u8>]) -> Self

Create a new CompileCtxt from source code

Source

pub fn from_files<L: LanguageTrait>(paths: &[String]) -> Result<Self>

Create a new CompileCtxt from files with default (original) ordering.

Source

pub fn from_files_with_order<L: LanguageTrait>( paths: &[String], order: FileOrder, ) -> Result<Self>

Create a new CompileCtxt from files with specified ordering.

Source

pub fn from_files_with_logical<L: LanguageTrait>( paths: &[(String, String)], ) -> Result<Self>

Create a new CompileCtxt from files with separate physical and logical paths. Physical paths are used to read files from disk; logical paths are stored for display. Each element is (physical_path, logical_path).

Source

pub fn from_files_with_logical_and_order<L: LanguageTrait>( paths: &[(String, String)], order: FileOrder, ) -> Result<Self>

Create a new CompileCtxt from files with separate physical and logical paths and specified ordering.

Source

pub fn compile_unit(&'tcx self, index: usize) -> CompileUnit<'tcx>

Create a context that references this CompileCtxt for a specific file index

Source

pub fn create_unit_globals(&'tcx self, owner: HirId) -> &'tcx Scope<'tcx>

Source

pub fn create_globals(&'tcx self) -> &'tcx Scope<'tcx>

Source

pub fn get_scope(&'tcx self, scope_id: ScopeId) -> &'tcx Scope<'tcx>

Source

pub fn opt_get_scope(&'tcx self, scope_id: ScopeId) -> Option<&'tcx Scope<'tcx>>

Source

pub fn opt_get_symbol(&'tcx self, owner: SymId) -> Option<&'tcx Symbol>

Source

pub fn get_symbol(&'tcx self, owner: SymId) -> &'tcx Symbol

Source

pub fn find_symbol_by_block_id( &'tcx self, block_id: BlockId, ) -> Option<&'tcx Symbol>

Find the primary symbol associated with a block ID

Source

pub fn arena(&'tcx self) -> &'tcx Arena<'tcx>

Access the arena for allocations

Source

pub fn alloc_file_ident( &'tcx self, id: HirId, name: &'tcx str, symbol: &'tcx Symbol, ) -> &'tcx HirIdent<'tcx>

Allocate a new file identifier node with the given ID, name and symbol

Source

pub fn alloc_scope(&'tcx self, owner: HirId) -> &'tcx Scope<'tcx>

Source

pub fn merge_two_scopes( &'tcx self, first: &'tcx Scope<'tcx>, second: &'tcx Scope<'tcx>, )

Merge the second scope into the first.

This combines all symbols from the second scope into the first scope. Any future lookup of second’s scope ID will redirect to first.

Source

pub fn set_file_root_id(&self, index: usize, start: HirId)

Source

pub fn file_root_id(&self, index: usize) -> Option<HirId>

Source

pub fn file_path(&self, index: usize) -> Option<&str>

Source

pub fn get_parse_tree(&self, index: usize) -> Option<&dyn ParseTree>

Get the generic parse tree for a specific file

Source

pub fn get_files(&self) -> Vec<String>

Get all file paths from the compilation context

Source

pub fn get_hir_node(&'tcx self, id: HirId) -> Option<HirNode<'tcx>>

Get a HIR node by ID from the Arena’s DashMap (O(1) concurrent lookup)

Source

pub fn hir_node_exists(&self, id: HirId) -> bool

Check if a HIR node exists in the Arena (O(1) check)

Source

pub fn hir_node_count(&self) -> usize

Get the total count of HIR nodes in the Arena

Source

pub fn all_hir_node_ids(&'tcx self) -> Vec<HirId>

Get all HIR node IDs from the Arena

Source

pub fn find_blocks_by_name( &self, name: &'tcx str, ) -> Vec<(usize, BlockKind, BlockId)>

Get all blocks by name

Source

pub fn find_blocks_by_kind( &self, kind: BlockKind, ) -> Vec<(usize, Option<String>, BlockId)>

Get all blocks by kind

Source

pub fn find_blocks_in_unit( &self, unit_index: usize, ) -> Vec<(Option<String>, BlockKind, BlockId)>

Get blocks in a specific unit

Source

pub fn find_blocks_by_kind_in_unit( &self, kind: BlockKind, unit_index: usize, ) -> Vec<BlockId>

Get blocks of a specific kind in a specific unit

Source

pub fn get_block_info( &self, block_id: BlockId, ) -> Option<(usize, Option<String>, BlockKind)>

Get block info by ID

Source

pub fn get_all_blocks(&self) -> Vec<(BlockId, usize, Option<String>, BlockKind)>

Get all blocks with their metadata

Source

pub fn get_all_symbols(&'tcx self) -> Vec<&'tcx Symbol>

Get all symbols from the symbol map

Source

pub fn symbol_count(&self) -> usize

Get the count of registered symbols (excluding unresolved)

Source

pub fn for_each_symbol<F>(&'tcx self, f: F)
where F: FnMut(SymId, &'tcx Symbol),

Iterate over all symbols and their IDs (excluding unresolved)

Trait Implementations§

Source§

impl<'tcx> Debug for CompileCtxt<'tcx>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'tcx> Default for CompileCtxt<'tcx>

Source§

fn default() -> CompileCtxt<'tcx>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'tcx> !Freeze for CompileCtxt<'tcx>

§

impl<'tcx> !RefUnwindSafe for CompileCtxt<'tcx>

§

impl<'tcx> Send for CompileCtxt<'tcx>

§

impl<'tcx> Sync for CompileCtxt<'tcx>

§

impl<'tcx> Unpin for CompileCtxt<'tcx>

§

impl<'tcx> !UnwindSafe for CompileCtxt<'tcx>

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.

Source§

impl<T> Instrument for T

Source§

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

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

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

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

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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