From f67d34e4ec379aeed3ee2c05227a228c748b4d9d Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 18 Oct 2017 12:32:34 +0100 Subject: Indentation fixes in lllc --- lllc/main.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'lllc') diff --git a/lllc/main.cpp b/lllc/main.cpp index 912ce16a..8b990eec 100644 --- a/lllc/main.cpp +++ b/lllc/main.cpp @@ -35,15 +35,15 @@ using namespace dev::solidity; using namespace dev::eth; static string const VersionString = - string(ETH_PROJECT_VERSION) + - (string(SOL_VERSION_PRERELEASE).empty() ? "" : "-" + string(SOL_VERSION_PRERELEASE)) + - (string(SOL_VERSION_BUILDINFO).empty() ? "" : "+" + string(SOL_VERSION_BUILDINFO)); + string(ETH_PROJECT_VERSION) + + (string(SOL_VERSION_PRERELEASE).empty() ? "" : "-" + string(SOL_VERSION_PRERELEASE)) + + (string(SOL_VERSION_BUILDINFO).empty() ? "" : "+" + string(SOL_VERSION_BUILDINFO)); static void help() { cout << "Usage lllc [OPTIONS] " << endl - << "Options:" << endl + << "Options:" << endl << " -b,--binary Parse, compile and assemble; output byte code in binary." << endl << " -x,--hex Parse, compile and assemble; output byte code in hex." << endl << " -a,--assembly Only parse and compile; show assembly." << endl @@ -51,12 +51,12 @@ static void help() << " -o,--optimise Turn on/off the optimiser; off by default." << endl << " -h,--help Show this help message and exit." << endl << " -V,--version Show the version and exit." << endl; - exit(0); + exit(0); } static void version() { - cout << "LLLC, the Lovely Little Language Compiler " << endl; + cout << "LLLC, the Lovely Little Language Compiler" << endl; cout << "Version: " << VersionString << endl; exit(0); } @@ -131,7 +131,9 @@ int main(int argc, char** argv) vector errors; if (src.empty()) + { errors.push_back("Empty file."); + } else if (mode == Disassemble) { cout << disassemble(fromHex(src)) << endl; @@ -145,12 +147,17 @@ int main(int argc, char** argv) cout.write((char const*)bs.data(), bs.size()); } else if (mode == ParseTree) + { cout << parseLLL(src) << endl; + } else if (mode == Assembly) + { cout << compileLLLToAsm(src, optimise ? true : false, &errors, contentsString) << endl; + } + for (auto const& i: errors) cerr << i << endl; - if ( errors.size() ) + if (errors.size()) return 1; return 0; } -- cgit v1.2.3 From 7186e142b8ea546d98dc8ddb630da47362be8b0a Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 18 Oct 2017 12:34:29 +0100 Subject: Rename contentsString to readFileAsString --- lllc/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lllc') diff --git a/lllc/main.cpp b/lllc/main.cpp index 8b990eec..4ff204ba 100644 --- a/lllc/main.cpp +++ b/lllc/main.cpp @@ -127,7 +127,7 @@ int main(int argc, char** argv) } } else - src = contentsString(infile); + src = readFileAsString(infile); vector errors; if (src.empty()) @@ -140,7 +140,7 @@ int main(int argc, char** argv) } else if (mode == Binary || mode == Hex) { - auto bs = compileLLL(src, optimise ? true : false, &errors, contentsString); + auto bs = compileLLL(src, optimise ? true : false, &errors, readFileAsString); if (mode == Hex) cout << toHex(bs) << endl; else if (mode == Binary) @@ -152,7 +152,7 @@ int main(int argc, char** argv) } else if (mode == Assembly) { - cout << compileLLLToAsm(src, optimise ? true : false, &errors, contentsString) << endl; + cout << compileLLLToAsm(src, optimise ? true : false, &errors, readFileAsString) << endl; } for (auto const& i: errors) -- cgit v1.2.3 From 6f2865228cb02f0ba0b58990a9d3006dbe2692c6 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 18 Oct 2017 12:54:47 +0100 Subject: Add readStandardInput helper --- lllc/main.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'lllc') diff --git a/lllc/main.cpp b/lllc/main.cpp index 4ff204ba..5679bc2b 100644 --- a/lllc/main.cpp +++ b/lllc/main.cpp @@ -118,14 +118,7 @@ int main(int argc, char** argv) string src; if (infile.empty()) - { - string s; - while (!cin.eof()) - { - getline(cin, s); - src.append(s); - } - } + src = readStandardInput(); else src = readFileAsString(infile); -- cgit v1.2.3