Skip to content

Commit

Permalink
Rename examplevm to example-vm
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Aug 31, 2018
1 parent 1504410 commit f66eb4b
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ after_build:
if ($env:GENERATOR) {
cd C:\projects\evmc\build\test
Release\evmc-test.exe
C:\install\bin\evmc-vmtester.exe C:\install\bin\evmc-examplevm.dll
C:\install\bin\evmc-vmtester.exe C:\install\bin\evmc-example-vm.dll
}
4 changes: 2 additions & 2 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ jobs:
cmake ~/project/examples/use_instructions_in_cmake -DCMAKE_PREFIX_PATH=~/install
cmake --build .
- run:
name: "Run evmc-vmtester libevmc-examplevm.so"
command: ~/install/bin/evmc-vmtester ~/install/lib/libevmc-examplevm.so
name: "Run evmc-vmtester libevmc-example-vm.so"
command: ~/install/bin/evmc-vmtester ~/install/lib/libevmc-example-vm.so

build-clang-3.8:
<<: *build
Expand Down
10 changes: 5 additions & 5 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ add_library(evmc-example-host STATIC example_host.cpp)
target_link_libraries(evmc-example-host PRIVATE evmc)


add_library(evmc-examplevm examplevm.c)
target_link_libraries(evmc-examplevm PRIVATE evmc)
set_source_files_properties(examplevm.c PROPERTIES COMPILE_DEFINITIONS PROJECT_VERSION=${PROJECT_VERSION})
add_library(evmc-example-vm example_vm.c)
target_link_libraries(evmc-example-vm PRIVATE evmc)
set_source_files_properties(example_vm.c PROPERTIES COMPILE_DEFINITIONS PROJECT_VERSION=${PROJECT_VERSION})


add_executable(evmc-example example.c)
target_link_libraries(evmc-example PRIVATE evmc-example-host evmc-examplevm evmc)
target_link_libraries(evmc-example PRIVATE evmc-example-host evmc-example-vm evmc)


install(TARGETS evmc-examplevm
install(TARGETS evmc-example-vm
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
Expand Down
6 changes: 3 additions & 3 deletions examples/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

#include "example_host.h"
#include "examplevm.h"
#include "example_vm.h"

#include <evmc/helpers.h>

Expand All @@ -13,10 +13,10 @@

int main()
{
struct evmc_instance* vm = evmc_create_examplevm();
struct evmc_instance* vm = evmc_create_example_vm();
if (!evmc_is_abi_compatible(vm))
return 1;
// EVM bytecode goes here. This is one of the examples examplevm.c
// EVM bytecode goes here. This is one of the examples.
const uint8_t code[] = "\x30\x60\x00\x52\x59\x60\x00\xf3";
const size_t code_size = sizeof(code);
const struct evmc_uint256be code_hash = {.bytes = {1, 2, 3}};
Expand Down
20 changes: 12 additions & 8 deletions examples/examplevm.c → examples/example_vm.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#include "examplevm.h"
/* EVMC: Ethereum Client-VM Connector API.
* Copyright 2018 The EVMC Authors.
* Licensed under the Apache License, Version 2.0. See the LICENSE file.
*/
#include "example_vm.h"

#include <limits.h>
#include <stdio.h>
Expand All @@ -11,7 +15,7 @@
#define PROJECT_VERSION 0.0.0
#endif

struct examplevm
struct example_vm
{
struct evmc_instance instance;
int verbose;
Expand All @@ -29,7 +33,7 @@ static void destroy(struct evmc_instance* evm)
/// VMs are allowed to omit this function implementation.
static int set_option(struct evmc_instance* instance, char const* name, char const* value)
{
struct examplevm* vm = (struct examplevm*)instance;
struct example_vm* vm = (struct example_vm*)instance;
if (strcmp(name, "verbose") == 0)
{
long int v = strtol(value, NULL, 0);
Expand Down Expand Up @@ -71,7 +75,7 @@ static struct evmc_result execute(struct evmc_instance* instance,
return ret;
}

struct examplevm* vm = (struct examplevm*)instance;
struct example_vm* vm = (struct example_vm*)instance;

// Simulate executing by checking for some code patterns.
// Solidity inline assembly is used in the examples instead of EVM bytecode.
Expand Down Expand Up @@ -125,23 +129,23 @@ static void set_tracer(struct evmc_instance* instance,
evmc_trace_callback callback,
struct evmc_tracer_context* context)
{
struct examplevm* vm = (struct examplevm*)instance;
struct example_vm* vm = (struct example_vm*)instance;
vm->trace_callback = callback;
vm->tracer_context = context;
}

struct evmc_instance* evmc_create_examplevm()
struct evmc_instance* evmc_create_example_vm()
{
struct evmc_instance init = {
.abi_version = EVMC_ABI_VERSION,
.name = "examplevm",
.name = "example_vm",
.version = STR(PROJECT_VERSION),
.destroy = destroy,
.execute = execute,
.set_option = set_option,
.set_tracer = set_tracer,
};
struct examplevm* vm = calloc(1, sizeof(struct examplevm));
struct example_vm* vm = calloc(1, sizeof(struct example_vm));
struct evmc_instance* interface = &vm->instance;
memcpy(interface, &init, sizeof(init));
return interface;
Expand Down
2 changes: 1 addition & 1 deletion examples/examplevm.h → examples/example_vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
/**
* Creates EVMC Example VM.
*/
EVMC_EXPORT struct evmc_instance* evmc_create_examplevm(void);
EVMC_EXPORT struct evmc_instance* evmc_create_example_vm(void);

0 comments on commit f66eb4b

Please sign in to comment.