EVMC
evmc::result Class Reference

The EVM code execution result. More...

#include <evmc.hpp>

Inherits evmc_result.

Public Member Functions

 result (evmc_status_code _status_code, int64_t _gas_left, const uint8_t *_output_data, size_t _output_size) noexcept
 Creates the result from the provided arguments. More...
 
 result (evmc_result const &res) noexcept
 Converting constructor from raw evmc_result.
 
 ~result () noexcept
 Destructor responsible for automatically releasing attached resources.
 
 result (result &&other) noexcept
 Move constructor.
 
resultoperator= (result &&other) noexcept
 Move assignment operator. More...
 
evmc_result release_raw () noexcept
 Releases the ownership and returns the raw copy of evmc_result. More...
 

Public Attributes

evmc_address create_address
 The address of the contract created by create instructions. More...
 
int64_t gas_left
 The amount of gas left after the execution. More...
 
const uint8_t * output_data
 The reference to output data. More...
 
size_t output_size
 The size of the output data. More...
 
enum evmc_status_code status_code
 The execution status code.
 

Detailed Description

The EVM code execution result.

This is a RAII wrapper for evmc_result and objects of this type automatically release attached resources.

Definition at line 365 of file evmc.hpp.

Constructor & Destructor Documentation

◆ result()

evmc::result::result ( evmc_status_code  _status_code,
int64_t  _gas_left,
const uint8_t *  _output_data,
size_t  _output_size 
)
inlinenoexcept

Creates the result from the provided arguments.

The provided output is copied to memory allocated with malloc() and the evmc_result::release function is set to one invoking free().

Parameters
_status_codeThe status code.
_gas_leftThe amount of gas left.
_output_dataThe pointer to the output.
_output_sizeThe output size.

Definition at line 383 of file evmc.hpp.

387  : evmc_result{make_result(_status_code, _gas_left, _output_data, _output_size)}
388  {}
constexpr auto make_result
Alias for evmc_make_result().
Definition: evmc.hpp:359
The EVM code execution result.
Definition: evmc.h:392

Member Function Documentation

◆ operator=()

result& evmc::result::operator= ( result &&  other)
inlinenoexcept

Move assignment operator.

The self-assigment MUST never happen.

Parameters
otherThe other result object.
Returns
The reference to the left-hand side object.

Definition at line 412 of file evmc.hpp.

413  {
414  this->~result(); // Release this object.
415  static_cast<evmc_result&>(*this) = other; // Copy data.
416  other.release = nullptr; // Disable releasing of the rvalue object.
417  return *this;
418  }
~result() noexcept
Destructor responsible for automatically releasing attached resources.
Definition: evmc.hpp:394

◆ release_raw()

evmc_result evmc::result::release_raw ( )
inlinenoexcept

Releases the ownership and returns the raw copy of evmc_result.

This method drops the ownership of the result (result's resources are not going to be released when this object is destructed). It is the caller's responsibility having the returned copy of the result to release it. This object MUST NOT be used after this method is invoked.

Returns
The copy of this object converted to raw evmc_result.

Definition at line 428 of file evmc.hpp.

429  {
430  const auto out = evmc_result{*this}; // Copy data.
431  this->release = nullptr; // Disable releasing of this object.
432  return out;
433  }
evmc_release_result_fn release
The method releasing all resources associated with the result object.
Definition: evmc.h:443

Member Data Documentation

◆ create_address

evmc_address evmc_result::create_address

The address of the contract created by create instructions.

This field has valid value only if:

Definition at line 454 of file evmc.h.

◆ gas_left

int64_t evmc_result::gas_left

The amount of gas left after the execution.

If evmc_result::status_code is neither EVMC_SUCCESS nor EVMC_REVERT the value MUST be 0.

Definition at line 402 of file evmc.h.

◆ output_data

const uint8_t* evmc_result::output_data

The reference to output data.

The output contains data coming from RETURN opcode (iff evmc_result::code field is EVMC_SUCCESS) or from REVERT opcode.

The memory containing the output data is owned by EVM and has to be freed with evmc_result::release().

This MAY be NULL.

Definition at line 415 of file evmc.h.

◆ output_size

size_t evmc_result::output_size

The size of the output data.

If output_data is NULL this MUST be 0.

Definition at line 422 of file evmc.h.


The documentation for this class was generated from the following file: