Rename examplevm to example-vm

This commit is contained in:
Paweł Bylica 2018-08-30 18:27:44 +02:00
parent 0bb3a67284
commit 759e67a1c6
No known key found for this signature in database
GPG Key ID: 7A0C037434FE77EF
6 changed files with 24 additions and 20 deletions

View File

@ -54,5 +54,5 @@ after_build:
if ($env:GENERATOR) { if ($env:GENERATOR) {
cd C:\projects\evmc\build\test cd C:\projects\evmc\build\test
Release\evmc-test.exe 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
} }

View File

@ -54,8 +54,8 @@ jobs:
cmake ~/project/examples/use_instructions_in_cmake -DCMAKE_PREFIX_PATH=~/install cmake ~/project/examples/use_instructions_in_cmake -DCMAKE_PREFIX_PATH=~/install
cmake --build . cmake --build .
- run: - run:
name: "Run evmc-vmtester libevmc-examplevm.so" name: "Run evmc-vmtester libevmc-example-vm.so"
command: ~/install/bin/evmc-vmtester ~/install/lib/libevmc-examplevm.so command: ~/install/bin/evmc-vmtester ~/install/lib/libevmc-example-vm.so
build-clang-3.8: build-clang-3.8:
<<: *build <<: *build

View File

@ -15,16 +15,16 @@ add_library(evmc-example-host STATIC example_host.cpp)
target_link_libraries(evmc-example-host PRIVATE evmc) target_link_libraries(evmc-example-host PRIVATE evmc)
add_library(evmc-examplevm examplevm.c) add_library(evmc-example-vm example_vm.c)
target_link_libraries(evmc-examplevm PRIVATE evmc) target_link_libraries(evmc-example-vm PRIVATE evmc)
set_source_files_properties(examplevm.c PROPERTIES COMPILE_DEFINITIONS PROJECT_VERSION=${PROJECT_VERSION}) set_source_files_properties(example_vm.c PROPERTIES COMPILE_DEFINITIONS PROJECT_VERSION=${PROJECT_VERSION})
add_executable(evmc-example example.c) 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} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}

View File

@ -4,7 +4,7 @@
*/ */
#include "example_host.h" #include "example_host.h"
#include "examplevm.h" #include "example_vm.h"
#include <evmc/helpers.h> #include <evmc/helpers.h>
@ -13,10 +13,10 @@
int main() int main()
{ {
struct evmc_instance* vm = evmc_create_examplevm(); struct evmc_instance* vm = evmc_create_example_vm();
if (!evmc_is_abi_compatible(vm)) if (!evmc_is_abi_compatible(vm))
return 1; 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 uint8_t code[] = "\x30\x60\x00\x52\x59\x60\x00\xf3";
const size_t code_size = sizeof(code); const size_t code_size = sizeof(code);
const struct evmc_uint256be code_hash = {.bytes = {1, 2, 3}}; const struct evmc_uint256be code_hash = {.bytes = {1, 2, 3}};

View File

@ -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 <limits.h>
#include <stdio.h> #include <stdio.h>
@ -11,7 +15,7 @@
#define PROJECT_VERSION 0.0.0 #define PROJECT_VERSION 0.0.0
#endif #endif
struct examplevm struct example_vm
{ {
struct evmc_instance instance; struct evmc_instance instance;
int verbose; int verbose;
@ -29,7 +33,7 @@ static void destroy(struct evmc_instance* evm)
/// VMs are allowed to omit this function implementation. /// VMs are allowed to omit this function implementation.
static int set_option(struct evmc_instance* instance, char const* name, char const* value) 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) if (strcmp(name, "verbose") == 0)
{ {
long int v = strtol(value, NULL, 0); long int v = strtol(value, NULL, 0);
@ -71,7 +75,7 @@ static struct evmc_result execute(struct evmc_instance* instance,
return ret; return ret;
} }
struct examplevm* vm = (struct examplevm*)instance; struct example_vm* vm = (struct example_vm*)instance;
// Simulate executing by checking for some code patterns. // Simulate executing by checking for some code patterns.
// Solidity inline assembly is used in the examples instead of EVM bytecode. // Solidity inline assembly is used in the examples instead of EVM bytecode.
@ -125,23 +129,23 @@ static void set_tracer(struct evmc_instance* instance,
evmc_trace_callback callback, evmc_trace_callback callback,
struct evmc_tracer_context* context) struct evmc_tracer_context* context)
{ {
struct examplevm* vm = (struct examplevm*)instance; struct example_vm* vm = (struct example_vm*)instance;
vm->trace_callback = callback; vm->trace_callback = callback;
vm->tracer_context = context; vm->tracer_context = context;
} }
struct evmc_instance* evmc_create_examplevm() struct evmc_instance* evmc_create_example_vm()
{ {
struct evmc_instance init = { struct evmc_instance init = {
.abi_version = EVMC_ABI_VERSION, .abi_version = EVMC_ABI_VERSION,
.name = "examplevm", .name = "example_vm",
.version = STR(PROJECT_VERSION), .version = STR(PROJECT_VERSION),
.destroy = destroy, .destroy = destroy,
.execute = execute, .execute = execute,
.set_option = set_option, .set_option = set_option,
.set_tracer = set_tracer, .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; struct evmc_instance* interface = &vm->instance;
memcpy(interface, &init, sizeof(init)); memcpy(interface, &init, sizeof(init));
return interface; return interface;

View File

@ -11,4 +11,4 @@
/** /**
* Creates EVMC Example VM. * Creates EVMC Example VM.
*/ */
EVMC_EXPORT struct evmc_instance* evmc_create_examplevm(void); EVMC_EXPORT struct evmc_instance* evmc_create_example_vm(void);