Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/pycparser/c_ast.py: 1%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1#-----------------------------------------------------------------
2# ** ATTENTION **
3# This code was automatically generated from the file:
4# _c_ast.cfg
5#
6# Do not modify it directly. Modify the configuration file and
7# run the generator again.
8# ** ** *** ** **
9#
10# pycparser: c_ast.py
11#
12# AST Node classes.
13#
14# Eli Bendersky [https://eli.thegreenplace.net/]
15# License: BSD
16#-----------------------------------------------------------------
19import sys
21def _repr(obj):
22 """
23 Get the representation of an object, with dedicated pprint-like format for lists.
24 """
25 if isinstance(obj, list):
26 return '[' + (',\n '.join((_repr(e).replace('\n', '\n ') for e in obj))) + '\n]'
27 else:
28 return repr(obj)
30class Node(object):
31 __slots__ = ()
32 """ Abstract base class for AST nodes.
33 """
34 def __repr__(self):
35 """ Generates a python representation of the current node
36 """
37 result = self.__class__.__name__ + '('
39 indent = ''
40 separator = ''
41 for name in self.__slots__[:-2]:
42 result += separator
43 result += indent
44 result += name + '=' + (_repr(getattr(self, name)).replace('\n', '\n ' + (' ' * (len(name) + len(self.__class__.__name__)))))
46 separator = ','
47 indent = '\n ' + (' ' * len(self.__class__.__name__))
49 result += indent + ')'
51 return result
53 def children(self):
54 """ A sequence of all children that are Nodes
55 """
56 pass
58 def show(self, buf=sys.stdout, offset=0, attrnames=False, nodenames=False, showcoord=False, _my_node_name=None):
59 """ Pretty print the Node and all its attributes and
60 children (recursively) to a buffer.
62 buf:
63 Open IO buffer into which the Node is printed.
65 offset:
66 Initial offset (amount of leading spaces)
68 attrnames:
69 True if you want to see the attribute names in
70 name=value pairs. False to only see the values.
72 nodenames:
73 True if you want to see the actual node names
74 within their parents.
76 showcoord:
77 Do you want the coordinates of each Node to be
78 displayed.
79 """
80 lead = ' ' * offset
81 if nodenames and _my_node_name is not None:
82 buf.write(lead + self.__class__.__name__+ ' <' + _my_node_name + '>: ')
83 else:
84 buf.write(lead + self.__class__.__name__+ ': ')
86 if self.attr_names:
87 if attrnames:
88 nvlist = [(n, getattr(self,n)) for n in self.attr_names]
89 attrstr = ', '.join('%s=%s' % nv for nv in nvlist)
90 else:
91 vlist = [getattr(self, n) for n in self.attr_names]
92 attrstr = ', '.join('%s' % v for v in vlist)
93 buf.write(attrstr)
95 if showcoord:
96 buf.write(' (at %s)' % self.coord)
97 buf.write('\n')
99 for (child_name, child) in self.children():
100 child.show(
101 buf,
102 offset=offset + 2,
103 attrnames=attrnames,
104 nodenames=nodenames,
105 showcoord=showcoord,
106 _my_node_name=child_name)
109class NodeVisitor(object):
110 """ A base NodeVisitor class for visiting c_ast nodes.
111 Subclass it and define your own visit_XXX methods, where
112 XXX is the class name you want to visit with these
113 methods.
115 For example:
117 class ConstantVisitor(NodeVisitor):
118 def __init__(self):
119 self.values = []
121 def visit_Constant(self, node):
122 self.values.append(node.value)
124 Creates a list of values of all the constant nodes
125 encountered below the given node. To use it:
127 cv = ConstantVisitor()
128 cv.visit(node)
130 Notes:
132 * generic_visit() will be called for AST nodes for which
133 no visit_XXX method was defined.
134 * The children of nodes for which a visit_XXX was
135 defined will not be visited - if you need this, call
136 generic_visit() on the node.
137 You can use:
138 NodeVisitor.generic_visit(self, node)
139 * Modeled after Python's own AST visiting facilities
140 (the ast module of Python 3.0)
141 """
143 _method_cache = None
145 def visit(self, node):
146 """ Visit a node.
147 """
149 if self._method_cache is None:
150 self._method_cache = {}
152 visitor = self._method_cache.get(node.__class__.__name__, None)
153 if visitor is None:
154 method = 'visit_' + node.__class__.__name__
155 visitor = getattr(self, method, self.generic_visit)
156 self._method_cache[node.__class__.__name__] = visitor
158 return visitor(node)
160 def generic_visit(self, node):
161 """ Called if no explicit visitor function exists for a
162 node. Implements preorder visiting of the node.
163 """
164 for c in node:
165 self.visit(c)
167class ArrayDecl(Node):
168 __slots__ = ('type', 'dim', 'dim_quals', 'coord', '__weakref__')
169 def __init__(self, type, dim, dim_quals, coord=None):
170 self.type = type
171 self.dim = dim
172 self.dim_quals = dim_quals
173 self.coord = coord
175 def children(self):
176 nodelist = []
177 if self.type is not None: nodelist.append(("type", self.type))
178 if self.dim is not None: nodelist.append(("dim", self.dim))
179 return tuple(nodelist)
181 def __iter__(self):
182 if self.type is not None:
183 yield self.type
184 if self.dim is not None:
185 yield self.dim
187 attr_names = ('dim_quals', )
189class ArrayRef(Node):
190 __slots__ = ('name', 'subscript', 'coord', '__weakref__')
191 def __init__(self, name, subscript, coord=None):
192 self.name = name
193 self.subscript = subscript
194 self.coord = coord
196 def children(self):
197 nodelist = []
198 if self.name is not None: nodelist.append(("name", self.name))
199 if self.subscript is not None: nodelist.append(("subscript", self.subscript))
200 return tuple(nodelist)
202 def __iter__(self):
203 if self.name is not None:
204 yield self.name
205 if self.subscript is not None:
206 yield self.subscript
208 attr_names = ()
210class Assignment(Node):
211 __slots__ = ('op', 'lvalue', 'rvalue', 'coord', '__weakref__')
212 def __init__(self, op, lvalue, rvalue, coord=None):
213 self.op = op
214 self.lvalue = lvalue
215 self.rvalue = rvalue
216 self.coord = coord
218 def children(self):
219 nodelist = []
220 if self.lvalue is not None: nodelist.append(("lvalue", self.lvalue))
221 if self.rvalue is not None: nodelist.append(("rvalue", self.rvalue))
222 return tuple(nodelist)
224 def __iter__(self):
225 if self.lvalue is not None:
226 yield self.lvalue
227 if self.rvalue is not None:
228 yield self.rvalue
230 attr_names = ('op', )
232class Alignas(Node):
233 __slots__ = ('alignment', 'coord', '__weakref__')
234 def __init__(self, alignment, coord=None):
235 self.alignment = alignment
236 self.coord = coord
238 def children(self):
239 nodelist = []
240 if self.alignment is not None: nodelist.append(("alignment", self.alignment))
241 return tuple(nodelist)
243 def __iter__(self):
244 if self.alignment is not None:
245 yield self.alignment
247 attr_names = ()
249class BinaryOp(Node):
250 __slots__ = ('op', 'left', 'right', 'coord', '__weakref__')
251 def __init__(self, op, left, right, coord=None):
252 self.op = op
253 self.left = left
254 self.right = right
255 self.coord = coord
257 def children(self):
258 nodelist = []
259 if self.left is not None: nodelist.append(("left", self.left))
260 if self.right is not None: nodelist.append(("right", self.right))
261 return tuple(nodelist)
263 def __iter__(self):
264 if self.left is not None:
265 yield self.left
266 if self.right is not None:
267 yield self.right
269 attr_names = ('op', )
271class Break(Node):
272 __slots__ = ('coord', '__weakref__')
273 def __init__(self, coord=None):
274 self.coord = coord
276 def children(self):
277 return ()
279 def __iter__(self):
280 return
281 yield
283 attr_names = ()
285class Case(Node):
286 __slots__ = ('expr', 'stmts', 'coord', '__weakref__')
287 def __init__(self, expr, stmts, coord=None):
288 self.expr = expr
289 self.stmts = stmts
290 self.coord = coord
292 def children(self):
293 nodelist = []
294 if self.expr is not None: nodelist.append(("expr", self.expr))
295 for i, child in enumerate(self.stmts or []):
296 nodelist.append(("stmts[%d]" % i, child))
297 return tuple(nodelist)
299 def __iter__(self):
300 if self.expr is not None:
301 yield self.expr
302 for child in (self.stmts or []):
303 yield child
305 attr_names = ()
307class Cast(Node):
308 __slots__ = ('to_type', 'expr', 'coord', '__weakref__')
309 def __init__(self, to_type, expr, coord=None):
310 self.to_type = to_type
311 self.expr = expr
312 self.coord = coord
314 def children(self):
315 nodelist = []
316 if self.to_type is not None: nodelist.append(("to_type", self.to_type))
317 if self.expr is not None: nodelist.append(("expr", self.expr))
318 return tuple(nodelist)
320 def __iter__(self):
321 if self.to_type is not None:
322 yield self.to_type
323 if self.expr is not None:
324 yield self.expr
326 attr_names = ()
328class Compound(Node):
329 __slots__ = ('block_items', 'coord', '__weakref__')
330 def __init__(self, block_items, coord=None):
331 self.block_items = block_items
332 self.coord = coord
334 def children(self):
335 nodelist = []
336 for i, child in enumerate(self.block_items or []):
337 nodelist.append(("block_items[%d]" % i, child))
338 return tuple(nodelist)
340 def __iter__(self):
341 for child in (self.block_items or []):
342 yield child
344 attr_names = ()
346class CompoundLiteral(Node):
347 __slots__ = ('type', 'init', 'coord', '__weakref__')
348 def __init__(self, type, init, coord=None):
349 self.type = type
350 self.init = init
351 self.coord = coord
353 def children(self):
354 nodelist = []
355 if self.type is not None: nodelist.append(("type", self.type))
356 if self.init is not None: nodelist.append(("init", self.init))
357 return tuple(nodelist)
359 def __iter__(self):
360 if self.type is not None:
361 yield self.type
362 if self.init is not None:
363 yield self.init
365 attr_names = ()
367class Constant(Node):
368 __slots__ = ('type', 'value', 'coord', '__weakref__')
369 def __init__(self, type, value, coord=None):
370 self.type = type
371 self.value = value
372 self.coord = coord
374 def children(self):
375 nodelist = []
376 return tuple(nodelist)
378 def __iter__(self):
379 return
380 yield
382 attr_names = ('type', 'value', )
384class Continue(Node):
385 __slots__ = ('coord', '__weakref__')
386 def __init__(self, coord=None):
387 self.coord = coord
389 def children(self):
390 return ()
392 def __iter__(self):
393 return
394 yield
396 attr_names = ()
398class Decl(Node):
399 __slots__ = ('name', 'quals', 'align', 'storage', 'funcspec', 'type', 'init', 'bitsize', 'coord', '__weakref__')
400 def __init__(self, name, quals, align, storage, funcspec, type, init, bitsize, coord=None):
401 self.name = name
402 self.quals = quals
403 self.align = align
404 self.storage = storage
405 self.funcspec = funcspec
406 self.type = type
407 self.init = init
408 self.bitsize = bitsize
409 self.coord = coord
411 def children(self):
412 nodelist = []
413 if self.type is not None: nodelist.append(("type", self.type))
414 if self.init is not None: nodelist.append(("init", self.init))
415 if self.bitsize is not None: nodelist.append(("bitsize", self.bitsize))
416 return tuple(nodelist)
418 def __iter__(self):
419 if self.type is not None:
420 yield self.type
421 if self.init is not None:
422 yield self.init
423 if self.bitsize is not None:
424 yield self.bitsize
426 attr_names = ('name', 'quals', 'align', 'storage', 'funcspec', )
428class DeclList(Node):
429 __slots__ = ('decls', 'coord', '__weakref__')
430 def __init__(self, decls, coord=None):
431 self.decls = decls
432 self.coord = coord
434 def children(self):
435 nodelist = []
436 for i, child in enumerate(self.decls or []):
437 nodelist.append(("decls[%d]" % i, child))
438 return tuple(nodelist)
440 def __iter__(self):
441 for child in (self.decls or []):
442 yield child
444 attr_names = ()
446class Default(Node):
447 __slots__ = ('stmts', 'coord', '__weakref__')
448 def __init__(self, stmts, coord=None):
449 self.stmts = stmts
450 self.coord = coord
452 def children(self):
453 nodelist = []
454 for i, child in enumerate(self.stmts or []):
455 nodelist.append(("stmts[%d]" % i, child))
456 return tuple(nodelist)
458 def __iter__(self):
459 for child in (self.stmts or []):
460 yield child
462 attr_names = ()
464class DoWhile(Node):
465 __slots__ = ('cond', 'stmt', 'coord', '__weakref__')
466 def __init__(self, cond, stmt, coord=None):
467 self.cond = cond
468 self.stmt = stmt
469 self.coord = coord
471 def children(self):
472 nodelist = []
473 if self.cond is not None: nodelist.append(("cond", self.cond))
474 if self.stmt is not None: nodelist.append(("stmt", self.stmt))
475 return tuple(nodelist)
477 def __iter__(self):
478 if self.cond is not None:
479 yield self.cond
480 if self.stmt is not None:
481 yield self.stmt
483 attr_names = ()
485class EllipsisParam(Node):
486 __slots__ = ('coord', '__weakref__')
487 def __init__(self, coord=None):
488 self.coord = coord
490 def children(self):
491 return ()
493 def __iter__(self):
494 return
495 yield
497 attr_names = ()
499class EmptyStatement(Node):
500 __slots__ = ('coord', '__weakref__')
501 def __init__(self, coord=None):
502 self.coord = coord
504 def children(self):
505 return ()
507 def __iter__(self):
508 return
509 yield
511 attr_names = ()
513class Enum(Node):
514 __slots__ = ('name', 'values', 'coord', '__weakref__')
515 def __init__(self, name, values, coord=None):
516 self.name = name
517 self.values = values
518 self.coord = coord
520 def children(self):
521 nodelist = []
522 if self.values is not None: nodelist.append(("values", self.values))
523 return tuple(nodelist)
525 def __iter__(self):
526 if self.values is not None:
527 yield self.values
529 attr_names = ('name', )
531class Enumerator(Node):
532 __slots__ = ('name', 'value', 'coord', '__weakref__')
533 def __init__(self, name, value, coord=None):
534 self.name = name
535 self.value = value
536 self.coord = coord
538 def children(self):
539 nodelist = []
540 if self.value is not None: nodelist.append(("value", self.value))
541 return tuple(nodelist)
543 def __iter__(self):
544 if self.value is not None:
545 yield self.value
547 attr_names = ('name', )
549class EnumeratorList(Node):
550 __slots__ = ('enumerators', 'coord', '__weakref__')
551 def __init__(self, enumerators, coord=None):
552 self.enumerators = enumerators
553 self.coord = coord
555 def children(self):
556 nodelist = []
557 for i, child in enumerate(self.enumerators or []):
558 nodelist.append(("enumerators[%d]" % i, child))
559 return tuple(nodelist)
561 def __iter__(self):
562 for child in (self.enumerators or []):
563 yield child
565 attr_names = ()
567class ExprList(Node):
568 __slots__ = ('exprs', 'coord', '__weakref__')
569 def __init__(self, exprs, coord=None):
570 self.exprs = exprs
571 self.coord = coord
573 def children(self):
574 nodelist = []
575 for i, child in enumerate(self.exprs or []):
576 nodelist.append(("exprs[%d]" % i, child))
577 return tuple(nodelist)
579 def __iter__(self):
580 for child in (self.exprs or []):
581 yield child
583 attr_names = ()
585class FileAST(Node):
586 __slots__ = ('ext', 'coord', '__weakref__')
587 def __init__(self, ext, coord=None):
588 self.ext = ext
589 self.coord = coord
591 def children(self):
592 nodelist = []
593 for i, child in enumerate(self.ext or []):
594 nodelist.append(("ext[%d]" % i, child))
595 return tuple(nodelist)
597 def __iter__(self):
598 for child in (self.ext or []):
599 yield child
601 attr_names = ()
603class For(Node):
604 __slots__ = ('init', 'cond', 'next', 'stmt', 'coord', '__weakref__')
605 def __init__(self, init, cond, next, stmt, coord=None):
606 self.init = init
607 self.cond = cond
608 self.next = next
609 self.stmt = stmt
610 self.coord = coord
612 def children(self):
613 nodelist = []
614 if self.init is not None: nodelist.append(("init", self.init))
615 if self.cond is not None: nodelist.append(("cond", self.cond))
616 if self.next is not None: nodelist.append(("next", self.next))
617 if self.stmt is not None: nodelist.append(("stmt", self.stmt))
618 return tuple(nodelist)
620 def __iter__(self):
621 if self.init is not None:
622 yield self.init
623 if self.cond is not None:
624 yield self.cond
625 if self.next is not None:
626 yield self.next
627 if self.stmt is not None:
628 yield self.stmt
630 attr_names = ()
632class FuncCall(Node):
633 __slots__ = ('name', 'args', 'coord', '__weakref__')
634 def __init__(self, name, args, coord=None):
635 self.name = name
636 self.args = args
637 self.coord = coord
639 def children(self):
640 nodelist = []
641 if self.name is not None: nodelist.append(("name", self.name))
642 if self.args is not None: nodelist.append(("args", self.args))
643 return tuple(nodelist)
645 def __iter__(self):
646 if self.name is not None:
647 yield self.name
648 if self.args is not None:
649 yield self.args
651 attr_names = ()
653class FuncDecl(Node):
654 __slots__ = ('args', 'type', 'coord', '__weakref__')
655 def __init__(self, args, type, coord=None):
656 self.args = args
657 self.type = type
658 self.coord = coord
660 def children(self):
661 nodelist = []
662 if self.args is not None: nodelist.append(("args", self.args))
663 if self.type is not None: nodelist.append(("type", self.type))
664 return tuple(nodelist)
666 def __iter__(self):
667 if self.args is not None:
668 yield self.args
669 if self.type is not None:
670 yield self.type
672 attr_names = ()
674class FuncDef(Node):
675 __slots__ = ('decl', 'param_decls', 'body', 'coord', '__weakref__')
676 def __init__(self, decl, param_decls, body, coord=None):
677 self.decl = decl
678 self.param_decls = param_decls
679 self.body = body
680 self.coord = coord
682 def children(self):
683 nodelist = []
684 if self.decl is not None: nodelist.append(("decl", self.decl))
685 if self.body is not None: nodelist.append(("body", self.body))
686 for i, child in enumerate(self.param_decls or []):
687 nodelist.append(("param_decls[%d]" % i, child))
688 return tuple(nodelist)
690 def __iter__(self):
691 if self.decl is not None:
692 yield self.decl
693 if self.body is not None:
694 yield self.body
695 for child in (self.param_decls or []):
696 yield child
698 attr_names = ()
700class Goto(Node):
701 __slots__ = ('name', 'coord', '__weakref__')
702 def __init__(self, name, coord=None):
703 self.name = name
704 self.coord = coord
706 def children(self):
707 nodelist = []
708 return tuple(nodelist)
710 def __iter__(self):
711 return
712 yield
714 attr_names = ('name', )
716class ID(Node):
717 __slots__ = ('name', 'coord', '__weakref__')
718 def __init__(self, name, coord=None):
719 self.name = name
720 self.coord = coord
722 def children(self):
723 nodelist = []
724 return tuple(nodelist)
726 def __iter__(self):
727 return
728 yield
730 attr_names = ('name', )
732class IdentifierType(Node):
733 __slots__ = ('names', 'coord', '__weakref__')
734 def __init__(self, names, coord=None):
735 self.names = names
736 self.coord = coord
738 def children(self):
739 nodelist = []
740 return tuple(nodelist)
742 def __iter__(self):
743 return
744 yield
746 attr_names = ('names', )
748class If(Node):
749 __slots__ = ('cond', 'iftrue', 'iffalse', 'coord', '__weakref__')
750 def __init__(self, cond, iftrue, iffalse, coord=None):
751 self.cond = cond
752 self.iftrue = iftrue
753 self.iffalse = iffalse
754 self.coord = coord
756 def children(self):
757 nodelist = []
758 if self.cond is not None: nodelist.append(("cond", self.cond))
759 if self.iftrue is not None: nodelist.append(("iftrue", self.iftrue))
760 if self.iffalse is not None: nodelist.append(("iffalse", self.iffalse))
761 return tuple(nodelist)
763 def __iter__(self):
764 if self.cond is not None:
765 yield self.cond
766 if self.iftrue is not None:
767 yield self.iftrue
768 if self.iffalse is not None:
769 yield self.iffalse
771 attr_names = ()
773class InitList(Node):
774 __slots__ = ('exprs', 'coord', '__weakref__')
775 def __init__(self, exprs, coord=None):
776 self.exprs = exprs
777 self.coord = coord
779 def children(self):
780 nodelist = []
781 for i, child in enumerate(self.exprs or []):
782 nodelist.append(("exprs[%d]" % i, child))
783 return tuple(nodelist)
785 def __iter__(self):
786 for child in (self.exprs or []):
787 yield child
789 attr_names = ()
791class Label(Node):
792 __slots__ = ('name', 'stmt', 'coord', '__weakref__')
793 def __init__(self, name, stmt, coord=None):
794 self.name = name
795 self.stmt = stmt
796 self.coord = coord
798 def children(self):
799 nodelist = []
800 if self.stmt is not None: nodelist.append(("stmt", self.stmt))
801 return tuple(nodelist)
803 def __iter__(self):
804 if self.stmt is not None:
805 yield self.stmt
807 attr_names = ('name', )
809class NamedInitializer(Node):
810 __slots__ = ('name', 'expr', 'coord', '__weakref__')
811 def __init__(self, name, expr, coord=None):
812 self.name = name
813 self.expr = expr
814 self.coord = coord
816 def children(self):
817 nodelist = []
818 if self.expr is not None: nodelist.append(("expr", self.expr))
819 for i, child in enumerate(self.name or []):
820 nodelist.append(("name[%d]" % i, child))
821 return tuple(nodelist)
823 def __iter__(self):
824 if self.expr is not None:
825 yield self.expr
826 for child in (self.name or []):
827 yield child
829 attr_names = ()
831class ParamList(Node):
832 __slots__ = ('params', 'coord', '__weakref__')
833 def __init__(self, params, coord=None):
834 self.params = params
835 self.coord = coord
837 def children(self):
838 nodelist = []
839 for i, child in enumerate(self.params or []):
840 nodelist.append(("params[%d]" % i, child))
841 return tuple(nodelist)
843 def __iter__(self):
844 for child in (self.params or []):
845 yield child
847 attr_names = ()
849class PtrDecl(Node):
850 __slots__ = ('quals', 'type', 'coord', '__weakref__')
851 def __init__(self, quals, type, coord=None):
852 self.quals = quals
853 self.type = type
854 self.coord = coord
856 def children(self):
857 nodelist = []
858 if self.type is not None: nodelist.append(("type", self.type))
859 return tuple(nodelist)
861 def __iter__(self):
862 if self.type is not None:
863 yield self.type
865 attr_names = ('quals', )
867class Return(Node):
868 __slots__ = ('expr', 'coord', '__weakref__')
869 def __init__(self, expr, coord=None):
870 self.expr = expr
871 self.coord = coord
873 def children(self):
874 nodelist = []
875 if self.expr is not None: nodelist.append(("expr", self.expr))
876 return tuple(nodelist)
878 def __iter__(self):
879 if self.expr is not None:
880 yield self.expr
882 attr_names = ()
884class StaticAssert(Node):
885 __slots__ = ('cond', 'message', 'coord', '__weakref__')
886 def __init__(self, cond, message, coord=None):
887 self.cond = cond
888 self.message = message
889 self.coord = coord
891 def children(self):
892 nodelist = []
893 if self.cond is not None: nodelist.append(("cond", self.cond))
894 if self.message is not None: nodelist.append(("message", self.message))
895 return tuple(nodelist)
897 def __iter__(self):
898 if self.cond is not None:
899 yield self.cond
900 if self.message is not None:
901 yield self.message
903 attr_names = ()
905class Struct(Node):
906 __slots__ = ('name', 'decls', 'coord', '__weakref__')
907 def __init__(self, name, decls, coord=None):
908 self.name = name
909 self.decls = decls
910 self.coord = coord
912 def children(self):
913 nodelist = []
914 for i, child in enumerate(self.decls or []):
915 nodelist.append(("decls[%d]" % i, child))
916 return tuple(nodelist)
918 def __iter__(self):
919 for child in (self.decls or []):
920 yield child
922 attr_names = ('name', )
924class StructRef(Node):
925 __slots__ = ('name', 'type', 'field', 'coord', '__weakref__')
926 def __init__(self, name, type, field, coord=None):
927 self.name = name
928 self.type = type
929 self.field = field
930 self.coord = coord
932 def children(self):
933 nodelist = []
934 if self.name is not None: nodelist.append(("name", self.name))
935 if self.field is not None: nodelist.append(("field", self.field))
936 return tuple(nodelist)
938 def __iter__(self):
939 if self.name is not None:
940 yield self.name
941 if self.field is not None:
942 yield self.field
944 attr_names = ('type', )
946class Switch(Node):
947 __slots__ = ('cond', 'stmt', 'coord', '__weakref__')
948 def __init__(self, cond, stmt, coord=None):
949 self.cond = cond
950 self.stmt = stmt
951 self.coord = coord
953 def children(self):
954 nodelist = []
955 if self.cond is not None: nodelist.append(("cond", self.cond))
956 if self.stmt is not None: nodelist.append(("stmt", self.stmt))
957 return tuple(nodelist)
959 def __iter__(self):
960 if self.cond is not None:
961 yield self.cond
962 if self.stmt is not None:
963 yield self.stmt
965 attr_names = ()
967class TernaryOp(Node):
968 __slots__ = ('cond', 'iftrue', 'iffalse', 'coord', '__weakref__')
969 def __init__(self, cond, iftrue, iffalse, coord=None):
970 self.cond = cond
971 self.iftrue = iftrue
972 self.iffalse = iffalse
973 self.coord = coord
975 def children(self):
976 nodelist = []
977 if self.cond is not None: nodelist.append(("cond", self.cond))
978 if self.iftrue is not None: nodelist.append(("iftrue", self.iftrue))
979 if self.iffalse is not None: nodelist.append(("iffalse", self.iffalse))
980 return tuple(nodelist)
982 def __iter__(self):
983 if self.cond is not None:
984 yield self.cond
985 if self.iftrue is not None:
986 yield self.iftrue
987 if self.iffalse is not None:
988 yield self.iffalse
990 attr_names = ()
992class TypeDecl(Node):
993 __slots__ = ('declname', 'quals', 'align', 'type', 'coord', '__weakref__')
994 def __init__(self, declname, quals, align, type, coord=None):
995 self.declname = declname
996 self.quals = quals
997 self.align = align
998 self.type = type
999 self.coord = coord
1001 def children(self):
1002 nodelist = []
1003 if self.type is not None: nodelist.append(("type", self.type))
1004 return tuple(nodelist)
1006 def __iter__(self):
1007 if self.type is not None:
1008 yield self.type
1010 attr_names = ('declname', 'quals', 'align', )
1012class Typedef(Node):
1013 __slots__ = ('name', 'quals', 'storage', 'type', 'coord', '__weakref__')
1014 def __init__(self, name, quals, storage, type, coord=None):
1015 self.name = name
1016 self.quals = quals
1017 self.storage = storage
1018 self.type = type
1019 self.coord = coord
1021 def children(self):
1022 nodelist = []
1023 if self.type is not None: nodelist.append(("type", self.type))
1024 return tuple(nodelist)
1026 def __iter__(self):
1027 if self.type is not None:
1028 yield self.type
1030 attr_names = ('name', 'quals', 'storage', )
1032class Typename(Node):
1033 __slots__ = ('name', 'quals', 'align', 'type', 'coord', '__weakref__')
1034 def __init__(self, name, quals, align, type, coord=None):
1035 self.name = name
1036 self.quals = quals
1037 self.align = align
1038 self.type = type
1039 self.coord = coord
1041 def children(self):
1042 nodelist = []
1043 if self.type is not None: nodelist.append(("type", self.type))
1044 return tuple(nodelist)
1046 def __iter__(self):
1047 if self.type is not None:
1048 yield self.type
1050 attr_names = ('name', 'quals', 'align', )
1052class UnaryOp(Node):
1053 __slots__ = ('op', 'expr', 'coord', '__weakref__')
1054 def __init__(self, op, expr, coord=None):
1055 self.op = op
1056 self.expr = expr
1057 self.coord = coord
1059 def children(self):
1060 nodelist = []
1061 if self.expr is not None: nodelist.append(("expr", self.expr))
1062 return tuple(nodelist)
1064 def __iter__(self):
1065 if self.expr is not None:
1066 yield self.expr
1068 attr_names = ('op', )
1070class Union(Node):
1071 __slots__ = ('name', 'decls', 'coord', '__weakref__')
1072 def __init__(self, name, decls, coord=None):
1073 self.name = name
1074 self.decls = decls
1075 self.coord = coord
1077 def children(self):
1078 nodelist = []
1079 for i, child in enumerate(self.decls or []):
1080 nodelist.append(("decls[%d]" % i, child))
1081 return tuple(nodelist)
1083 def __iter__(self):
1084 for child in (self.decls or []):
1085 yield child
1087 attr_names = ('name', )
1089class While(Node):
1090 __slots__ = ('cond', 'stmt', 'coord', '__weakref__')
1091 def __init__(self, cond, stmt, coord=None):
1092 self.cond = cond
1093 self.stmt = stmt
1094 self.coord = coord
1096 def children(self):
1097 nodelist = []
1098 if self.cond is not None: nodelist.append(("cond", self.cond))
1099 if self.stmt is not None: nodelist.append(("stmt", self.stmt))
1100 return tuple(nodelist)
1102 def __iter__(self):
1103 if self.cond is not None:
1104 yield self.cond
1105 if self.stmt is not None:
1106 yield self.stmt
1108 attr_names = ()
1110class Pragma(Node):
1111 __slots__ = ('string', 'coord', '__weakref__')
1112 def __init__(self, string, coord=None):
1113 self.string = string
1114 self.coord = coord
1116 def children(self):
1117 nodelist = []
1118 return tuple(nodelist)
1120 def __iter__(self):
1121 return
1122 yield
1124 attr_names = ('string', )