mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Added anonymous flag to event.
added test
This commit is contained in:
parent
fc0bdc3d81
commit
2986ecbd75
7
AST.h
7
AST.h
@ -556,14 +556,16 @@ public:
|
||||
EventDefinition(SourceLocation const& _location,
|
||||
ASTPointer<ASTString> const& _name,
|
||||
ASTPointer<ASTString> const& _documentation,
|
||||
ASTPointer<ParameterList> const& _parameters):
|
||||
Declaration(_location, _name), Documented(_documentation), m_parameters(_parameters) {}
|
||||
ASTPointer<ParameterList> const& _parameters,
|
||||
bool _anonymous = false):
|
||||
Declaration(_location, _name), Documented(_documentation), m_parameters(_parameters) , m_anonymous(_anonymous){}
|
||||
|
||||
virtual void accept(ASTVisitor& _visitor) override;
|
||||
virtual void accept(ASTConstVisitor& _visitor) const override;
|
||||
|
||||
std::vector<ASTPointer<VariableDeclaration>> const& getParameters() const { return m_parameters->getParameters(); }
|
||||
ParameterList const& getParameterList() const { return *m_parameters; }
|
||||
bool IsAnonymous() const { return m_anonymous; }
|
||||
|
||||
virtual TypePointer getType(ContractDefinition const* = nullptr) const override
|
||||
{
|
||||
@ -574,6 +576,7 @@ public:
|
||||
|
||||
private:
|
||||
ASTPointer<ParameterList> m_parameters;
|
||||
bool m_anonymous;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -542,9 +542,12 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
|
||||
appendTypeConversion(*arguments[arg - 1]->getType(),
|
||||
*function.getParameterTypes()[arg - 1], true);
|
||||
}
|
||||
m_context << u256(h256::Arith(dev::sha3(function.getCanonicalSignature(event.getName()))));
|
||||
++numIndexed;
|
||||
solAssert(numIndexed <= 4, "Too many indexed arguments.");
|
||||
if (!event.IsAnonymous())
|
||||
{
|
||||
m_context << u256(h256::Arith(dev::sha3(function.getCanonicalSignature(event.getName()))));
|
||||
++numIndexed;
|
||||
}
|
||||
solAssert(numIndexed <= 4 - (event.IsAnonymous() ? 1 : 0), "Too many indexed arguments.");
|
||||
// Copy all non-indexed arguments to memory (data)
|
||||
m_context << u256(0);
|
||||
for (unsigned arg = 0; arg < arguments.size(); ++arg)
|
||||
|
@ -70,6 +70,7 @@ std::unique_ptr<std::string> InterfaceHandler::getABIInterface(ContractDefinitio
|
||||
Json::Value event;
|
||||
event["type"] = "event";
|
||||
event["name"] = it->getName();
|
||||
//todo add anonymous!;
|
||||
Json::Value params(Json::arrayValue);
|
||||
for (auto const& p: it->getParameters())
|
||||
{
|
||||
|
@ -388,6 +388,12 @@ ASTPointer<EventDefinition> Parser::parseEventDefinition()
|
||||
docstring = make_shared<ASTString>(m_scanner->getCurrentCommentLiteral());
|
||||
|
||||
expectToken(Token::Event);
|
||||
bool anonymous = false;
|
||||
if (m_scanner->getCurrentToken() == Token::Anonymous)
|
||||
{
|
||||
anonymous = true;
|
||||
m_scanner->next();
|
||||
}
|
||||
ASTPointer<ASTString> name(expectIdentifierToken());
|
||||
ASTPointer<ParameterList> parameters;
|
||||
if (m_scanner->getCurrentToken() == Token::LParen)
|
||||
@ -396,7 +402,7 @@ ASTPointer<EventDefinition> Parser::parseEventDefinition()
|
||||
parameters = createEmptyParameterList();
|
||||
nodeFactory.markEndPosition();
|
||||
expectToken(Token::Semicolon);
|
||||
return nodeFactory.createNode<EventDefinition>(name, docstring, parameters);
|
||||
return nodeFactory.createNode<EventDefinition>(name, docstring, parameters, anonymous);
|
||||
}
|
||||
|
||||
ASTPointer<ModifierInvocation> Parser::parseModifierInvocation()
|
||||
|
Loading…
Reference in New Issue
Block a user