diff options
author | Christian <c@ethdev.com> | 2014-12-18 21:39:16 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2014-12-18 21:39:16 +0800 |
commit | f744c34ccc30e053eb61aecb5621f4e8060a8b0c (patch) | |
tree | 112a0d2a426501c10c3c6554e9dd9d176ff15935 /CompilerStack.cpp | |
parent | a98afc8eaa20146359dd212fc2eb0bd0fe18d893 (diff) | |
download | dexon-solidity-f744c34ccc30e053eb61aecb5621f4e8060a8b0c.tar.gz dexon-solidity-f744c34ccc30e053eb61aecb5621f4e8060a8b0c.tar.zst dexon-solidity-f744c34ccc30e053eb61aecb5621f4e8060a8b0c.zip |
Possibility to replace source and obtain ContractDefinition by name.
Diffstat (limited to 'CompilerStack.cpp')
-rw-r--r-- | CompilerStack.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/CompilerStack.cpp b/CompilerStack.cpp index 9fdc88ba..79716fde 100644 --- a/CompilerStack.cpp +++ b/CompilerStack.cpp @@ -36,13 +36,12 @@ namespace dev namespace solidity { -void CompilerStack::addSource(string const& _name, string const& _content) +bool CompilerStack::addSource(string const& _name, string const& _content) { - if (m_sources.count(_name)) - BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Source by given name already exists.")); - + bool existed = m_sources.count(_name); reset(true); m_sources[_name].scanner = make_shared<Scanner>(CharStream(_content), _name); + return existed; } void CompilerStack::setSource(string const& _sourceCode) @@ -181,6 +180,11 @@ SourceUnit const& CompilerStack::getAST(string const& _sourceName) const return *getSource(_sourceName).ast; } +ContractDefinition const& CompilerStack::getContractDefinition(string const& _contractName) const +{ + return *getContract(_contractName).contract; +} + bytes CompilerStack::staticCompile(std::string const& _sourceCode, bool _optimize) { CompilerStack stack; |