vise/go/vm/opcodes.go

35 lines
575 B
Go
Raw Normal View History

2023-03-31 11:52:04 +02:00
package vm
2023-03-31 20:24:30 +02:00
import (
"encoding/binary"
)
2023-03-31 11:52:04 +02:00
const VERSION = 0
const (
2023-03-31 20:24:30 +02:00
BACK = iota
CATCH
2023-03-31 11:52:04 +02:00
CROAK
LOAD
RELOAD
2023-03-31 11:59:55 +02:00
MAP
2023-03-31 20:24:30 +02:00
MOVE
2023-03-31 11:52:04 +02:00
_MAX
)
2023-03-31 20:24:30 +02:00
func NewLine(instructionList []byte, instruction uint16, args []string, post []byte, szPost []uint8) []byte {
b := []byte{0x00, 0x00}
binary.BigEndian.PutUint16(b, instruction)
for _, arg := range args {
b = append(b, uint8(len(arg)))
b = append(b, []byte(arg)...)
}
if post != nil {
b = append(b, uint8(len(post)))
b = append(b, post...)
}
if szPost != nil {
b = append(b, szPost...)
}
return append(instructionList, b...)
}