github.com/myafeier/go-ethereum@v1.6.8-0.20170719123245-3e0dbe0eaa72/core/vm/memory_table.go (about) 1 // Copyright 2017 The go-ethereum Authors 2 // This file is part of the go-ethereum library. 3 // 4 // The go-ethereum library is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU Lesser General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // The go-ethereum library is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU Lesser General Public License for more details. 13 // 14 // You should have received a copy of the GNU Lesser General Public License 15 // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. 16 17 package vm 18 19 import ( 20 "math/big" 21 22 "github.com/ethereum/go-ethereum/common/math" 23 ) 24 25 func memorySha3(stack *Stack) *big.Int { 26 return calcMemSize(stack.Back(0), stack.Back(1)) 27 } 28 29 func memoryCalldataCopy(stack *Stack) *big.Int { 30 return calcMemSize(stack.Back(0), stack.Back(2)) 31 } 32 33 func memoryCodeCopy(stack *Stack) *big.Int { 34 return calcMemSize(stack.Back(0), stack.Back(2)) 35 } 36 37 func memoryExtCodeCopy(stack *Stack) *big.Int { 38 return calcMemSize(stack.Back(1), stack.Back(3)) 39 } 40 41 func memoryMLoad(stack *Stack) *big.Int { 42 return calcMemSize(stack.Back(0), big.NewInt(32)) 43 } 44 45 func memoryMStore8(stack *Stack) *big.Int { 46 return calcMemSize(stack.Back(0), big.NewInt(1)) 47 } 48 49 func memoryMStore(stack *Stack) *big.Int { 50 return calcMemSize(stack.Back(0), big.NewInt(32)) 51 } 52 53 func memoryCreate(stack *Stack) *big.Int { 54 return calcMemSize(stack.Back(1), stack.Back(2)) 55 } 56 57 func memoryCall(stack *Stack) *big.Int { 58 x := calcMemSize(stack.Back(5), stack.Back(6)) 59 y := calcMemSize(stack.Back(3), stack.Back(4)) 60 61 return math.BigMax(x, y) 62 } 63 64 func memoryCallCode(stack *Stack) *big.Int { 65 x := calcMemSize(stack.Back(5), stack.Back(6)) 66 y := calcMemSize(stack.Back(3), stack.Back(4)) 67 68 return math.BigMax(x, y) 69 } 70 func memoryDelegateCall(stack *Stack) *big.Int { 71 x := calcMemSize(stack.Back(4), stack.Back(5)) 72 y := calcMemSize(stack.Back(2), stack.Back(3)) 73 74 return math.BigMax(x, y) 75 } 76 77 func memoryReturn(stack *Stack) *big.Int { 78 return calcMemSize(stack.Back(0), stack.Back(1)) 79 } 80 81 func memoryLog(stack *Stack) *big.Int { 82 mSize, mStart := stack.Back(1), stack.Back(0) 83 return calcMemSize(mStart, mSize) 84 }