Minor fixes in address resolving.
This commit is contained in:
@@ -18,23 +18,29 @@ uint64_t Address::resolve(BEd &ctx) {
|
|||||||
} else if constexpr (std::is_same_v<T, Number>) {
|
} else if constexpr (std::is_same_v<T, Number>) {
|
||||||
line = addr.i;
|
line = addr.i;
|
||||||
} else if constexpr (std::is_same_v<T, Block>) {
|
} else if constexpr (std::is_same_v<T, Block>) {
|
||||||
|
uint64_t current_line = ctx.active->line;
|
||||||
|
if (ctx.active->vase.lines() > 0 && current_line == 0)
|
||||||
|
current_line = 1;
|
||||||
if (addr.dir == Direction::Forward) {
|
if (addr.dir == Direction::Forward) {
|
||||||
if (ctx.active->parser) {
|
if (ctx.active->parser) {
|
||||||
if (ctx.active->line == 0)
|
uint64_t closing = ctx.active->parser->next_closing(current_line - 1);
|
||||||
ctx.active->line = 1;
|
if (closing == UINT64_MAX)
|
||||||
line = ctx.active->parser->next_closing(ctx.active->line - 1) + 1;
|
line = ctx.active->vase.lines();
|
||||||
|
else
|
||||||
|
line = closing + 1;
|
||||||
|
} else {
|
||||||
|
line = current_line + 10;
|
||||||
if (line > ctx.active->vase.lines())
|
if (line > ctx.active->vase.lines())
|
||||||
line = ctx.active->vase.lines();
|
line = ctx.active->vase.lines();
|
||||||
} else {
|
|
||||||
line = ctx.active->line + 10;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ctx.active->parser) {
|
if (ctx.active->parser) {
|
||||||
if (ctx.active->line == 0)
|
line = ctx.active->parser->prev_opening(current_line - 1) + 1;
|
||||||
ctx.active->line = 1;
|
|
||||||
line = ctx.active->parser->prev_opening(ctx.active->line - 1) + 1;
|
|
||||||
} else {
|
} else {
|
||||||
line = ctx.active->line - 10;
|
if (current_line > 10)
|
||||||
|
line = current_line - 10;
|
||||||
|
else
|
||||||
|
line = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ void Command::register_posix(BEd &ctx) {
|
|||||||
.address_mode = Command::AddressMode::Single,
|
.address_mode = Command::AddressMode::Single,
|
||||||
.suffix = Command::SuffixKind::Suffix,
|
.suffix = Command::SuffixKind::Suffix,
|
||||||
.desc = "Print line number",
|
.desc = "Print line number",
|
||||||
.accept_zero = false,
|
.accept_zero = true,
|
||||||
.handle = [](BEd &ctx, std::span<const uint64_t> addresses, std::string_view) {
|
.handle = [](BEd &ctx, std::span<const uint64_t> addresses, std::string_view) {
|
||||||
if (!addresses.size())
|
if (!addresses.size())
|
||||||
std::cout << ctx.active->vase.lines() << std::endl;
|
std::cout << ctx.active->vase.lines() << std::endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user