revert 213 commits (to 56092) from the last month. 10 still need work to resolve...
[AROS.git] / workbench / libs / mesa / src / glsl / ir_hierarchical_visitor.cpp
blobb5eacd6d2d480e4cd21230d683156e311a0f74be
1 /*
2 * Copyright © 2010 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 #include "ir.h"
25 #include "ir_hierarchical_visitor.h"
27 ir_hierarchical_visitor::ir_hierarchical_visitor()
29 this->base_ir = NULL;
30 this->callback = NULL;
31 this->data = NULL;
32 this->in_assignee = false;
35 ir_visitor_status
36 ir_hierarchical_visitor::visit(ir_variable *ir)
38 if (this->callback != NULL)
39 this->callback(ir, this->data);
41 return visit_continue;
44 ir_visitor_status
45 ir_hierarchical_visitor::visit(ir_constant *ir)
47 if (this->callback != NULL)
48 this->callback(ir, this->data);
50 return visit_continue;
53 ir_visitor_status
54 ir_hierarchical_visitor::visit(ir_loop_jump *ir)
56 if (this->callback != NULL)
57 this->callback(ir, this->data);
59 return visit_continue;
62 ir_visitor_status
63 ir_hierarchical_visitor::visit(ir_dereference_variable *ir)
65 if (this->callback != NULL)
66 this->callback(ir, this->data);
68 return visit_continue;
71 ir_visitor_status
72 ir_hierarchical_visitor::visit_enter(ir_loop *ir)
74 if (this->callback != NULL)
75 this->callback(ir, this->data);
77 return visit_continue;
80 ir_visitor_status
81 ir_hierarchical_visitor::visit_leave(ir_loop *ir)
83 (void) ir;
84 return visit_continue;
87 ir_visitor_status
88 ir_hierarchical_visitor::visit_enter(ir_function_signature *ir)
90 if (this->callback != NULL)
91 this->callback(ir, this->data);
93 return visit_continue;
96 ir_visitor_status
97 ir_hierarchical_visitor::visit_leave(ir_function_signature *ir)
99 (void) ir;
100 return visit_continue;
103 ir_visitor_status
104 ir_hierarchical_visitor::visit_enter(ir_function *ir)
106 if (this->callback != NULL)
107 this->callback(ir, this->data);
109 return visit_continue;
112 ir_visitor_status
113 ir_hierarchical_visitor::visit_leave(ir_function *ir)
115 (void) ir;
116 return visit_continue;
119 ir_visitor_status
120 ir_hierarchical_visitor::visit_enter(ir_expression *ir)
122 if (this->callback != NULL)
123 this->callback(ir, this->data);
125 return visit_continue;
128 ir_visitor_status
129 ir_hierarchical_visitor::visit_leave(ir_expression *ir)
131 (void) ir;
132 return visit_continue;
135 ir_visitor_status
136 ir_hierarchical_visitor::visit_enter(ir_texture *ir)
138 if (this->callback != NULL)
139 this->callback(ir, this->data);
141 return visit_continue;
144 ir_visitor_status
145 ir_hierarchical_visitor::visit_leave(ir_texture *ir)
147 (void) ir;
148 return visit_continue;
151 ir_visitor_status
152 ir_hierarchical_visitor::visit_enter(ir_swizzle *ir)
154 if (this->callback != NULL)
155 this->callback(ir, this->data);
157 return visit_continue;
160 ir_visitor_status
161 ir_hierarchical_visitor::visit_leave(ir_swizzle *ir)
163 (void) ir;
164 return visit_continue;
167 ir_visitor_status
168 ir_hierarchical_visitor::visit_enter(ir_dereference_array *ir)
170 if (this->callback != NULL)
171 this->callback(ir, this->data);
173 return visit_continue;
176 ir_visitor_status
177 ir_hierarchical_visitor::visit_leave(ir_dereference_array *ir)
179 (void) ir;
180 return visit_continue;
183 ir_visitor_status
184 ir_hierarchical_visitor::visit_enter(ir_dereference_record *ir)
186 if (this->callback != NULL)
187 this->callback(ir, this->data);
189 return visit_continue;
192 ir_visitor_status
193 ir_hierarchical_visitor::visit_leave(ir_dereference_record *ir)
195 (void) ir;
196 return visit_continue;
199 ir_visitor_status
200 ir_hierarchical_visitor::visit_enter(ir_assignment *ir)
202 if (this->callback != NULL)
203 this->callback(ir, this->data);
205 return visit_continue;
208 ir_visitor_status
209 ir_hierarchical_visitor::visit_leave(ir_assignment *ir)
211 (void) ir;
212 return visit_continue;
215 ir_visitor_status
216 ir_hierarchical_visitor::visit_enter(ir_call *ir)
218 if (this->callback != NULL)
219 this->callback(ir, this->data);
221 return visit_continue;
224 ir_visitor_status
225 ir_hierarchical_visitor::visit_leave(ir_call *ir)
227 (void) ir;
228 return visit_continue;
231 ir_visitor_status
232 ir_hierarchical_visitor::visit_enter(ir_return *ir)
234 if (this->callback != NULL)
235 this->callback(ir, this->data);
237 return visit_continue;
240 ir_visitor_status
241 ir_hierarchical_visitor::visit_leave(ir_return *ir)
243 (void) ir;
244 return visit_continue;
247 ir_visitor_status
248 ir_hierarchical_visitor::visit_enter(ir_discard *ir)
250 if (this->callback != NULL)
251 this->callback(ir, this->data);
253 return visit_continue;
256 ir_visitor_status
257 ir_hierarchical_visitor::visit_leave(ir_discard *ir)
259 (void) ir;
260 return visit_continue;
263 ir_visitor_status
264 ir_hierarchical_visitor::visit_enter(ir_if *ir)
266 if (this->callback != NULL)
267 this->callback(ir, this->data);
269 return visit_continue;
272 ir_visitor_status
273 ir_hierarchical_visitor::visit_leave(ir_if *ir)
275 (void) ir;
276 return visit_continue;
279 void
280 ir_hierarchical_visitor::run(exec_list *instructions)
282 visit_list_elements(this, instructions);
286 void
287 visit_tree(ir_instruction *ir,
288 void (*callback)(class ir_instruction *ir, void *data),
289 void *data)
291 ir_hierarchical_visitor v;
293 v.callback = callback;
294 v.data = data;
296 ir->accept(&v);