[Wasm] Indent blocks of produced WAT

Makes it more readable
This commit is contained in:
Svyatoslav Kuzmich
2020-11-04 16:12:31 +03:00
parent 4d59a58291
commit b371b61cf5
@@ -59,8 +59,16 @@ class WasmIrToText : SExpressionBuilder() {
}
private fun appendInstr(wasmInstr: WasmInstr) {
val op = wasmInstr.operator
if (op == WasmOp.END || op == WasmOp.ELSE)
indent--
newLine()
stringBuilder.append(wasmInstr.operator.mnemonic)
if (op == WasmOp.BLOCK || op == WasmOp.LOOP || op == WasmOp.IF || op == WasmOp.ELSE)
indent++
if (wasmInstr.operator in setOf(WasmOp.CALL_INDIRECT, WasmOp.TABLE_INIT)) {
wasmInstr.immediates.reversed().forEach {
appendImmediate(it)