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