Object types ------------ Immediate -> Int (30-bits) Char (2 bytes) Boolean Reference -> Binary -> Floats Strings Symbols Array Frame Representation -------------- So, everything is stored in four byte 'nsObjs'. The first two bits (sometimes three) of this are type information. Bit 0: Set: Immediate Bit 1: Set: Short Immediate Bit 2: Set: Character Unset: Boolean Unset: 30-bit Integer Unset: Reference Bit 1: Set: Magic Pointer Unset: Reference Object So, 00 - Integer 010 - Boolean 110 - Character 01 - Reference 11 - Magic Pointer If it is a reference, then the remaining 30-bits contain the "object reference number" The object reference number is the index into an array of actual object memory references. This is done for several reasons: 1) Physical addresses may really want to use 32-bits of information. By confining this to the object reference array, we don't have to worry about it. 2) It allows me to implement ReplaceObject. 3) Somehow, I think it might aid with garbage collection. The 'nsRefType' is the generic reference object type. I think it has the following basic slots: primclass: PRIMC_BINARY, PRIMC_ARRAY, PRIMC_FRAME stuff: void * (class specific stuff goes here /* ---------------------------------------------------------------------- */ Symbols are weird. Because I want every symbol 'foo resolve to the same nsObj. I don't want to be creating unnecesary nsObj's for each symbol. This means that I have to keep a table of them. For now, that table will be a binary tree (because I have that code lying around). Each binary tree will contain these structures: symTabS { nsObj nso; /* The object */ int16 *ustr; /* The ustr */ }; Comparison is done using ustrcasecmp() on ustr. /* ---------------------------------------------------------------------- */ Frames: Okay, frames are essentially lookup tables. The catch is that they need to use frame maps. What is a frame map? Just another little lookup table. For now, let's keep it (very) simple. The frame map is an array of things, so I need to implement arrays first. Okay, I've just decided that frame maps don't have to be nsObjs. They are going to just be an array of pairs. The frame itself can be an array with a frame map. nsFrmPairS { nsObj symbol; /* The slot name */ int16 index; /* The index in the array for this slot */ }; nsObjFrmS { struct nsFrmPair *map_array; /* The frame map */ nsObj frm_array; /* The array containing the objects */ }; To use this, just find the symbol in the map, then reference that index in the array. Currently, we're sequential searching the frame map. We should endeavor to speed this up in the future, but for now, it's opaque and simple, so we can make it work and change it later. /* ---------------------------------------------------------------------- */ Arrays: Arrays are fairly simple. They contain the following: nsObjArrS { int16 num_elems; /* The number of elements in this array */ int16 max_elems; /* The maximun number of elements in this array */ nsObj nso_array[1]; /* The array. */ }; This is playing the usual realloc trick with arrays. I'll have to write my own array realloc routine, though.