Update code to review comments

This commit is contained in:
wechman
2022-09-28 12:05:41 +02:00
parent dd251379e7
commit d3d28e96a8
2 changed files with 12 additions and 12 deletions
@@ -680,6 +680,11 @@ bool IRGeneratorForStatements::visit(UnaryOperation const& _unaryOperation)
// TODO extract from function call
FunctionDefinition const& function = *_unaryOperation.annotation().userDefinedFunction;
solAssert(
dynamic_cast<SourceUnit const*>(function.scope()),
"Only file-level functions and library functions can be bound to a user type operator."
);
FunctionType const* functionType = dynamic_cast<FunctionType const*>(
function.libraryFunction() ? function.typeViaContractName() : function.type()
);
@@ -687,8 +692,6 @@ bool IRGeneratorForStatements::visit(UnaryOperation const& _unaryOperation)
functionType = dynamic_cast<FunctionType const&>(*functionType).asBoundFunction();
solAssert(functionType);
// TODO virtual?
string parameter = expressionAsType(_unaryOperation.subExpression(), *functionType->selfType());
solAssert(!parameter.empty());
solAssert(function.isImplemented(), "");
@@ -812,6 +815,11 @@ bool IRGeneratorForStatements::visit(BinaryOperation const& _binOp)
// TODO extract from function call
FunctionDefinition const& function = *_binOp.annotation().userDefinedFunction;
solAssert(
dynamic_cast<SourceUnit const*>(function.scope()),
"Only file-level functions and library functions can be bound to a user type operator."
);
FunctionType const* functionType = dynamic_cast<FunctionType const*>(
function.libraryFunction() ? function.typeViaContractName() : function.type()
);
@@ -819,8 +827,6 @@ bool IRGeneratorForStatements::visit(BinaryOperation const& _binOp)
functionType = dynamic_cast<FunctionType const&>(*functionType).asBoundFunction();
solAssert(functionType);
// TODO virtual?
string left = expressionAsType(_binOp.leftExpression(), *functionType->selfType());
string right = expressionAsType(_binOp.rightExpression(), *functionType->parameterTypes().at(0));
solAssert(!left.empty() && !right.empty());