aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/vm.go
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2014-06-23 20:07:43 +0800
committerzelig <viktor.tron@gmail.com>2014-06-23 20:07:43 +0800
commitf58c7ac5a6f5d77649c1c07dce94bf6d5c146c31 (patch)
tree31e286974108e02b29ed5eff0a73646f605998c2 /ethchain/vm.go
parent63157c798d613f1ca638597515bb89768e2c1aad (diff)
parentd890258af6de8c5ef9701826fb4ee7c353788ad5 (diff)
downloadgo-tangerine-f58c7ac5a6f5d77649c1c07dce94bf6d5c146c31.tar
go-tangerine-f58c7ac5a6f5d77649c1c07dce94bf6d5c146c31.tar.gz
go-tangerine-f58c7ac5a6f5d77649c1c07dce94bf6d5c146c31.tar.bz2
go-tangerine-f58c7ac5a6f5d77649c1c07dce94bf6d5c146c31.tar.lz
go-tangerine-f58c7ac5a6f5d77649c1c07dce94bf6d5c146c31.tar.xz
go-tangerine-f58c7ac5a6f5d77649c1c07dce94bf6d5c146c31.tar.zst
go-tangerine-f58c7ac5a6f5d77649c1c07dce94bf6d5c146c31.zip
merge upstream
Diffstat (limited to 'ethchain/vm.go')
-rw-r--r--ethchain/vm.go34
1 files changed, 17 insertions, 17 deletions
diff --git a/ethchain/vm.go b/ethchain/vm.go
index 75bcfd782..3a999f0a4 100644
--- a/ethchain/vm.go
+++ b/ethchain/vm.go
@@ -328,21 +328,21 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
stack.Push(base)
case LT:
require(2)
- y, x := stack.Popn()
- vm.Printf(" %v < %v", x, y)
+ x, y := stack.Popn()
+ vm.Printf(" %v < %v", y, x)
// x < y
- if x.Cmp(y) < 0 {
+ if y.Cmp(x) < 0 {
stack.Push(ethutil.BigTrue)
} else {
stack.Push(ethutil.BigFalse)
}
case GT:
require(2)
- y, x := stack.Popn()
- vm.Printf(" %v > %v", x, y)
+ x, y := stack.Popn()
+ vm.Printf(" %v > %v", y, x)
// x > y
- if x.Cmp(y) > 0 {
+ if y.Cmp(x) > 0 {
stack.Push(ethutil.BigTrue)
} else {
stack.Push(ethutil.BigFalse)
@@ -361,10 +361,10 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
case NOT:
require(1)
x := stack.Pop()
- if x.Cmp(ethutil.BigFalse) == 0 {
- stack.Push(ethutil.BigTrue)
- } else {
+ if x.Cmp(ethutil.BigFalse) > 0 {
stack.Push(ethutil.BigFalse)
+ } else {
+ stack.Push(ethutil.BigTrue)
}
// 0x10 range
@@ -523,7 +523,10 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
case MLOAD:
require(1)
offset := stack.Pop()
- stack.Push(ethutil.BigD(mem.Get(offset.Int64(), 32)))
+ val := ethutil.BigD(mem.Get(offset.Int64(), 32))
+ stack.Push(val)
+
+ vm.Printf(" => 0x%x", val.Bytes())
case MSTORE: // Store the value at stack top-1 in to memory at location stack top
require(2)
// Pop value of the stack
@@ -542,17 +545,14 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
require(1)
loc := stack.Pop()
val := closure.GetMem(loc)
+
stack.Push(val.BigInt())
- vm.Printf(" {} 0x%x", val)
+ vm.Printf(" {0x%x} 0x%x", loc.Bytes(), val.Bytes())
case SSTORE:
require(2)
val, loc := stack.Popn()
-
- // FIXME This should be handled in the Trie it self
- if val.Cmp(big.NewInt(0)) != 0 {
- closure.SetStorage(loc, ethutil.NewValue(val))
- }
+ closure.SetStorage(loc, ethutil.NewValue(val))
// Add the change to manifest
vm.state.manifest.AddStorageChange(closure.Object(), loc.Bytes(), val)
@@ -691,7 +691,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
fallthrough
case STOP: // Stop the closure
- vm.Printf(" (g) %v", closure.Gas).Endl()
+ vm.Endl()
return closure.Return(nil), nil
default: