parser wip pt2
[henge/webcc.git] / src / apc / ir.h
diff --git a/src/apc/ir.h b/src/apc/ir.h
new file mode 100644 (file)
index 0000000..d4ab90b
--- /dev/null
@@ -0,0 +1,72 @@
+/* Structures allocated for and updated during parse time that
+   are the IR before writing to the output file */
+
+#define BUFF_SIZE 256
+#define MAX_SUBCLASSES 16
+#define MAX_SETS 256
+#define MAX_ELES 256
+#define MAX_REFS 256
+#define MAX_MODELS 256
+
+//These IR buffers will be condensed into their respective output files.
+//parse_init() all to zero.
+struct cdat CB[BUFF_SIZE];
+struct vdat VB[BUFF_SIZE];
+struct odat OB[BUFF_SIZE];
+
+//indexes for buffers
+int cbi = 0;
+int vbi = 0;
+int obi = 0;
+
+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];
+};
+
+//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];
+};
+
+struct ref {
+  int x, y, z, objref;
+};
+
+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];
+};
+
+struct ele {
+  int odat_id;
+  int parent_id;//offset into class set_stack
+};
+
+//TODO: Do vdats need labels?
+struct vdat {
+  int num_models;
+  int msi; //model_stack_index
+  struct model model_list[MAX_MODELS];
+};
+
+//8 ids for each direction
+//fdat_id ordered by alphabetical direction
+struct model {
+  char label[32];
+  int fdat_id[8];
+};
+