pub struct SemanticModel {
pub hir: Program,
pub enums: Vec<EnumDecl>,
pub symbols: Vec<Symbol>,
}Expand description
The resolved program model: the Opy HIR semantic program plus the queryable symbol index and custom-enum declarations.
Custom enums are not retained in the Opy HIR (they fold to numeric constants at use sites, reference behavior), so they are carried here from the CST to keep declarations queryable.
Fields§
§hir: Program§enums: Vec<EnumDecl>§symbols: Vec<Symbol>Implementations§
Source§impl SemanticModel
impl SemanticModel
Sourcepub fn build(hir: Program, cst: &Program) -> SemanticModel
pub fn build(hir: Program, cst: &Program) -> SemanticModel
Build the queryable model from a resolved HIR program and its parsed CST (required for custom-enum declarations).
Sourcepub fn declarations(&self) -> &[Declaration]
pub fn declarations(&self) -> &[Declaration]
The HIR declarations (globals, players, subroutines, constants,
macros). Custom enums are queried through SemanticModel::enums.
Sourcepub fn defines(&self) -> &[Define]
pub fn defines(&self) -> &[Define]
The recorded preprocessing defines (macro-expansion provenance).
Sourcepub fn symbols(&self) -> &[Symbol]
pub fn symbols(&self) -> &[Symbol]
Every indexed program-scope symbol with its declaration site and reference sites.
Sourcepub fn symbol(&self, name: &str) -> Option<&Symbol>
pub fn symbol(&self, name: &str) -> Option<&Symbol>
The first symbol bound under name (a subroutine declaration and a
def definition of the same name index as separate symbols).
Sourcepub fn symbol_at(&self, span: Span) -> Option<&Symbol>
pub fn symbol_at(&self, span: Span) -> Option<&Symbol>
The symbol whose declaration site contains span, or — failing that —
the symbol owning a reference site containing span.
Sourcepub fn provenance(&self, span: Span) -> Option<SourceLocation>
pub fn provenance(&self, span: Span) -> Option<SourceLocation>
Resolve a span to its file id, path, and line/column through the file registry.
Trait Implementations§
Source§impl Clone for SemanticModel
impl Clone for SemanticModel
Source§fn clone(&self) -> SemanticModel
fn clone(&self) -> SemanticModel
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more