summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/d5/tengo/compiler/symbol_table.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2019-03-05 23:08:54 +0100
committerWim <wim@42.be>2019-03-05 23:10:45 +0100
commit325d62b41c03f0530513a4f404cc8d7349b6885b (patch)
treed6f9f2809bdcd3a35b696b412c24cf6f54ddab78 /vendor/github.com/d5/tengo/compiler/symbol_table.go
parente955a056e2aa4a07c6375315113886b2ee86138c (diff)
downloadmatterbridge-msglm-325d62b41c03f0530513a4f404cc8d7349b6885b.tar.gz
matterbridge-msglm-325d62b41c03f0530513a4f404cc8d7349b6885b.tar.bz2
matterbridge-msglm-325d62b41c03f0530513a4f404cc8d7349b6885b.zip
Update vendor d5/tengo
Diffstat (limited to 'vendor/github.com/d5/tengo/compiler/symbol_table.go')
-rw-r--r--vendor/github.com/d5/tengo/compiler/symbol_table.go28
1 files changed, 22 insertions, 6 deletions
diff --git a/vendor/github.com/d5/tengo/compiler/symbol_table.go b/vendor/github.com/d5/tengo/compiler/symbol_table.go
index da55a826..fb029b31 100644
--- a/vendor/github.com/d5/tengo/compiler/symbol_table.go
+++ b/vendor/github.com/d5/tengo/compiler/symbol_table.go
@@ -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