# wasm: Implement elem_ptr · gitcafe/zig

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

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

Visibility: public

Requested revision: 29013220d95f60669c4a181d157157aea9f137b5

Requested commit: 29013220d95f60669c4a181d157157aea9f137b5

Commit: 29013220d95f60669c4a181d157157aea9f137b5

Tree: 0d56abd5a9d6eb7a037df535d47b9f900912fa1f

Author: Luuk de Gram

Committer: Luuk de Gram

## Message

```
wasm: Implement elem_ptr

This implements lowering elem_ptr for decl's and constants.
To generate the correct pointer, we perform a relocation by using the addend
that represents the offset. The offset is calculated by taking the element's size
and multiplying that by the index.

For constants this generates a single immediate instruction, and for decl's
this generates a single pointer address.

```

## Parents

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

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