Mercurial > hg > CbC > CbC_gcc
comparison gcc/tree-iterator.c @ 55:77e2b8dfacca gcc-4.4.5
update it from 4.4.3 to 4.5.0
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 12 Feb 2010 23:39:51 +0900 |
parents | a06113de4d67 |
children | b7f97abdc517 |
comparison
equal
deleted
inserted
replaced
52:c156f1bd5cd9 | 55:77e2b8dfacca |
---|---|
236 TREE_SIDE_EFFECTS (i->container) = 0; | 236 TREE_SIDE_EFFECTS (i->container) = 0; |
237 | 237 |
238 i->ptr = next; | 238 i->ptr = next; |
239 } | 239 } |
240 | 240 |
241 /* Move all statements in the statement list after I to a new | |
242 statement list. I itself is unchanged. */ | |
243 | |
244 tree | |
245 tsi_split_statement_list_after (const tree_stmt_iterator *i) | |
246 { | |
247 struct tree_statement_list_node *cur, *next; | |
248 tree old_sl, new_sl; | |
249 | |
250 cur = i->ptr; | |
251 /* How can we possibly split after the end, or before the beginning? */ | |
252 gcc_assert (cur); | |
253 next = cur->next; | |
254 | |
255 old_sl = i->container; | |
256 new_sl = alloc_stmt_list (); | |
257 TREE_SIDE_EFFECTS (new_sl) = 1; | |
258 | |
259 STATEMENT_LIST_HEAD (new_sl) = next; | |
260 STATEMENT_LIST_TAIL (new_sl) = STATEMENT_LIST_TAIL (old_sl); | |
261 STATEMENT_LIST_TAIL (old_sl) = cur; | |
262 cur->next = NULL; | |
263 next->prev = NULL; | |
264 | |
265 return new_sl; | |
266 } | |
267 | |
268 /* Move all statements in the statement list before I to a new | |
269 statement list. I is set to the head of the new list. */ | |
270 | |
271 tree | |
272 tsi_split_statement_list_before (tree_stmt_iterator *i) | |
273 { | |
274 struct tree_statement_list_node *cur, *prev; | |
275 tree old_sl, new_sl; | |
276 | |
277 cur = i->ptr; | |
278 /* How can we possibly split after the end, or before the beginning? */ | |
279 gcc_assert (cur); | |
280 prev = cur->prev; | |
281 | |
282 old_sl = i->container; | |
283 new_sl = alloc_stmt_list (); | |
284 TREE_SIDE_EFFECTS (new_sl) = 1; | |
285 i->container = new_sl; | |
286 | |
287 STATEMENT_LIST_HEAD (new_sl) = cur; | |
288 STATEMENT_LIST_TAIL (new_sl) = STATEMENT_LIST_TAIL (old_sl); | |
289 STATEMENT_LIST_TAIL (old_sl) = prev; | |
290 cur->prev = NULL; | |
291 if (prev) | |
292 prev->next = NULL; | |
293 else | |
294 STATEMENT_LIST_HEAD (old_sl) = NULL; | |
295 | |
296 return new_sl; | |
297 } | |
298 | |
299 /* Return the first expression in a sequence of COMPOUND_EXPRs, | 241 /* Return the first expression in a sequence of COMPOUND_EXPRs, |
300 or in a STATEMENT_LIST. */ | 242 or in a STATEMENT_LIST. */ |
301 | 243 |
302 tree | 244 tree |
303 expr_first (tree expr) | 245 expr_first (tree expr) |
318 } | 260 } |
319 | 261 |
320 /* Return the last expression in a sequence of COMPOUND_EXPRs, | 262 /* Return the last expression in a sequence of COMPOUND_EXPRs, |
321 or in a STATEMENT_LIST. */ | 263 or in a STATEMENT_LIST. */ |
322 | 264 |
323 #define EXPR_LAST_BODY do { \ | |
324 if (expr == NULL_TREE) \ | |
325 return expr;\ | |
326 if (TREE_CODE (expr) == STATEMENT_LIST) \ | |
327 { \ | |
328 struct tree_statement_list_node *n = STATEMENT_LIST_TAIL (expr); \ | |
329 return n ? n->stmt : NULL_TREE; \ | |
330 } \ | |
331 while (TREE_CODE (expr) == COMPOUND_EXPR) \ | |
332 expr = TREE_OPERAND (expr, 1); \ | |
333 return expr; \ | |
334 } while (0) | |
335 | |
336 tree | 265 tree |
337 expr_last (tree expr) | 266 expr_last (tree expr) |
338 { | 267 { |
339 if (expr == NULL_TREE) | 268 if (expr == NULL_TREE) |
340 return expr; | 269 return expr; |
349 expr = TREE_OPERAND (expr, 1); | 278 expr = TREE_OPERAND (expr, 1); |
350 | 279 |
351 return expr; | 280 return expr; |
352 } | 281 } |
353 | 282 |
354 /* If EXPR is a single statement return it. If EXPR is a | |
355 STATEMENT_LIST containing exactly one statement S, return S. | |
356 Otherwise, return NULL. */ | |
357 | |
358 tree | |
359 expr_only (tree expr) | |
360 { | |
361 if (expr == NULL_TREE) | |
362 return NULL_TREE; | |
363 | |
364 if (TREE_CODE (expr) == STATEMENT_LIST) | |
365 { | |
366 struct tree_statement_list_node *n = STATEMENT_LIST_TAIL (expr); | |
367 if (n && STATEMENT_LIST_HEAD (expr) == n) | |
368 return n->stmt; | |
369 else | |
370 return NULL_TREE; | |
371 } | |
372 | |
373 if (TREE_CODE (expr) == COMPOUND_EXPR) | |
374 return NULL_TREE; | |
375 | |
376 return expr; | |
377 } | |
378 | |
379 #include "gt-tree-iterator.h" | 283 #include "gt-tree-iterator.h" |