Pass YulString instead of std::string to Object::subObjectAt

This commit is contained in:
r0qs 2023-09-22 14:29:14 +02:00
parent 84d3af4a29
commit b5d4e1d685
No known key found for this signature in database
GPG Key ID: 61503DBA6667276C
3 changed files with 8 additions and 8 deletions

View File

@ -190,7 +190,7 @@ std::vector<size_t> Object::pathToSubObject(YulString _qualifiedName) const
return path;
}
Object const* Object::subObjectAt(std::string const& _qualifiedName)
Object const* Object::subObjectAt(YulString _qualifiedName)
{
if (_qualifiedName.empty())
return nullptr;
@ -198,14 +198,14 @@ Object const* Object::subObjectAt(std::string const& _qualifiedName)
// If there is no `.` in the given `_qualifiedName`, the target
// object name is considered to be the `_qualifiedName`, otherwise,
// the target object name is the last element in the path given by `_qualifiedName`.
std::string targetObjectName = _qualifiedName;
size_t targetObjectPos = _qualifiedName.find_last_of(".");
YulString targetObjectName = _qualifiedName;
size_t targetObjectPos = _qualifiedName.str().find_last_of(".");
if (targetObjectPos != std::string::npos)
targetObjectName = _qualifiedName.substr(targetObjectPos + 1);
targetObjectName = YulString(_qualifiedName.str().substr(targetObjectPos + 1));
Object const* foundObject = nullptr;
this->visitPath(YulString(_qualifiedName), [&](Object const* _subObject) -> bool {
if (targetObjectName != _subObject->name.str())
this->visitPath(_qualifiedName, [&](Object const* _subObject) -> bool {
if (targetObjectName != _subObject->name)
return false;
foundObject = _subObject;
return true;

View File

@ -119,7 +119,7 @@ public:
/// Searches for a subobject at @param _qualifiedName within the current object.
/// @returns a pointer to the subobject or a nullptr if it was not found.
Object const* subObjectAt(std::string const& _qualifiedName);
Object const* subObjectAt(YulString _qualifiedName);
/// Visits all subobjects in the path given by the @a _qualifiedName
/// of the current object applying the function @a _visitor.

View File

@ -253,7 +253,7 @@ public:
{
if (!m_inputIsCodeBlock)
{
Object const* subObject = m_object->subObjectAt(_objectPath);
Object const* subObject = m_object->subObjectAt(YulString(_objectPath));
if (subObject == nullptr)
solThrow(Exception, "Assembly object not found.");