mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #12016 from ethereum/external-fp-10358
Add ``.address`` and ``.selector`` in inside assembly for external function pointers
This commit is contained in:
@@ -823,6 +823,16 @@ bool ContractCompiler::visit(InlineAssembly const& _inlineAssembly)
|
||||
if (suffix == "length")
|
||||
stackDiff--;
|
||||
}
|
||||
else if (
|
||||
auto const* functionType = dynamic_cast<FunctionType const*>(variable->type());
|
||||
functionType && functionType->kind() == FunctionType::Kind::External
|
||||
)
|
||||
{
|
||||
solAssert(suffix == "selector" || suffix == "address", "");
|
||||
solAssert(variable->type()->sizeOnStack() == 2, "");
|
||||
if (suffix == "selector")
|
||||
stackDiff--;
|
||||
}
|
||||
else
|
||||
solAssert(false, "");
|
||||
}
|
||||
@@ -889,6 +899,16 @@ bool ContractCompiler::visit(InlineAssembly const& _inlineAssembly)
|
||||
solAssert(suffix.empty(), "");
|
||||
}
|
||||
}
|
||||
else if (
|
||||
auto const* functionType = dynamic_cast<FunctionType const*>(variable->type());
|
||||
functionType && functionType->kind() == FunctionType::Kind::External
|
||||
)
|
||||
{
|
||||
solAssert(suffix == "selector" || suffix == "address", "");
|
||||
solAssert(variable->type()->sizeOnStack() == 2, "");
|
||||
if (suffix == "selector")
|
||||
stackDiff--;
|
||||
}
|
||||
else
|
||||
solAssert(suffix.empty(), "");
|
||||
|
||||
|
||||
@@ -188,6 +188,18 @@ private:
|
||||
solAssert(suffix == "offset" || suffix == "length", "");
|
||||
value = IRVariable{*varDecl}.part(suffix).name();
|
||||
}
|
||||
else if (
|
||||
auto const* functionType = dynamic_cast<FunctionType const*>(varDecl->type());
|
||||
functionType && functionType->kind() == FunctionType::Kind::External
|
||||
)
|
||||
{
|
||||
solAssert(suffix == "selector" || suffix == "address", "");
|
||||
solAssert(varDecl->type()->sizeOnStack() == 2, "");
|
||||
if (suffix == "selector")
|
||||
value = IRVariable{*varDecl}.part("functionSelector").name();
|
||||
else
|
||||
value = IRVariable{*varDecl}.part("address").name();
|
||||
}
|
||||
else
|
||||
solAssert(false, "");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user