Documentation ¶
Overview ¶
Package scope defines helpers and operators for Arbor's Compiler Scope
Index ¶
- type Scope
- type SymbolData
- type SymbolTable
- func (s *SymbolTable) AddToScope(name string, sym *SymbolData)
- func (s *SymbolTable) GetCurrentLevel() int
- func (s *SymbolTable) LookupSymbol(name string) (*SymbolData, int)
- func (s *SymbolTable) LookupSymbolInAllScopes(name string) (*SymbolData, int)
- func (s *SymbolTable) PopScope() error
- func (s *SymbolTable) PushNewScope()
- func (s *SymbolTable) ResetStackAndLockScope()
- func (s *SymbolTable) ResolveType(sym *SymbolData) *SymbolData
- func (s *SymbolTable) String() string
- type TypeData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SymbolData ¶
type SymbolData struct { // Type is the type of the node Type TypeData // Location is where the symbol is stored in the program Location string // Lexeme is the lexeme where this type was defined Lexeme lexer.Lexeme // IsConstant denotes if this symbol can be reassigned IsConstant bool // Methods are the methods on the type Methods map[string][]*types.FnType // The Constructors of the Type Constructors []*types.FnType // IsType is weather this symbol is a type IsType bool }
SymbolData is the data related to the symbol.
func (*SymbolData) IsSatisfiedBy ¶
func (s *SymbolData) IsSatisfiedBy(t types.TypeNode) bool
IsSatisfiedBy checks if the symbol is satisfied by this type
func (*SymbolData) String ¶
func (s *SymbolData) String() string
type SymbolTable ¶
type SymbolTable struct {
// contains filtered or unexported fields
}
SymbolTable is a comprehensive list of symbols currently in scope
func (*SymbolTable) AddToScope ¶
func (s *SymbolTable) AddToScope(name string, sym *SymbolData)
AddToScope adds the variable to the scope
func (*SymbolTable) GetCurrentLevel ¶
func (s *SymbolTable) GetCurrentLevel() int
GetCurrentLevel gets the current level of scope
func (*SymbolTable) LookupSymbol ¶
func (s *SymbolTable) LookupSymbol(name string) (*SymbolData, int)
LookupSymbol looks up the symbol in our table. returns the symboldata and the scope level (0 is the current scope). if symbol is not found, returns nil and -1
func (*SymbolTable) LookupSymbolInAllScopes ¶
func (s *SymbolTable) LookupSymbolInAllScopes(name string) (*SymbolData, int)
func (*SymbolTable) PopScope ¶
func (s *SymbolTable) PopScope() error
PopScope pops the global state
func (*SymbolTable) PushNewScope ¶
func (s *SymbolTable) PushNewScope()
PushNewScope Pushes a new scope on to the ScopeStack
func (*SymbolTable) ResetStackAndLockScope ¶
func (s *SymbolTable) ResetStackAndLockScope()
ResetStackAndLockScope resets the stack so we are looking at the global scope again, and then prevents the scope from growing again
func (*SymbolTable) ResolveType ¶
func (s *SymbolTable) ResolveType(sym *SymbolData) *SymbolData
func (*SymbolTable) String ¶
func (s *SymbolTable) String() string