Skip to content
This repository has been archived by the owner on Jan 5, 2019. It is now read-only.

Add wast2wasm tool #165

Merged
merged 1 commit into from
May 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/evm2wasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

#include <string>

std::string wast2wasm(const std::string& input, bool debug = false);
std::string evm2wasm(const std::string& input);
6 changes: 3 additions & 3 deletions libs/evm2wasm/evm2wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

using namespace std;

namespace {

string wast2wasm(const string& input, bool debug = false) {
string wast2wasm(const string& input, bool debug) {
wasm::Module module;

try {
Expand Down Expand Up @@ -48,6 +46,8 @@ string wast2wasm(const string& input, bool debug = false) {
return output.str();
}

namespace {

string evm2wast(const string& input) {
(void)input;
// FIXME: do evm magic here
Expand Down
3 changes: 2 additions & 1 deletion tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
add_subdirectory(evm2wasm)
add_subdirectory(evm2wasm)
add_subdirectory(wast2wasm)
2 changes: 2 additions & 0 deletions tools/wast2wasm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_executable(wast2wasm main.cpp)
target_link_libraries(wast2wasm PRIVATE libevm2wasm)
35 changes: 35 additions & 0 deletions tools/wast2wasm/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <string>
#include <iostream>
#include <fstream>
#include <streambuf>

#include <evm2wasm.h>

using namespace std;

int main(int argc, char **argv) {
(void)argc;
(void)argv;

string input;
while (!cin.eof())
{
string tmp;
// NOTE: this will read until EOF or NL
getline(cin, tmp);
input.append(tmp);
input.append("\n");
}

if (!input.size())
return 1;

string output = wast2wasm(input);

if (!output.size())
return 1;

cout << output << endl;

return 0;
}