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 --- solc/CommandLineInterface.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'solc/CommandLineInterface.cpp') diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 1686dc2e..b4c9fe82 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -424,7 +424,7 @@ void CommandLineInterface::readInputFilesAndConfigureRemappings() continue; } - m_sourceCodes[infile.string()] = dev::contentsString(infile.string()); + m_sourceCodes[infile.string()] = dev::readFileAsString(infile.string()); path = boost::filesystem::canonical(infile).string(); } m_allowedDirectories.push_back(boost::filesystem::path(path).remove_filename()); @@ -447,7 +447,7 @@ bool CommandLineInterface::parseLibraryOption(string const& _input) try { if (fs::is_regular_file(_input)) - data = contentsString(_input); + data = readFileAsString(_input); } catch (fs::filesystem_error const&) { @@ -698,7 +698,7 @@ bool CommandLineInterface::processInput() return ReadCallback::Result{false, "Not a valid file."}; else { - auto contents = dev::contentsString(canonicalPath.string()); + auto contents = dev::readFileAsString(canonicalPath.string()); m_sourceCodes[path.string()] = contents; return ReadCallback::Result{true, contents}; } -- 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 --- solc/CommandLineInterface.cpp | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'solc/CommandLineInterface.cpp') diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index b4c9fe82..fe1461b4 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -430,14 +430,7 @@ void CommandLineInterface::readInputFilesAndConfigureRemappings() m_allowedDirectories.push_back(boost::filesystem::path(path).remove_filename()); } if (addStdin) - { - string s; - while (!cin.eof()) - { - getline(cin, s); - m_sourceCodes[g_stdinFileName].append(s + '\n'); - } - } + m_sourceCodes[g_stdinFileName] = dev::readStandardInput(); } bool CommandLineInterface::parseLibraryOption(string const& _input) @@ -731,13 +724,7 @@ bool CommandLineInterface::processInput() if (m_args.count(g_argStandardJSON)) { - string input; - while (!cin.eof()) - { - string tmp; - getline(cin, tmp); - input.append(tmp + "\n"); - } + string input = dev::readStandardInput(); StandardCompiler compiler(fileReader); cout << compiler.compile(input) << endl; return true; -- cgit v1.2.3 From 039cc25b1fd875e9f4cfd0f0649f2b4ed67640e1 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 21 Aug 2017 20:35:27 +0100 Subject: Always require a contract/sourceName in CompilerStack --- solc/CommandLineInterface.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'solc/CommandLineInterface.cpp') diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 1686dc2e..3ab564c3 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -951,9 +951,10 @@ void CommandLineInterface::handleAst(string const& _argStr) for (auto const& sourceCode: m_sourceCodes) asts.push_back(&m_compiler->ast(sourceCode.first)); map gasCosts; - if (m_compiler->runtimeAssemblyItems()) + // FIXME: shouldn't this be done for every contract? + if (m_compiler->runtimeAssemblyItems("")) gasCosts = GasEstimator::breakToStatementLevel( - GasEstimator::structuralEstimation(*m_compiler->runtimeAssemblyItems(), asts), + GasEstimator::structuralEstimation(*m_compiler->runtimeAssemblyItems(""), asts), asts ); -- cgit v1.2.3 From 2ce35b77becab2395dce218b106a7ce904a1b141 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 21 Aug 2017 21:49:58 +0100 Subject: Implement CompilerStack.lastContractName() --- solc/CommandLineInterface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'solc/CommandLineInterface.cpp') diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 3ab564c3..c4241a9e 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -952,9 +952,9 @@ void CommandLineInterface::handleAst(string const& _argStr) asts.push_back(&m_compiler->ast(sourceCode.first)); map gasCosts; // FIXME: shouldn't this be done for every contract? - if (m_compiler->runtimeAssemblyItems("")) + if (m_compiler->runtimeAssemblyItems(m_compiler->lastContractName())) gasCosts = GasEstimator::breakToStatementLevel( - GasEstimator::structuralEstimation(*m_compiler->runtimeAssemblyItems(""), asts), + GasEstimator::structuralEstimation(*m_compiler->runtimeAssemblyItems(m_compiler->lastContractName()), asts), asts ); -- cgit v1.2.3