Skip to content

Commit

Permalink
add test code
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Jul 29, 2018
1 parent 7f54da1 commit dc50760
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/hera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@
#include <wasm-printing.h>
#include <wasm-validator.h>

#if HAVE_WAVM
#include <IR/Module.h>
#include <IR/Validate.h>
#include <WASM/WASM.h>
#include <Runtime/Runtime.h>
#include <Runtime/Linker.h>
#include <Runtime/Intrinsics.h>
#endif

#include <evmc/evmc.h>

#include <evm2wasm.h>
Expand Down Expand Up @@ -66,6 +75,45 @@ struct hera_instance : evmc_instance {
hera_instance() : evmc_instance({EVMC_ABI_VERSION, "hera", "0.0.0", nullptr, nullptr, nullptr}) {}
};

/**** wavm stuff*****/
#if HAVE_WAVM
struct TestResolver : Runtime::Resolver
{
bool resolve(
const std::string& moduleName,
const std::string& exportName,
IR::ObjectType type,
Runtime::Object*& outObject) override
{
return false;
}
};

void wavm_test() {
IR::Module module;
if (!IR::loadModule("test.wasm", module)) abort();

Runtime::Compartment* compartment = Runtime::createCompartment();
Runtime::Context* context = Runtime::createContext(compartment);

TestResolver resolver;
Runtime::LinkResult linkResult = Runtime::linkModule(module, resolver);
if (!linkResult.success) abort();

Runtime::ModuleInstance* moduleInstance = IR::instantiateModule(
compartment,
module,
std::move(linkResult.resolvedImports),
"test.wasm");

if (!moduleInstance) abort();

Runtime::FunctionInstance* startFunction = moduleInstance->startFunction;
}
#endif
/**** end of wavm stuff*****/


namespace {

bool hasWasmPreamble(vector<uint8_t> const& _input) {
Expand Down

0 comments on commit dc50760

Please # to comment.