| 19 | namespace wabt { |
| 20 | |
| 21 | const 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 | |
| 44 | Token::Token(Location loc, TokenType token_type) |
| 45 | : loc(loc), token_type_(token_type) { |
no outgoing calls
no test coverage detected