# wasm: Implement emulated stack · gitcafe/zig

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

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

Visibility: public

Requested revision: 261f13414b6bafbe075ce5066964b36a3a5b5e16

Requested commit: 261f13414b6bafbe075ce5066964b36a3a5b5e16

Commit: 261f13414b6bafbe075ce5066964b36a3a5b5e16

Tree: 18df3c82a434a6400cb30251258f18dab8d6a072

Author: Luuk de Gram

Committer: Luuk de Gram

## Message

```
wasm: Implement emulated stack

All non-temporary locals will now use stack memory.
When `airAlloc` is called, we create a new local, move the stack pointer,
and write its offset into the local. Arguments act as a register and do not
use any stack space.

We no longer use offsets for binary operations, but instead write the result
into a local. In this case, the local is simply used as a register, and does not
require stack space. This allows us to ensure the order of instructions is correct,
and we no longer require any patching/inserting at a specific offset.

print_air was missing the logic to print the type of a `ty_str`.

```

## Parents

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

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