herkforth data
herkforth data objects can be anywhere in memory. Each is a word in the
herkforth dictionary (with flags set to flags-data
of course). The CFA
points to the data
field of the following structure:
Data is in this format:
- [32 bits] type
- [32 bits] length
- [length bytes] data
IMPORTANT: the pointer points directly to the data
field, not the beginning
of the structure. The idea is that you get a pointer directly to the data, with
meta-data before that address. Meta-data is easily accessed, and easily
ignored.
The format for the meta-data may change. For example to give the type and length only 16 bits.
Here are currently used values for type:
- 0: unknown/raw
- 1: text (can contain any bit pattern, this just means it's assumed to be human-readable)
- 2: herkforth source tokens
- 3: herkforth source block (unreleased and undocumented at this time)
Currently, the editor ignores the value of the type field. But in the future, different types will be displayed and edited differently.
Saving
All data objects are persistant.
When you bootstrap (herkforth bootstrapping) the data objects are collected
from wherever they are (by following the CFAs of data words) and end up in one
big lump. But since they will be collected from wherever, if you need to make
one bigger, you can copy it some place (such as onto the heap) where it has
room to expand. the word data-resize
is being written to do this for you.