aboutsummaryrefslogtreecommitdiffstats
path: root/GlobalContext.cpp
diff options
context:
space:
mode:
authorGav Wood <i@gavwood.com>2015-02-21 04:56:37 +0800
committerGav Wood <i@gavwood.com>2015-02-21 04:56:37 +0800
commit89d84edb16812ff9e4b1049ee0257d65c75f5a3c (patch)
treebaeda13e44a8fc0f6ac2f705fdf334da14405f39 /GlobalContext.cpp
parentd552ceb50f8e3888abf5b9a6095a5fb60ee91b5f (diff)
parent852405116654bda9f4dc1d4876a2368184b30a8c (diff)
downloaddexon-solidity-89d84edb16812ff9e4b1049ee0257d65c75f5a3c.tar
dexon-solidity-89d84edb16812ff9e4b1049ee0257d65c75f5a3c.tar.gz
dexon-solidity-89d84edb16812ff9e4b1049ee0257d65c75f5a3c.tar.bz2
dexon-solidity-89d84edb16812ff9e4b1049ee0257d65c75f5a3c.tar.lz
dexon-solidity-89d84edb16812ff9e4b1049ee0257d65c75f5a3c.tar.xz
dexon-solidity-89d84edb16812ff9e4b1049ee0257d65c75f5a3c.tar.zst
dexon-solidity-89d84edb16812ff9e4b1049ee0257d65c75f5a3c.zip
Merge branch 'develop'
Conflicts: README.md evmjit libdevcrypto/CryptoPP.cpp libethereum/State.cpp neth/main.cpp
Diffstat (limited to 'GlobalContext.cpp')
-rw-r--r--GlobalContext.cpp65
1 files changed, 30 insertions, 35 deletions
diff --git a/GlobalContext.cpp b/GlobalContext.cpp
index f4805b1f..60de5105 100644
--- a/GlobalContext.cpp
+++ b/GlobalContext.cpp
@@ -16,6 +16,7 @@
*/
/**
* @author Christian <c@ethdev.com>
+ * @author Gav Wood <g@ethdev.com>
* @date 2014
* Container of the (implicit and explicit) global objects.
*/
@@ -33,33 +34,29 @@ namespace solidity
{
GlobalContext::GlobalContext():
-m_magicVariables(vector<shared_ptr<MagicVariableDeclaration const>>{make_shared<MagicVariableDeclaration>("block", make_shared<MagicType>(MagicType::Kind::BLOCK)),
- make_shared<MagicVariableDeclaration>("msg", make_shared<MagicType>(MagicType::Kind::MSG)),
- make_shared<MagicVariableDeclaration>("tx", make_shared<MagicType>(MagicType::Kind::TX)),
- make_shared<MagicVariableDeclaration>("suicide",
- make_shared<FunctionType>(TypePointers({std::make_shared<IntegerType>(0,
- IntegerType::Modifier::ADDRESS)}),
- TypePointers(),
- FunctionType::Location::SUICIDE)),
- make_shared<MagicVariableDeclaration>("sha3",
- make_shared<FunctionType>(TypePointers({std::make_shared<IntegerType>(256, IntegerType::Modifier::HASH)}),
- TypePointers({std::make_shared<IntegerType>(256, IntegerType::Modifier::HASH)}),
- FunctionType::Location::SHA3)),
- make_shared<MagicVariableDeclaration>("sha256",
- make_shared<FunctionType>(TypePointers({std::make_shared<IntegerType>(256, IntegerType::Modifier::HASH)}),
- TypePointers({std::make_shared<IntegerType>(256, IntegerType::Modifier::HASH)}),
- FunctionType::Location::SHA256)),
- make_shared<MagicVariableDeclaration>("ecrecover",
- make_shared<FunctionType>(TypePointers({std::make_shared<IntegerType>(256, IntegerType::Modifier::HASH),
- std::make_shared<IntegerType>(8, IntegerType::Modifier::HASH),
- std::make_shared<IntegerType>(256, IntegerType::Modifier::HASH),
- std::make_shared<IntegerType>(256, IntegerType::Modifier::HASH)}),
- TypePointers({std::make_shared<IntegerType>(0, IntegerType::Modifier::ADDRESS)}),
- FunctionType::Location::ECRECOVER)),
- make_shared<MagicVariableDeclaration>("ripemd160",
- make_shared<FunctionType>(TypePointers({std::make_shared<IntegerType>(256, IntegerType::Modifier::HASH)}),
- TypePointers({std::make_shared<IntegerType>(160, IntegerType::Modifier::HASH)}),
- FunctionType::Location::RIPEMD160))})
+m_magicVariables(vector<shared_ptr<MagicVariableDeclaration const>>{make_shared<MagicVariableDeclaration>("block", make_shared<MagicType>(MagicType::Kind::Block)),
+ make_shared<MagicVariableDeclaration>("msg", make_shared<MagicType>(MagicType::Kind::Message)),
+ make_shared<MagicVariableDeclaration>("tx", make_shared<MagicType>(MagicType::Kind::Transaction)),
+ make_shared<MagicVariableDeclaration>("suicide",
+ make_shared<FunctionType>(strings{"address"}, strings{}, FunctionType::Location::Suicide)),
+ make_shared<MagicVariableDeclaration>("sha3",
+ make_shared<FunctionType>(strings(), strings{"hash"}, FunctionType::Location::SHA3, true)),
+ make_shared<MagicVariableDeclaration>("log0",
+ make_shared<FunctionType>(strings{"hash"},strings{}, FunctionType::Location::Log0)),
+ make_shared<MagicVariableDeclaration>("log1",
+ make_shared<FunctionType>(strings{"hash", "hash"},strings{}, FunctionType::Location::Log1)),
+ make_shared<MagicVariableDeclaration>("log2",
+ make_shared<FunctionType>(strings{"hash", "hash", "hash"},strings{}, FunctionType::Location::Log2)),
+ make_shared<MagicVariableDeclaration>("log3",
+ make_shared<FunctionType>(strings{"hash", "hash", "hash", "hash"},strings{}, FunctionType::Location::Log3)),
+ make_shared<MagicVariableDeclaration>("log4",
+ make_shared<FunctionType>(strings{"hash", "hash", "hash", "hash", "hash"},strings{}, FunctionType::Location::Log4)),
+ make_shared<MagicVariableDeclaration>("sha256",
+ make_shared<FunctionType>(strings(), strings{"hash"}, FunctionType::Location::SHA256, true)),
+ make_shared<MagicVariableDeclaration>("ecrecover",
+ make_shared<FunctionType>(strings{"hash", "hash8", "hash", "hash"}, strings{"address"}, FunctionType::Location::ECRecover)),
+ make_shared<MagicVariableDeclaration>("ripemd160",
+ make_shared<FunctionType>(strings(), strings{"hash160"}, FunctionType::Location::RIPEMD160, true))})
{
}
@@ -71,7 +68,7 @@ void GlobalContext::setCurrentContract(ContractDefinition const& _contract)
vector<Declaration const*> GlobalContext::getDeclarations() const
{
vector<Declaration const*> declarations;
- declarations.reserve(m_magicVariables.size() + 1);
+ declarations.reserve(m_magicVariables.size());
for (ASTPointer<Declaration const> const& variable: m_magicVariables)
declarations.push_back(variable.get());
return declarations;
@@ -86,14 +83,12 @@ MagicVariableDeclaration const* GlobalContext::getCurrentThis() const
}
-vector<MagicVariableDeclaration const*> GlobalContext::getMagicVariables() const
+MagicVariableDeclaration const* GlobalContext::getCurrentSuper() const
{
- vector<MagicVariableDeclaration const*> declarations;
- declarations.reserve(m_magicVariables.size() + 1);
- for (ASTPointer<MagicVariableDeclaration const> const& variable: m_magicVariables)
- declarations.push_back(variable.get());
- declarations.push_back(getCurrentThis());
- return declarations;
+ if (!m_superPointer[m_currentContract])
+ m_superPointer[m_currentContract] = make_shared<MagicVariableDeclaration>(
+ "super", make_shared<ContractType>(*m_currentContract, true));
+ return m_superPointer[m_currentContract].get();
}
}