mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Ast-Import from standard-json
This commit is contained in:
@@ -33,10 +33,44 @@ using namespace std;
|
||||
namespace solidity::frontend
|
||||
{
|
||||
|
||||
/// Magic variables get negative ids for easy differentiation
|
||||
int magicVariableToID(std::string const& _name)
|
||||
{
|
||||
if (_name == "abi") return -1;
|
||||
else if (_name == "addmod") return -2;
|
||||
else if (_name == "assert") return -3;
|
||||
else if (_name == "block") return -4;
|
||||
else if (_name == "blockhash") return -5;
|
||||
else if (_name == "ecrecover") return -6;
|
||||
else if (_name == "gasleft") return -7;
|
||||
else if (_name == "keccak256") return -8;
|
||||
else if (_name == "log0") return -10;
|
||||
else if (_name == "log1") return -11;
|
||||
else if (_name == "log2") return -12;
|
||||
else if (_name == "log3") return -13;
|
||||
else if (_name == "log4") return -14;
|
||||
else if (_name == "msg") return -15;
|
||||
else if (_name == "mulmod") return -16;
|
||||
else if (_name == "now") return -17;
|
||||
else if (_name == "require") return -18;
|
||||
else if (_name == "revert") return -19;
|
||||
else if (_name == "ripemd160") return -20;
|
||||
else if (_name == "selfdestruct") return -21;
|
||||
else if (_name == "sha256") return -22;
|
||||
else if (_name == "sha3") return -23;
|
||||
else if (_name == "suicide") return -24;
|
||||
else if (_name == "super") return -25;
|
||||
else if (_name == "tx") return -26;
|
||||
else if (_name == "type") return -27;
|
||||
else if (_name == "this") return -28;
|
||||
else
|
||||
solAssert(false, "Unknown magic variable: \"" + _name + "\".");
|
||||
}
|
||||
|
||||
inline vector<shared_ptr<MagicVariableDeclaration const>> constructMagicVariables()
|
||||
{
|
||||
static auto const magicVarDecl = [](string const& _name, Type const* _type) {
|
||||
return make_shared<MagicVariableDeclaration>(_name, _type);
|
||||
return make_shared<MagicVariableDeclaration>(magicVariableToID(_name), _name, _type);
|
||||
};
|
||||
|
||||
return {
|
||||
@@ -97,7 +131,7 @@ vector<Declaration const*> GlobalContext::declarations() const
|
||||
MagicVariableDeclaration const* GlobalContext::currentThis() const
|
||||
{
|
||||
if (!m_thisPointer[m_currentContract])
|
||||
m_thisPointer[m_currentContract] = make_shared<MagicVariableDeclaration>("this", TypeProvider::contract(*m_currentContract));
|
||||
m_thisPointer[m_currentContract] = make_shared<MagicVariableDeclaration>(magicVariableToID("this"), "this", TypeProvider::contract(*m_currentContract));
|
||||
return m_thisPointer[m_currentContract].get();
|
||||
|
||||
}
|
||||
@@ -105,7 +139,7 @@ MagicVariableDeclaration const* GlobalContext::currentThis() const
|
||||
MagicVariableDeclaration const* GlobalContext::currentSuper() const
|
||||
{
|
||||
if (!m_superPointer[m_currentContract])
|
||||
m_superPointer[m_currentContract] = make_shared<MagicVariableDeclaration>("super", TypeProvider::contract(*m_currentContract, true));
|
||||
m_superPointer[m_currentContract] = make_shared<MagicVariableDeclaration>(magicVariableToID("super"), "super", TypeProvider::contract(*m_currentContract, true));
|
||||
return m_superPointer[m_currentContract].get();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user