EVMC
evmc::VM Class Reference

The VM instance. More...

#include <evmc.hpp>

Public Member Functions

 VM (evmc_vm *vm) noexcept
 Converting constructor from evmc_vm.
 
 ~VM () noexcept
 Destructor responsible for automatically destroying the VM instance.
 
 VM (const VM &)=delete
 
VMoperator= (const VM &)=delete
 
 VM (VM &&other) noexcept
 Move constructor.
 
VMoperator= (VM &&other) noexcept
 Move assignment operator.
 
 VM (evmc_vm *vm, std::initializer_list< std::pair< const char *, const char *>> options) noexcept
 The constructor that captures a VM instance and configures the instance with the provided list of options. More...
 
 operator bool () const noexcept
 Checks if contains a valid pointer to the VM instance.
 
bool is_abi_compatible () const noexcept
 Checks whenever the VM instance is ABI compatible with the current EVMC API.
 
char const * name () const noexcept
 The name of the EVMC VM implementation. More...
 
char const * version () const noexcept
 The version of the EVMC VM implementation, e.g. More...
 
evmc_capabilities_flagset get_capabilities () const noexcept
 The example implementation of the evmc_vm::get_capabilities() method. More...
 
evmc_set_option_result set_option (const char name[], const char value[]) noexcept
 Sets the option for the VM, if the feature is supported by the VM. More...
 
result execute (const evmc_host_interface &host, evmc_host_context *ctx, evmc_revision rev, const evmc_message &msg, const uint8_t *code, size_t code_size) noexcept
 Executes code in the VM instance. More...
 
result execute (Host &host, evmc_revision rev, const evmc_message &msg, const uint8_t *code, size_t code_size) noexcept
 Convenient variant of the VM::execute() that takes reference to evmc::Host class.
 
result execute (evmc_revision rev, const evmc_message &msg, const uint8_t *code, size_t code_size) noexcept
 Executes code without the Host context. More...
 

Detailed Description

The VM instance.

This is a RAII wrapper for evmc_vm, and object of this type automatically destroys the VM instance.

Definition at line 526 of file evmc.hpp.

Constructor & Destructor Documentation

◆ VM()

evmc::VM::VM ( evmc_vm vm,
std::initializer_list< std::pair< const char *, const char *>>  options 
)
inlinenoexcept

The constructor that captures a VM instance and configures the instance with the provided list of options.

Definition at line 627 of file evmc.hpp.

629  : m_instance{vm}
630 {
631  // This constructor is implemented outside of the class definition to workaround a doxygen bug.
632  for (const auto& option : options)
633  set_option(option.first, option.second);
634 }
evmc_set_option_result set_option(const char name[], const char value[]) noexcept
Sets the option for the VM, if the feature is supported by the VM.
Definition: evmc.hpp:580

Member Function Documentation

◆ execute() [1/2]

result evmc::VM::execute ( const evmc_host_interface host,
evmc_host_context ctx,
evmc_revision  rev,
const evmc_message msg,
const uint8_t *  code,
size_t  code_size 
)
inlinenoexcept

Executes code in the VM instance.

See also
evmc_execute_fn.

Definition at line 586 of file evmc.hpp.

592  {
593  return result{m_instance->execute(m_instance, &host, ctx, rev, &msg, code, code_size)};
594  }
The EVM code execution result.
Definition: evmc.hpp:266
evmc_execute_fn execute
Pointer to function executing a code by the VM instance.
Definition: evmc.h:893

◆ execute() [2/2]

result evmc::VM::execute ( evmc_revision  rev,
const evmc_message msg,
const uint8_t *  code,
size_t  code_size 
)
inlinenoexcept

Executes code without the Host context.

The same as execute(const evmc_host_interface&, evmc_host_context*, evmc_revision, const evmc_message&, const uint8_t*, size_t), but without providing the Host context and interface. This method is for experimental precompiles support where execution is guaranteed not to require any Host access.

Definition at line 614 of file evmc.hpp.

618  {
619  return result{
620  m_instance->execute(m_instance, nullptr, nullptr, rev, &msg, code, code_size)};
621  }
The EVM code execution result.
Definition: evmc.hpp:266
evmc_execute_fn execute
Pointer to function executing a code by the VM instance.
Definition: evmc.h:893

◆ get_capabilities()

evmc_capabilities_flagset evmc::VM::get_capabilities ( ) const
inlinenoexcept

The example implementation of the evmc_vm::get_capabilities() method.

Definition at line 574 of file evmc.hpp.

575  {
576  return m_instance->get_capabilities(m_instance);
577  }
evmc_get_capabilities_fn get_capabilities
A method returning capabilities supported by the VM instance.
Definition: evmc.h:905

◆ name()

char const* evmc::VM::name ( ) const
inlinenoexcept

The name of the EVMC VM implementation.

It MUST be a NULL-terminated not empty string. The content MUST be UTF-8 encoded (this implies ASCII encoding is also allowed).

Definition at line 568 of file evmc.hpp.

568 { return m_instance->name; }
const char * name
The name of the EVMC VM implementation.
Definition: evmc.h:871

◆ set_option()

evmc_set_option_result evmc::VM::set_option ( const char  name[],
const char  value[] 
)
inlinenoexcept

Sets the option for the VM, if the feature is supported by the VM.

See also
evmc_set_option_fn

Definition at line 580 of file evmc.hpp.

581  {
582  return evmc_set_option(m_instance, name, value);
583  }
char const * name() const noexcept
The name of the EVMC VM implementation.
Definition: evmc.hpp:568
static enum evmc_set_option_result evmc_set_option(struct evmc_vm *vm, char const *name, char const *value)
Sets the option for the VM, if the feature is supported by the VM.
Definition: helpers.h:73

◆ version()

char const* evmc::VM::version ( ) const
inlinenoexcept

The version of the EVMC VM implementation, e.g.

"1.2.3b4".

It MUST be a NULL-terminated not empty string. The content MUST be UTF-8 encoded (this implies ASCII encoding is also allowed).

Definition at line 571 of file evmc.hpp.

571 { return m_instance->version; }
const char * version
The version of the EVMC VM implementation, e.g.
Definition: evmc.h:879

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