[−][src]Trait moore_svlog::BaseContext
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>
Get the global context.
Provided methods
fn sess(&self) -> &'gcx Session
Get the compiler session.
fn arena(&self) -> &'gcx GlobalArenas<'gcx>
Access the arena into which values are to be allocated.
fn tables(&self) -> &GlobalTables<'gcx>
Access the tables.
fn unimp<T: HasSpan + HasDesc, R>(&self, node: &T) -> Result<R>
Emit an internal compiler error that a node is not implemented.
fn unimp_msg<T: HasSpan + HasDesc, R>(
&self,
msg: impl Into<String>,
node: &T
) -> Result<R>
&self,
msg: impl Into<String>,
node: &T
) -> Result<R>
Emit an internal compiler error and message that a node is not
implemented. Same as [unimp
], but the caller can provide a message
prefix.
fn alloc_id(&self, span: Span) -> NodeId
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.
fn span(&self, node_id: NodeId) -> Span
Return the diagnostic span associated with a ndoe id.
fn set_ast(&self, node_id: NodeId, ast: AstNode<'gcx>)
Associate an AST node with a node id.
fn map_ast(&self, ast: AstNode<'gcx>) -> NodeId
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
Call [map_ast
] and [set_parent
].
fn ast_of(&self, node_id: NodeId) -> Result<AstNode<'gcx>>
Obtain the AST node associated with a node id.
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)
Internalize an HIR node.
fn interned_hir(&self, id: NodeId) -> HirNode<'gcx>
Lookup an internalized HIR node.
fn get_interned_hir(&self, id: NodeId) -> Option<HirNode<'gcx>>
Lookup an internalized HIR node.
fn intern_type(&self, ty: TypeKind<'gcx>) -> Type<'gcx>
Internalize a type.
fn intern_value(&self, value: ValueData<'gcx>) -> Value<'gcx>
Internalize a value.
fn mkty_void(&self) -> Type<'gcx>
Make a void type.
fn mkty_time(&self) -> Type<'gcx>
Make a time type.
fn mkty_bit(&self) -> Type<'gcx>
Make a bit type.
fn mkty_logic(&self) -> Type<'gcx>
Make a logic type.
fn mkty_named(&self, name: Spanned<Name>, binding: NodeEnvId) -> Type<'gcx>
Make a named type.
fn mkty_int(&self, width: usize) -> Type<'gcx>
Make a 2-value integer type.
fn mkty_integer(&self, width: usize) -> Type<'gcx>
Make a 4-value integer type.
fn mkty_struct(&self, def_id: NodeId) -> Type<'gcx>
Make a struct type.
fn mkty_packed_array(&self, size: usize, elem_ty: Type<'gcx>) -> Type<'gcx>
Make a packed array type.
fn intern_param_env(&self, env: ParamEnvData<'gcx>) -> ParamEnv
Internalize a parameter environment.
fn param_env_data(&self, env: ParamEnv) -> &'gcx ParamEnvData<'gcx>
Get the ParamEnvData
associated with a 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)
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.
fn param_env_contexts(&self, env: ParamEnv) -> Vec<NodeId>
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)
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>
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
Check if a node is the parent of another.
fn resolve_upwards_or_error(
&self,
name: Spanned<Name>,
start_at: NodeId
) -> Result<NodeId>
&self,
name: Spanned<Name>,
start_at: NodeId
) -> Result<NodeId>
Resolve a name upwards or emit a diagnostic if nothing is found.
fn resolve_downwards_or_error(
&self,
name: Spanned<Name>,
start_at: NodeId
) -> Result<NodeId>
&self,
name: Spanned<Name>,
start_at: NodeId
) -> Result<NodeId>
Resolve a name downwards or emit a diagnostic if nothing is found.
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>
Get a lowering hint on a node.
fn constant_int_value_of(
&self,
node_id: NodeId,
env: ParamEnv
) -> Result<&'gcx BigInt>
&self,
node_id: NodeId,
env: ParamEnv
) -> Result<&'gcx BigInt>
Compute the constant value of a node and make sure it is an integer.