Trait moore_svlog::Context [−][src]
pub trait Context<'gcx>: DiagEmitter + QueryDatabase<'gcx> + HasTypeStorage<'gcx> {
Show 33 methods
fn gcx(&self) -> &GlobalContext<'gcx>;
fn sess(&self) -> &'gcx Session { ... }
fn arena(&self) -> &'gcx GlobalArenas<'gcx> { ... }
fn tables(&self) -> &GlobalTables<'gcx> { ... }
fn unimp<T: HasSpan + HasDesc, R>(&self, node: &T) -> Result<R> { ... }
fn unimp_msg<T: HasSpan + HasDesc, R>(
&self,
msg: impl Into<String>,
node: &T
) -> Result<R> { ... }
fn alloc_id(&self, span: Span) -> NodeId { ... }
fn span(&self, node_id: NodeId) -> Span { ... }
fn set_span(&self, node_id: NodeId, span: Span) { ... }
fn set_ast(&self, node_id: NodeId, ast: AstNode<'gcx>) { ... }
fn map_ast(&self, ast: AstNode<'gcx>) -> NodeId { ... }
fn map_ast_with_parent(&self, ast: AstNode<'gcx>, parent: NodeId) -> NodeId { ... }
fn ast_of(&self, node_id: NodeId) -> Result<AstNode<'gcx>> { ... }
fn register_ast(&self, node: &'gcx dyn AnyNode<'gcx>) { ... }
fn ast_for_id(&self, node_id: NodeId) -> &'gcx dyn AnyNode<'gcx> { ... }
fn intern_hir(&self, id: NodeId, hir: HirNode<'gcx>) { ... }
fn intern_hir_with_parent(
&self,
id: NodeId,
hir: HirNode<'gcx>,
parent: NodeId
) { ... }
fn interned_hir(&self, id: NodeId) -> HirNode<'gcx> { ... }
fn get_interned_hir(&self, id: NodeId) -> Option<HirNode<'gcx>> { ... }
fn intern_value(&self, value: ValueData<'gcx>) -> Value<'gcx> { ... }
fn intern_param_env(&self, env: ParamEnvData<'gcx>) -> ParamEnv { ... }
fn param_env_data(&self, env: ParamEnv) -> &'gcx ParamEnvData<'gcx> { ... }
fn default_param_env(&self) -> ParamEnv { ... }
fn add_param_env_context(&self, env: ParamEnv, context: NodeId) { ... }
fn param_env_contexts(&self, env: ParamEnv) -> Vec<NodeId>ⓘ { ... }
fn set_parent(&self, node_id: NodeId, parent_id: NodeId) { ... }
fn parent_node_id(&self, node_id: NodeId) -> Option<NodeId> { ... }
fn is_parent_of(&self, parent_id: NodeId, child_id: NodeId) -> bool { ... }
fn resolve_upwards_or_error(
&self,
name: Spanned<Name>,
start_at: NodeId
) -> Result<NodeId> { ... }
fn resolve_downwards_or_error(
&self,
name: Spanned<Name>,
start_at: NodeId
) -> Result<NodeId> { ... }
fn set_lowering_hint(&self, node_id: NodeId, hint: Hint) { ... }
fn lowering_hint(&self, node_id: NodeId) -> Option<Hint> { ... }
fn constant_int_value_of(
&self,
node_id: NodeId,
env: ParamEnv
) -> Result<&'gcx BigInt> { ... }
}
Expand description
The fundamental compiler context.
This trait represents the context within which most compiler operations take
place. It is implemented by GlobalContext
and also provides access to
the global context via the gcx()
method.
Required methods
fn gcx(&self) -> &GlobalContext<'gcx>
fn gcx(&self) -> &GlobalContext<'gcx>
Get the global context.
Provided methods
fn arena(&self) -> &'gcx GlobalArenas<'gcx>
fn arena(&self) -> &'gcx GlobalArenas<'gcx>
Access the arena into which values are to be allocated.
fn tables(&self) -> &GlobalTables<'gcx>
fn tables(&self) -> &GlobalTables<'gcx>
Access the tables.
Emit an internal compiler error that a node is not implemented.
Emit an internal compiler error and message that a node is not
implemented. Same as [unimp
], but the caller can provide a message
prefix.
Allocate a new node id.
The provided span is used primarily for diagnostic messages and is supposed to easily identify the node to the user in case of an error.
Allocate a node id for an AST node and associate that id with the node.
fn map_ast_with_parent(&self, ast: AstNode<'gcx>, parent: NodeId) -> NodeId
fn map_ast_with_parent(&self, ast: AstNode<'gcx>, parent: NodeId) -> NodeId
Call [map_ast
] and [set_parent
].
Obtain the AST node associated with a node id.
fn register_ast(&self, node: &'gcx dyn AnyNode<'gcx>)
fn register_ast(&self, node: &'gcx dyn AnyNode<'gcx>)
Register an ast::AnyNode
for later retrieval by ID.
fn ast_for_id(&self, node_id: NodeId) -> &'gcx dyn AnyNode<'gcx>
fn ast_for_id(&self, node_id: NodeId) -> &'gcx dyn AnyNode<'gcx>
Obtain an ast::AnyNode
associated with a node id.
fn intern_hir(&self, id: NodeId, hir: HirNode<'gcx>)
fn intern_hir(&self, id: NodeId, hir: HirNode<'gcx>)
Internalize an HIR node.
fn intern_hir_with_parent(&self, id: NodeId, hir: HirNode<'gcx>, parent: NodeId)
fn intern_hir_with_parent(&self, id: NodeId, hir: HirNode<'gcx>, parent: NodeId)
Internalize an HIR node.
fn interned_hir(&self, id: NodeId) -> HirNode<'gcx>
fn interned_hir(&self, id: NodeId) -> HirNode<'gcx>
Lookup an internalized HIR node.
fn get_interned_hir(&self, id: NodeId) -> Option<HirNode<'gcx>>
fn get_interned_hir(&self, id: NodeId) -> Option<HirNode<'gcx>>
Lookup an internalized HIR node.
fn intern_value(&self, value: ValueData<'gcx>) -> Value<'gcx>
fn intern_value(&self, value: ValueData<'gcx>) -> Value<'gcx>
Internalize a value.
fn intern_param_env(&self, env: ParamEnvData<'gcx>) -> ParamEnv
fn intern_param_env(&self, env: ParamEnvData<'gcx>) -> ParamEnv
Internalize a parameter environment.
fn param_env_data(&self, env: ParamEnv) -> &'gcx ParamEnvData<'gcx>
fn param_env_data(&self, env: ParamEnv) -> &'gcx ParamEnvData<'gcx>
Get the ParamEnvData
associated with a ParamEnv
.
fn default_param_env(&self) -> ParamEnv
fn default_param_env(&self) -> ParamEnv
Get the default parameter environment.
This is useful for instantiations without any parameter assignment, e.g. for the top-level module.
fn add_param_env_context(&self, env: ParamEnv, context: NodeId)
fn add_param_env_context(&self, env: ParamEnv, context: NodeId)
Associate a context with a param env.
A context in this sense is the node that the param env relates to. Usually this is the node that actually generated the param env, e.g. a module instantiation.
Get the contexts associated with a parameter environment.
Returns what has previously been added with add_param_env_context
.
fn set_parent(&self, node_id: NodeId, parent_id: NodeId)
fn set_parent(&self, node_id: NodeId, parent_id: NodeId)
Associate a parent with a node.
Panics if node_id
already has a parent assigned.
fn parent_node_id(&self, node_id: NodeId) -> Option<NodeId>
fn parent_node_id(&self, node_id: NodeId) -> Option<NodeId>
Find the parent node of a node.
Returns None
if the node has no parent. Pretty much every node has a
parent, assigned more or less in lexographical order.
fn is_parent_of(&self, parent_id: NodeId, child_id: NodeId) -> bool
fn is_parent_of(&self, parent_id: NodeId, child_id: NodeId) -> bool
Check if a node is the parent of another.
Resolve a name upwards or emit a diagnostic if nothing is found.
Resolve a name downwards or emit a diagnostic if nothing is found.
fn set_lowering_hint(&self, node_id: NodeId, hint: Hint)
fn set_lowering_hint(&self, node_id: NodeId, hint: Hint)
Set a lowering hint on a node.
fn lowering_hint(&self, node_id: NodeId) -> Option<Hint>
fn lowering_hint(&self, node_id: NodeId) -> Option<Hint>
Get a lowering hint on a node.