# wasm: generate function to get tag name · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/3c27df6b135f998facce1aa09a9926e840671a05)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 3c27df6b135f998facce1aa09a9926e840671a05

Requested commit: 3c27df6b135f998facce1aa09a9926e840671a05

Commit: 3c27df6b135f998facce1aa09a9926e840671a05

Tree: 4b400276a9df4f27bf574f671b2376dc3f8362cc

Author: Luuk de Gram

Committer: Luuk de Gram

## Message

```
wasm: generate function to get tag name

When we lower the instruction for `@tagName` we generate a new
function if it doesn't exist yet for that decl. This function creates
an if-else chain to determine which value was provided. Each tag
generates a constant that contains its name as the value. For each
tag we generate a case where the pointer of the string is stored in
the result slice. The length of the tagname is comptime-known, therefore
will be stored in the slice directly without having it being part of
the tagname symbol. In the future this can use a jump table instead
of an if-else chain, similar to the `switch` instruction.

```

## Parents

- [490a411fd4e00fee65bc014fa7b1af59042d269b](https://git.cafe/gitcafe/zig/commit/490a411fd4e00fee65bc014fa7b1af59042d269b?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/3c27df6b135f998facce1aa09a9926e840671a05?format=markdown)
