-/* Structures allocated for and updated during parse time that
- are the IR before writing to the output file */
+/*!@file
+ \brief Intermediate Representation (IR) between Directory Structure and Engine Grammar
+ \details The IR serves as a storage structure that is populated during the
+ parsing of the input directory structure. After parsing is complete,
+ the IR will be condensed (removed of excess allocated space) and then
+ output as the Engine Grammar. In this file we describe the semantic actions
+ that are called at each step, and the memory buffers that they populate.
+ See parser.y for the description on how the input grammar is constructed,
+ and where/when semantic actions are called.
+ TODO: or just write it here.
+ \author Jordan Lavatai
+ \date Aug 2016
+ ----------------------------------------------------------------------------*/
+
+
+#include <stdint.h>
#define BUF_SIZE 256
-#define MAX_SUBCLASSES 16
#define MAX_SETS 256
#define MAX_ELES 256
-#define MAX_REFS 256
+#define MAX_QUADS 256
#define MAX_MODELS 256
+#define MAX_POSTS 256
+#define MAX_CLASS_DEPTH 256
+#define MAX_CLASSES 256
+#define MAX_FRAMES 256
+#define PTRS_IN_PAGE 1024
+
+/* Called after the cdat open operator has been recognized in grammar. Allocates
+ the space for a cdat on the cdat_buf, pushes that pointer onto
+ the cdat_stack */
+void
+push_cdat(char*);
+/* Called after a cdat end operator has been recognized in grammar. Sets
+ top stack cdat ** to null and decrements stack pointer */
+void
+pop_cdat(void);
-//indexes for buffers
-int cbi = 0;
-int vbi = 0;
-int obi = 0;
+/* Called after an odat has been populated. Allocates memory for
+ the next odat. */
-struct ref {
- int x, y, z, objref;
-};
+void
+insert_set_label(char*, uint64_t);
-struct ele {
- int odat_id;
- int parent_id;//offset into class set_stack
-};
+/* Populate the sets representation in CURR_CDAT with a ref_id and insert a link
+ into the link_buf that will resolve the ref_id to an actual odat after parse time. */
+void
+insert_set_olink(uint64_t);
-//TODO: Add jump table
-struct set {
- int odat_id;
- int parent_id;//offset into CB
- int num_ele;
- int ele_index; //same as num_ele?
- struct ele ele_list[MAX_ELES];
-};
+/* Put the vlink in the link_buf to be processed after parsetime */
+void
+insert_set_vlink(uint64_t, char*);
+/* Put svlink in the link_buf to be processed after parsetime */
+void
+insert_set_svlink(uint64_t);
-//8 ids for each direction
-//fdat_id ordered by alphabetical direction
-struct model {
- char label[32];
- int fdat_id[8];
-};
+/* Called for every set reduction except for sets with olinks. Populates the
+ set data structures in the CDAT and in the ODAT. Uses the name and ref_id
+ from insert_set_label. Also inserts a ref into the ref_buf with the CURR_ODAT
+ pointer so that we can also resolve the odat from its ref_id. */
+void
+insert_set(void);
-//TODO: Do vdats need labels?
-struct vdat {
- int num_models;
- int msi; //model_stack_index
- struct model model_list[MAX_MODELS];
-} vdat_buf[BUF_SIZE];
+/* Insertion of eles is practically equivalent to how sets are inserted because both
+ share the same data type (ODAT). Like sets, eles have links, labels
+ and odats. Eles have the added notion of a parent set, and so must be inserted
+ into said parent set, but this is the only place they truly differ from sets. */
-struct cdat {
- char label[32];
- int num_subclasses;
- int num_sets;
- int subclass_index;
- int set_index;
- struct cdat* subclass_list[MAX_SUBCLASSES];
- struct set set_list[MAX_SETS];
-} cdat_buf[BUF_SIZE];
+void
+insert_ele_label(char*, uint64_t);
-//Element or a set
-struct odat {
- char label[32];
- int vdat_id;
- int class_id;
- int num_ref;
- int ref_index;
- struct ref ref_list[MAX_REFS];
-} odat_buf[BUF_SIZE];
+/* Insert an ele olink into the CURR_ODAT */
+void
+insert_ele_olink(uint64_t);
+/* Insert a ele vlink into CURR_ODAT*/
+void
+insert_ele_vlink(uint64_t, char*);
+
+/* Inserts an ele short vlink into CURR_ODAT*/
+void
+insert_ele_svlink(uint64_t);
+
+/* inserts ele into CURR_CLASS and CURR_ODAT */
+void
+insert_ele(void);
+
+void
+insert_vdat(void);
+/* Inserts the hitbox into the CURR_ODAT */
void
-inc_cbi(void);
+insert_hitbox(int);
+/* Inserts the root into the CURR_ODAT */
void
-set_class_label(char*);
+insert_root(int, int, int);
+/* Inserts a quad into the CURR_ODAT */
void
-inc_subclass_index(void);
+insert_quad(int, int, int, uint64_t);
void
-inc_subclass_index(void);
+insert_model(void);
void
-inc_ref(void);
+insert_framesheet(char, char*, uint64_t, int, int, int);
void
-inc_models(void);
+insert_frame_pointer(char, void*);
+