Skip to content

Primitives, Padding and their Implementation

Xanderplayz16 edited this page Jun 30, 2022 · 2 revisions

NOTE: The content here regards the implementation details of cish, and therefore may not be up to date. There is no guarantee the following content is completely accurate.

All primitives, heap-allocations, and types are represented as a machine_reg_t union defined as the following:

typedef union machine_register {
	heap_alloc_t* heap_alloc;
	int64_t long_int;
	double float_int;
	char char_int;
	int bool_flag;
	machine_ins_t* ip;
} machine_reg_t;

The size of machine_reg_t is not guaranteed, but all runtime values in SuperForth are the same size. Although this may seem to be a waste of memory at first, by ensuring each value starts at the same memory location and lasts for the same length, padding has already been completed, which is better for cache locality.

Clone this wiki locally