Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WASM: Unescape string #1756

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ RUN(NAME exit_02b FAIL LABELS cpython llvm c wasm wasm_x86 wasm_x64)
RUN(NAME exit_02c FAIL LABELS cpython llvm c)

# Test all four backends
RUN(NAME print_01 LABELS cpython llvm c wasm) # wasm not yet supports sep and end keywords
RUN(NAME print_01 LABELS cpython llvm c wasm wasm_x86 wasm_x64)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change is good

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will enable this test in one of the upcoming PRs.

RUN(NAME print_03 LABELS x86 c wasm wasm_x86 wasm_x64) # simple test case specifically for x86, wasm_x86 and wasm_x64
RUN(NAME print_04 LABELS cpython llvm c)
RUN(NAME print_06 LABELS cpython llvm c)
Expand Down
5 changes: 3 additions & 2 deletions src/libasr/codegen/asr_to_wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2084,8 +2084,9 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {
}

void visit_StringConstant(const ASR::StringConstant_t &x) {
emit_string(x.m_s);
m_wa.emit_i32_const(m_string_to_iov_loc_map[x.m_s]);
std::string s = unescape_string(m_al, x.m_s);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string should have been unescaped in ASR already. See #1759.

So the proper fix for this is to fix the frontend to keep the string unescaped.

emit_string(s);
m_wa.emit_i32_const(m_string_to_iov_loc_map[s]);
}

void visit_ArrayConstant(const ASR::ArrayConstant_t &x) {
Expand Down