mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Restore efficient subobject search
This commit is contained in:
parent
98b5b6c916
commit
1ec239c63f
@ -33,7 +33,6 @@
|
|||||||
#include <boost/algorithm/string/split.hpp>
|
#include <boost/algorithm/string/split.hpp>
|
||||||
#include <boost/algorithm/string/replace.hpp>
|
#include <boost/algorithm/string/replace.hpp>
|
||||||
|
|
||||||
#include <range/v3/algorithm/find_if.hpp>
|
|
||||||
#include <range/v3/view/transform.hpp>
|
#include <range/v3/view/transform.hpp>
|
||||||
|
|
||||||
using namespace solidity;
|
using namespace solidity;
|
||||||
@ -53,6 +52,12 @@ std::string indent(std::string const& _input)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Object const* Object::at(YulString _name) const
|
||||||
|
{
|
||||||
|
size_t subIndex = this->subIndexByName.at(_name);
|
||||||
|
return dynamic_cast<Object const*>(this->subObjects[subIndex].get());
|
||||||
|
}
|
||||||
|
|
||||||
std::string Data::toString(Dialect const*, DebugInfoSelection const&, CharStreamProvider const*) const
|
std::string Data::toString(Dialect const*, DebugInfoSelection const&, CharStreamProvider const*) const
|
||||||
{
|
{
|
||||||
return "data \"" + name.str() + "\" hex\"" + util::toHex(data) + "\"";
|
return "data \"" + name.str() + "\" hex\"" + util::toHex(data) + "\"";
|
||||||
@ -156,22 +161,15 @@ void Object::visitPath(YulString _qualifiedName, std::function<bool(Object const
|
|||||||
{
|
{
|
||||||
yulAssert(!currentSubObjectName.empty(), "");
|
yulAssert(!currentSubObjectName.empty(), "");
|
||||||
|
|
||||||
auto subObjectIt = ranges::find_if(
|
YulString subObjectName = YulString{currentSubObjectName};
|
||||||
object->subObjects,
|
yulAssert(
|
||||||
[¤tSubObjectName](auto const& _subObject) { return _subObject->name.str() == currentSubObjectName; }
|
object->subIndexByName.count(subObjectName),
|
||||||
|
"Assembly object not found or does not contain code."
|
||||||
);
|
);
|
||||||
|
object = object->at(subObjectName);
|
||||||
if (subObjectIt != object->subObjects.end())
|
if (object && _visitor(object))
|
||||||
{
|
|
||||||
object = dynamic_cast<Object const*>(subObjectIt->get());
|
|
||||||
if (object)
|
|
||||||
{
|
|
||||||
yulAssert(object, "Assembly object <" + object->name.str() + "> not found or does not contain code.");
|
|
||||||
if (_visitor(object))
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<size_t> Object::pathToSubObject(YulString _qualifiedName) const
|
std::vector<size_t> Object::pathToSubObject(YulString _qualifiedName) const
|
||||||
|
@ -130,6 +130,8 @@ public:
|
|||||||
std::function<bool(Object const*)> _visitor
|
std::function<bool(Object const*)> _visitor
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
Object const* at(YulString _name) const;
|
||||||
|
|
||||||
/// sub id for object if it is subobject of another object, max value if it is not subobject
|
/// sub id for object if it is subobject of another object, max value if it is not subobject
|
||||||
size_t subId = std::numeric_limits<size_t>::max();
|
size_t subId = std::numeric_limits<size_t>::max();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user