#include "segment.h" #include "operators.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(chunk).name() == label) { return address; } } } throw std::runtime_error("Bad label: "s + label); } std::vector Segment::getCode() { std::vector result; for (const auto& chunk: *this) result = result + chunk->getCode(); return result; } void Segment::insertAddresses() { } void Segment::optimize() { // TODO }