mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Old codegen: implemented shortcut for <address>.code.length
This commit is contained in:
parent
2bf85ea44f
commit
d6d880dc53
@ -1473,6 +1473,29 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Another special case for `address.code.length`, which should simply call extcodesize
|
||||||
|
if (
|
||||||
|
auto innerExpression = dynamic_cast<MemberAccess const*>(&_memberAccess.expression());
|
||||||
|
member == "length" &&
|
||||||
|
innerExpression &&
|
||||||
|
innerExpression->memberName() == "code" &&
|
||||||
|
innerExpression->expression().annotation().type->category() == Type::Category::Address
|
||||||
|
)
|
||||||
|
{
|
||||||
|
solAssert(innerExpression->annotation().type->category() == Type::Category::Array, "");
|
||||||
|
|
||||||
|
innerExpression->expression().accept(*this);
|
||||||
|
|
||||||
|
utils().convertType(
|
||||||
|
*innerExpression->expression().annotation().type,
|
||||||
|
*TypeProvider::address(),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
m_context << Instruction::EXTCODESIZE;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
_memberAccess.expression().accept(*this);
|
_memberAccess.expression().accept(*this);
|
||||||
switch (_memberAccess.expression().annotation().type->category())
|
switch (_memberAccess.expression().annotation().type->category())
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user