Syncing to desktop

This commit is contained in:
2019-12-08 21:51:43 -06:00
parent 930491c840
commit 5b5e519ddf
9 changed files with 202 additions and 4 deletions

View File

@@ -30,8 +30,9 @@ const (
)
type Program struct {
code []int
ptr int
originalCode []int
code []int
ptr int
state int
error error
@@ -44,11 +45,22 @@ type Program struct {
func NewProgram(prog []int) *Program {
p := new(Program)
p.originalCode = make([]int, len(prog))
p.code = make([]int, len(prog))
copy(p.originalCode, prog)
p.Reset()
return p
}
func (p *Program) Reset() {
copy(p.code, p.originalCode)
p.ptr = 0
p.state = RET_OK
p.error = nil
p.waitingForInput = false
p.waitingForOutput = false
p.input = make(chan int)
p.output = make(chan int)
copy(p.code, prog)
return p
}
func (p *Program) GetCode() []int {