-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
119 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
modules/abcde/src/commonMain/kotlin/me/yricky/oh/abcd/isa/util/V2AInstParser.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package me.yricky.oh.abcd.isa.util | ||
|
||
import me.yricky.oh.abcd.isa.Asm | ||
import me.yricky.oh.abcd.isa.InstFmt | ||
|
||
object V2AInstParser:InstDisAsmParser { | ||
override fun id(): String = "${InstDisAsmParser.ID_PREFIX}.v2a" | ||
override fun title(): String = "参数寄存器解析插件" | ||
override fun description(): String = "解析字节码中的参数寄存器" | ||
|
||
override fun parseArg(asmItem: Asm.AsmItem, index: Int): String? { | ||
val arg = asmItem.opUnits[index] | ||
val format = asmItem.ins.format | ||
return when(format[index]){ | ||
is InstFmt.RegV -> { | ||
val v = arg.toInt() | ||
val vRegs = asmItem.asm.code.numVRegs | ||
if (v < vRegs) "v${v}" else when(val aIndex = v - vRegs){ | ||
0 -> "FunctionObject" | ||
1 -> "NewTarget" | ||
2 -> "this" | ||
else -> "arg${aIndex - 3}" | ||
} | ||
} | ||
else -> null | ||
} | ||
} | ||
} |