From 325d62b41c03f0530513a4f404cc8d7349b6885b Mon Sep 17 00:00:00 2001 From: Wim Date: Tue, 5 Mar 2019 23:08:54 +0100 Subject: Update vendor d5/tengo --- .../github.com/d5/tengo/compiler/symbol_table.go | 28 +++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'vendor/github.com/d5/tengo/compiler/symbol_table.go') 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 -- cgit v1.2.3