| 170 | } |
| 171 | |
| 172 | std::vector<evmasm::SubAssemblyID> Object::pathToSubObject(std::string_view _qualifiedName) const |
| 173 | { |
| 174 | yulAssert(_qualifiedName != name, ""); |
| 175 | yulAssert(subIndexByName.count(name) == 0, ""); |
| 176 | |
| 177 | if (boost::algorithm::starts_with(_qualifiedName, name + ".")) |
| 178 | _qualifiedName = _qualifiedName.substr(name.length() + 1); |
| 179 | yulAssert(!_qualifiedName.empty(), ""); |
| 180 | |
| 181 | std::vector<std::string> subObjectPathComponents; |
| 182 | boost::algorithm::split(subObjectPathComponents, _qualifiedName, boost::is_any_of(".")); |
| 183 | |
| 184 | std::vector<evmasm::SubAssemblyID> path; |
| 185 | Object const* object = this; |
| 186 | for (std::string const& currentSubObjectName: subObjectPathComponents) |
| 187 | { |
| 188 | yulAssert(!currentSubObjectName.empty(), ""); |
| 189 | auto subIndexIt = object->subIndexByName.find(currentSubObjectName); |
| 190 | yulAssert( |
| 191 | subIndexIt != object->subIndexByName.end(), |
| 192 | "Assembly object <" + std::string(_qualifiedName) + "> not found or does not contain code." |
| 193 | ); |
| 194 | object = dynamic_cast<Object const*>(object->subObjects[subIndexIt->second].get()); |
| 195 | yulAssert(object, "Assembly object <" + std::string(_qualifiedName) + "> not found or does not contain code."); |
| 196 | yulAssert(!object->subId.empty()); |
| 197 | path.emplace_back(object->subId); |
| 198 | } |
| 199 | |
| 200 | return path; |
| 201 | } |
| 202 | |
| 203 | std::shared_ptr<AST const> Object::code() const |
| 204 | { |