# wasm: airStructFieldPtr \- Support packed structs · gitcafe/zig

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

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

Visibility: public

Requested revision: 4af5bbde53da7f6ac8acc630135e569885bd94c4

Requested commit: 4af5bbde53da7f6ac8acc630135e569885bd94c4

Commit: 4af5bbde53da7f6ac8acc630135e569885bd94c4

Tree: 83c9bc7b3707f9f7447bea8d69bf00324c290c18

Author: Luuk de Gram

Committer: Luuk de Gram

## Message

```
wasm: airStructFieldPtr - Support packed structs

Simplifies the airStructFieldPtr(index) functions to only obtain the
correct struct type and field index, which is then passed into the
structFieldPtr function. This function now calculates the byte-offset
of the field's address and returns a new `WValue` with this offset.
This means we only have to do this calculation in a single function,
and no longer have to duplicate any logic. This also handles both
regular (tagged) unions and packed unions.

```

## Parents

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

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