diff options
author | Wim <wim@42.be> | 2019-06-16 23:33:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-16 23:33:25 +0200 |
commit | cb712ff37d3c20a21695e00c52fff213a6fd40b4 (patch) | |
tree | 0ba0ee4f55bf6ace2656562465cc82d807e741b9 /vendor/github.com/d5/tengo/compiler | |
parent | f4ae61044888f591830e6c1be9a2bdb14f88943e (diff) | |
download | matterbridge-msglm-cb712ff37d3c20a21695e00c52fff213a6fd40b4.tar.gz matterbridge-msglm-cb712ff37d3c20a21695e00c52fff213a6fd40b4.tar.bz2 matterbridge-msglm-cb712ff37d3c20a21695e00c52fff213a6fd40b4.zip |
Update vendor (#852)
Diffstat (limited to 'vendor/github.com/d5/tengo/compiler')
5 files changed, 31 insertions, 13 deletions
diff --git a/vendor/github.com/d5/tengo/compiler/ast/ident_list.go b/vendor/github.com/d5/tengo/compiler/ast/ident_list.go index ee8f7db2..8dd6d307 100644 --- a/vendor/github.com/d5/tengo/compiler/ast/ident_list.go +++ b/vendor/github.com/d5/tengo/compiler/ast/ident_list.go @@ -8,9 +8,10 @@ import ( // IdentList represents a list of identifiers. type IdentList struct { - LParen source.Pos - List []*Ident - RParen source.Pos + LParen source.Pos + VarArgs bool + List []*Ident + RParen source.Pos } // Pos returns the position of first character belonging to the node. @@ -50,8 +51,12 @@ func (n *IdentList) NumFields() int { func (n *IdentList) String() string { var list []string - for _, e := range n.List { - list = append(list, e.String()) + for i, e := range n.List { + if n.VarArgs && i == len(n.List)-1 { + list = append(list, "..."+e.String()) + } else { + list = append(list, e.String()) + } } return "(" + strings.Join(list, ", ") + ")" diff --git a/vendor/github.com/d5/tengo/compiler/compiler.go b/vendor/github.com/d5/tengo/compiler/compiler.go index 4a3ec3ad..8bde5dc9 100644 --- a/vendor/github.com/d5/tengo/compiler/compiler.go +++ b/vendor/github.com/d5/tengo/compiler/compiler.go @@ -477,6 +477,7 @@ func (c *Compiler) Compile(node ast.Node) error { Instructions: instructions, NumLocals: numLocals, NumParameters: len(node.Type.Params.List), + VarArgs: node.Type.Params.VarArgs, SourceMap: sourceMap, } diff --git a/vendor/github.com/d5/tengo/compiler/instructions.go b/vendor/github.com/d5/tengo/compiler/instructions.go index 80c88d13..14dde1d8 100644 --- a/vendor/github.com/d5/tengo/compiler/instructions.go +++ b/vendor/github.com/d5/tengo/compiler/instructions.go @@ -13,7 +13,7 @@ func MakeInstruction(opcode Opcode, operands ...int) []byte { totalLen += w } - instruction := make([]byte, totalLen, totalLen) + instruction := make([]byte, totalLen) instruction[0] = byte(opcode) offset := 1 diff --git a/vendor/github.com/d5/tengo/compiler/parser/parser.go b/vendor/github.com/d5/tengo/compiler/parser/parser.go index 1f609ab5..27dd48f0 100644 --- a/vendor/github.com/d5/tengo/compiler/parser/parser.go +++ b/vendor/github.com/d5/tengo/compiler/parser/parser.go @@ -610,19 +610,31 @@ func (p *Parser) parseIdentList() *ast.IdentList { var params []*ast.Ident lparen := p.expect(token.LParen) + isVarArgs := false if p.token != token.RParen { + if p.token == token.Ellipsis { + isVarArgs = true + p.next() + } + params = append(params, p.parseIdent()) - for p.token == token.Comma { + for !isVarArgs && p.token == token.Comma { p.next() + if p.token == token.Ellipsis { + isVarArgs = true + p.next() + } params = append(params, p.parseIdent()) } } + rparen := p.expect(token.RParen) return &ast.IdentList{ - LParen: lparen, - RParen: rparen, - List: params, + LParen: lparen, + RParen: rparen, + VarArgs: isVarArgs, + List: params, } } diff --git a/vendor/github.com/d5/tengo/compiler/symbol_scopes.go b/vendor/github.com/d5/tengo/compiler/symbol_scopes.go index 15204b35..e0c0d94b 100644 --- a/vendor/github.com/d5/tengo/compiler/symbol_scopes.go +++ b/vendor/github.com/d5/tengo/compiler/symbol_scopes.go @@ -6,7 +6,7 @@ type SymbolScope string // List of symbol scopes const ( ScopeGlobal SymbolScope = "GLOBAL" - ScopeLocal = "LOCAL" - ScopeBuiltin = "BUILTIN" - ScopeFree = "FREE" + ScopeLocal SymbolScope = "LOCAL" + ScopeBuiltin SymbolScope = "BUILTIN" + ScopeFree SymbolScope = "FREE" ) |