mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
do not use Object::pathToSubObject in getSubObject
This commit is contained in:
parent
3078ab2d9c
commit
97fc74f74d
@ -100,7 +100,6 @@ std::shared_ptr<Object> ObjectParser::parseObject(Object* _containingObject)
|
|||||||
}
|
}
|
||||||
if (_containingObject)
|
if (_containingObject)
|
||||||
{
|
{
|
||||||
ret->subId = _containingObject->subObjects.size();
|
|
||||||
addNamedSubObject(*_containingObject, ret->name, ret);
|
addNamedSubObject(*_containingObject, ret->name, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,18 +87,38 @@ public:
|
|||||||
}.printErrorInformation(_errors);
|
}.printErrorInformation(_errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<Object> getSubObject(shared_ptr<Object> const& _rootObject, string const& _path)
|
shared_ptr<Object> getSubObject(shared_ptr<Object> const& _object, string const& _path)
|
||||||
{
|
{
|
||||||
if (_path.empty())
|
if (_path.empty() || _path == _object->name.str())
|
||||||
return _rootObject;
|
return _object;
|
||||||
|
|
||||||
auto pathToSubObject = _rootObject->pathToSubObject(YulString(_path));
|
yulAssert(
|
||||||
auto subObject = _rootObject;
|
boost::algorithm::starts_with(_path, _object->name.str() + "."),
|
||||||
|
"Assembly object not found."
|
||||||
|
);
|
||||||
|
|
||||||
for (auto const& i: pathToSubObject)
|
const auto subObjectPath = _path.substr(_object->name.str().length() + 1);
|
||||||
subObject = dynamic_pointer_cast<Object>(subObject->subObjects[i]);
|
const auto subObjectName = subObjectPath.substr(0, subObjectPath.find_first_of('.'));
|
||||||
|
|
||||||
return subObject;
|
auto subObjectIt = find_if(
|
||||||
|
_object->subObjects.begin(),
|
||||||
|
_object->subObjects.end(),
|
||||||
|
[subObjectName](auto const& subObject) { return subObject->name.str() == subObjectName; }
|
||||||
|
);
|
||||||
|
|
||||||
|
yulAssert(
|
||||||
|
subObjectIt != _object->subObjects.end(),
|
||||||
|
"Assembly object not found."
|
||||||
|
);
|
||||||
|
|
||||||
|
auto subObject = dynamic_pointer_cast<Object>(*subObjectIt);
|
||||||
|
|
||||||
|
yulAssert(
|
||||||
|
subObject != nullptr,
|
||||||
|
"Assembly object may not contain code."
|
||||||
|
);
|
||||||
|
|
||||||
|
return getSubObject(subObject, subObjectPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void parse(string const& _input, string const& _objectPath)
|
void parse(string const& _input, string const& _objectPath)
|
||||||
|
Loading…
Reference in New Issue
Block a user