Rename read file callback.

This commit is contained in:
chriseth
2017-08-23 17:37:35 +02:00
parent ab5e3a8f6d
commit 9ac2ac14c1
10 changed files with 36 additions and 33 deletions
+4 -4
View File
@@ -239,7 +239,7 @@ bool CompilerStack::analyze()
if (noErrors)
{
SMTChecker smtChecker(m_errorReporter, m_readFile);
SMTChecker smtChecker(m_errorReporter, m_smtQuery);
for (Source const* source: m_sourceOrder)
smtChecker.analyze(*source->ast);
}
@@ -535,17 +535,17 @@ StringMap CompilerStack::loadMissingSources(SourceUnit const& _ast, std::string
if (m_sources.count(importPath) || newSources.count(importPath))
continue;
ReadFile::Result result{false, string("File not supplied initially.")};
ReadCallback::Result result{false, string("File not supplied initially.")};
if (m_readFile)
result = m_readFile(importPath);
if (result.success)
newSources[importPath] = result.contentsOrErrorMessage;
newSources[importPath] = result.responseOrErrorMessage;
else
{
m_errorReporter.parserError(
import->location(),
string("Source \"" + importPath + "\" not found: " + result.contentsOrErrorMessage)
string("Source \"" + importPath + "\" not found: " + result.responseOrErrorMessage)
);
continue;
}
+3 -2
View File
@@ -82,7 +82,7 @@ public:
/// Creates a new compiler stack.
/// @param _readFile callback to used to read files for import statements. Must return
/// and must not emit exceptions.
explicit CompilerStack(ReadFile::Callback const& _readFile = ReadFile::Callback()):
explicit CompilerStack(ReadCallback::Callback const& _readFile = ReadCallback::Callback()):
m_readFile(_readFile),
m_errorList(),
m_errorReporter(m_errorList) {}
@@ -287,7 +287,8 @@ private:
std::string target;
};
ReadFile::Callback m_readFile;
ReadCallback::Callback m_readFile;
ReadCallback::Callback m_smtQuery;
bool m_optimize = false;
unsigned m_optimizeRuns = 200;
std::map<std::string, h160> m_libraries;
+4 -4
View File
@@ -27,17 +27,17 @@ namespace dev
namespace solidity
{
class ReadFile: boost::noncopyable
class ReadCallback: boost::noncopyable
{
public:
/// File reading result.
/// File reading or generic query result.
struct Result
{
bool success;
std::string contentsOrErrorMessage;
std::string responseOrErrorMessage;
};
/// File reading callback.
/// File reading or generic query callback.
using Callback = std::function<Result(std::string const&)>;
};
+4 -4
View File
@@ -203,10 +203,10 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
for (auto const& url: sources[sourceName]["urls"])
{
ReadFile::Result result = m_readFile(url.asString());
ReadCallback::Result result = m_readFile(url.asString());
if (result.success)
{
if (!hash.empty() && !hashMatchesContent(hash, result.contentsOrErrorMessage))
if (!hash.empty() && !hashMatchesContent(hash, result.responseOrErrorMessage))
errors.append(formatError(
false,
"IOError",
@@ -215,13 +215,13 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
));
else
{
m_compilerStack.addSource(sourceName, result.contentsOrErrorMessage);
m_compilerStack.addSource(sourceName, result.responseOrErrorMessage);
found = true;
break;
}
}
else
failures.push_back("Cannot import url (\"" + url.asString() + "\"): " + result.contentsOrErrorMessage);
failures.push_back("Cannot import url (\"" + url.asString() + "\"): " + result.responseOrErrorMessage);
}
for (auto const& failure: failures)
+2 -2
View File
@@ -40,7 +40,7 @@ public:
/// Creates a new StandardCompiler.
/// @param _readFile callback to used to read files for import statements. Must return
/// and must not emit exceptions.
explicit StandardCompiler(ReadFile::Callback const& _readFile = ReadFile::Callback())
explicit StandardCompiler(ReadCallback::Callback const& _readFile = ReadCallback::Callback())
: m_compilerStack(_readFile), m_readFile(_readFile)
{
}
@@ -56,7 +56,7 @@ private:
Json::Value compileInternal(Json::Value const& _input);
CompilerStack m_compilerStack;
ReadFile::Callback m_readFile;
ReadCallback::Callback m_readFile;
};
}