-\r
-\r
-extern\r
-int\r
-name_u8_cpy(struct name*, struct name*);\r
-\r
-extern\r
-int\r
-name_u8_cmp(struct name*, struct name*);\r
-\r
-extern\r
-int\r
-name_u8_set(struct name*, ucs4_t);\r
-\r
-int\r
-ir_init(void);\r
-struct cdat*\r
-alloc_cdat(void);\r
-struct odat*\r
-alloc_odat(void);\r
-void\r
-alloc_vdat(void);\r
-struct link*\r
-alloc_link(void);\r
-struct ref*\r
-alloc_ref(void);\r
-struct set*\r
-alloc_set(void);\r
-struct cdat*\r
-curr_cdat(void);\r
-struct odat*\r
-curr_odat(void);\r
-struct vdat*\r
-curr_vdat(void);\r
-struct map*\r
-curr_map(void);\r
-struct set*\r
-curr_cdat_set(void);\r
-struct set*\r
-curr_set(int);\r
-struct ref*\r
-curr_ref(void);\r
-struct model*\r
-curr_model(void);\r
-\r
-/* ir.c */\r
-void\r
-inc_posts(void);\r
-void\r
-push_cdat(struct name*);\r
-void\r
-pop_cdat(void);\r
-void\r
-insert_link_name(struct name*);\r
-void\r
-insert_link_namelist(struct name*);\r
-void\r
-insert_ss_name(struct name*);\r
-void\r
-insert_ss_namelist(struct name*);\r
-void\r
-insert_mlink(struct name*, int);\r
-void\r
-insert_vlink(struct name*, int);\r
-void\r
-insert_ref(struct odat*, int);\r
-void\r
-alloc_vdat(void);\r
-void\r
-insert_vdat(void);\r
-void\r
-insert_map(struct name*, int, int, int, int, uint8_t*);\r
-void\r
-insert_framesheet(struct name*, int, int, int, int, uint8_t*);\r
-\r
-\r
-\r
-//type safety handled by macro expansion (do not call these directly from code, make dependent macros for access to these)\r
-#define CHUNKS_LEN(STACK) ((STACK).csp - (STACK).chunks)\r
-#define CURRENT_CHUNK(STACK) ((STACK).chunks[CHUNKS_LEN(STACK) - 1])\r
-#define CHUNKS_FULL(STACK) ( (STACK).csp >= \\r
- (STACK).chunks + MAX_CHUNKS * (STACK).chunk_size)\r
-#define CURRENT_DSP(STACK,TYPE) ((TYPE*) ((STACK).dsp[CHUNKS_LEN(STACK) - 1]))\r
-#define DATA_FULL(STACK,TYPE) ((void*) CURRENT_DSP(STACK,TYPE) >= \\r
- (CURRENT_CHUNK(STACK) + (STACK).chunk_size))\r
-#define CSP_PUSH(STACK) (*(++(STACK).csp) = malloc((STACK).chunk_size))\r
-#define CURRENT_DATP(STACK,TYPE) (((TYPE**)(STACK).dsp)[CHUNKS_LEN(STACK) - 1])\r
-#define PREVIOUS_DATP(STACK,TYPE) (((TYPE**)(STACK).dsp)[CHUNKS_LEN(STACK) - 2])\r
-#define ALLOC_DAT(STACK,TYPE) (++CURRENT_DATP(STACK,TYPE))\r
-#define INIT_STACK(STACK,TYPE) \\r
- { int i; \\r
- (STACK).chunk_size = PAGES_PER_CHUNK * pagesize; \\r
- (STACK).max_dats = (STACK).chunk_size / sizeof (TYPE); \\r
- CSP_PUSH(STACK); \\r
- for( i = 0; i < MAX_CHUNKS; i++){ \\r
- (STACK).dsp[i] += pagesize; \\r
- } \\r
- }\r
-//Stack-specific macros (called directly from code (safety enforcement)\r
-#define INIT_ODAT() (INIT_STACK(ocs, struct odat))\r
-#define CURRENT_ODAT() (CURRENT_DATP(ocs,struct odat))\r
-#define ODAT_FULL() (DATA_FULL(ocs,struct odat))\r
-#define ODAT_ALLOC() (ALLOC_DAT(ocs,struct odat))\r
-#define OCS_FULL() (CHUNKS_FULL(ocs))\r
-#define INIT_VDAT() (INIT_STACK(vcs, struct vdat))\r
-#define CURRENT_VDAT() (CURRENT_DATP(vcs,struct vdat))\r
-#define VDAT_FULL() (DATA_FULL(vcs,struct vdat))\r
-#define VDAT_ALLOC() (ALLOC_DAT(vcs,struct vdat))\r
-#define VCS_FULL() (CHUNKS_FULL(vcs))\r
-#define INIT_CDAT() (INIT_STACK(ccs, struct cdat))\r
-#define CURRENT_CDAT() (CURRENT_DATP(ccs,struct cdat))\r
-#define CDAT_FULL() (DATA_FULL(ccs, struct cdat))\r
-#define CDAT_ALLOC() (ALLOC_DAT(ccs, struct cdat))\r
-#define CCS_FULL() (CHUNKS_FULL(ccs))\r
-#define INIT_SET() (INIT_STACK(scs, struct set))\r
-#define CURRENT_SET() (CURRENT_DATP(scs, struct set))\r
-#define SET_FULL() (DATA_FULL(scs, struct set))\r
-#define SET_ALLOC() (ALLOC_DAT(scs, struct set))\r
-#define SCS_FULL() (CHUNKS_FULL(scs))\r
-#define INIT_LINK() (INIT_STACK(lcs, struct link))\r
-#define CURRENT_LINK() (CURRENT_DATP(lcs,struct link))\r
-#define LDAT_FULL() (DATA_FULL(lcs, struct link))\r
-#define LDAT_ALLOC() (ALLOC_DAT(lcs, struct link))\r
-#define LCS_FULL() (CHUNKS_FULL(lcs))\r
-#define INIT_POST() (INIT_STACK(rcs, struct ref))\r
-#define CURRENT_POST() (CURRENT_DATP(pcs,struct ref))\r
-#define POST_FULL() (DATA_FULL(pcs,struct ref))\r
-#define POST_ALLOC() (ALLOC_DAT(pcs,struct ref))\r
-#define PCS_FULL() (CHUNKS_FULL(pcs))\r
-#define INIT_REF() (INIT_STACK(rcs, struct ref))\r
-#define CURRENT_REF() (CURRENT_DATP(rcs,struct ref))\r
-#define PREVIOUS_REF() (PREVIOUS_DATP(rcs, struct ref))\r
-#define REF_FULL() (DATA_FULL(rcs,struct ref))\r
-#define REF_ALLOC() (ALLOC_DAT(rcs,struct ref))\r
-#define RCS_FULL() (CHUNKS_FULL(rcs))\r
-//Metadata\r
-#define CURRENT_MODEL() (CURRENT_VDAT()->model_list[CURRENT_VDAT()->num_models])\r
-\r
-\r
-\r
-/* Dynamically allocate memory for a class data structure,\r
- or cdat, after a class has been identified in a grammar.\r
- We also create a stack of class pointers so that\r
- we can access the cdat during processing of that\r
- cdats sets and elements, a requirement because the\r
- nature of recursive classes prevents us from accessing\r
- the cdat based on the previous index into cdat_buf,\r
- which is a list of all allocated cdats\r
-/* Cdats: A cdat is a class data structure. Cdats serve as the central */\r
-/* data types of the IR. Cdats contain pointers to their subclasses so that the relationship between */\r
-/* classes can be determined, but the subclasses are not represented inside */\r
-/* of the cdat itself but rather in subsequent cdats in cdat_buf. We */\r
-/* can determine the number of subclasses (the last index into cdat_buf */\r
-/* that represents a subclass of some arbitrary cdat) each cdat has by */\r
-/* incrementing num_classes during parse time. */\r
-/* TODO: Should classes point to their parent class? */\r
-/* TODO: Talk more about cdat set structure */\r
-struct cdat {\r
- struct name name;\r
- int idx;\r
- int num_classes;\r
- int num_sets;\r
- struct cdat* class_list[MAX_CLASSES];\r
- struct set* set_list[MAX_SETS];\r
-};\r
-\r
-\r
-/* Sets: What is a set? \r
- Instantiation?\r
- Associations? \r
- Containment?\r
- Usage?\r
- The set is populated at parse time AFTER the elements are populated, due to\r
- the nature of bottom up parsing. */\r
-struct set {\r
- int cdat_idx;\r
- int num_sets;\r
- struct set* set_list[MAX_SETS];\r
-};\r
-\r
-/* Refs: Each set/ele has a reference to its object data (odat) through a refid.\r
- refids are unsigned 64 byte integers that map to the hex values RGBA. During\r
- the construction of the directory structure, users can choose a RGBA value for\r
- each object that any other object can refer to via links (see link). If a user\r
- does not choose an RGBA value, then the object is given one from the system space.\r
- We maintain a doubly linked list of refs in the ref_buf at parse time so that\r
- links can be resolved after the parsing of the directory structure is complete.\r
- For every 16th ref, we create a post so that we can reduce on the search time for\r
- a random access. */\r
-\r
-struct ref {\r
- int type; //TODO: Is this needed?\r
- struct ref* nextref;\r
- struct ref* lastref;\r
- struct odat* odatp;\r
- int refid; //0xFFFFFF->digit\r
-};\r
-\r
-/* Links: At parse time, a set/ele can include a link in their\r
- grammar representation instead of the actual data and this signifies\r
- to the APC that that set/ele wishes to use the data of another\r
- set/ele, either its video data (vdat) or object data (odat). The link\r
- itself contains the type of link it is, the refid OR name, and\r
- which set/ele created the link. During parse time, links can be made\r
- to o/vdats that have yet to be parsed. In order to accomodate for this,\r
- we resolve all links AFTER parse time by iterating through the link_buf,\r
- finding the refid that was stored for some object (if the refid exists),\r
- and creating a relative pointer from the original object to the data that\r
- was linked */\r
-\r
-/* TODO: Explain links more betta */\r
-\r
-struct olink {\r
- int src_refid;\r