diff options
-rw-r--r-- | src/passes/Print.cpp | 4 | ||||
-rw-r--r-- | src/wasm-features.h | 15 | ||||
-rw-r--r-- | test/example/c-api-multiple-tables.c | 2 | ||||
-rw-r--r-- | test/passes/dwarf_with_exceptions.bin.txt | 2 |
4 files changed, 22 insertions, 1 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 9b59de444..a10467018 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -3240,6 +3240,10 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> { } o << maybeNewLine; } + if (curr->hasFeaturesSection) { + doIndent(o, indent); + o << ";; features section: " << curr->features.toString() << '\n'; + } decIndent(); o << maybeNewLine; currModule = nullptr; diff --git a/src/wasm-features.h b/src/wasm-features.h index d2e3f343f..237dc7757 100644 --- a/src/wasm-features.h +++ b/src/wasm-features.h @@ -75,6 +75,21 @@ struct FeatureSet { } } + std::string toString() { + std::string ret; + uint32_t x = 1; + while (x & Feature::All) { + if (features & x) { + if (!ret.empty()) { + ret += ", "; + } + ret += toString(Feature(x)); + } + x <<= 1; + } + return ret; + } + FeatureSet() : features(MVP) {} FeatureSet(uint32_t features) : features(features) {} operator uint32_t() const { return features; } diff --git a/test/example/c-api-multiple-tables.c b/test/example/c-api-multiple-tables.c index 4ba612658..9d0c9ebfd 100644 --- a/test/example/c-api-multiple-tables.c +++ b/test/example/c-api-multiple-tables.c @@ -1,6 +1,6 @@ #include <assert.h> -#include <string.h> #include <binaryen-c.h> +#include <string.h> // "hello world" type example: create a function that adds two i32s and returns // the result diff --git a/test/passes/dwarf_with_exceptions.bin.txt b/test/passes/dwarf_with_exceptions.bin.txt index b11fa6437..5dd594461 100644 --- a/test/passes/dwarf_with_exceptions.bin.txt +++ b/test/passes/dwarf_with_exceptions.bin.txt @@ -120,6 +120,7 @@ ;; custom section ".debug_line", size 92 ;; custom section ".debug_str", size 194 ;; custom section "producers", size 137 + ;; features section: exception-handling, reference-types ) DWARF debug info ================ @@ -541,4 +542,5 @@ file_names[ 1]: ;; custom section ".debug_line", size 145 ;; custom section ".debug_str", size 194 ;; custom section "producers", size 137 + ;; features section: exception-handling, reference-types ) |