slang_frontend/semantic_analysis/analyzer_modules/
scope_manager.rs1use super::super::traits::ScopeManager;
2use slang_shared::{CompilationContext, SymbolKind};
3use slang_types::TypeId;
4
5pub struct ContextScopeManager<'a> {
11 context: &'a mut CompilationContext,
12}
13
14impl<'a> ContextScopeManager<'a> {
15 pub fn new(context: &'a mut CompilationContext) -> Self {
20 Self { context }
21 }
22}
23
24impl ScopeManager for ContextScopeManager<'_> {
25 fn enter_scope(&mut self) {
26 self.context.begin_scope();
27 }
28
29 fn exit_scope(&mut self) {
30 self.context.end_scope();
31 }
32
33 fn define_symbol(
34 &mut self,
35 name: String,
36 kind: SymbolKind,
37 type_id: TypeId,
38 is_mutable: bool,
39 ) -> Result<(), String> {
40 self.context.define_symbol(name, kind, type_id, is_mutable)
41 }
42}