simplified some code

This commit is contained in:
Julien Dessaux 2021-10-06 18:35:21 +02:00
parent dbba21a74b
commit d141d68c1b

View file

@ -84,13 +84,11 @@ func (p *Pointer) eval(c int, f *field.Field) (done bool, returnValue *int) {
} }
} }
case '!': case '!':
v := p.ss.head.Pop() if p.ss.head.Pop() == 0 {
if v == 0 { p.ss.head.Push(1)
v = 1
} else { } else {
v = 0 p.ss.head.Push(0)
} }
p.ss.head.Push(v)
case '`': case '`':
b, a := p.ss.head.Pop(), p.ss.head.Pop() b, a := p.ss.head.Pop(), p.ss.head.Pop()
if a > b { if a > b {
@ -100,12 +98,12 @@ func (p *Pointer) eval(c int, f *field.Field) (done bool, returnValue *int) {
} }
p.ss.head.Push(a) p.ss.head.Push(a)
case '_': case '_':
v := p.ss.head.Pop() if p.ss.head.Pop() == 0 {
if v == 0 { p.dx = 1
p.Redirect('>')
} else { } else {
p.Redirect('<') p.dx = -1
} }
p.dy = 0
case '|': case '|':
v := p.ss.head.Pop() v := p.ss.head.Pop()
if v == 0 { if v == 0 {
@ -133,16 +131,16 @@ func (p *Pointer) eval(c int, f *field.Field) (done bool, returnValue *int) {
b, a := p.ss.head.Pop(), p.ss.head.Pop() b, a := p.ss.head.Pop(), p.ss.head.Pop()
if b == 0 { if b == 0 {
p.ss.head.Push(0) p.ss.head.Push(0)
return } else {
p.ss.head.Push(a / b)
} }
p.ss.head.Push(a / b)
case '%': case '%':
b, a := p.ss.head.Pop(), p.ss.head.Pop() b, a := p.ss.head.Pop(), p.ss.head.Pop()
if b == 0 { if b == 0 {
p.ss.head.Push(0) p.ss.head.Push(0)
return } else {
p.ss.head.Push(a % b)
} }
p.ss.head.Push(a % b)
case '"': case '"':
p.stringMode = true p.stringMode = true
case '\'': case '\'':