diff options
author | obscuren <geffobscura@gmail.com> | 2014-06-20 07:10:20 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-06-20 07:10:20 +0800 |
commit | 0c6b41f4c9edf33cf36b5e044b62e29161d50b07 (patch) | |
tree | 83497ea52afa5de5c1a9324b91eb37ddb9ed87cd /ethchain/vm.go | |
parent | f63f3853bbf13b3f4cb983d25b70276ae283d0cc (diff) | |
download | go-tangerine-0c6b41f4c9edf33cf36b5e044b62e29161d50b07.tar go-tangerine-0c6b41f4c9edf33cf36b5e044b62e29161d50b07.tar.gz go-tangerine-0c6b41f4c9edf33cf36b5e044b62e29161d50b07.tar.bz2 go-tangerine-0c6b41f4c9edf33cf36b5e044b62e29161d50b07.tar.lz go-tangerine-0c6b41f4c9edf33cf36b5e044b62e29161d50b07.tar.xz go-tangerine-0c6b41f4c9edf33cf36b5e044b62e29161d50b07.tar.zst go-tangerine-0c6b41f4c9edf33cf36b5e044b62e29161d50b07.zip |
CALLDATACOPY
Diffstat (limited to 'ethchain/vm.go')
-rw-r--r-- | ethchain/vm.go | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/ethchain/vm.go b/ethchain/vm.go index fc3c37dc1..b9e8353fb 100644 --- a/ethchain/vm.go +++ b/ethchain/vm.go @@ -433,9 +433,28 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro vm.Printf(" => %d", l) case CALLDATACOPY: - panic("not implemented") + var ( + size = int64(len(closure.Args)) + mOff = stack.Pop().Int64() + cOff = stack.Pop().Int64() + l = stack.Pop().Int64() + ) + + if cOff > size { + cOff = 0 + l = 0 + } else if cOff+l > size { + l = 0 + } + + code := closure.Args[cOff : cOff+l] + + mem.Set(mOff, l, code) case CODESIZE: - stack.Push(big.NewInt(int64(len(closure.Script)))) + l := big.NewInt(int64(len(closure.Script))) + stack.Push(l) + + vm.Printf(" => %d", l) case CODECOPY: var ( size = int64(len(closure.Script)) |