mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Try out the new assertion macro variants with less arguments
This commit is contained in:
@@ -2112,8 +2112,7 @@ bool ExpressionCompiler::visit(IndexRangeAccess const& _indexAccess)
|
||||
solUnimplementedAssert(
|
||||
arrayType->location() == DataLocation::CallData &&
|
||||
arrayType->isDynamicallySized() &&
|
||||
!arrayType->baseType()->isDynamicallyEncoded(),
|
||||
""
|
||||
!arrayType->baseType()->isDynamicallyEncoded()
|
||||
);
|
||||
|
||||
if (_indexAccess.startExpression())
|
||||
|
||||
@@ -155,7 +155,7 @@ ImmutableItem::ImmutableItem(CompilerContext& _compilerContext, VariableDeclarat
|
||||
|
||||
void ImmutableItem::retrieveValue(SourceLocation const&, bool) const
|
||||
{
|
||||
solUnimplementedAssert(m_dataType->isValueType(), "");
|
||||
solUnimplementedAssert(m_dataType->isValueType());
|
||||
|
||||
if (m_context.runtimeContext())
|
||||
CompilerUtils(m_context).loadFromMemory(
|
||||
@@ -172,7 +172,7 @@ void ImmutableItem::retrieveValue(SourceLocation const&, bool) const
|
||||
void ImmutableItem::storeValue(Type const& _sourceType, SourceLocation const&, bool _move) const
|
||||
{
|
||||
CompilerUtils utils(m_context);
|
||||
solUnimplementedAssert(m_dataType->isValueType(), "");
|
||||
solUnimplementedAssert(m_dataType->isValueType());
|
||||
solAssert(_sourceType.isValueType(), "");
|
||||
|
||||
utils.convertType(_sourceType, *m_dataType, true);
|
||||
|
||||
@@ -1217,7 +1217,7 @@ string YulUtilFunctions::extractByteArrayLengthFunction()
|
||||
std::string YulUtilFunctions::resizeArrayFunction(ArrayType const& _type)
|
||||
{
|
||||
solAssert(_type.location() == DataLocation::Storage, "");
|
||||
solUnimplementedAssert(_type.baseType()->storageBytes() <= 32, "...");
|
||||
solUnimplementedAssert(_type.baseType()->storageBytes() <= 32);
|
||||
|
||||
if (_type.isByteArray())
|
||||
return resizeDynamicByteArrayFunction(_type);
|
||||
@@ -1259,7 +1259,7 @@ string YulUtilFunctions::cleanUpStorageArrayEndFunction(ArrayType const& _type)
|
||||
solAssert(_type.location() == DataLocation::Storage, "");
|
||||
solAssert(_type.baseType()->category() != Type::Category::Mapping, "");
|
||||
solAssert(!_type.isByteArray(), "");
|
||||
solUnimplementedAssert(_type.baseType()->storageBytes() <= 32, "");
|
||||
solUnimplementedAssert(_type.baseType()->storageBytes() <= 32);
|
||||
|
||||
string functionName = "cleanup_storage_array_end_" + _type.identifier();
|
||||
return m_functionCollector.createFunction(functionName, [&](vector<string>& _args, vector<string>&) {
|
||||
@@ -1555,7 +1555,7 @@ string YulUtilFunctions::storageArrayPushFunction(ArrayType const& _type, Type c
|
||||
if (!_fromType)
|
||||
_fromType = _type.baseType();
|
||||
else if (_fromType->isValueType())
|
||||
solUnimplementedAssert(*_fromType == *_type.baseType(), "");
|
||||
solUnimplementedAssert(*_fromType == *_type.baseType());
|
||||
|
||||
string functionName =
|
||||
string{"array_push_from_"} +
|
||||
@@ -3304,10 +3304,10 @@ string YulUtilFunctions::conversionFunction(Type const& _from, Type const& _to)
|
||||
if (auto const* toFixedBytes = dynamic_cast<FixedBytesType const*>(&_to))
|
||||
convert = shiftLeftFunction(256 - toFixedBytes->numBytes() * 8);
|
||||
else if (dynamic_cast<FixedPointType const*>(&_to))
|
||||
solUnimplementedAssert(false, "");
|
||||
solUnimplemented("");
|
||||
else if (dynamic_cast<IntegerType const*>(&_to))
|
||||
{
|
||||
solUnimplementedAssert(fromCategory != Type::Category::FixedPoint, "");
|
||||
solUnimplementedAssert(fromCategory != Type::Category::FixedPoint);
|
||||
convert = identityFunction();
|
||||
}
|
||||
else if (toCategory == Type::Category::Enum)
|
||||
@@ -3346,8 +3346,8 @@ string YulUtilFunctions::conversionFunction(Type const& _from, Type const& _to)
|
||||
body = "converted := value";
|
||||
else
|
||||
{
|
||||
solUnimplementedAssert(toStructType.location() == DataLocation::Memory, "");
|
||||
solUnimplementedAssert(fromStructType.location() != DataLocation::Memory, "");
|
||||
solUnimplementedAssert(toStructType.location() == DataLocation::Memory);
|
||||
solUnimplementedAssert(fromStructType.location() != DataLocation::Memory);
|
||||
|
||||
if (fromStructType.location() == DataLocation::CallData)
|
||||
body = Whiskers(R"(
|
||||
@@ -3416,7 +3416,7 @@ string YulUtilFunctions::conversionFunction(Type const& _from, Type const& _to)
|
||||
}
|
||||
case Type::Category::Tuple:
|
||||
{
|
||||
solUnimplementedAssert(false, "Tuple conversion not implemented.");
|
||||
solUnimplemented("Tuple conversion not implemented.");
|
||||
break;
|
||||
}
|
||||
case Type::Category::TypeType:
|
||||
@@ -4107,7 +4107,7 @@ string YulUtilFunctions::zeroValueFunction(Type const& _type, bool _splitFunctio
|
||||
else if (auto const* structType = dynamic_cast<StructType const*>(&_type))
|
||||
templ("zeroValue", allocateAndInitializeMemoryStructFunction(*structType) + "()");
|
||||
else
|
||||
solUnimplementedAssert(false, "");
|
||||
solUnimplemented("");
|
||||
}
|
||||
|
||||
return templ.render();
|
||||
|
||||
@@ -544,7 +544,7 @@ string IRGenerator::generateGetter(VariableDeclaration const& _varDecl)
|
||||
if (_varDecl.immutable())
|
||||
{
|
||||
solAssert(paramTypes.empty(), "");
|
||||
solUnimplementedAssert(type->sizeOnStack() == 1, "");
|
||||
solUnimplementedAssert(type->sizeOnStack() == 1);
|
||||
return Whiskers(R"(
|
||||
/// @ast-id <astID>
|
||||
<sourceLocationComment>
|
||||
@@ -925,8 +925,8 @@ string IRGenerator::deployCode(ContractDefinition const& _contract)
|
||||
else
|
||||
for (VariableDeclaration const* immutable: ContractType(_contract).immutableVariables())
|
||||
{
|
||||
solUnimplementedAssert(immutable->type()->isValueType(), "");
|
||||
solUnimplementedAssert(immutable->type()->sizeOnStack() == 1, "");
|
||||
solUnimplementedAssert(immutable->type()->isValueType());
|
||||
solUnimplementedAssert(immutable->type()->sizeOnStack() == 1);
|
||||
immutables.emplace_back(map<string, string>{
|
||||
{"immutableName"s, to_string(immutable->id())},
|
||||
{"value"s, "mload(" + to_string(m_context.immutableMemoryOffset(*immutable)) + ")"}
|
||||
|
||||
@@ -108,7 +108,7 @@ private:
|
||||
{
|
||||
auto const& reference = m_references.at(&_identifier);
|
||||
auto const varDecl = dynamic_cast<VariableDeclaration const*>(reference.declaration);
|
||||
solUnimplementedAssert(varDecl, "");
|
||||
solUnimplementedAssert(varDecl);
|
||||
string const& suffix = reference.suffix;
|
||||
|
||||
string value;
|
||||
@@ -737,7 +737,7 @@ bool IRGeneratorForStatements::visit(UnaryOperation const& _unaryOperation)
|
||||
) << "(" << IRVariable(_unaryOperation.subExpression()).name() << ")\n";
|
||||
}
|
||||
else
|
||||
solUnimplementedAssert(false, "Unary operator not yet implemented");
|
||||
solUnimplemented("Unary operator not yet implemented");
|
||||
}
|
||||
else if (resultType.category() == Type::Category::FixedBytes)
|
||||
{
|
||||
@@ -755,7 +755,7 @@ bool IRGeneratorForStatements::visit(UnaryOperation const& _unaryOperation)
|
||||
appendSimpleUnaryOperation(_unaryOperation, _unaryOperation.subExpression());
|
||||
}
|
||||
else
|
||||
solUnimplementedAssert(false, "Unary operator not yet implemented");
|
||||
solUnimplemented("Unary operator not yet implemented");
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -1546,7 +1546,7 @@ void IRGeneratorForStatements::endVisit(FunctionCallOptions const& _options)
|
||||
setLocation(_options);
|
||||
FunctionType const& previousType = dynamic_cast<FunctionType const&>(*_options.expression().annotation().type);
|
||||
|
||||
solUnimplementedAssert(!previousType.bound(), "");
|
||||
solUnimplementedAssert(!previousType.bound());
|
||||
|
||||
// Copy over existing values.
|
||||
for (auto const& item: previousType.stackItems())
|
||||
@@ -1716,7 +1716,7 @@ void IRGeneratorForStatements::endVisit(MemberAccess const& _memberAccess)
|
||||
{
|
||||
solUnimplementedAssert(
|
||||
dynamic_cast<FunctionType const&>(*_memberAccess.expression().annotation().type).kind() ==
|
||||
FunctionType::Kind::External, ""
|
||||
FunctionType::Kind::External
|
||||
);
|
||||
define(IRVariable{_memberAccess}, IRVariable(_memberAccess.expression()).part("address"));
|
||||
}
|
||||
@@ -2264,7 +2264,7 @@ void IRGeneratorForStatements::endVisit(IndexRangeAccess const& _indexRangeAcces
|
||||
break;
|
||||
}
|
||||
default:
|
||||
solUnimplementedAssert(false, "Index range accesses is implemented only on calldata arrays.");
|
||||
solUnimplemented("Index range accesses is implemented only on calldata arrays.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2910,8 +2910,8 @@ void IRGeneratorForStatements::writeToLValue(IRLValue const& _lvalue, IRVariable
|
||||
[&](IRLValue::Stack const& _stack) { assign(_stack.variable, _value); },
|
||||
[&](IRLValue::Immutable const& _immutable)
|
||||
{
|
||||
solUnimplementedAssert(_lvalue.type.isValueType(), "");
|
||||
solUnimplementedAssert(_lvalue.type.sizeOnStack() == 1, "");
|
||||
solUnimplementedAssert(_lvalue.type.isValueType());
|
||||
solUnimplementedAssert(_lvalue.type.sizeOnStack() == 1);
|
||||
solAssert(_lvalue.type == *_immutable.variable->type(), "");
|
||||
size_t memOffset = m_context.immutableMemoryOffset(*_immutable.variable);
|
||||
|
||||
@@ -2970,8 +2970,8 @@ IRVariable IRGeneratorForStatements::readFromLValue(IRLValue const& _lvalue)
|
||||
define(result, _stack.variable);
|
||||
},
|
||||
[&](IRLValue::Immutable const& _immutable) {
|
||||
solUnimplementedAssert(_lvalue.type.isValueType(), "");
|
||||
solUnimplementedAssert(_lvalue.type.sizeOnStack() == 1, "");
|
||||
solUnimplementedAssert(_lvalue.type.isValueType());
|
||||
solUnimplementedAssert(_lvalue.type.sizeOnStack() == 1);
|
||||
solAssert(_lvalue.type == *_immutable.variable->type(), "");
|
||||
if (m_context.executionContext() == IRGenerationContext::ExecutionContext::Creation)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user