diff options
author | Wim <wim@42.be> | 2020-07-18 17:27:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-18 17:27:41 +0200 |
commit | 23d8742f0d95096b92f11729fb47f86ac3b68d43 (patch) | |
tree | 7b8acb02b051ae06e5454fda4a9d5118428fe016 /vendor/github.com/d5/tengo/v2/vm.go | |
parent | 3b6a8be07b9422714db30fb50977f342057febf3 (diff) | |
download | matterbridge-msglm-23d8742f0d95096b92f11729fb47f86ac3b68d43.tar.gz matterbridge-msglm-23d8742f0d95096b92f11729fb47f86ac3b68d43.tar.bz2 matterbridge-msglm-23d8742f0d95096b92f11729fb47f86ac3b68d43.zip |
Update dependencies for 1.18.0 release (#1175)
Diffstat (limited to 'vendor/github.com/d5/tengo/v2/vm.go')
-rw-r--r-- | vendor/github.com/d5/tengo/v2/vm.go | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/vendor/github.com/d5/tengo/v2/vm.go b/vendor/github.com/d5/tengo/v2/vm.go index af8783f0..811ecef9 100644 --- a/vendor/github.com/d5/tengo/v2/vm.go +++ b/vendor/github.com/d5/tengo/v2/vm.go @@ -537,12 +537,36 @@ func (v *VM) run() { } case parser.OpCall: numArgs := int(v.curInsts[v.ip+1]) - v.ip++ + spread := int(v.curInsts[v.ip+2]) + v.ip += 2 + value := v.stack[v.sp-1-numArgs] if !value.CanCall() { v.err = fmt.Errorf("not callable: %s", value.TypeName()) return } + + if spread == 1 { + v.sp-- + switch arr := v.stack[v.sp].(type) { + case *Array: + for _, item := range arr.Value { + v.stack[v.sp] = item + v.sp++ + } + numArgs += len(arr.Value) - 1 + case *ImmutableArray: + for _, item := range arr.Value { + v.stack[v.sp] = item + v.sp++ + } + numArgs += len(arr.Value) - 1 + default: + v.err = fmt.Errorf("not an array: %s", arr.TypeName()) + return + } + } + if callee, ok := value.(*CompiledFunction); ok { if callee.VarArgs { // if the closure is variadic, |