romainguy / kotlin-explorer

Desktop tool to quickly explore disassembled Kotlin code.
Apache License 2.0
782 stars 23 forks source link

Add a Code Model #30

Closed alonalbert closed 5 months ago

alonalbert commented 5 months ago

This makes it easier to detect jumps and toggle show-line-number

alonalbert commented 5 months ago

Regarding the indentations, I changed things up a bit.

Note that we have to account for long line numbers so:

class Foo
    <init>()V // Foo.<init>()
        1:    0000: invoke-direct {v0}, Ljava/lang/Object;.<init>:()V // method@0008
              0003: return-void

Might seem to sparse, but when line numbers get big:

    <init>()V // Foo.<init>()
        1000: 0000: invoke-direct {v0}, Ljava/lang/Object;.<init>:()V // method@0008
              0003: return-void

It makes sense.

I have a plan to use the max line number to derive the width, but will leave this to a future cl.

alonalbert commented 5 months ago

FYI, the OAT parser has a bug in ti. Infinte loop sometimes I'm investigating

alonalbert commented 5 months ago

OK, fixed it.

romainguy commented 5 months ago

Note that we have to account for long line numbers so

That's what I thought. Have you tried eating up into the left indent instead? I don't know how pretty it would look but something like this:

class Foo
    <init>()V // Foo.<init>()
1:      0000: invoke-direct {v0}, Ljava/lang/Object;.<init>:()V // method@0008
        0003: return-void
    <bar>()V // Foo.<init>()
1000:   0000: invoke-direct {v0}, Ljava/lang/Object;.<init>:()V // method@0008
        0003: return-void