A QuakeC program's memory: its globals, and every entity's fields laid end to end, as the program addresses them.
Values are floats, integers (entity numbers, function indices, string offsets, field
offsets and pointers), or binaries for strings made while running. A slot never written
is 0.
A pointer is a byte address: global slot n is at 4 * n, field slot f of entity
e at field_base() + 4 * (e * entity_fields + f), and memory from alloc/2 at
heap_base() and up. load/2 and store/3 read and write through one.
Writes take effect in place (QuakeC.Memory): every copy of the struct sees them.
copy/1 gives memory written apart from the original. The memory belongs to the
process that made it (new/1), works from any process while that process lives, and
release/1 frees it sooner.
qc = QuakeC.new(progs)
QuakeC.put_global(qc, "time", 1.5)
QuakeC.field(qc, 1, "origin")
Summary
Functions
bytes of fresh zeroed memory, rounded up to whole words: the memory and its address.
Every field of entity set back to zero.
Memory holding the same values as qc, written apart from it.
Field name of entity; 0 when the program has no such field.
The address of field slot offset of entity.
The address of field slot 0 of entity 0.
The offset of field name, or nil when the program has none.
Field slot offset of entity.
The type of field name, or nil.
Vector field name of entity.
Write integer or float value into words words from address address.
A value as a float.
Give back memory alloc/2 handed out at address; any other address is left alone.
The global named name.
Whether the program has a global name.
The vector global named name.
The address of the first word alloc/2 hands out.
The value at address address; an address outside every space reads 0.
Copy words words from address from to address to, as they stood before the copy;
the ranges may overlap. Words from below address 0 read 0; a copy to an address
outside every space raises.
Fresh memory for progs: its initial globals, every entity field zero.
Set the global named name when the program declares one; otherwise leave the memory as it is.
Set field name of entity; a vector sets three slots. A field the program lacks is left alone.
Set field slot offset of entity.
Set the global named name; a vector sets three slots.
Set global slot offset.
Set the three slots from offset.
Free qc's memory (QuakeC.Memory.delete/1); neither it nor any copy may be used after.
The global slot offset.
The three slots from offset as a vector.
Write value at address address.
A string value as text: an offset into the program's strings, or a made string.
Set global slot offset: :ok when only the memory's words changed, or the memory to
use from then on (QuakeC.Memory.put/3).
Types
Functions
@spec alloc(t(), non_neg_integer()) :: {t(), pos_integer()}
bytes of fresh zeroed memory, rounded up to whole words: the memory and its address.
@spec clear_entity(t(), non_neg_integer()) :: t()
Every field of entity set back to zero.
Memory holding the same values as qc, written apart from it.
@spec field(t(), non_neg_integer(), String.t()) :: value()
Field name of entity; 0 when the program has no such field.
@spec field_address(t(), non_neg_integer(), non_neg_integer()) :: pos_integer()
The address of field slot offset of entity.
@spec field_base() :: pos_integer()
The address of field slot 0 of entity 0.
@spec field_offset(t(), String.t()) :: non_neg_integer() | nil
The offset of field name, or nil when the program has none.
@spec field_slot(t(), non_neg_integer(), non_neg_integer()) :: value()
Field slot offset of entity.
The type of field name, or nil.
@spec field_vector(t(), non_neg_integer(), String.t()) :: vector()
Vector field name of entity.
@spec fill(t(), integer(), non_neg_integer(), number()) :: t()
Write integer or float value into words words from address address.
A value as a float.
Give back memory alloc/2 handed out at address; any other address is left alone.
The global named name.
Whether the program has a global name.
The vector global named name.
@spec heap_base() :: pos_integer()
The address of the first word alloc/2 hands out.
The value at address address; an address outside every space reads 0.
@spec move(t(), integer(), integer(), non_neg_integer()) :: t()
Copy words words from address from to address to, as they stood before the copy;
the ranges may overlap. Words from below address 0 read 0; a copy to an address
outside every space raises.
@spec new(QuakeC.Progs.t()) :: t()
Fresh memory for progs: its initial globals, every entity field zero.
Set the global named name when the program declares one; otherwise leave the memory as it is.
Set field name of entity; a vector sets three slots. A field the program lacks is left alone.
@spec put_field_slot(t(), non_neg_integer(), non_neg_integer(), value()) :: t()
Set field slot offset of entity.
Set the global named name; a vector sets three slots.
@spec put_slot(t(), non_neg_integer(), value()) :: t()
Set global slot offset.
@spec put_slot_vector(t(), non_neg_integer(), vector()) :: t()
Set the three slots from offset.
@spec release(t()) :: :ok
Free qc's memory (QuakeC.Memory.delete/1); neither it nor any copy may be used after.
@spec slot(t(), non_neg_integer()) :: value()
The global slot offset.
@spec slot_vector(t(), non_neg_integer()) :: vector()
The three slots from offset as a vector.
Write value at address address.
A string value as text: an offset into the program's strings, or a made string.
@spec update_slot(t(), non_neg_integer(), value()) :: :ok | t()
Set global slot offset: :ok when only the memory's words changed, or the memory to
use from then on (QuakeC.Memory.put/3).