native: align the disassembly/comment column in the `-v -b native` output

pull/13724/head
Delyan Angelov 2022-03-12 11:08:32 +02:00
parent 40504e8600
commit 83762fa4a4
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
1 changed files with 11 additions and 4 deletions

View File

@ -7,6 +7,7 @@ import os
import strings
import v.ast
import v.util
import v.mathutil as mu
import v.token
import v.errors
import v.pref
@ -453,19 +454,25 @@ fn (mut g Gen) println(comment string) {
return
}
addr := g.debug_pos.hex()
mut sb := strings.new_builder(80)
// println('$g.debug_pos "$addr"')
print(term.red(strings.repeat(`0`, 6 - addr.len) + addr + ' '))
sb.write_string(term.red(strings.repeat(`0`, 6 - addr.len) + addr + ' '))
for i := g.debug_pos; i < g.pos(); i++ {
s := g.buf[i].hex()
if s.len == 1 {
print(term.blue('0'))
sb.write_string(term.blue('0'))
}
gbihex := g.buf[i].hex()
hexstr := term.blue(gbihex) + ' '
print(hexstr)
sb.write_string(hexstr)
}
g.debug_pos = g.buf.len
println(' ' + comment)
//
colored := sb.str()
plain := term.strip_ansi(colored)
padding := ' '.repeat(mu.max(1, 40 - plain.len))
final := '$colored$padding$comment'
println(final)
}
fn (mut g Gen) gen_forc_stmt(node ast.ForCStmt) {