mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Allow indexed structs in events with encoder v2.
This commit is contained in:
parent
0c2d623ee4
commit
a8d0ef4bad
@ -578,17 +578,7 @@ bool TypeChecker::visit(EventDefinition const& _eventDef)
|
|||||||
for (ASTPointer<VariableDeclaration> const& var: _eventDef.parameters())
|
for (ASTPointer<VariableDeclaration> const& var: _eventDef.parameters())
|
||||||
{
|
{
|
||||||
if (var->isIndexed())
|
if (var->isIndexed())
|
||||||
{
|
|
||||||
numIndexed++;
|
numIndexed++;
|
||||||
if (
|
|
||||||
_eventDef.sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::ABIEncoderV2) &&
|
|
||||||
dynamic_cast<ReferenceType const*>(type(*var).get())
|
|
||||||
)
|
|
||||||
m_errorReporter.typeError(
|
|
||||||
var->location(),
|
|
||||||
"Indexed reference types cannot yet be used with ABIEncoderV2."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (!type(*var)->canLiveOutsideStorage())
|
if (!type(*var)->canLiveOutsideStorage())
|
||||||
m_errorReporter.typeError(var->location(), "Type is required to live outside storage.");
|
m_errorReporter.typeError(var->location(), "Type is required to live outside storage.");
|
||||||
if (!type(*var)->interfaceType(false))
|
if (!type(*var)->interfaceType(false))
|
||||||
|
@ -731,6 +731,7 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
|
|||||||
}
|
}
|
||||||
arguments.front()->accept(*this);
|
arguments.front()->accept(*this);
|
||||||
utils().fetchFreeMemoryPointer();
|
utils().fetchFreeMemoryPointer();
|
||||||
|
solAssert(function.parameterTypes().front()->isValueType(), "");
|
||||||
utils().packedEncode(
|
utils().packedEncode(
|
||||||
{arguments.front()->annotation().type},
|
{arguments.front()->annotation().type},
|
||||||
{function.parameterTypes().front()}
|
{function.parameterTypes().front()}
|
||||||
@ -744,29 +745,33 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
|
|||||||
_functionCall.expression().accept(*this);
|
_functionCall.expression().accept(*this);
|
||||||
auto const& event = dynamic_cast<EventDefinition const&>(function.declaration());
|
auto const& event = dynamic_cast<EventDefinition const&>(function.declaration());
|
||||||
unsigned numIndexed = 0;
|
unsigned numIndexed = 0;
|
||||||
|
TypePointers paramTypes = function.parameterTypes();
|
||||||
// All indexed arguments go to the stack
|
// All indexed arguments go to the stack
|
||||||
for (unsigned arg = arguments.size(); arg > 0; --arg)
|
for (unsigned arg = arguments.size(); arg > 0; --arg)
|
||||||
if (event.parameters()[arg - 1]->isIndexed())
|
if (event.parameters()[arg - 1]->isIndexed())
|
||||||
{
|
{
|
||||||
++numIndexed;
|
++numIndexed;
|
||||||
arguments[arg - 1]->accept(*this);
|
arguments[arg - 1]->accept(*this);
|
||||||
if (auto const& arrayType = dynamic_pointer_cast<ArrayType const>(function.parameterTypes()[arg - 1]))
|
if (auto const& referenceType = dynamic_pointer_cast<ReferenceType const>(paramTypes[arg - 1]))
|
||||||
{
|
{
|
||||||
utils().fetchFreeMemoryPointer();
|
utils().fetchFreeMemoryPointer();
|
||||||
utils().packedEncode(
|
utils().packedEncode(
|
||||||
{arguments[arg - 1]->annotation().type},
|
{arguments[arg - 1]->annotation().type},
|
||||||
{arrayType}
|
{referenceType}
|
||||||
);
|
);
|
||||||
utils().toSizeAfterFreeMemoryPointer();
|
utils().toSizeAfterFreeMemoryPointer();
|
||||||
m_context << Instruction::KECCAK256;
|
m_context << Instruction::KECCAK256;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
solAssert(paramTypes[arg - 1]->isValueType(), "");
|
||||||
utils().convertType(
|
utils().convertType(
|
||||||
*arguments[arg - 1]->annotation().type,
|
*arguments[arg - 1]->annotation().type,
|
||||||
*function.parameterTypes()[arg - 1],
|
*paramTypes[arg - 1],
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!event.isAnonymous())
|
if (!event.isAnonymous())
|
||||||
{
|
{
|
||||||
m_context << u256(h256::Arith(dev::keccak256(function.externalSignature())));
|
m_context << u256(h256::Arith(dev::keccak256(function.externalSignature())));
|
||||||
@ -782,7 +787,7 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
|
|||||||
{
|
{
|
||||||
arguments[arg]->accept(*this);
|
arguments[arg]->accept(*this);
|
||||||
nonIndexedArgTypes.push_back(arguments[arg]->annotation().type);
|
nonIndexedArgTypes.push_back(arguments[arg]->annotation().type);
|
||||||
nonIndexedParamTypes.push_back(function.parameterTypes()[arg]);
|
nonIndexedParamTypes.push_back(paramTypes[arg]);
|
||||||
}
|
}
|
||||||
utils().fetchFreeMemoryPointer();
|
utils().fetchFreeMemoryPointer();
|
||||||
utils().abiEncode(nonIndexedArgTypes, nonIndexedParamTypes);
|
utils().abiEncode(nonIndexedArgTypes, nonIndexedParamTypes);
|
||||||
|
Loading…
Reference in New Issue
Block a user