mirror of
https://github.com/irmen/prog8.git
synced 2024-07-30 01:29:08 +00:00
made stackvm source a bit more readable
This commit is contained in:
parent
00baec12ab
commit
0f53f87895
@ -602,6 +602,10 @@ open class Instruction(val opcode: Opcode,
|
|||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
val argStr = arg?.toString() ?: ""
|
val argStr = arg?.toString() ?: ""
|
||||||
|
val opcodesWithVarArgument = setOf(
|
||||||
|
Opcode.INC_VAR, Opcode.DEC_VAR,
|
||||||
|
Opcode.SHR_VAR, Opcode.SHL_VAR, Opcode.ROL_VAR, Opcode.ROR_VAR,
|
||||||
|
Opcode.ROL2_VAR, Opcode.ROR2_VAR, Opcode.POP_VAR, Opcode.PUSH_VAR)
|
||||||
val result =
|
val result =
|
||||||
when {
|
when {
|
||||||
opcode==Opcode.LINE -> "_line ${arg!!.stringvalue}"
|
opcode==Opcode.LINE -> "_line ${arg!!.stringvalue}"
|
||||||
@ -609,6 +613,10 @@ open class Instruction(val opcode: Opcode,
|
|||||||
val syscall = Syscall.values().find { it.callNr==arg!!.numericValue() }
|
val syscall = Syscall.values().find { it.callNr==arg!!.numericValue() }
|
||||||
"syscall $syscall"
|
"syscall $syscall"
|
||||||
}
|
}
|
||||||
|
opcodesWithVarArgument.contains(opcode) -> {
|
||||||
|
// opcodes that manipulate a variable
|
||||||
|
"${opcode.toString().toLowerCase()} ${argStr.substring(1, argStr.length-1)}"
|
||||||
|
}
|
||||||
callLabel==null -> "${opcode.toString().toLowerCase()} $argStr"
|
callLabel==null -> "${opcode.toString().toLowerCase()} $argStr"
|
||||||
else -> "${opcode.toString().toLowerCase()} $callLabel $argStr"
|
else -> "${opcode.toString().toLowerCase()} $callLabel $argStr"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user