basic for loop + examples -> era3
This commit is contained in:
parent
dd7af341a3
commit
0bc8b2ef55
24 changed files with 222 additions and 201 deletions
17
core/vm.go
17
core/vm.go
|
|
@ -133,6 +133,9 @@ const (
|
|||
// 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
|
||||
// InstructionDestructureTuple pop a tuple, and push all its items to the stack, with the top item on the stack
|
||||
// being the last item in the tuple.
|
||||
InstructionDestructureTuple
|
||||
|
||||
// InstructionIndexList index into a list. The lower item is the container, and the top item
|
||||
// is the index. [..., container, index] -> [..., item]
|
||||
|
|
@ -251,6 +254,8 @@ func (b Bytecode) String() string {
|
|||
return "INDEX_LIST"
|
||||
case InstructionIndexTuple:
|
||||
return "INDEX_TUPLE"
|
||||
case InstructionDestructureTuple:
|
||||
return "DESTRUCTURE_TUPLE"
|
||||
}
|
||||
return "UNDEFINED"
|
||||
}
|
||||
|
|
@ -605,10 +610,7 @@ var DefaultGlobals = map[string]Value{
|
|||
&StringSignature{},
|
||||
),
|
||||
},
|
||||
quickComposite(
|
||||
&FloatSignature{},
|
||||
&NilSignature{},
|
||||
),
|
||||
&FloatSignature{},
|
||||
},
|
||||
func(vm *VM, _ Value, args []Value) (Value, error) {
|
||||
switch v := args[0].(type) {
|
||||
|
|
@ -620,7 +622,7 @@ var DefaultGlobals = map[string]Value{
|
|||
case *StringValue:
|
||||
num, err := strconv.ParseFloat(v.Text, FloatSize)
|
||||
if err != nil {
|
||||
return &NilValue{}, nil
|
||||
return &FloatValue{}, nil
|
||||
}
|
||||
|
||||
return &FloatValue{num}, nil
|
||||
|
|
@ -1014,6 +1016,11 @@ func (vm *VM) Next() bool {
|
|||
items,
|
||||
})
|
||||
|
||||
case InstructionDestructureTuple:
|
||||
t := vm.Stack.Pop().(*TupleValue)
|
||||
|
||||
vm.Stack.Push(t.Items...)
|
||||
|
||||
case InstructionDescend:
|
||||
vm.descend()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue