MCPcopy Create free account
hub / github.com/WebAssembly/wabt / GetTokenTypeName

Function GetTokenTypeName

src/token.cc:21–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19namespace wabt {
20
21const char* GetTokenTypeName(TokenType token_type) {
22 static const char* s_names[] = {
23#define WABT_TOKEN(name, string) string,
24#define WABT_TOKEN_FIRST(name, string)
25#define WABT_TOKEN_LAST(name, string)
26#include "wabt/token.def"
27#undef WABT_TOKEN
28#undef WABT_TOKEN_FIRST
29#undef WABT_TOKEN_LAST
30 };
31
32 static_assert(
33 WABT_ARRAY_SIZE(s_names) == WABT_ENUM_COUNT(TokenType),
34 "Expected TokenType names list length to match number of TokenTypes.");
35
36 int x = static_cast<int>(token_type);
37 if (x < WABT_ENUM_COUNT(TokenType)) {
38 return s_names[x];
39 }
40
41 return "Invalid";
42}
43
44Token::Token(Location loc, TokenType token_type)
45 : loc(loc), token_type_(token_type) {

Callers 3

ExpectMethod · 0.85
ParseSimdV128ConstMethod · 0.85
to_stringMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected