aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/interface
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-04-10 19:48:41 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-04-10 19:49:47 +0800
commit623b8eb107a97861e3e7e0c13acee39c8d5f4075 (patch)
tree9a6b09990052496a078d8cb115db35629c8b7063 /libsolidity/interface
parentfefb3fad6fa20b9c99dd987a7869c297b279032e (diff)
downloaddexon-solidity-623b8eb107a97861e3e7e0c13acee39c8d5f4075.tar
dexon-solidity-623b8eb107a97861e3e7e0c13acee39c8d5f4075.tar.gz
dexon-solidity-623b8eb107a97861e3e7e0c13acee39c8d5f4075.tar.bz2
dexon-solidity-623b8eb107a97861e3e7e0c13acee39c8d5f4075.tar.lz
dexon-solidity-623b8eb107a97861e3e7e0c13acee39c8d5f4075.tar.xz
dexon-solidity-623b8eb107a97861e3e7e0c13acee39c8d5f4075.tar.zst
dexon-solidity-623b8eb107a97861e3e7e0c13acee39c8d5f4075.zip
Pull out ReadFile from CompilerStack
Diffstat (limited to 'libsolidity/interface')
-rw-r--r--libsolidity/interface/CompilerStack.cpp4
-rw-r--r--libsolidity/interface/CompilerStack.h14
-rw-r--r--libsolidity/interface/ReadFile.h45
3 files changed, 50 insertions, 13 deletions
diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp
index effc8309..9ad28573 100644
--- a/libsolidity/interface/CompilerStack.cpp
+++ b/libsolidity/interface/CompilerStack.cpp
@@ -55,7 +55,7 @@ using namespace std;
using namespace dev;
using namespace dev::solidity;
-CompilerStack::CompilerStack(ReadFileCallback const& _readFile):
+CompilerStack::CompilerStack(ReadFile::Callback const& _readFile):
m_readFile(_readFile), m_parseSuccessful(false) {}
void CompilerStack::setRemappings(vector<string> const& _remappings)
@@ -522,7 +522,7 @@ StringMap CompilerStack::loadMissingSources(SourceUnit const& _ast, std::string
if (m_sources.count(importPath) || newSources.count(importPath))
continue;
- ReadFileResult result{false, string("File not supplied initially.")};
+ ReadFile::Result result{false, string("File not supplied initially.")};
if (m_readFile)
result = m_readFile(importPath);
diff --git a/libsolidity/interface/CompilerStack.h b/libsolidity/interface/CompilerStack.h
index 65850683..9c37eead 100644
--- a/libsolidity/interface/CompilerStack.h
+++ b/libsolidity/interface/CompilerStack.h
@@ -36,6 +36,7 @@
#include <libevmasm/SourceLocation.h>
#include <libevmasm/LinkerObject.h>
#include <libsolidity/interface/Exceptions.h>
+#include <libsolidity/interface/ReadFile.h>
namespace dev
{
@@ -77,18 +78,9 @@ enum class DocumentationType: uint8_t
class CompilerStack: boost::noncopyable
{
public:
- struct ReadFileResult
- {
- bool success;
- std::string contentsOrErrorMessage;
- };
-
- /// File reading callback.
- using ReadFileCallback = std::function<ReadFileResult(std::string const&)>;
-
/// Creates a new compiler stack.
/// @param _readFile callback to used to read files for import statements. Should return
- explicit CompilerStack(ReadFileCallback const& _readFile = ReadFileCallback());
+ explicit CompilerStack(ReadFile::Callback const& _readFile = ReadFile::Callback());
/// Sets path remappings in the format "context:prefix=target"
void setRemappings(std::vector<std::string> const& _remappings);
@@ -263,7 +255,7 @@ private:
std::string target;
};
- ReadFileCallback m_readFile;
+ ReadFile::Callback m_readFile;
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
new file mode 100644
index 00000000..2e8a6bd8
--- /dev/null
+++ b/libsolidity/interface/ReadFile.h
@@ -0,0 +1,45 @@
+/*
+ This file is part of solidity.
+
+ solidity is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ solidity is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with solidity. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#pragma once
+
+#include <string>
+#include <functional>
+#include <boost/noncopyable.hpp>
+
+namespace dev
+{
+
+namespace solidity
+{
+
+class ReadFile: boost::noncopyable
+{
+public:
+ /// File reading result.
+ struct Result
+ {
+ bool success;
+ std::string contentsOrErrorMessage;
+ };
+
+ /// File reading callback.
+ using Callback = std::function<Result(std::string const&)>;
+};
+
+}
+}