Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
WASM: handle_print(): Use globals and fix revisiting expr
  • Loading branch information
ubaidsk committed Feb 21, 2023
commit 57d6715af18f15ea9c7bc5a3d202e20c6dc08d5a
11 changes: 5 additions & 6 deletions src/libasr/codegen/asr_to_wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3038,19 +3038,18 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {
} else if (t->type == ASR::ttypeType::Complex) {
emit_call_fd_write(1, "(", 1, 0);
this->visit_expr(*x.m_values[i]);
wasm::emit_drop(m_code_section, m_al); // drop imag part
if (a_kind == 4) {
wasm::emit_f64_promote_f32(m_code_section, m_al);
wasm::emit_set_global(m_code_section, m_al, 2);
wasm::emit_f64_promote_f32(m_code_section, m_al);
} else {
wasm::emit_set_global(m_code_section, m_al, 2);
}
wasm::emit_call(m_code_section, m_al, 3 /* print_f64 */);
emit_call_fd_write(1, ",", 1, 0);
this->visit_expr(*x.m_values[i]);
if (a_kind == 4) {
wasm::emit_f64_promote_f32(m_code_section, m_al);
}
wasm::emit_get_global(m_code_section, m_al, 2);
wasm::emit_call(m_code_section, m_al, 3 /* print_f64 */);
emit_call_fd_write(1, ")", 1, 0);
wasm::emit_drop(m_code_section, m_al); // drop real part
}
}

Expand Down