forked from lug/matterbridge
Update vendor d5/tengo
This commit is contained in:
28
vendor/github.com/d5/tengo/compiler/symbol_table.go
generated
vendored
28
vendor/github.com/d5/tengo/compiler/symbol_table.go
generated
vendored
@@ -2,12 +2,13 @@ package compiler
|
||||
|
||||
// SymbolTable represents a symbol table.
|
||||
type SymbolTable struct {
|
||||
parent *SymbolTable
|
||||
block bool
|
||||
store map[string]*Symbol
|
||||
numDefinition int
|
||||
maxDefinition int
|
||||
freeSymbols []*Symbol
|
||||
parent *SymbolTable
|
||||
block bool
|
||||
store map[string]*Symbol
|
||||
numDefinition int
|
||||
maxDefinition int
|
||||
freeSymbols []*Symbol
|
||||
builtinSymbols []*Symbol
|
||||
}
|
||||
|
||||
// NewSymbolTable creates a SymbolTable.
|
||||
@@ -37,6 +38,10 @@ func (t *SymbolTable) Define(name string) *Symbol {
|
||||
|
||||
// DefineBuiltin adds a symbol for builtin function.
|
||||
func (t *SymbolTable) DefineBuiltin(index int, name string) *Symbol {
|
||||
if t.parent != nil {
|
||||
return t.parent.DefineBuiltin(index, name)
|
||||
}
|
||||
|
||||
symbol := &Symbol{
|
||||
Name: name,
|
||||
Index: index,
|
||||
@@ -45,6 +50,8 @@ func (t *SymbolTable) DefineBuiltin(index int, name string) *Symbol {
|
||||
|
||||
t.store[name] = symbol
|
||||
|
||||
t.builtinSymbols = append(t.builtinSymbols, symbol)
|
||||
|
||||
return symbol
|
||||
}
|
||||
|
||||
@@ -101,6 +108,15 @@ func (t *SymbolTable) FreeSymbols() []*Symbol {
|
||||
return t.freeSymbols
|
||||
}
|
||||
|
||||
// BuiltinSymbols returns builtin symbols for the scope.
|
||||
func (t *SymbolTable) BuiltinSymbols() []*Symbol {
|
||||
if t.parent != nil {
|
||||
return t.parent.BuiltinSymbols()
|
||||
}
|
||||
|
||||
return t.builtinSymbols
|
||||
}
|
||||
|
||||
// Names returns the name of all the symbols.
|
||||
func (t *SymbolTable) Names() []string {
|
||||
var names []string
|
||||
|
||||
Reference in New Issue
Block a user