pushing to debug make
[henge/webcc.git] / src / apc / ir.c
1 #include <errno.h>
2 #include <ir.h>
3
4 //#define CURR_ODAT (OB[obi])
5 //#define CURR_VDAT (VB[vbi])
6 //#define CURR_CDAT (CB[cbi])
7
8 //TODO: label and vdat_id
9 void
10 insert_set()
11 {
12 cdat_buf[cbi].set_list[set_index].odat_id = obi;
13 cdat_buf[cbi].set_list[set_index].parent_id =//from lexer
14 //TODO: add ele_stack is created in element_list
15 //TODO: add set to odat_buf
16
17 }
18
19 #define CURR_QUAD (odat_buf[obi].ref_list[ref_index])
20 void
21 insert_ref(int x, int y, int z, int ref)
22 {
23 CURR_QUAD.x = x;
24 CURR_QUAD.y = y;
25 CURR_QUAD.z = z;
26 CURR_QUAD.ref = ref;
27 }
28
29
30 //Insert element into odat_buf and cdat_buf
31 void
32 insert_ele(char* label, int vdat_id)
33 {
34
35
36 odat_buf[obi].label = label;
37 odat_buf[obi].vdat_id = vdat_id;
38 //TODO: check set_obi to see if set_map_data exists
39 //comes from e
40 odat_buf[obi].num_ref = odat_buf[set_obi].num_ref;
41 odat_buf[obi].ref_list = odat_buf[set_obi].ref_list;
42 odat_buf[obi].class_id = cbi;
43
44 if(IS_SUBCLASS())
45 {
46 cdat_buf[cbi].subclass_list[subclass_index].set_list[set_index].ele_list[ele_index].odat_id = obi;
47 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;
48 }
49 else
50 {
51 cdat_buf[cbi].set_list[set_index].ele_list[ele_index].odat_id = obi;
52 cdat_buf[cbi].set_list[set_index].ele_list[ele_index].parent_id = cdat_buf[cbi].set_index;
53 }
54
55 obi++;
56 }
57
58
59 /* fd could be a directory entry */
60 int
61 insert_fdat(char* label, char direction, int fd)
62 {
63 vdat_buf[vbi].model_list[vdat_buf[vbi].len].label = label;
64 vdat_buf[vbi].model_list[vdat_buf[vbi].len].fdat_id[(int)direction] = fd;
65 }
66
67 void
68 condense()
69 {
70 FILE* vp, op, cp;
71 int v, m;
72 int num_models;
73
74 vp = fopen("vdat_output", w+);
75 if(!vp)
76 perror("vdat_output failed to open\n");
77
78 op = fopen("odat_output", w+);
79 if(!op)
80 perror("odat_output failed to open\n");
81
82 cp = fopen("cdat_output", w+);
83 if(!cp)
84 perror("cdat_output failed to open\n");
85
86
87
88 /* fwrite vdat */
89 for(v = 0; v <= vbi; v++)
90 {
91 num_models = vdat_buf[v].num_models; //data duplication for caching
92 for(m = 0; m <= num_models; m++)
93 {
94
95 }
96 }
97
98 /* fwrite odat */
99 /* Convert ref_list to actual offset */
100
101 /* fwrite cdat */
102
103
104 }
105 void
106 inc_cbi()
107 {
108 cbi++;
109 }
110
111 void
112 set_class_label(char* label)
113 {
114 cdat_buf[cbi].label = $1;
115 }
116
117 void
118 inc_subclass_idx()
119 {
120 cdat_buf[cbi].subclass_index++;
121 }
122
123 void
124 inc_set_index()
125 {
126 odat_buf[cbi].set_index++;
127 }
128
129 void
130 inc_ref()
131 {
132 odat_buf[obi].ref_index++;
133 odat_buf[obi].num_ref++;
134 }
135
136 //TODO: This needs to be changed to account for
137 // when the set is of a subclass.
138 void
139 inc_ele()
140 {
141 cdat_buf[cbi].set_stack[stack_index].num_ele++;
142 }
143
144 void
145 inc_models()
146 {
147 vdat_buf[vbi].num_models++;
148 }