compiler: support ...
variadic calls
This commit is contained in:
parent
b9171eda14
commit
057e1e2806
2 changed files with 18 additions and 5 deletions
|
@ -758,8 +758,9 @@ func (c *codegen) Visit(node ast.Node) ast.Visitor {
|
|||
}
|
||||
// Do not swap for builtin functions.
|
||||
if !isBuiltin {
|
||||
if typ, ok := c.typeOf(n.Fun).(*types.Signature); ok && typ.Variadic() {
|
||||
// pack variadic args into an array
|
||||
typ, ok := c.typeOf(n.Fun).(*types.Signature)
|
||||
if ok && typ.Variadic() && !n.Ellipsis.IsValid() {
|
||||
// pack variadic args into an array only if last argument is not of form `...`
|
||||
varSize := len(n.Args) - typ.Params().Len() + 1
|
||||
c.emitReverse(varSize)
|
||||
emit.Int(c.prog.BinWriter, int64(varSize))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue