pushing to debug make
[henge/webcc.git] / src / apc / ir.c
index 10aede8..ffc1020 100644 (file)
@@ -1,28 +1,22 @@
 #include <errno.h>
-#include <ir.h>
+#include <ir.h> 
 
-#define CURR_OBI (OB[obi])
-#define CURR_VBI (VB[vbi])
-#define CURR_CBI (CB[cbi])
-#define IS_SUBCLASS() (CB[cbi].num_subclasses)
+//#define CURR_ODAT (OB[obi])
+//#define CURR_VDAT (VB[vbi])
+//#define CURR_CDAT (CB[cbi])
 
 //TODO: label and vdat_id
 void
 insert_set()
 {
-  if(IS_SUBCLASS()) //if set is set of subclass
-    OB[obi].class_id = CB[cbi].subclass_list[subclass_index].label; //TODO: specify subclass other than label?
-  else
-    OB[obi].class_id = CB[cbi].label;
-
-  CB[cbi].set_list[set_index].odat_id = obi;
-  CB[cbi].set_list[set_index].parent_id = OB[obi].class_id;
+  cdat_buf[cbi].set_list[set_index].odat_id = obi;
+  cdat_buf[cbi].set_list[set_index].parent_id =//from lexer
   //TODO: add ele_stack is created in element_list
-  //TODO: add odat
+  //TODO: add set to odat_buf
 
 }
 
-#define CURR_QUAD (OB[obi].ref_list[ref_index])
+#define CURR_QUAD (odat_buf[obi].ref_list[ref_index])
 void
 insert_ref(int x, int y, int z, int ref)
 {
@@ -33,28 +27,29 @@ insert_ref(int x, int y, int z, int ref)
 }
 
 
-//Insert element into OB and CB
+//Insert element into odat_buf and cdat_buf
 void
 insert_ele(char* label, int vdat_id)
 {
 
 
-  OB[obi].label = label;
-  OB[obi].vdat_id = vdat_id;
+  odat_buf[obi].label = label;
+  odat_buf[obi].vdat_id = vdat_id;
   //TODO: check set_obi to see if set_map_data exists
-  OB[obi].num_ref = OB[set_obi].num_ref;
-  OB[obi].ref_list = OB[set_obi].ref_list;
-  OB[obi].class_id = cbi;
+  //comes from e
+  odat_buf[obi].num_ref = odat_buf[set_obi].num_ref;
+  odat_buf[obi].ref_list = odat_buf[set_obi].ref_list;
+  odat_buf[obi].class_id = cbi;
 
   if(IS_SUBCLASS())
     {
-      CB[cbi].subclass_list[subclass_index].set_list[set_index].ele_list[ele_index].odat_id = obi;
-      CB[cbi].subclass_list[subclass_index].set_list[set_index].ele_list[ele_index].parent_id = CB[cbi].subclass_list[subclass_index].set_index;
+      cdat_buf[cbi].subclass_list[subclass_index].set_list[set_index].ele_list[ele_index].odat_id = obi;
+      cdat_buf[cbi].subclass_list[subclass_index].set_list[set_index].ele_list[ele_index].parent_id = cdat_buf[cbi].subclass_list[subclass_index].set_index;
     }
   else
     {
-      CB[cbi].set_list[set_index].ele_list[ele_index].odat_id = obi;
-      CB[cbi].set_list[set_index].ele_list[ele_index].parent_id = CB[cbi].set_index;
+      cdat_buf[cbi].set_list[set_index].ele_list[ele_index].odat_id = obi;
+      cdat_buf[cbi].set_list[set_index].ele_list[ele_index].parent_id = cdat_buf[cbi].set_index;
     }
 
   obi++;
@@ -65,8 +60,8 @@ insert_ele(char* label, int vdat_id)
 int
 insert_fdat(char* label, char direction, int fd)
 {
-  VB[vbi].model_list[VB[vbi].len].label = label;
-  VB[vbi].model_list[VB[vbi].len].fdat_id[(int)direction] = fd;
+  vdat_buf[vbi].model_list[vdat_buf[vbi].len].label = label;
+  vdat_buf[vbi].model_list[vdat_buf[vbi].len].fdat_id[(int)direction] = fd;
 }
 
 void
@@ -93,7 +88,7 @@ condense()
   /* fwrite vdat */
   for(v = 0; v <= vbi; v++)
     {
-      num_models = VB[v].num_models; //data duplication for caching
+      num_models = vdat_buf[v].num_models; //data duplication for caching
       for(m = 0; m <= num_models; m++)
         {
             
@@ -107,4 +102,47 @@ condense()
 
 
 }
+void
+inc_cbi()
+{
+  cbi++;
+}
+
+void
+set_class_label(char* label)
+{
+  cdat_buf[cbi].label = $1;
+}
+
+void
+inc_subclass_idx()
+{
+  cdat_buf[cbi].subclass_index++;
+}
+
+void
+inc_set_index()
+{
+  odat_buf[cbi].set_index++;
+}
+
+void
+inc_ref()
+{
+  odat_buf[obi].ref_index++;
+  odat_buf[obi].num_ref++;
+}
+
+//TODO: This needs to be changed to account for
+//      when the set is of a subclass.
+void
+inc_ele()
+{
+  cdat_buf[cbi].set_stack[stack_index].num_ele++;
+}
 
+void
+inc_models()
+{
+  vdat_buf[vbi].num_models++;
+}