mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Update code to review comments
This commit is contained in:
@@ -416,7 +416,8 @@ bool ExpressionCompiler::visit(UnaryOperation const& _unaryOperation)
|
||||
solAssert(function->isFree(), "Only free functions can be bound to a user type operator.");
|
||||
|
||||
FunctionType const* functionType = dynamic_cast<FunctionType const*>(
|
||||
function->libraryFunction() ? function->typeViaContractName() : function->type());
|
||||
function->libraryFunction() ? function->typeViaContractName() : function->type()
|
||||
);
|
||||
solAssert(functionType);
|
||||
|
||||
functionType = dynamic_cast<FunctionType const&>(*functionType).asBoundFunction();
|
||||
|
||||
@@ -694,21 +694,22 @@ bool IRGeneratorForStatements::visit(UnaryOperation const& _unaryOperation)
|
||||
"Functions with parameters other than self parameter cannot be bound to a user type unary operator."
|
||||
);
|
||||
|
||||
string parameter = expressionAsType(_unaryOperation.subExpression(), *functionType->selfType());
|
||||
solAssert(!parameter.empty());
|
||||
string argument = expressionAsType(_unaryOperation.subExpression(), *functionType->selfType());
|
||||
solAssert(!argument.empty());
|
||||
solAssert(function->isImplemented(), "");
|
||||
|
||||
solAssert(
|
||||
function->returnParameters().size() == 1,
|
||||
"A function bound to the user type operator is supposed to return exactly one value."
|
||||
);
|
||||
solAssert(*_unaryOperation.annotation().type == *function->returnParameters().at(0)->type(),
|
||||
solAssert(
|
||||
*_unaryOperation.annotation().type == *function->returnParameters().at(0)->type(),
|
||||
"A return type of the bound function is supposed to be same as a operator type."
|
||||
);
|
||||
|
||||
define(_unaryOperation) <<
|
||||
m_context.enqueueFunctionForCodeGeneration(*function) <<
|
||||
("(" + parameter + ")\n");
|
||||
("(" + argument + ")\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user