aboutsummaryrefslogtreecommitdiffstats
path: root/ethvm/vm.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-09-19 19:19:19 +0800
committerobscuren <geffobscura@gmail.com>2014-09-19 19:19:19 +0800
commit80261c803a82e51413608a3dc5273c982844d135 (patch)
tree07bae1473db846065d62ac86b339aaadc9d781c1 /ethvm/vm.go
parent863785a52046bcfbbcaa57c83b4b43c215368760 (diff)
downloadgo-tangerine-80261c803a82e51413608a3dc5273c982844d135.tar
go-tangerine-80261c803a82e51413608a3dc5273c982844d135.tar.gz
go-tangerine-80261c803a82e51413608a3dc5273c982844d135.tar.bz2
go-tangerine-80261c803a82e51413608a3dc5273c982844d135.tar.lz
go-tangerine-80261c803a82e51413608a3dc5273c982844d135.tar.xz
go-tangerine-80261c803a82e51413608a3dc5273c982844d135.tar.zst
go-tangerine-80261c803a82e51413608a3dc5273c982844d135.zip
Fixed deref ptr
Diffstat (limited to 'ethvm/vm.go')
-rw-r--r--ethvm/vm.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/ethvm/vm.go b/ethvm/vm.go
index f1c23b370..7aff320f9 100644
--- a/ethvm/vm.go
+++ b/ethvm/vm.go
@@ -670,9 +670,13 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
stack.Pop()
case DUP1, DUP2, DUP3, DUP4, DUP5, DUP6, DUP7, DUP8, DUP9, DUP10, DUP11, DUP12, DUP13, DUP14, DUP15, DUP16:
n := int(op - DUP1 + 1)
- stack.Dupn(n)
+ v := stack.Dupn(n)
self.Printf(" => [%d] 0x%x", n, stack.Peek().Bytes())
+
+ if OpCode(closure.Get(new(big.Int).Add(pc, ethutil.Big1)).Uint()) == POP && OpCode(closure.Get(new(big.Int).Add(pc, big.NewInt(2))).Uint()) == POP {
+ fmt.Println(toValue(v))
+ }
case SWAP1, SWAP2, SWAP3, SWAP4, SWAP5, SWAP6, SWAP7, SWAP8, SWAP9, SWAP10, SWAP11, SWAP12, SWAP13, SWAP14, SWAP15, SWAP16:
n := int(op - SWAP1 + 2)
x, y := stack.Swapn(n)
@@ -1004,3 +1008,14 @@ func (self *Message) Exec(codeAddr []byte, caller ClosureRef) (ret []byte, err e
return
}
+
+// Mainly used for print variables and passing to Print*
+func toValue(val *big.Int) interface{} {
+ // Let's assume a string on right padded zero's
+ b := val.Bytes()
+ if b[0] != 0 && b[len(b)-1] == 0x0 && b[len(b)-2] == 0x0 {
+ return string(b)
+ }
+
+ return val
+}