parser wip pt2
[henge/webcc.git] / src / apc / ir.c
1 #include <errno.h>
2 #include <ir.h>
3
4 #define CURR_OBI (OB[obi])
5 #define CURR_VBI (VB[vbi])
6 #define CURR_CBI (CB[cbi])
7 #define IS_SUBCLASS() (CB[cbi].num_subclasses)
8
9 //TODO: label and vdat_id
10 void
11 insert_set()
12 {
13 if(IS_SUBCLASS()) //if set is set of subclass
14 OB[obi].class_id = CB[cbi].subclass_list[subclass_index].label; //TODO: specify subclass other than label?
15 else
16 OB[obi].class_id = CB[cbi].label;
17
18 CB[cbi].set_list[set_index].odat_id = obi;
19 CB[cbi].set_list[set_index].parent_id = OB[obi].class_id;
20 //TODO: add ele_stack is created in element_list
21 //TODO: add odat
22
23 }
24
25 #define CURR_QUAD (OB[obi].ref_list[ref_index])
26 void
27 insert_ref(int x, int y, int z, int ref)
28 {
29 CURR_QUAD.x = x;
30 CURR_QUAD.y = y;
31 CURR_QUAD.z = z;
32 CURR_QUAD.ref = ref;
33 }
34
35
36 //Insert element into OB and CB
37 void
38 insert_ele(char* label, int vdat_id)
39 {
40
41
42 OB[obi].label = label;
43 OB[obi].vdat_id = vdat_id;
44 //TODO: check set_obi to see if set_map_data exists
45 OB[obi].num_ref = OB[set_obi].num_ref;
46 OB[obi].ref_list = OB[set_obi].ref_list;
47 OB[obi].class_id = cbi;
48
49 if(IS_SUBCLASS())
50 {
51 CB[cbi].subclass_list[subclass_index].set_list[set_index].ele_list[ele_index].odat_id = obi;
52 CB[cbi].subclass_list[subclass_index].set_list[set_index].ele_list[ele_index].parent_id = CB[cbi].subclass_list[subclass_index].set_index;
53 }
54 else
55 {
56 CB[cbi].set_list[set_index].ele_list[ele_index].odat_id = obi;
57 CB[cbi].set_list[set_index].ele_list[ele_index].parent_id = CB[cbi].set_index;
58 }
59
60 obi++;
61 }
62
63
64 /* fd could be a directory entry */
65 int
66 insert_fdat(char* label, char direction, int fd)
67 {
68 VB[vbi].model_list[VB[vbi].len].label = label;
69 VB[vbi].model_list[VB[vbi].len].fdat_id[(int)direction] = fd;
70 }
71
72 void
73 condense()
74 {
75 FILE* vp, op, cp;
76 int v, m;
77 int num_models;
78
79 vp = fopen("vdat_output", w+);
80 if(!vp)
81 perror("vdat_output failed to open\n");
82
83 op = fopen("odat_output", w+);
84 if(!op)
85 perror("odat_output failed to open\n");
86
87 cp = fopen("cdat_output", w+);
88 if(!cp)
89 perror("cdat_output failed to open\n");
90
91
92
93 /* fwrite vdat */
94 for(v = 0; v <= vbi; v++)
95 {
96 num_models = VB[v].num_models; //data duplication for caching
97 for(m = 0; m <= num_models; m++)
98 {
99
100 }
101 }
102
103 /* fwrite odat */
104 /* Convert ref_list to actual offset */
105
106 /* fwrite cdat */
107
108
109 }
110