summaryrefslogtreecommitdiff
path: root/src/wasm.h
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-10-30 08:23:46 -0700
committerGitHub <noreply@github.com>2024-10-30 08:23:46 -0700
commita0f77adf4f05b47c5f2ecf87279f191195880393 (patch)
tree88b98ab1a2da8ccb76e2ffbc62c7267a3ee51a52 /src/wasm.h
parent2a1cb314d6a028cfd54374f89a47e111678c3d25 (diff)
downloadbinaryen-a0f77adf4f05b47c5f2ecf87279f191195880393.tar.gz
binaryen-a0f77adf4f05b47c5f2ecf87279f191195880393.tar.bz2
binaryen-a0f77adf4f05b47c5f2ecf87279f191195880393.zip
[NFC] Use more precise types for Expression IDs (#7038)
Make the ID enum an `int8_t`, and make the Specific ID a `constexpr` of that type. This seems more idiomatic and makes some code simpler, see the change to `find_all.h` which no longer needs a cast to compile. This has no performance impact.
Diffstat (limited to 'src/wasm.h')
-rw-r--r--src/wasm.h7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/wasm.h b/src/wasm.h
index 4901723fd..85473b1f9 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -647,7 +647,7 @@ enum StringEqOp {
class Expression {
public:
- enum Id {
+ enum Id : uint8_t {
InvalidId = 0,
BlockId,
IfId,
@@ -805,9 +805,8 @@ using ExpressionList = ArenaVector<Expression*>;
template<Expression::Id SID> class SpecificExpression : public Expression {
public:
- enum {
- SpecificId = SID // compile-time access to the type for the class
- };
+ // Compile-time access to the type for the class.
+ static constexpr Id SpecificId = SID;
SpecificExpression() : Expression(SID) {}
};