Ran gofmt
This commit is contained in:
parent
eb3f581b00
commit
07a783b6ba
30
creature.go
30
creature.go
@ -102,7 +102,9 @@ func (machine *Machine) Execute (offset int) {
|
||||
// EQ
|
||||
// checks if the last two words on the stack are equal
|
||||
equal := 0
|
||||
if machine.Pop() == machine.Pop() { equal = 1 }
|
||||
if machine.Pop() == machine.Pop() {
|
||||
equal = 1
|
||||
}
|
||||
machine.Push(equal)
|
||||
|
||||
case 0x9:
|
||||
@ -110,7 +112,9 @@ func (machine *Machine) Execute (offset int) {
|
||||
// checks if the last word on the stack is greater than
|
||||
// the second to last word on the stack
|
||||
greater := 0
|
||||
if machine.Pop() > machine.Pop() { greater = 1 }
|
||||
if machine.Pop() > machine.Pop() {
|
||||
greater = 1
|
||||
}
|
||||
machine.Push(greater)
|
||||
|
||||
case 0xa:
|
||||
@ -118,7 +122,9 @@ func (machine *Machine) Execute (offset int) {
|
||||
// checks if the last word on the stack is less than the
|
||||
// second to last word on the stack
|
||||
less := 0
|
||||
if machine.Pop() > machine.Pop() { less = 1 }
|
||||
if machine.Pop() > machine.Pop() {
|
||||
less = 1
|
||||
}
|
||||
machine.Push(less)
|
||||
|
||||
case 0xb:
|
||||
@ -126,7 +132,9 @@ func (machine *Machine) Execute (offset int) {
|
||||
// checks if the last two words on the stack are not
|
||||
// equal
|
||||
notEqual := 0
|
||||
if machine.Pop() != machine.Pop() { notEqual = 1 }
|
||||
if machine.Pop() != machine.Pop() {
|
||||
notEqual = 1
|
||||
}
|
||||
machine.Push(notEqual)
|
||||
|
||||
case 0xc:
|
||||
@ -156,7 +164,9 @@ func (machine *Machine) Execute (offset int) {
|
||||
// id specified by the last word on the stack. this may
|
||||
// push and pop various things from the stack
|
||||
id := machine.Pop()
|
||||
if machine.functions == nil { break }
|
||||
if machine.functions == nil {
|
||||
break
|
||||
}
|
||||
function, exists := machine.functions[id]
|
||||
if exists {
|
||||
function(machine)
|
||||
@ -203,7 +213,7 @@ func (machine *Machine) Pop () (word int) {
|
||||
return
|
||||
}
|
||||
|
||||
// Peek returns the word at address in the block
|
||||
// Peek returns the word at address in the block.
|
||||
func (machine *Machine) Peek(address int) (word int) {
|
||||
if address < len(machine.block) {
|
||||
word = machine.block[address]
|
||||
@ -211,7 +221,7 @@ func (machine *Machine) Peek (address int) (word int) {
|
||||
return
|
||||
}
|
||||
|
||||
// Poke sets the value at address in the block to word
|
||||
// Poke sets the value at address in the block to word.
|
||||
func (machine *Machine) Poke(address int, word int) {
|
||||
if address >= len(machine.block) {
|
||||
reallocatedBlock := make([]int, address*3/2)
|
||||
@ -240,7 +250,9 @@ func (machine *Machine) Register (id int, function MachineFunction) (err error)
|
||||
|
||||
// Unregister removes a function that is registered at the specified ID.
|
||||
func (machine *Machine) Unregister(id int) {
|
||||
if machine.functions == nil { return }
|
||||
if machine.functions == nil {
|
||||
return
|
||||
}
|
||||
delete(machine.functions, id)
|
||||
}
|
||||
|
||||
@ -250,5 +262,5 @@ func (machine *Machine) LoadMemory (block []int) {
|
||||
copy(machine.block, block)
|
||||
}
|
||||
|
||||
// Milk milks the stack machine
|
||||
// Milk milks the stack machine.
|
||||
func (machine *Machine) Milk() {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user