Fixing addressing

- Fix double resolve bug in address handler
- Fix multiple major issues with next_closing and prev_opening functions.
- add `=` ed command.
- Other minor fixes.
This commit is contained in:
2026-08-21 20:35:20 +01:00
parent 3e3fb6c39d
commit 556bb631f6
5 changed files with 73 additions and 52 deletions
+14 -11
View File
@@ -6,9 +6,7 @@ uint64_t Address::resolve(BEd &ctx) {
uint64_t result = std::visit(
[&](auto const &addr) -> uint64_t {
uint64_t line = 0;
using T = std::decay_t<decltype(addr)>;
if constexpr (std::is_same_v<T, std::monostate>) {
throw address_error("empty address");
} else if constexpr (std::is_same_v<T, None>) {
@@ -21,27 +19,32 @@ uint64_t Address::resolve(BEd &ctx) {
line = addr.i;
} else if constexpr (std::is_same_v<T, Block>) {
if (addr.dir == Direction::Forward) {
if (ctx.active->parser)
line = ctx.active->parser->next_closing(ctx.active->line);
else
if (ctx.active->parser) {
if (ctx.active->line == 0)
ctx.active->line = 1;
line = ctx.active->parser->next_closing(ctx.active->line - 1) + 1;
if (line > ctx.active->vase.lines())
line = ctx.active->vase.lines();
} else {
line = ctx.active->line + 10;
}
} else {
if (ctx.active->parser)
line = ctx.active->parser->prev_opening(ctx.active->line);
else
if (ctx.active->parser) {
if (ctx.active->line == 0)
ctx.active->line = 1;
line = ctx.active->parser->prev_opening(ctx.active->line - 1) + 1;
} else {
line = ctx.active->line - 10;
}
}
} else {
throw ed_error("Unhandled address given.");
}
if (offset < 0 && line < (uint64_t)-offset)
throw address_error("Can't have negative addresses");
line += offset;
if (line > ctx.active->vase.lines())
throw address_error("Line number too high.");
return line;
},
base