From cb712ff37d3c20a21695e00c52fff213a6fd40b4 Mon Sep 17 00:00:00 2001 From: Wim Date: Sun, 16 Jun 2019 23:33:25 +0200 Subject: Update vendor (#852) --- .../github.com/d5/tengo/compiler/ast/ident_list.go | 15 ++++++++++----- vendor/github.com/d5/tengo/compiler/compiler.go | 1 + vendor/github.com/d5/tengo/compiler/instructions.go | 2 +- vendor/github.com/d5/tengo/compiler/parser/parser.go | 20 ++++++++++++++++---- vendor/github.com/d5/tengo/compiler/symbol_scopes.go | 6 +++--- 5 files changed, 31 insertions(+), 13 deletions(-) (limited to 'vendor/github.com/d5/tengo/compiler') 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" ) -- cgit v1.2.3