github.com/aquanetwork/aquachain@v1.7.8/core/vm/memory_table.go (about) 1 // Copyright 2017 The aquachain Authors 2 // This file is part of the aquachain library. 3 // 4 // The aquachain 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 aquachain 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 aquachain library. If not, see <http://www.gnu.org/licenses/>. 16 17 package vm 18 19 import ( 20 "math/big" 21 22 "gitlab.com/aquachain/aquachain/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 memoryReturnDataCopy(stack *Stack) *big.Int { 34 return calcMemSize(stack.Back(0), stack.Back(2)) 35 } 36 37 func memoryCodeCopy(stack *Stack) *big.Int { 38 return calcMemSize(stack.Back(0), stack.Back(2)) 39 } 40 41 func memoryExtCodeCopy(stack *Stack) *big.Int { 42 return calcMemSize(stack.Back(1), stack.Back(3)) 43 } 44 45 func memoryMLoad(stack *Stack) *big.Int { 46 return calcMemSize(stack.Back(0), big.NewInt(32)) 47 } 48 49 func memoryMStore8(stack *Stack) *big.Int { 50 return calcMemSize(stack.Back(0), big.NewInt(1)) 51 } 52 53 func memoryMStore(stack *Stack) *big.Int { 54 return calcMemSize(stack.Back(0), big.NewInt(32)) 55 } 56 57 func memoryCreate(stack *Stack) *big.Int { 58 return calcMemSize(stack.Back(1), stack.Back(2)) 59 } 60 61 func memoryCall(stack *Stack) *big.Int { 62 x := calcMemSize(stack.Back(5), stack.Back(6)) 63 y := calcMemSize(stack.Back(3), stack.Back(4)) 64 65 return math.BigMax(x, y) 66 } 67 68 //func memoryCallCode(stack *Stack) *big.Int { 69 // x := calcMemSize(stack.Back(5), stack.Back(6)) 70 // y := calcMemSize(stack.Back(3), stack.Back(4)) 71 // 72 // return math.BigMax(x, y) 73 //} 74 func memoryDelegateCall(stack *Stack) *big.Int { 75 x := calcMemSize(stack.Back(4), stack.Back(5)) 76 y := calcMemSize(stack.Back(2), stack.Back(3)) 77 78 return math.BigMax(x, y) 79 } 80 81 func memoryStaticCall(stack *Stack) *big.Int { 82 x := calcMemSize(stack.Back(4), stack.Back(5)) 83 y := calcMemSize(stack.Back(2), stack.Back(3)) 84 85 return math.BigMax(x, y) 86 } 87 88 func memoryReturn(stack *Stack) *big.Int { 89 return calcMemSize(stack.Back(0), stack.Back(1)) 90 } 91 92 func memoryRevert(stack *Stack) *big.Int { 93 return calcMemSize(stack.Back(0), stack.Back(1)) 94 } 95 96 func memoryLog(stack *Stack) *big.Int { 97 mSize, mStart := stack.Back(1), stack.Back(0) 98 return calcMemSize(mStart, mSize) 99 }