diff options
author | zelig <viktor.tron@gmail.com> | 2014-06-26 23:37:56 +0800 |
---|---|---|
committer | zelig <viktor.tron@gmail.com> | 2014-06-26 23:37:56 +0800 |
commit | da38faa8f7c0f2a6620b54e46fc38a201845e104 (patch) | |
tree | 2656f980c91f9f93d98215867f75c9253e330019 /ethchain/vm.go | |
parent | 098136b68198083a47408ec5c04cd0c8f9fdcc87 (diff) | |
parent | 0ed19d9f2024744ba93d0e34db6939766b3cfed5 (diff) | |
download | dexon-da38faa8f7c0f2a6620b54e46fc38a201845e104.tar.gz dexon-da38faa8f7c0f2a6620b54e46fc38a201845e104.tar.zst dexon-da38faa8f7c0f2a6620b54e46fc38a201845e104.zip |
merge upstream; fix port in use warning; new logger API
Diffstat (limited to 'ethchain/vm.go')
-rw-r--r-- | ethchain/vm.go | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/ethchain/vm.go b/ethchain/vm.go index 4c1821f56..20d355674 100644 --- a/ethchain/vm.go +++ b/ethchain/vm.go @@ -102,22 +102,21 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro vmlogger.Debugf("(~) %x gas: %v (d) %x\n", closure.object.Address(), closure.Gas, closure.Args) - // Memory for the current closure - mem := &Memory{} - // New stack (should this be shared?) - stack := NewStack() - require := func(m int) { - if stack.Len() < m { - isRequireError = true - panic(fmt.Sprintf("stack err = %d, req = %d", stack.Len(), m)) + var ( + op OpCode + + mem = &Memory{} + stack = NewStack() + pc = big.NewInt(0) + step = 0 + prevStep = 0 + require = func(m int) { + if stack.Len() < m { + isRequireError = true + panic(fmt.Sprintf("%04v (%v) stack err size = %d, required = %d", pc, op, stack.Len(), m)) + } } - } - - // Program counter - pc := big.NewInt(0) - // Current step count - step := 0 - prevStep := 0 + ) for { prevStep = step @@ -128,7 +127,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro // Get the memory location of pc val := closure.Get(pc) // Get the opcode (it must be an opcode!) - op := OpCode(val.Uint()) + op = OpCode(val.Uint()) gas := new(big.Int) addStepGasUsage := func(amount *big.Int) { |