Skip to content

Commit df93895

Browse files
authored
Print the features section in a comment (#3563)
1 parent 60eb7c8 commit df93895

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

src/passes/Print.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3240,6 +3240,10 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> {
32403240
}
32413241
o << maybeNewLine;
32423242
}
3243+
if (curr->hasFeaturesSection) {
3244+
doIndent(o, indent);
3245+
o << ";; features section: " << curr->features.toString() << '\n';
3246+
}
32433247
decIndent();
32443248
o << maybeNewLine;
32453249
currModule = nullptr;

src/wasm-features.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,21 @@ struct FeatureSet {
7575
}
7676
}
7777

78+
std::string toString() {
79+
std::string ret;
80+
uint32_t x = 1;
81+
while (x & Feature::All) {
82+
if (features & x) {
83+
if (!ret.empty()) {
84+
ret += ", ";
85+
}
86+
ret += toString(Feature(x));
87+
}
88+
x <<= 1;
89+
}
90+
return ret;
91+
}
92+
7893
FeatureSet() : features(MVP) {}
7994
FeatureSet(uint32_t features) : features(features) {}
8095
operator uint32_t() const { return features; }

test/example/c-api-multiple-tables.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <assert.h>
2-
#include <string.h>
32
#include <binaryen-c.h>
3+
#include <string.h>
44

55
// "hello world" type example: create a function that adds two i32s and returns
66
// the result

test/passes/dwarf_with_exceptions.bin.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
;; custom section ".debug_line", size 92
121121
;; custom section ".debug_str", size 194
122122
;; custom section "producers", size 137
123+
;; features section: exception-handling, reference-types
123124
)
124125
DWARF debug info
125126
================
@@ -541,4 +542,5 @@ file_names[ 1]:
541542
;; custom section ".debug_line", size 145
542543
;; custom section ".debug_str", size 194
543544
;; custom section "producers", size 137
545+
;; features section: exception-handling, reference-types
544546
)

0 commit comments

Comments
 (0)