blob: db8394175c2cc962b66c92dd5c3970aef1323d68 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#include "segment.h"
using namespace std::string_literals;
size_t Segment::getAddressOfLabel(const std::string& label)
{
size_t address{0};
auto i{begin()};
while (i != end()) {
Chunk& chunk{**i};
address += chunk.size();
if (typeid(chunk) == typeid(Label)) {
if (dynamic_cast<Label&>(chunk).name() == label) {
return address;
}
}
}
throw std::runtime_error("Bad label: "s + label);
}
|