Skip to content

Commit 67006ae

Browse files
committed
fix misc bugs
1 parent b30f072 commit 67006ae

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/wasm-compiler/constants.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const MAKE_COMPLEX_FX = wasm
5252
f64.store(i32.add(global.get(HEAP_PTR), i32.const(8)), local.get("$img")),
5353

5454
i32.const(TYPE_TAG.COMPLEX),
55-
i64.extend_i32_s(global.get(HEAP_PTR)),
55+
i64.extend_i32_u(global.get(HEAP_PTR)),
5656

5757
global.set(HEAP_PTR, i32.add(global.get(HEAP_PTR), i32.const(16)))
5858
);
@@ -672,6 +672,11 @@ export const GET_LEX_ADDR_FX = wasm
672672
"$tag",
673673
i32.load(i32.add(i32.add(local.get("$env"), i32.const(4)), i32.mul(local.get("$index"), i32.const(12))))
674674
),
675+
676+
wasm.call("$_log_int").args(i64.extend_i32_u(local.get("$depth"))),
677+
wasm.call("$_log_int").args(i64.extend_i32_u(local.get("$index"))),
678+
wasm.call("$_log_int").args(i64.extend_i32_u(local.get("$tag"))),
679+
675680
wasm
676681
.if(i32.eq(local.get("$tag"), i32.const(TYPE_TAG.UNBOUND)))
677682
.then(wasm.call("$_log_error").args(i32.const(ERROR_MAP.UNBOUND[0])), wasm.unreachable()),

src/wasm-compiler/wasm-util/builder.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ const wasm = {
567567
}
568568

569569
const buildBlock = (index: number): [WasmBlock, ...WasmInstruction[]] => {
570-
const body = bodies[bodies.length - index - 1];
570+
const body = bodies[index];
571571
if (!body) {
572572
throw new Error(
573573
`No body found for block at index ${index} in br_table`
@@ -578,15 +578,15 @@ const wasm = {
578578
wasm
579579
.block(typeof labels[index] === "string" ? labels[index] : undefined)
580580
.body(
581-
...(index === labels.length - 1
581+
...(index === 0
582582
? [wasm.br_table(value, ...labels)]
583-
: buildBlock(index + 1))
583+
: buildBlock(index - 1))
584584
),
585585
...(Array.isArray(body) ? body : [body]),
586586
];
587587
};
588588

589-
return buildBlock(0);
589+
return buildBlock(bodies.length - 1);
590590
},
591591
};
592592

0 commit comments

Comments
 (0)