Adding bytes.concat function type.

This commit is contained in:
Djordje Mijovic 2021-02-24 16:24:23 +01:00
parent a27c9c39b2
commit 1493326e48
4 changed files with 27 additions and 0 deletions

View File

@ -2877,6 +2877,7 @@ string FunctionType::richIdentifier() const
case Kind::MulMod: id += "mulmod"; break;
case Kind::ArrayPush: id += "arraypush"; break;
case Kind::ArrayPop: id += "arraypop"; break;
case Kind::BytesConcat: id += "bytesconcat"; break;
case Kind::ObjectCreation: id += "objectcreation"; break;
case Kind::Assert: id += "assert"; break;
case Kind::Require: id += "require"; break;
@ -3736,6 +3737,20 @@ MemberList::MemberMap TypeType::nativeMembers(ASTNode const* _currentScope) cons
for (ASTPointer<EnumValue> const& enumValue: enumDef.members())
members.emplace_back(enumValue.get(), enumType);
}
else if (
auto const* arrayType = dynamic_cast<ArrayType const*>(m_actualType);
arrayType && arrayType->isByteArray()
)
members.emplace_back("concat", TypeProvider::function(
TypePointers{},
TypePointers{TypeProvider::bytesMemory()},
strings{},
strings{string()},
FunctionType::Kind::BytesConcat,
/* _arbitraryParameters */ true,
StateMutability::Pure
));
return members;
}

View File

@ -1158,6 +1158,7 @@ public:
MulMod, ///< MULMOD
ArrayPush, ///< .push() to a dynamically sized array in storage
ArrayPop, ///< .pop() from a dynamically sized array in storage
BytesConcat, ///< .concat() on bytes (type type)
ObjectCreation, ///< array creation using new
Assert, ///< assert()
Require, ///< require()

View File

@ -1021,6 +1021,12 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
ArrayUtils(m_context).popStorageArrayElement(*arrayType);
break;
}
case FunctionType::Kind::BytesConcat:
{
_functionCall.expression().accept(*this);
solUnimplementedAssert(false, "Bytes concat not implemented in codegen yet.");
break;
}
case FunctionType::Kind::ObjectCreation:
{
ArrayType const& arrayType = dynamic_cast<ArrayType const&>(*_functionCall.annotation().type);

View File

@ -1323,6 +1323,11 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall)
}
break;
}
case FunctionType::Kind::BytesConcat:
{
solUnimplementedAssert(false, "bytes.concat not yet implemented in codegen.");
break;
}
case FunctionType::Kind::MetaType:
{
break;