package scope import "jinx/pkg/lang/vm/code" type ScopeID int type ScopeKind int const ( ScopeKindNormal ScopeKind = iota ScopeKindFunction ) type SymbolScope struct { variableSymbols []Symbol[SymbolVariable] functionSymbols []Symbol[SymbolFunction] } func NewSymbolScope() SymbolScope { return SymbolScope{ variableSymbols: make([]Symbol[SymbolVariable], 0), functionSymbols: make([]Symbol[SymbolFunction], 0), } } type FunctionScope struct { id ScopeID unit code.Marker subUnitCount int } func NewFunctionScope(id ScopeID, unit code.Marker) FunctionScope { return FunctionScope{ id: id, unit: unit, subUnitCount: 0, } } func (sf FunctionScope) ID() ScopeID { return sf.id } func (sf FunctionScope) Unit() code.Marker { return sf.unit } func (sf FunctionScope) IsRootScope() bool { return sf.ID() == ScopeID(0) }