mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-07-03 11:57:45 +00:00
Update vendor (#1257)
This commit is contained in:
4
vendor/github.com/d5/tengo/v2/compiler.go
generated
vendored
4
vendor/github.com/d5/tengo/v2/compiler.go
generated
vendored
@ -323,7 +323,7 @@ func (c *Compiler) Compile(node parser.Node) error {
|
||||
return err
|
||||
}
|
||||
case *parser.Ident:
|
||||
symbol, _, ok := c.symbolTable.Resolve(node.Name)
|
||||
symbol, _, ok := c.symbolTable.Resolve(node.Name, false)
|
||||
if !ok {
|
||||
return c.errorf(node, "unresolved reference '%s'", node.Name)
|
||||
}
|
||||
@ -659,7 +659,7 @@ func (c *Compiler) compileAssign(
|
||||
return c.errorf(node, "operator ':=' not allowed with selector")
|
||||
}
|
||||
|
||||
symbol, depth, exists := c.symbolTable.Resolve(ident)
|
||||
symbol, depth, exists := c.symbolTable.Resolve(ident, false)
|
||||
if op == token.Define {
|
||||
if depth == 0 && exists {
|
||||
return c.errorf(node, "'%s' redeclared in this block", ident)
|
||||
|
2
vendor/github.com/d5/tengo/v2/script.go
generated
vendored
2
vendor/github.com/d5/tengo/v2/script.go
generated
vendored
@ -116,7 +116,7 @@ func (s *Script) Compile() (*Compiled, error) {
|
||||
// global symbol names to indexes
|
||||
globalIndexes := make(map[string]int, len(globals))
|
||||
for _, name := range symbolTable.Names() {
|
||||
symbol, _, _ := symbolTable.Resolve(name)
|
||||
symbol, _, _ := symbolTable.Resolve(name, false)
|
||||
if symbol.Scope == ScopeGlobal {
|
||||
globalIndexes[name] = symbol.Index
|
||||
}
|
||||
|
56
vendor/github.com/d5/tengo/v2/symbol_table.go
generated
vendored
56
vendor/github.com/d5/tengo/v2/symbol_table.go
generated
vendored
@ -44,6 +44,17 @@ func (t *SymbolTable) Define(name string) *Symbol {
|
||||
|
||||
if t.Parent(true) == nil {
|
||||
symbol.Scope = ScopeGlobal
|
||||
|
||||
// if symbol is defined in a block of global scope, symbol index must
|
||||
// be tracked at the root-level table instead.
|
||||
if p := t.parent; p != nil {
|
||||
for p.parent != nil {
|
||||
p = p.parent
|
||||
}
|
||||
t.numDefinition--
|
||||
p.numDefinition++
|
||||
}
|
||||
|
||||
} else {
|
||||
symbol.Scope = ScopeLocal
|
||||
}
|
||||
@ -71,25 +82,36 @@ func (t *SymbolTable) DefineBuiltin(index int, name string) *Symbol {
|
||||
// Resolve resolves a symbol with a given name.
|
||||
func (t *SymbolTable) Resolve(
|
||||
name string,
|
||||
) (symbol *Symbol, depth int, ok bool) {
|
||||
symbol, ok = t.store[name]
|
||||
if !ok && t.parent != nil {
|
||||
symbol, depth, ok = t.parent.Resolve(name)
|
||||
if !ok {
|
||||
return
|
||||
recur bool,
|
||||
) (*Symbol, int, bool) {
|
||||
symbol, ok := t.store[name]
|
||||
if ok {
|
||||
// symbol can be used if
|
||||
if symbol.Scope != ScopeLocal || // it's not of local scope, OR,
|
||||
symbol.LocalAssigned || // it's assigned at least once, OR,
|
||||
recur { // it's defined in higher level
|
||||
return symbol, 0, true
|
||||
}
|
||||
depth++
|
||||
|
||||
// if symbol is defined in parent table and if it's not global/builtin
|
||||
// then it's free variable.
|
||||
if !t.block && depth > 0 &&
|
||||
symbol.Scope != ScopeGlobal &&
|
||||
symbol.Scope != ScopeBuiltin {
|
||||
return t.defineFree(symbol), depth, true
|
||||
}
|
||||
return
|
||||
}
|
||||
return
|
||||
|
||||
if t.parent == nil {
|
||||
return nil, 0, false
|
||||
}
|
||||
|
||||
symbol, depth, ok := t.parent.Resolve(name, true)
|
||||
if !ok {
|
||||
return nil, 0, false
|
||||
}
|
||||
depth++
|
||||
|
||||
// if symbol is defined in parent table and if it's not global/builtin
|
||||
// then it's free variable.
|
||||
if !t.block && depth > 0 &&
|
||||
symbol.Scope != ScopeGlobal &&
|
||||
symbol.Scope != ScopeBuiltin {
|
||||
return t.defineFree(symbol), depth, true
|
||||
}
|
||||
return symbol, depth, true
|
||||
}
|
||||
|
||||
// Fork creates a new symbol table for a new scope.
|
||||
|
Reference in New Issue
Block a user