not done yet
This commit is contained in:
parent
b73af5f92f
commit
49c15f6fb6
15 changed files with 473 additions and 389 deletions
27
core/vm.go
27
core/vm.go
|
|
@ -102,6 +102,8 @@ const (
|
|||
// items to include minus one. (value of 0 => 1 item, value of 1 => 2 items, etc.) The order is reversed compared
|
||||
// to on the stack; the top value on the stack is the last in the list.
|
||||
InstructionFormList
|
||||
// InstructionConcatLists concatenate lists, producing a new list with the values of both lists. Pops two lists.
|
||||
InstructionConcatLists
|
||||
|
||||
// InstructionBreakpoint for debugging purposes
|
||||
InstructionBreakpoint
|
||||
|
|
@ -187,6 +189,8 @@ func (b Bytecode) String() string {
|
|||
return "APPEND"
|
||||
case InstructionAccessProperty:
|
||||
return "ACCESS_PROPERTY"
|
||||
case InstructionConcatLists:
|
||||
return "CONCAT_LISTS"
|
||||
}
|
||||
return "UNDEFINED"
|
||||
}
|
||||
|
|
@ -377,6 +381,21 @@ var DefaultGlobals = map[string]Value{
|
|||
nil,
|
||||
true,
|
||||
},
|
||||
"byte": &BuiltinFunctionValue{
|
||||
"char",
|
||||
&FunctionSignature{
|
||||
[]TypeSignature{&StringSignature{}},
|
||||
&NumberSignature{},
|
||||
},
|
||||
func(vm *VM, this Value, args []Value) (Value, error) {
|
||||
s := args[0].(*StringValue).Text
|
||||
b := []byte(s)[0]
|
||||
|
||||
return &NumberValue{float64(b)}, nil
|
||||
},
|
||||
nil,
|
||||
true,
|
||||
},
|
||||
"assertEq": &BuiltinFunctionValue{
|
||||
"assertEq",
|
||||
&FunctionSignature{
|
||||
|
|
@ -710,6 +729,14 @@ func (vm *VM) Next() bool {
|
|||
list.Items = append(list.Items, value)
|
||||
vm.stack.Push(list)
|
||||
|
||||
case InstructionConcatLists:
|
||||
r := vm.stack.Pop().(*ListValue)
|
||||
l := vm.stack.Pop().(*ListValue)
|
||||
|
||||
vm.stack.Push(&ListValue{
|
||||
append(l.Items, r.Items...),
|
||||
})
|
||||
|
||||
case InstructionDescend:
|
||||
vm.descend()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue