aboutsummaryrefslogtreecommitdiffstats
path: root/solc/CommandLineInterface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'solc/CommandLineInterface.cpp')
-rw-r--r--solc/CommandLineInterface.cpp41
1 files changed, 19 insertions, 22 deletions
diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp
index 271511d4..9e2cb77a 100644
--- a/solc/CommandLineInterface.cpp
+++ b/solc/CommandLineInterface.cpp
@@ -424,20 +424,13 @@ 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());
}
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)
@@ -447,7 +440,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 +691,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};
}
@@ -716,19 +709,22 @@ bool CommandLineInterface::processInput()
if (m_args.count(g_argAllowPaths))
{
vector<string> paths;
- for (string const& path: boost::split(paths, m_args[g_argAllowPaths].as<string>(), boost::is_any_of(",")))
- m_allowedDirectories.push_back(boost::filesystem::path(path));
+ for (string const& path: boost::split(paths, m_args[g_argAllowPaths].as<string>(), boost::is_any_of(","))) {
+ auto filesystem_path = boost::filesystem::path(path);
+ // If the given path had a trailing slash, the Boost filesystem
+ // path will have it's last component set to '.'. This breaks
+ // path comparison in later parts of the code, so we need to strip
+ // it.
+ if (filesystem_path.filename() == ".") {
+ filesystem_path.remove_filename();
+ }
+ m_allowedDirectories.push_back(filesystem_path);
+ }
}
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;
@@ -942,9 +938,10 @@ void CommandLineInterface::handleAst(string const& _argStr)
for (auto const& sourceCode: m_sourceCodes)
asts.push_back(&m_compiler->ast(sourceCode.first));
map<ASTNode const*, eth::GasMeter::GasConsumption> gasCosts;
- if (m_compiler->runtimeAssemblyItems())
+ // FIXME: shouldn't this be done for every contract?
+ 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
);