[SMTChecker] Support type(I).interfaceId

This commit is contained in:
Alex Beregszaszi
2020-09-14 20:34:52 +01:00
parent 552a5f0913
commit 83934254ea
3 changed files with 42 additions and 1 deletions
+9
View File
@@ -888,6 +888,15 @@ bool SMTEncoder::visit(MemberAccess const& _memberAccess)
IntegerType const& integerType = dynamic_cast<IntegerType const&>(*magicType->typeArgument());
defineExpr(_memberAccess, memberName == "min" ? integerType.minValue() : integerType.maxValue());
}
else if (memberName == "interfaceId")
{
// TODO: move this calculation into ContractDefinition and share with ExpressionCompiler
ContractDefinition const& contract = dynamic_cast<ContractType const&>(*magicType->typeArgument()).contractDefinition();
uint64_t result{0};
for (auto const& function: contract.interfaceFunctionList(false))
result ^= fromBigEndian<uint64_t>(function.first.ref());
defineExpr(_memberAccess, result);
}
else
// NOTE: supporting name, creationCode, runtimeCode would be easy enough, but the bytes/string they return are not
// at all useable in the SMT checker currently