aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/interface/CompilerStack.cpp
diff options
context:
space:
mode:
authorDenton Liu <liu.denton+github@gmail.com>2016-08-15 22:58:01 +0800
committerDenton Liu <liu.denton+github@gmail.com>2016-08-19 22:34:50 +0800
commite00f802f725e284af453d70a48d450a4d5c9925e (patch)
tree26e5ef14ebbd9a47dbf6cd5e5ed95d2dba9776a0 /libsolidity/interface/CompilerStack.cpp
parent64cec9793a881e5a8ee77cb73e3f3599f330c044 (diff)
downloaddexon-solidity-e00f802f725e284af453d70a48d450a4d5c9925e.tar.gz
dexon-solidity-e00f802f725e284af453d70a48d450a4d5c9925e.tar.zst
dexon-solidity-e00f802f725e284af453d70a48d450a4d5c9925e.zip
Remove standard contracts
Diffstat (limited to 'libsolidity/interface/CompilerStack.cpp')
-rw-r--r--libsolidity/interface/CompilerStack.cpp33
1 files changed, 6 insertions, 27 deletions
diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp
index 0e5ead2b..bd79bb73 100644
--- a/libsolidity/interface/CompilerStack.cpp
+++ b/libsolidity/interface/CompilerStack.cpp
@@ -42,26 +42,8 @@ using namespace std;
using namespace dev;
using namespace dev::solidity;
-const map<string, string> StandardSources = map<string, string>{
- {"coin", R"(import "CoinReg";import "Config";import "configUser";contract coin is configUser{function coin(bytes3 name, uint denom) {CoinReg(Config(configAddr()).lookup(3)).register(name, denom);}})"},
- {"Coin", R"(contract Coin{function isApprovedFor(address _target,address _proxy)constant returns(bool _r){}function isApproved(address _proxy)constant returns(bool _r){}function sendCoinFrom(address _from,uint256 _val,address _to){}function coinBalanceOf(address _a)constant returns(uint256 _r){}function sendCoin(uint256 _val,address _to){}function coinBalance()constant returns(uint256 _r){}function approve(address _a){}})"},
- {"CoinReg", R"(contract CoinReg{function count()constant returns(uint256 r){}function info(uint256 i)constant returns(address addr,bytes3 name,uint256 denom){}function register(bytes3 name,uint256 denom){}function unregister(){}})"},
- {"configUser", R"(contract configUser{function configAddr()constant returns(address a){ return 0xc6d9d2cd449a754c494264e1809c50e34d64562b;}})"},
- {"Config", R"(contract Config{function lookup(uint256 service)constant returns(address a){}function kill(){}function unregister(uint256 id){}function register(uint256 id,address service){}})"},
- {"mortal", R"(import "owned";contract mortal is owned {function kill() { if (msg.sender == owner) suicide(owner); }})"},
- {"named", R"(import "Config";import "NameReg";import "configUser";contract named is configUser {function named(bytes32 name) {NameReg(Config(configAddr()).lookup(1)).register(name);}})"},
- {"NameReg", R"(contract NameReg{function register(bytes32 name){}function addressOf(bytes32 name)constant returns(address addr){}function unregister(){}function nameOf(address addr)constant returns(bytes32 name){}})"},
- {"owned", R"(contract owned{function owned(){owner = msg.sender;}modifier onlyowner(){if(msg.sender==owner)_}address owner;})"},
- {"service", R"(import "Config";import "configUser";contract service is configUser{function service(uint _n){Config(configAddr()).register(_n, this);}})"},
- {"std", R"(import "owned";import "mortal";import "Config";import "configUser";import "NameReg";import "named";)"}
-};
-
-CompilerStack::CompilerStack(bool _addStandardSources, ReadFileCallback const& _readFile):
- m_readFile(_readFile), m_parseSuccessful(false)
-{
- if (_addStandardSources)
- addSources(StandardSources, true); // add them as libraries
-}
+CompilerStack::CompilerStack(ReadFileCallback const& _readFile):
+ m_readFile(_readFile), m_parseSuccessful(false) {}
void CompilerStack::setRemappings(vector<string> const& _remappings)
{
@@ -81,7 +63,7 @@ void CompilerStack::setRemappings(vector<string> const& _remappings)
swap(m_remappings, remappings);
}
-void CompilerStack::reset(bool _keepSources, bool _addStandardSources)
+void CompilerStack::reset(bool _keepSources)
{
m_parseSuccessful = false;
if (_keepSources)
@@ -90,8 +72,6 @@ void CompilerStack::reset(bool _keepSources, bool _addStandardSources)
else
{
m_sources.clear();
- if (_addStandardSources)
- addSources(StandardSources, true);
}
m_globalContext.reset();
m_sourceOrder.clear();
@@ -616,10 +596,9 @@ CompilerStack::Contract const& CompilerStack::contract(string const& _contractNa
if (_contractName.empty())
// try to find some user-supplied contract
for (auto const& it: m_sources)
- if (!StandardSources.count(it.first))
- for (ASTPointer<ASTNode> const& node: it.second.ast->nodes())
- if (auto contract = dynamic_cast<ContractDefinition const*>(node.get()))
- contractName = contract->name();
+ for (ASTPointer<ASTNode> const& node: it.second.ast->nodes())
+ if (auto contract = dynamic_cast<ContractDefinition const*>(node.get()))
+ contractName = contract->name();
auto it = m_contracts.find(contractName);
if (it == m_contracts.end())
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Contract " + _contractName + " not found."));