aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-07-14 03:06:04 +0800
committerchriseth <chris@ethereum.org>2017-08-23 23:37:35 +0800
commit9ac2ac14c1819be2341c6947245bf63b02795528 (patch)
tree0f935509daf2d166a6095924530263059894a764
parentab5e3a8f6d9b92cef521b6855bf7ab649ebf751f (diff)
downloaddexon-solidity-9ac2ac14c1819be2341c6947245bf63b02795528.tar
dexon-solidity-9ac2ac14c1819be2341c6947245bf63b02795528.tar.gz
dexon-solidity-9ac2ac14c1819be2341c6947245bf63b02795528.tar.bz2
dexon-solidity-9ac2ac14c1819be2341c6947245bf63b02795528.tar.lz
dexon-solidity-9ac2ac14c1819be2341c6947245bf63b02795528.tar.xz
dexon-solidity-9ac2ac14c1819be2341c6947245bf63b02795528.tar.zst
dexon-solidity-9ac2ac14c1819be2341c6947245bf63b02795528.zip
Rename read file callback.
-rw-r--r--libsolidity/formal/SMTChecker.h2
-rw-r--r--libsolidity/formal/SMTLib2Interface.cpp6
-rw-r--r--libsolidity/formal/SMTLib2Interface.h2
-rw-r--r--libsolidity/interface/CompilerStack.cpp8
-rw-r--r--libsolidity/interface/CompilerStack.h5
-rw-r--r--libsolidity/interface/ReadFile.h8
-rw-r--r--libsolidity/interface/StandardCompiler.cpp8
-rw-r--r--libsolidity/interface/StandardCompiler.h4
-rw-r--r--solc/CommandLineInterface.cpp14
-rw-r--r--solc/jsonCompiler.cpp12
10 files changed, 36 insertions, 33 deletions
diff --git a/libsolidity/formal/SMTChecker.h b/libsolidity/formal/SMTChecker.h
index afe5897d..f0968cc7 100644
--- a/libsolidity/formal/SMTChecker.h
+++ b/libsolidity/formal/SMTChecker.h
@@ -34,7 +34,7 @@ class ErrorReporter;
class SMTChecker: private ASTConstVisitor
{
public:
- SMTChecker(ErrorReporter& _errorReporter, ReadFile::Callback const& _readCallback);
+ SMTChecker(ErrorReporter& _errorReporter, ReadCallback::Callback const& _readCallback);
void analyze(SourceUnit const& _sources);
diff --git a/libsolidity/formal/SMTLib2Interface.cpp b/libsolidity/formal/SMTLib2Interface.cpp
index 8cc4da66..4b118abc 100644
--- a/libsolidity/formal/SMTLib2Interface.cpp
+++ b/libsolidity/formal/SMTLib2Interface.cpp
@@ -18,6 +18,7 @@
#include <libsolidity/formal/SMTLib2Interface.h>
#include <libsolidity/interface/Exceptions.h>
+#include <libsolidity/interface/ReadFile.h>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/join.hpp>
@@ -33,10 +34,11 @@
using namespace std;
using namespace dev;
+using namespace dev::solidity;
using namespace dev::solidity::smt;
-SMTLib2Interface::SMTLib2Interface(ReadFile::Callback const& _readFileCallback):
- m_communicator(_readFileCallback)
+SMTLib2Interface::SMTLib2Interface(ReadCallback::Callback const& _queryCallback):
+ m_queryCallback(_queryCallback)
{
reset();
}
diff --git a/libsolidity/formal/SMTLib2Interface.h b/libsolidity/formal/SMTLib2Interface.h
index 5755ae3f..957f2ea4 100644
--- a/libsolidity/formal/SMTLib2Interface.h
+++ b/libsolidity/formal/SMTLib2Interface.h
@@ -42,7 +42,7 @@ namespace smt
class SMTLib2Interface: public SolverInterface, public boost::noncopyable
{
public:
- SMTLib2Interface(ReadFile::Callback const& _readFileCallback);
+ SMTLib2Interface(ReadCallback::Callback const& _queryCallback);
void reset() override;
diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp
index 50e20b3d..363f45dd 100644
--- a/libsolidity/interface/CompilerStack.cpp
+++ b/libsolidity/interface/CompilerStack.cpp
@@ -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;
}
diff --git a/libsolidity/interface/CompilerStack.h b/libsolidity/interface/CompilerStack.h
index bb0f4126..361b8a45 100644
--- a/libsolidity/interface/CompilerStack.h
+++ b/libsolidity/interface/CompilerStack.h
@@ -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;
diff --git a/libsolidity/interface/ReadFile.h b/libsolidity/interface/ReadFile.h
index 2e8a6bd8..7068629d 100644
--- a/libsolidity/interface/ReadFile.h
+++ b/libsolidity/interface/ReadFile.h
@@ -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&)>;
};
diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp
index 7a6f9989..be823743 100644
--- a/libsolidity/interface/StandardCompiler.cpp
+++ b/libsolidity/interface/StandardCompiler.cpp
@@ -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)
diff --git a/libsolidity/interface/StandardCompiler.h b/libsolidity/interface/StandardCompiler.h
index d9787a40..11a0b4c2 100644
--- a/libsolidity/interface/StandardCompiler.h
+++ b/libsolidity/interface/StandardCompiler.h
@@ -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;
};
}
diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp
index bfc53aef..315f951e 100644
--- a/solc/CommandLineInterface.cpp
+++ b/solc/CommandLineInterface.cpp
@@ -663,7 +663,7 @@ Allowed options)",
bool CommandLineInterface::processInput()
{
- ReadFile::Callback fileReader = [this](string const& _path)
+ ReadCallback::Callback fileReader = [this](string const& _path)
{
try
{
@@ -683,25 +683,25 @@ bool CommandLineInterface::processInput()
}
}
if (!isAllowed)
- return ReadFile::Result{false, "File outside of allowed directories."};
+ return ReadCallback::Result{false, "File outside of allowed directories."};
else if (!boost::filesystem::exists(path))
- return ReadFile::Result{false, "File not found."};
+ return ReadCallback::Result{false, "File not found."};
else if (!boost::filesystem::is_regular_file(canonicalPath))
- return ReadFile::Result{false, "Not a valid file."};
+ return ReadCallback::Result{false, "Not a valid file."};
else
{
auto contents = dev::contentsString(canonicalPath.string());
m_sourceCodes[path.string()] = contents;
- return ReadFile::Result{true, contents};
+ return ReadCallback::Result{true, contents};
}
}
catch (Exception const& _exception)
{
- return ReadFile::Result{false, "Exception in read callback: " + boost::diagnostic_information(_exception)};
+ return ReadCallback::Result{false, "Exception in read callback: " + boost::diagnostic_information(_exception)};
}
catch (...)
{
- return ReadFile::Result{false, "Unknown exception in read callback."};
+ return ReadCallback::Result{false, "Unknown exception in read callback."};
}
};
diff --git a/solc/jsonCompiler.cpp b/solc/jsonCompiler.cpp
index ab928ac0..684d49e4 100644
--- a/solc/jsonCompiler.cpp
+++ b/solc/jsonCompiler.cpp
@@ -41,9 +41,9 @@ typedef void (*CStyleReadFileCallback)(char const* _path, char** o_contents, cha
namespace
{
-ReadFile::Callback wrapReadCallback(CStyleReadFileCallback _readCallback = nullptr)
+ReadCallback::Callback wrapReadCallback(CStyleReadFileCallback _readCallback = nullptr)
{
- ReadFile::Callback readCallback;
+ ReadCallback::Callback readCallback;
if (_readCallback)
{
readCallback = [=](string const& _path)
@@ -51,23 +51,23 @@ ReadFile::Callback wrapReadCallback(CStyleReadFileCallback _readCallback = nullp
char* contents_c = nullptr;
char* error_c = nullptr;
_readCallback(_path.c_str(), &contents_c, &error_c);
- ReadFile::Result result;
+ ReadCallback::Result result;
result.success = true;
if (!contents_c && !error_c)
{
result.success = false;
- result.contentsOrErrorMessage = "File not found.";
+ result.responseOrErrorMessage = "File not found.";
}
if (contents_c)
{
result.success = true;
- result.contentsOrErrorMessage = string(contents_c);
+ result.responseOrErrorMessage = string(contents_c);
free(contents_c);
}
if (error_c)
{
result.success = false;
- result.contentsOrErrorMessage = string(error_c);
+ result.responseOrErrorMessage = string(error_c);
free(error_c);
}
return result;