# wasm: Implement vector_init for array & structs · gitcafe/zig

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

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

Visibility: public

Requested revision: ae1e3c8f9bc86eeefb5a83233884a134f7b974f4

Requested commit: ae1e3c8f9bc86eeefb5a83233884a134f7b974f4

Commit: ae1e3c8f9bc86eeefb5a83233884a134f7b974f4

Tree: ed25223280b2ccfffd74691b73e558065ec7925d

Author: Luuk de Gram

Committer: Luuk de Gram

## Message

```
wasm: Implement vector_init for array & structs

Implements the instruction `vector_init` for structs and arrays.
For arrays, it checks if the element must be passed by reference or not.
When not, it can simply use the `offset` field of a store instruction to copy the values
into the array. When it is byref, it will move the pointer by the element size, and then perform
a store operation. This ensures types like structs will be moved into the right position.
For structs we will always move the pointer, as we currently cannot verify if all fields are
not by ref.

```

## Parents

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

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