diff options
author | chriseth <c@ethdev.com> | 2016-06-08 01:44:32 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-06-09 00:16:46 +0800 |
commit | 3150ab2bcfe6ab66d426916fc1a003ae52799b72 (patch) | |
tree | b7fc2c8c910c97c883816364bd62bb7c646dd75b /libsolidity/interface/CompilerStack.h | |
parent | 63b63056893717a9ec4565ba6c1e7c746592054b (diff) | |
download | dexon-solidity-3150ab2bcfe6ab66d426916fc1a003ae52799b72.tar.gz dexon-solidity-3150ab2bcfe6ab66d426916fc1a003ae52799b72.tar.zst dexon-solidity-3150ab2bcfe6ab66d426916fc1a003ae52799b72.zip |
Allow remappings to change depending on the context.
Diffstat (limited to 'libsolidity/interface/CompilerStack.h')
-rw-r--r-- | libsolidity/interface/CompilerStack.h | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/libsolidity/interface/CompilerStack.h b/libsolidity/interface/CompilerStack.h index c7f98184..e111c982 100644 --- a/libsolidity/interface/CompilerStack.h +++ b/libsolidity/interface/CompilerStack.h @@ -75,15 +75,23 @@ enum class DocumentationType: uint8_t class CompilerStack: boost::noncopyable { public: - /// File reading callback, should return a pair of content and error message (exactly one nonempty) - /// for a given path. - using ReadFileCallback = std::function<std::pair<std::string, std::string>(std::string const&)>; + struct ReadFileResult + { + bool success; + std::string contentsOrErrorMesage; + }; + + /// 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 /// @param _addStandardSources Adds standard sources if @a _addStandardSources. explicit CompilerStack(bool _addStandardSources = true, ReadFileCallback const& _readFile = ReadFileCallback()); + /// Sets path remappings in the format "context:prefix=target" + void setRemappings(std::vector<std::string> const& _remappings); + /// Resets the compiler to a state where the sources are not parsed or even removed. void reset(bool _keepSources = false, bool _addStandardSources = true); @@ -209,6 +217,7 @@ private: /// @a m_readFile and stores the absolute paths of all imports in the AST annotations. /// @returns the newly loaded sources. StringMap loadMissingSources(SourceUnit const& _ast, std::string const& _path); + std::string applyRemapping(std::string const& _path, std::string const& _context); void resolveImports(); /// Checks whether there are libraries with the same name, reports that as an error and /// @returns false in this case. @@ -226,7 +235,17 @@ private: Contract const& contract(std::string const& _contractName = "") const; Source const& source(std::string const& _sourceName = "") const; + struct Remapping + { + std::string context; + std::string prefix; + std::string target; + }; + ReadFileCallback m_readFile; + /// list of path prefix remappings, e.g. mylibrary: github.com/ethereum = /usr/local/ethereum + /// "context:prefix=target" + std::vector<Remapping> m_remappings; bool m_parseSuccessful; std::map<std::string const, Source> m_sources; std::shared_ptr<GlobalContext> m_globalContext; |