Skip to content

Commit d72728b

Browse files
committed
WASM: Store starting offset of instructions in Data struct
Instructions can be decoded from this offset as required
1 parent 1dc1856 commit d72728b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/libasr/codegen/wasm_to_wat.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,17 @@ class WATGenerator : public WASMDecoder<WATGenerator> {
9393
}
9494

9595
for (uint32_t i = 0; i < data_segments.size(); i++) {
96+
std::string date_segment_insts;
97+
{
98+
WASM_INSTS_VISITOR::WATVisitor v =
99+
WASM_INSTS_VISITOR::WATVisitor(
100+
wasm_bytes, data_segments.p[i].insts_start_index, "",
101+
"");
102+
v.decode_instructions();
103+
date_segment_insts = v.src;
104+
}
96105
result += indent + "(data (;" + std::to_string(i) + ";) (" +
97-
data_segments[i].insts + ") \"" + data_segments[i].text +
106+
date_segment_insts + ") \"" + data_segments[i].text +
98107
"\")";
99108
}
100109

src/libasr/codegen/wasm_utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct Import {
4444
};
4545

4646
struct Data {
47-
std::string insts;
47+
uint32_t insts_start_index;
4848
std::string text;
4949
};
5050

0 commit comments

Comments
 (0)