github.com/theQRL/go-zond@v0.1.1/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 func memoryKeccak256(stack *Stack) (uint64, bool) { 20 return calcMemSize64(stack.Back(0), stack.Back(1)) 21 } 22 23 func memoryCallDataCopy(stack *Stack) (uint64, bool) { 24 return calcMemSize64(stack.Back(0), stack.Back(2)) 25 } 26 27 func memoryReturnDataCopy(stack *Stack) (uint64, bool) { 28 return calcMemSize64(stack.Back(0), stack.Back(2)) 29 } 30 31 func memoryCodeCopy(stack *Stack) (uint64, bool) { 32 return calcMemSize64(stack.Back(0), stack.Back(2)) 33 } 34 35 func memoryExtCodeCopy(stack *Stack) (uint64, bool) { 36 return calcMemSize64(stack.Back(1), stack.Back(3)) 37 } 38 39 func memoryMLoad(stack *Stack) (uint64, bool) { 40 return calcMemSize64WithUint(stack.Back(0), 32) 41 } 42 43 func memoryMStore8(stack *Stack) (uint64, bool) { 44 return calcMemSize64WithUint(stack.Back(0), 1) 45 } 46 47 func memoryMStore(stack *Stack) (uint64, bool) { 48 return calcMemSize64WithUint(stack.Back(0), 32) 49 } 50 51 func memoryMcopy(stack *Stack) (uint64, bool) { 52 mStart := stack.Back(0) // stack[0]: dest 53 if stack.Back(1).Gt(mStart) { 54 mStart = stack.Back(1) // stack[1]: source 55 } 56 return calcMemSize64(mStart, stack.Back(2)) // stack[2]: length 57 } 58 59 func memoryCreate(stack *Stack) (uint64, bool) { 60 return calcMemSize64(stack.Back(1), stack.Back(2)) 61 } 62 63 func memoryCreate2(stack *Stack) (uint64, bool) { 64 return calcMemSize64(stack.Back(1), stack.Back(2)) 65 } 66 67 func memoryCall(stack *Stack) (uint64, bool) { 68 x, overflow := calcMemSize64(stack.Back(5), stack.Back(6)) 69 if overflow { 70 return 0, true 71 } 72 y, overflow := calcMemSize64(stack.Back(3), stack.Back(4)) 73 if overflow { 74 return 0, true 75 } 76 if x > y { 77 return x, false 78 } 79 return y, false 80 } 81 func memoryDelegateCall(stack *Stack) (uint64, bool) { 82 x, overflow := calcMemSize64(stack.Back(4), stack.Back(5)) 83 if overflow { 84 return 0, true 85 } 86 y, overflow := calcMemSize64(stack.Back(2), stack.Back(3)) 87 if overflow { 88 return 0, true 89 } 90 if x > y { 91 return x, false 92 } 93 return y, false 94 } 95 96 func memoryStaticCall(stack *Stack) (uint64, bool) { 97 x, overflow := calcMemSize64(stack.Back(4), stack.Back(5)) 98 if overflow { 99 return 0, true 100 } 101 y, overflow := calcMemSize64(stack.Back(2), stack.Back(3)) 102 if overflow { 103 return 0, true 104 } 105 if x > y { 106 return x, false 107 } 108 return y, false 109 } 110 111 func memoryReturn(stack *Stack) (uint64, bool) { 112 return calcMemSize64(stack.Back(0), stack.Back(1)) 113 } 114 115 func memoryRevert(stack *Stack) (uint64, bool) { 116 return calcMemSize64(stack.Back(0), stack.Back(1)) 117 } 118 119 func memoryLog(stack *Stack) (uint64, bool) { 120 return calcMemSize64(stack.Back(0), stack.Back(1)) 121 }