add basic support for tuples
This commit is contained in:
parent
7bb277045c
commit
e03d18c7db
7 changed files with 339 additions and 18 deletions
16
core/vm.go
16
core/vm.go
|
|
@ -132,6 +132,10 @@ const (
|
|||
// InstructionConcatLists concatenate lists, producing a new list with the values of both lists. Pops two lists.
|
||||
InstructionConcatLists
|
||||
|
||||
// InstructionFormTuple pop n+1 (u16) items from the stack, and create a new tuple with the items. The top value
|
||||
// on the stack is the last value in the tuple.
|
||||
InstructionFormTuple
|
||||
|
||||
// InstructionBreakpoint for debugging purposes
|
||||
InstructionBreakpoint
|
||||
)
|
||||
|
|
@ -992,6 +996,18 @@ func (vm *VM) Next() bool {
|
|||
append(l.Items, r.Items...),
|
||||
})
|
||||
|
||||
case InstructionFormTuple:
|
||||
n := int(vm.NextU16())
|
||||
|
||||
items := make([]Value, n)
|
||||
for i := n - 1; i >= 0; i-- {
|
||||
items[i] = vm.Stack.Pop()
|
||||
}
|
||||
|
||||
vm.Stack.Push(&TupleValue{
|
||||
items,
|
||||
})
|
||||
|
||||
case InstructionDescend:
|
||||
vm.descend()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue