# wasm: Implement 'field_ptr' constants · gitcafe/zig

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

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

Visibility: public

Requested revision: 0e2fcab334083d3cbc786e891be6c97e9fd81595

Requested commit: 0e2fcab334083d3cbc786e891be6c97e9fd81595

Commit: 0e2fcab334083d3cbc786e891be6c97e9fd81595

Tree: 7a9042737d071235a7cb17fc68365982f7a835f6

Author: Luuk de Gram

Committer: Luuk de Gram

## Message

```
wasm: Implement 'field_ptr' constants

This implements the `field_ptr` value for pointers. As the value only provides us with the index,
we must calculate the offset from the container type using said index. (i.e. the offset from a struct field at index 2).

Besides this, small miscellaneous fixes/updates were done to get remaining behavior tests passing:
 - We start the function table index at 1, so unresolved function pointers don't can be null-checked properly.
 - Implement genTypedValue for floats up to f64.
 - Fix zero-sized arguments by only creating `args` for non-zero-sized types.
 - lowerConstant now works for all decl_ref's.
 - lowerConstant properly lowers optional pointers, so `null` pointers are lowered to `0`.

```

## Parents

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

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