Coverage Summary for Class: MessageCall (org.ethereum.vm)

Class Method, % Line, %
MessageCall 0% (0/10) 0% (0/18)
MessageCall$1 0% (0/1) 0% (0/1)
MessageCall$MsgType 0% (0/3) 0% (0/13)
Total 0% (0/14) 0% (0/32)


1 /* 2  * This file is part of RskJ 3  * Copyright (C) 2017 RSK Labs Ltd. 4  * (derived from ethereumJ library, Copyright (c) 2016 <ether.camp>) 5  * 6  * This program is free software: you can redistribute it and/or modify 7  * it under the terms of the GNU Lesser General Public License as published by 8  * the Free Software Foundation, either version 3 of the License, or 9  * (at your option) any later version. 10  * 11  * This program is distributed in the hope that it will be useful, 12  * but WITHOUT ANY WARRANTY; without even the implied warranty of 13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14  * GNU Lesser General Public License for more details. 15  * 16  * You should have received a copy of the GNU Lesser General Public License 17  * along with this program. If not, see <http://www.gnu.org/licenses/>. 18  */ 19  20  21 package org.ethereum.vm; 22  23 /** 24  * A wrapper for a message call from a contract to another account. 25  * This can either be a normal CALL, CALLCODE, DELEGATECALL or POST call. 26  */ 27 public class MessageCall { 28  29  public enum MsgType { 30  CALL, 31  CALLCODE, 32  DELEGATECALL, 33  STATICCALL, 34  POST; 35  36  /** 37  * Indicates that the code is executed in the context of the caller 38  */ 39  public boolean isStateless() { 40  return this == CALLCODE || this == DELEGATECALL; 41  } 42  43  public static MsgType fromOpcode(OpCode opCode) { 44  switch (opCode) { 45  case CALL: return CALL; 46  case CALLCODE: return CALLCODE; 47  case DELEGATECALL: return DELEGATECALL; 48  case STATICCALL: return STATICCALL; 49  default: 50  throw new RuntimeException("Invalid call opcode: " + opCode); 51  } 52  } 53  } 54  55  /** 56  * Type of internal call. Either CALL, CALLCODE or POST 57  */ 58  private final MsgType type; 59  60  /** 61  * gas to pay for the call, remaining gas will be refunded to the caller 62  */ 63  private final DataWord gas; 64  /** 65  * address of account which code to call 66  */ 67  private final DataWord codeAddress; 68  /** 69  * the value that can be transfer along with the code execution 70  */ 71  private final DataWord endowment; 72  /** 73  * start of memory to be input data to the call 74  */ 75  private final DataWord inDataOffs; 76  /** 77  * size of memory to be input data to the call 78  */ 79  private final DataWord inDataSize; 80  /** 81  * start of memory to be output of the call 82  */ 83  private DataWord outDataOffs; 84  /** 85  * size of memory to be output data to the call 86  */ 87  private DataWord outDataSize; 88  89  public MessageCall(MsgType type, DataWord gas, DataWord codeAddress, 90  DataWord endowment, DataWord inDataOffs, DataWord inDataSize) { 91  this.type = type; 92  this.gas = gas; 93  this.codeAddress = codeAddress; 94  this.endowment = endowment; 95  this.inDataOffs = inDataOffs; 96  this.inDataSize = inDataSize; 97  } 98  99  public MessageCall(MsgType type, DataWord gas, DataWord codeAddress, 100  DataWord endowment, DataWord inDataOffs, DataWord inDataSize, 101  DataWord outDataOffs, DataWord outDataSize) { 102  this(type, gas, codeAddress, endowment, inDataOffs, inDataSize); 103  this.outDataOffs = outDataOffs; 104  this.outDataSize = outDataSize; 105  } 106  107  public MsgType getType() { 108  return type; 109  } 110  111  public DataWord getGas() { 112  return gas; 113  } 114  115  public DataWord getCodeAddress() { 116  return codeAddress; 117  } 118  119  public DataWord getEndowment() { 120  return endowment; 121  } 122  123  public DataWord getInDataOffs() { 124  return inDataOffs; 125  } 126  127  public DataWord getInDataSize() { 128  return inDataSize; 129  } 130  131  public DataWord getOutDataOffs() { 132  return outDataOffs; 133  } 134  135  public DataWord getOutDataSize() { 136  return outDataSize; 137  } 138 }