mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
core/vm: make slt/sgt cleaner
This commit is contained in:
parent
fb7c46e80e
commit
29ee636e56
1 changed files with 16 additions and 42 deletions
|
|
@ -198,32 +198,19 @@ func opSlt(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stac
|
||||||
xSign := x.Cmp(tt255)
|
xSign := x.Cmp(tt255)
|
||||||
ySign := y.Cmp(tt255)
|
ySign := y.Cmp(tt255)
|
||||||
|
|
||||||
if xSign >= 0 {
|
switch {
|
||||||
//x negative
|
case xSign >= 0 && ySign < 0:
|
||||||
if ySign < 0 {
|
|
||||||
// y positive
|
|
||||||
y.SetUint64(1)
|
y.SetUint64(1)
|
||||||
return nil, nil
|
|
||||||
}
|
case xSign < 0 && ySign >= 0:
|
||||||
// Both negative
|
y.SetUint64(0)
|
||||||
|
|
||||||
|
default:
|
||||||
if x.Cmp(y) < 0 {
|
if x.Cmp(y) < 0 {
|
||||||
y.SetUint64(1)
|
y.SetUint64(1)
|
||||||
} else {
|
} else {
|
||||||
y.SetUint64(0)
|
y.SetUint64(0)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// x positive
|
|
||||||
if ySign >= 0 {
|
|
||||||
// y negative
|
|
||||||
y.SetUint64(0)
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
// Both positive
|
|
||||||
if x.Cmp(y) >= 0 {
|
|
||||||
y.SetUint64(0)
|
|
||||||
} else {
|
|
||||||
y.SetUint64(1)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
evm.interpreter.intPool.put(x)
|
evm.interpreter.intPool.put(x)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|
@ -235,27 +222,14 @@ func opSgt(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stac
|
||||||
xSign := x.Cmp(tt255)
|
xSign := x.Cmp(tt255)
|
||||||
ySign := y.Cmp(tt255)
|
ySign := y.Cmp(tt255)
|
||||||
|
|
||||||
if xSign >= 0 {
|
switch {
|
||||||
//x negative
|
case xSign >= 0 && ySign < 0:
|
||||||
if ySign < 0 {
|
|
||||||
// y positive
|
|
||||||
y.SetUint64(0)
|
y.SetUint64(0)
|
||||||
return nil, nil
|
|
||||||
}
|
case xSign < 0 && ySign >= 0:
|
||||||
// Both negative (note: equality -> 0)
|
|
||||||
if x.Cmp(y) <= 0 {
|
|
||||||
y.SetUint64(0)
|
|
||||||
} else {
|
|
||||||
y.SetUint64(1)
|
y.SetUint64(1)
|
||||||
}
|
|
||||||
} else {
|
default:
|
||||||
// x positive
|
|
||||||
if ySign >= 0 {
|
|
||||||
// y negative
|
|
||||||
y.SetUint64(1)
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
// Both positive
|
|
||||||
if x.Cmp(y) > 0 {
|
if x.Cmp(y) > 0 {
|
||||||
y.SetUint64(1)
|
y.SetUint64(1)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue