We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4c9e1cf commit 3df4a1aCopy full SHA for 3df4a1a
1 file changed
src/libasr/codegen/asr_to_wasm.cpp
@@ -2084,6 +2084,23 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {
2084
m_code_section, m_al,
2085
nesting_level - cur_loop_nesting_level); // branch to start of loop
2086
}
2087
+
2088
+ void visit_Assert(const ASR::Assert_t &x) {
2089
+ this->visit_expr(*x.m_test);
2090
+ wasm::emit_i32_eqz(m_code_section, m_al);
2091
+ wasm::emit_b8(m_code_section, m_al, 0x04); // emit if start
2092
+ wasm::emit_b8(m_code_section, m_al, 0x40); // empty block type
2093
+ if (x.m_msg) {
2094
+ std::string msg =
2095
+ ASR::down_cast<ASR::StringConstant_t>(x.m_msg)->m_s;
2096
+ print_msg("AssertionError: " + msg);
2097
+ } else {
2098
+ print_msg("AssertionError");
2099
+ }
2100
+ wasm::emit_i32_const(m_code_section, m_al, 1); // non-zero exit code
2101
+ exit();
2102
+ wasm::emit_expr_end(m_code_section, m_al); // emit if end
2103
2104
};
2105
2106
Result<Vec<uint8_t>> asr_to_wasm_bytes_stream(ASR::TranslationUnit_t &asr,
0 commit comments