1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

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

This commit is contained in:
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

View File

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