github.com/luckypickle/go-ethereum-vet@v1.14.2/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/luckypickle/go-ethereum-vet/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 memoryCreate2(stack *Stack) *big.Int {
    62  	return calcMemSize(stack.Back(1), stack.Back(2))
    63  }
    64  
    65  func memoryCall(stack *Stack) *big.Int {
    66  	x := calcMemSize(stack.Back(5), stack.Back(6))
    67  	y := calcMemSize(stack.Back(3), stack.Back(4))
    68  
    69  	return math.BigMax(x, y)
    70  }
    71  
    72  func memoryDelegateCall(stack *Stack) *big.Int {
    73  	x := calcMemSize(stack.Back(4), stack.Back(5))
    74  	y := calcMemSize(stack.Back(2), stack.Back(3))
    75  
    76  	return math.BigMax(x, y)
    77  }
    78  
    79  func memoryStaticCall(stack *Stack) *big.Int {
    80  	x := calcMemSize(stack.Back(4), stack.Back(5))
    81  	y := calcMemSize(stack.Back(2), stack.Back(3))
    82  
    83  	return math.BigMax(x, y)
    84  }
    85  
    86  func memoryReturn(stack *Stack) *big.Int {
    87  	return calcMemSize(stack.Back(0), stack.Back(1))
    88  }
    89  
    90  func memoryRevert(stack *Stack) *big.Int {
    91  	return calcMemSize(stack.Back(0), stack.Back(1))
    92  }
    93  
    94  func memoryLog(stack *Stack) *big.Int {
    95  	mSize, mStart := stack.Back(1), stack.Back(0)
    96  	return calcMemSize(mStart, mSize)
    97  }