Skip to content

Commit

Permalink
Merge pull request #62 from ewasm/binaryen
Browse files Browse the repository at this point in the history
Remove obsolete features from ShellInterface
  • Loading branch information
axic authored Mar 14, 2018
2 parents 05093de + e15d5ba commit aebe6db
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 28 deletions.
6 changes: 6 additions & 0 deletions src/eei.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ string toHex(evm_uint256be const& value) {

}

void EthereumInterface::importGlobals(std::map<Name, Literal>& globals, Module& wasm) {
(void)globals;
(void)wasm;
HERA_DEBUG << "importGlobals\n";
}

#if HERA_DEBUGGING
Literal EthereumInterface::callDebugImport(Import *import, LiteralList& arguments) {
heraAssert(import->module == Name("debug"), "Import namespace error.");
Expand Down
2 changes: 2 additions & 0 deletions src/eei.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ struct EthereumInterface : ShellExternalInterface {
Literal callDebugImport(Import *import, LiteralList& arguments);
#endif

void importGlobals(std::map<Name, Literal>& globals, Module& wasm) override;

void trap(const char* why) override {
throw InternalErrorException(std::string("Trap condition: ") + why);
}
Expand Down
35 changes: 7 additions & 28 deletions src/shell-interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,37 +111,16 @@ struct ShellExternalInterface : ModuleInstance::ExternalInterface {
}

void importGlobals(std::map<Name, Literal>& globals, Module& wasm) override {
// add spectest globals
for (auto& import : wasm.imports) {
if (import->kind == ExternalKind::Global && import->module == SPECTEST && import->base == GLOBAL) {
switch (import->globalType) {
case i32: globals[import->name] = Literal(int32_t(666)); break;
case i64: globals[import->name] = Literal(int64_t(666)); break;
case f32: globals[import->name] = Literal(float(666.6)); break;
case f64: globals[import->name] = Literal(double(666.6)); break;
default: WASM_UNREACHABLE();
}
} else if (import->kind == ExternalKind::Memory && import->module == SPECTEST && import->base == MEMORY) {
// imported memory has initial 1 and max 2
wasm.memory.initial = 1;
wasm.memory.max = 2;
}
}
(void)globals;
(void)wasm;
trap("No globals supported.");
}

Literal callImport(Import *import, LiteralList& arguments) override {
if (import->module == SPECTEST && import->base == PRINT) {
for (auto argument : arguments) {
std::cout << argument << '\n';
}
return Literal();
} else if (import->module == ENV && import->base == EXIT) {
// XXX hack for torture tests
std::cout << "exit()\n";
throw ExitException();
}
Fatal() << "callImport: unknown import: " << import->module.str << "."
<< import->name.str;
(void)import;
(void)arguments;
trap("No imports supported.");
return Literal();
}

Literal callTable(Index index, LiteralList& arguments, Type result, ModuleInstance& instance) override {
Expand Down

0 comments on commit aebe6db

Please sign in to comment.