# `QuakeC.Compiler`
[🔗](https://github.com/jaman/cauldron/blob/v0.2.2/quake_c/lib/quake_c/compiler.ex#L1)

Compiles a QuakeC program to Elixir: every function becomes a function of a generated
module, and a dispatch module calls one by its index.

    dispatch = QuakeC.Compiler.load(progs)
    {host, budget, returned} =
      dispatch.call(function_index, argc, host, {builtins, trace}, budget, args)

`args` is a tuple of the words of the arguments, three a parameter, and `returned` the
three words of the return value. A builtin is called with the arguments in the
parameter slots from 4, and its return value is read from the return slots 1 to 3.
`dispatch.call_with_args/7` takes the same and a list of parameter slots, and returns
`{host, budget, returned, kept}`, `kept` a tuple of those slots as the call left them:
a builtin's parameter slots, the parameter slots of a function that hands values back,
and otherwise the arguments as given.

The generated modules are compiled in parallel, loaded, and their code kept in the cache
directory (the application setting `:quake_c, :cache_dir`, by default the user cache
directory's `quake_c`), named by the program's digest and the compiler's own code (older
code for the same program is removed), so a program is compiled once. A program loaded
once stays loaded for the life of the node.

# `load`

```elixir
@spec load(QuakeC.Progs.t()) :: module()
```

The dispatch module of `progs`, compiling and loading it when this node has not yet.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
