mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Provide access to the name of contracts.
This commit is contained in:
@@ -1361,6 +1361,18 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess)
|
||||
);
|
||||
m_context << Instruction::POP;
|
||||
}
|
||||
else if (member == "name")
|
||||
{
|
||||
TypePointer arg = dynamic_cast<MagicType const&>(*_memberAccess.expression().annotation().type).typeArgument();
|
||||
ContractDefinition const& contract = dynamic_cast<ContractType const&>(*arg).contractDefinition();
|
||||
m_context << u256(contract.name().length() + 32);
|
||||
utils().allocateMemory();
|
||||
// store string length
|
||||
m_context << u256(contract.name().length()) << Instruction::DUP2 << Instruction::MSTORE;
|
||||
// adjust pointer
|
||||
m_context << Instruction::DUP1 << u256(32) << Instruction::ADD;
|
||||
utils().storeStringData(contract.name());
|
||||
}
|
||||
else
|
||||
solAssert(false, "Unknown magic member.");
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user