Lexer actually lexes filenames now, and odats are made out of mapvariants
[henge/webcc.git] / src / apc / ir.c
index 4e23d16..5673d0c 100755 (executable)
@@ -53,12 +53,12 @@ struct odat*
 curr_odat(void);\r
 \r
 extern\r
-struct variant*\r
-curr_variant(void);\r
+struct map*\r
+curr_map(void);\r
 \r
 extern\r
-struct variant*\r
-alloc_variant(void);\r
+struct map*\r
+alloc_map(void);\r
 \r
 extern\r
 struct vdat*\r
@@ -125,6 +125,45 @@ pop_cdat
   cdat_stackp--;\r
 }\r
 \r
+\r
+/* Every odat has a single map variant. We track the odats that have related map variants\r
+   by adding the name of the map to the end of the odat name. E.g. for an odat with name\r
+   A and map variants a,b,c we get A_a, A_b, A_c. We create new odats for each map variant*/\r
+void\r
+insert_map\r
+( uint8_t* name,\r
+  int height,\r
+  int width,\r
+  uint8_t* filepath\r
+)\r
+{\r
+  struct odat* curr_odatp;\r
+  int curr_odat_vdatid;\r
+\r
+  curr_odatp = curr_odat();\r
+\r
+  curr_odat_vdatid = curr_odatp->vdat_id;\r
+  \r
+\r
+   \r
+  if(curr_odatp->map.name[0] != 0) //odat already has a map so make a new odat\r
+    { curr_odatp = alloc_odat();\r
+      curr_odatp->vdat_id = curr_odat_vdatid;\r
+    }\r
+  /* Add a delimiter '_' in between odat name and map variant name */\r
+  u8_strcat(curr_odatp->map.name, (uint8_t*) '_'); \r
+  u8_strcat(curr_odatp->map.name, name);\r
+  \r
+  u8_strcpy(curr_odatp->map.filepath, filepath);\r
+  curr_odatp->map.height = height;\r
+  curr_odatp->map.width = width;\r
+  \r
+}\r
+  \r
+\r
+\r
+\r
+\r
 /* Called in the reduction of a set. While both odats (eles and sets)\r
    have identical label terminals, we are unable to give a single grammatical rule\r
    for both due to how we allocate odats in the odat buf. Due to the\r
@@ -151,6 +190,7 @@ insert_set_label
   u8_cpy(curr_set_odatp->name, name, 32);\r
   u8_cpy(curr_setp->name, name, 32);\r
   curr_set_odatp->parent_odatp = NULL;\r
+  curr_set_odatp->map.name[0] = 0;\r
 \r
   if(ref_id != -1)\r
     { curr_set_odatp->ref_id = ref_id;\r
@@ -244,7 +284,7 @@ insert_set
   struct ref* curr_refp;\r
   struct vdat* curr_vdatp;\r
 \r
-  curr_odatp = curr_set_odatp; //allocated at insert_set_label, preserved in global space\r
+  curr_odatp = curr_set_odatp; //allocated at insert_set_label\r
   curr_cdatp = curr_cdat();\r
   curr_setp = curr_set();\r
   prev_refp = curr_ref();\r
@@ -299,6 +339,7 @@ insert_ele_label
   curr_odatp = alloc_odat();\r
 \r
   u8_cpy(curr_odatp->name, name, 32);\r
+  curr_odatp->map.name[0] = 0;\r
 \r
   if(ref_id != -1)\r
     curr_odatp->ref_id = ref_id;\r
@@ -427,26 +468,6 @@ insert_vdat
 }\r
 \r
 \r
-void\r
-insert_variant\r
-(uint8_t* filename, int height, int width, uint8_t* filepath)\r
-{ struct variant* curr_variantp;\r
-  int x, y, pixel, num_frames, n;\r
-  int* pixel_buf;\r
-  \r
-  /* Allocate the mdat */\r
-  curr_variantp = alloc_variant();\r
-\r
-  u8_strcpy(curr_variantp->filename, filename);\r
-  u8_strcpy(curr_variantp->filepath, filepath);\r
-  curr_variantp->height = height;\r
-  curr_variantp->width = width;\r
-\r
-  //curr_mdatp->quad_list[num_quads].x/.y/.z/ref_id */\r
-\r
-\r
-  curr_set_odatp->variant_list[curr_set_odatp->vli++] = curr_variantp;\r
-}\r
   \r
 \r
 /* void */\r