Skip to content

Commit c2fb2e9

Browse files
committed
WASM: Temporary fix for mismatching index for print_i64/f64
1 parent 2602a03 commit c2fb2e9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/libasr/codegen/asr_to_wasm.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {
524524

525525
wasm::emit_get_local(m_code_section, m_al, 0);
526526
wasm::emit_i64_trunc_f64_s(m_code_section, m_al);
527-
wasm::emit_call(m_code_section, m_al, 2 /* print_i64 */);
527+
wasm::emit_call(m_code_section, m_al, no_of_imports /* print_i64 */);
528528
emit_call_fd_write(1, ".", 1, 0);
529529

530530
wasm::emit_get_local(m_code_section, m_al, 0);
@@ -575,7 +575,7 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {
575575
});
576576

577577
wasm::emit_get_local(m_code_section, m_al, 3);
578-
wasm::emit_call(m_code_section, m_al, 2 /* print_i64 */);
578+
wasm::emit_call(m_code_section, m_al, no_of_imports /* print_i64 */);
579579

580580
wasm::emit_b8(m_code_section, m_al, 0x0F); // emit wasm return instruction
581581
wasm::emit_expr_end(m_code_section, m_al);
@@ -2368,11 +2368,11 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {
23682368
switch (a_kind) {
23692369
case 4: {
23702370
wasm::emit_i64_extend_i32_s(m_code_section, m_al);
2371-
wasm::emit_call(m_code_section, m_al, 2 /* print_i64 */);
2371+
wasm::emit_call(m_code_section, m_al, no_of_imports /* print_i64 */);
23722372
break;
23732373
}
23742374
case 8: {
2375-
wasm::emit_call(m_code_section, m_al, 2 /* print_i64 */);
2375+
wasm::emit_call(m_code_section, m_al, no_of_imports /* print_i64 */);
23762376
break;
23772377
}
23782378
default: {
@@ -2386,11 +2386,11 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {
23862386
switch (a_kind) {
23872387
case 4: {
23882388
wasm::emit_f64_promote_f32(m_code_section, m_al);
2389-
wasm::emit_call(m_code_section, m_al, 3 /* print_f64 */);
2389+
wasm::emit_call(m_code_section, m_al, no_of_imports + 1 /* print_f64 */);
23902390
break;
23912391
}
23922392
case 8: {
2393-
wasm::emit_call(m_code_section, m_al, 3 /* print_f64 */);
2393+
wasm::emit_call(m_code_section, m_al, no_of_imports + 1 /* print_f64 */);
23942394
break;
23952395
}
23962396
default: {

0 commit comments

Comments
 (0)