diff --git a/libserpent/CMakeLists.txt b/libserpent/CMakeLists.txt index a0768c32f..47179defc 100644 --- a/libserpent/CMakeLists.txt +++ b/libserpent/CMakeLists.txt @@ -43,4 +43,5 @@ message("Installation path: ${CMAKE_INSTALL_PREFIX}") install( TARGETS ${EXECUTABLE} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} ) +#install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libserpent.so DESTINATION lib ) diff --git a/libserpent/example.cpp b/libserpent/example.cpp deleted file mode 100644 index 1ce2590d0..000000000 --- a/libserpent/example.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include -#include - -using namespace std; - -int main() { - cout << printAST(compileToLLL(get_file_contents("examples/namecoin.se"))) << "\n"; - cout << decimalSub("10234", "10234") << "\n"; - cout << decimalSub("10234", "10233") << "\n"; -} diff --git a/libserpent/funcs.cpp b/libserpent/funcs.cpp index e80fcff06..3a5573f23 100644 --- a/libserpent/funcs.cpp +++ b/libserpent/funcs.cpp @@ -9,15 +9,28 @@ #include "compiler.h" #include "rewriter.h" #include "tokenize.h" +#include +#include Node compileToLLL(std::string input) { return rewrite(parseSerpent(input)); } -std::string compile(std::string input) { - return compileLLL(compileToLLL(input)); +std::vector compile(std::string input) { + return eth::compileLLL(printSimple(compileToLLL(input))); } std::vector prettyCompile(std::string input) { - return prettyCompileLLL(compileToLLL(input)); + return deserialize(bytesToString( + eth::compileLLL(printSimple(compileToLLL(input))))); +} + +std::string bytesToString(std::vector input) { + std::string o; + for (unsigned i = 0; i < input.size(); i++) o += (char)input[i]; + return o; +} + +std::string bytesToHex(std::vector input) { + return binToHex(bytesToString(input)); } diff --git a/libserpent/funcs.h b/libserpent/funcs.h index 0f3355ec8..a9c562f1a 100644 --- a/libserpent/funcs.h +++ b/libserpent/funcs.h @@ -24,6 +24,10 @@ Node compileToLLL(std::string input); -std::string compile(std::string input); +std::vector compile(std::string input); std::vector prettyCompile(std::string input); + +std::string bytesToString(std::vector input); + +std::string bytesToHex(std::vector input); diff --git a/sc/cmdline.cpp b/sc/cmdline.cpp index 71d9928b2..03e501ea1 100644 --- a/sc/cmdline.cpp +++ b/sc/cmdline.cpp @@ -3,6 +3,8 @@ #include #include #include +#include +#include int main(int argv, char** argc) { if (argv == 1) { @@ -45,7 +47,7 @@ int main(int argv, char** argc) { std::cout << printAST(buildFragmentTree(parseLLL(input, true))) << "\n"; } else if (command == "compile_lll") { - std::cout << binToHex(compileLLL(parseLLL(input, true))) << "\n"; + std::cout << bytesToHex(eth::compileLLL(input)) << "\n"; } else if (command == "dereference") { std::cout << printAST(dereference(parseLLL(input, true)), haveSec) <<"\n"; @@ -54,10 +56,11 @@ int main(int argv, char** argc) { std::cout << printTokens(prettyAssemble(parseLLL(input, true))) <<"\n"; } else if (command == "pretty_compile_lll") { - std::cout << printTokens(prettyCompileLLL(parseLLL(input, true))) << "\n"; + std::cout << printTokens(deserialize(bytesToString( + eth::compileLLL(input)))) << "\n"; } else if (command == "pretty_compile") { - std::cout << printTokens(prettyCompile(input)) << "\n"; + std::cout << printTokens(deserialize(bytesToString(compile(input)))) << "\n"; } else if (command == "assemble") { std::cout << assemble(parseLLL(input, true)) << "\n"; @@ -72,7 +75,7 @@ int main(int argv, char** argc) { std::cout << printTokens(deserialize(hexToBin(input))) << "\n"; } else if (command == "compile") { - std::cout << binToHex(compile(input)) << "\n"; + std::cout << bytesToHex(compile(input)) << "\n"; } else if (command == "encode_datalist") { std::vector tokens = tokenize(input);