codekingpro/portable-devtools
114k
1#-----------------------------------------------------------------2# ** ATTENTION **3# This code was automatically generated from the file:4# _c_ast.cfg5#6# Do not modify it directly. Modify the configuration file and7# run the generator again.8# ** ** *** ** **9#10# pycparser: c_ast.py11#12# AST Node classes.13#14# Eli Bendersky [https://eli.thegreenplace.net/]15# License: BSD16#-----------------------------------------------------------------17 18 19import sys20 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)29 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 node36 """37 result = self.__class__.__name__ + '('38 39 indent = ''40 separator = ''41 for name in self.__slots__[:-2]:42 result += separator43 result += indent44 result += name + '=' + (_repr(getattr(self, name)).replace('\n', '\n ' + (' ' * (len(name) + len(self.__class__.__name__)))))45 46 separator = ','47 indent = '\n ' + (' ' * len(self.__class__.__name__))48 49 result += indent + ')'50 51 return result52 53 def children(self):54 """ A sequence of all children that are Nodes55 """56 pass57 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 and60 children (recursively) to a buffer.61 62 buf:63 Open IO buffer into which the Node is printed.64 65 offset:66 Initial offset (amount of leading spaces)67 68 attrnames:69 True if you want to see the attribute names in70 name=value pairs. False to only see the values.71 72 nodenames:73 True if you want to see the actual node names74 within their parents.75 76 showcoord:77 Do you want the coordinates of each Node to be78 displayed.79 """80 lead = ' ' * offset81 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__+ ': ')85 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)94 95 if showcoord:96 buf.write(' (at %s)' % self.coord)97 buf.write('\n')98 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)107 108 109class NodeVisitor(object):110 """ A base NodeVisitor class for visiting c_ast nodes.111 Subclass it and define your own visit_XXX methods, where112 XXX is the class name you want to visit with these113 methods.114 115 For example:116 117 class ConstantVisitor(NodeVisitor):118 def __init__(self):119 self.values = []120 121 def visit_Constant(self, node):122 self.values.append(node.value)123 124 Creates a list of values of all the constant nodes125 encountered below the given node. To use it:126 127 cv = ConstantVisitor()128 cv.visit(node)129 130 Notes:131 132 * generic_visit() will be called for AST nodes for which133 no visit_XXX method was defined.134 * The children of nodes for which a visit_XXX was135 defined will not be visited - if you need this, call136 generic_visit() on the node.137 You can use:138 NodeVisitor.generic_visit(self, node)139 * Modeled after Python's own AST visiting facilities140 (the ast module of Python 3.0)141 """142 143 _method_cache = None144 145 def visit(self, node):146 """ Visit a node.147 """148 149 if self._method_cache is None:150 self._method_cache = {}151 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__] = visitor157 158 return visitor(node)159 160 def generic_visit(self, node):161 """ Called if no explicit visitor function exists for a162 node. Implements preorder visiting of the node.163 """164 for c in node:165 self.visit(c)166 167class ArrayDecl(Node):168 __slots__ = ('type', 'dim', 'dim_quals', 'coord', '__weakref__')169 def __init__(self, type, dim, dim_quals, coord=None):170 self.type = type171 self.dim = dim172 self.dim_quals = dim_quals173 self.coord = coord174 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)180 181 def __iter__(self):182 if self.type is not None:183 yield self.type184 if self.dim is not None:185 yield self.dim186 187 attr_names = ('dim_quals', )188 189class ArrayRef(Node):190 __slots__ = ('name', 'subscript', 'coord', '__weakref__')191 def __init__(self, name, subscript, coord=None):192 self.name = name193 self.subscript = subscript194 self.coord = coord195 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)201 202 def __iter__(self):203 if self.name is not None:204 yield self.name205 if self.subscript is not None:206 yield self.subscript207 208 attr_names = ()209 210class Assignment(Node):211 __slots__ = ('op', 'lvalue', 'rvalue', 'coord', '__weakref__')212 def __init__(self, op, lvalue, rvalue, coord=None):213 self.op = op214 self.lvalue = lvalue215 self.rvalue = rvalue216 self.coord = coord217 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)223 224 def __iter__(self):225 if self.lvalue is not None:226 yield self.lvalue227 if self.rvalue is not None:228 yield self.rvalue229 230 attr_names = ('op', )231 232class Alignas(Node):233 __slots__ = ('alignment', 'coord', '__weakref__')234 def __init__(self, alignment, coord=None):235 self.alignment = alignment236 self.coord = coord237 238 def children(self):239 nodelist = []240 if self.alignment is not None: nodelist.append(("alignment", self.alignment))241 return tuple(nodelist)242 243 def __iter__(self):244 if self.alignment is not None:245 yield self.alignment246 247 attr_names = ()248 249class BinaryOp(Node):250 __slots__ = ('op', 'left', 'right', 'coord', '__weakref__')251 def __init__(self, op, left, right, coord=None):252 self.op = op253 self.left = left254 self.right = right255 self.coord = coord256 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)262 263 def __iter__(self):264 if self.left is not None:265 yield self.left266 if self.right is not None:267 yield self.right268 269 attr_names = ('op', )270 271class Break(Node):272 __slots__ = ('coord', '__weakref__')273 def __init__(self, coord=None):274 self.coord = coord275 276 def children(self):277 return ()278 279 def __iter__(self):280 return281 yield282 283 attr_names = ()284 285class Case(Node):286 __slots__ = ('expr', 'stmts', 'coord', '__weakref__')287 def __init__(self, expr, stmts, coord=None):288 self.expr = expr289 self.stmts = stmts290 self.coord = coord291 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)298 299 def __iter__(self):300 if self.expr is not None:301 yield self.expr302 for child in (self.stmts or []):303 yield child304 305 attr_names = ()306 307class Cast(Node):308 __slots__ = ('to_type', 'expr', 'coord', '__weakref__')309 def __init__(self, to_type, expr, coord=None):310 self.to_type = to_type311 self.expr = expr312 self.coord = coord313 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)319 320 def __iter__(self):321 if self.to_type is not None:322 yield self.to_type323 if self.expr is not None:324 yield self.expr325 326 attr_names = ()327 328class Compound(Node):329 __slots__ = ('block_items', 'coord', '__weakref__')330 def __init__(self, block_items, coord=None):331 self.block_items = block_items332 self.coord = coord333 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)339 340 def __iter__(self):341 for child in (self.block_items or []):342 yield child343 344 attr_names = ()345 346class CompoundLiteral(Node):347 __slots__ = ('type', 'init', 'coord', '__weakref__')348 def __init__(self, type, init, coord=None):349 self.type = type350 self.init = init351 self.coord = coord352 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)358 359 def __iter__(self):360 if self.type is not None:361 yield self.type362 if self.init is not None:363 yield self.init364 365 attr_names = ()366 367class Constant(Node):368 __slots__ = ('type', 'value', 'coord', '__weakref__')369 def __init__(self, type, value, coord=None):370 self.type = type371 self.value = value372 self.coord = coord373 374 def children(self):375 nodelist = []376 return tuple(nodelist)377 378 def __iter__(self):379 return380 yield381 382 attr_names = ('type', 'value', )383 384class Continue(Node):385 __slots__ = ('coord', '__weakref__')386 def __init__(self, coord=None):387 self.coord = coord388 389 def children(self):390 return ()391 392 def __iter__(self):393 return394 yield395 396 attr_names = ()397 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 = name402 self.quals = quals403 self.align = align404 self.storage = storage405 self.funcspec = funcspec406 self.type = type407 self.init = init408 self.bitsize = bitsize409 self.coord = coord410 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)417 418 def __iter__(self):419 if self.type is not None:420 yield self.type421 if self.init is not None:422 yield self.init423 if self.bitsize is not None:424 yield self.bitsize425 426 attr_names = ('name', 'quals', 'align', 'storage', 'funcspec', )427 428class DeclList(Node):429 __slots__ = ('decls', 'coord', '__weakref__')430 def __init__(self, decls, coord=None):431 self.decls = decls432 self.coord = coord433 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)439 440 def __iter__(self):441 for child in (self.decls or []):442 yield child443 444 attr_names = ()445 446class Default(Node):447 __slots__ = ('stmts', 'coord', '__weakref__')448 def __init__(self, stmts, coord=None):449 self.stmts = stmts450 self.coord = coord451 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)457 458 def __iter__(self):459 for child in (self.stmts or []):460 yield child461 462 attr_names = ()463 464class DoWhile(Node):465 __slots__ = ('cond', 'stmt', 'coord', '__weakref__')466 def __init__(self, cond, stmt, coord=None):467 self.cond = cond468 self.stmt = stmt469 self.coord = coord470 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)476 477 def __iter__(self):478 if self.cond is not None:479 yield self.cond480 if self.stmt is not None:481 yield self.stmt482 483 attr_names = ()484 485class EllipsisParam(Node):486 __slots__ = ('coord', '__weakref__')487 def __init__(self, coord=None):488 self.coord = coord489 490 def children(self):491 return ()492 493 def __iter__(self):494 return495 yield496 497 attr_names = ()498 499class EmptyStatement(Node):500 __slots__ = ('coord', '__weakref__')501 def __init__(self, coord=None):502 self.coord = coord503 504 def children(self):505 return ()506 507 def __iter__(self):508 return509 yield510 511 attr_names = ()512 513class Enum(Node):514 __slots__ = ('name', 'values', 'coord', '__weakref__')515 def __init__(self, name, values, coord=None):516 self.name = name517 self.values = values518 self.coord = coord519 520 def children(self):521 nodelist = []522 if self.values is not None: nodelist.append(("values", self.values))523 return tuple(nodelist)524 525 def __iter__(self):526 if self.values is not None:527 yield self.values528 529 attr_names = ('name', )530 531class Enumerator(Node):532 __slots__ = ('name', 'value', 'coord', '__weakref__')533 def __init__(self, name, value, coord=None):534 self.name = name535 self.value = value536 self.coord = coord537 538 def children(self):539 nodelist = []540 if self.value is not None: nodelist.append(("value", self.value))541 return tuple(nodelist)542 543 def __iter__(self):544 if self.value is not None:545 yield self.value546 547 attr_names = ('name', )548 549class EnumeratorList(Node):550 __slots__ = ('enumerators', 'coord', '__weakref__')551 def __init__(self, enumerators, coord=None):552 self.enumerators = enumerators553 self.coord = coord554 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)560 561 def __iter__(self):562 for child in (self.enumerators or []):563 yield child564 565 attr_names = ()566 567class ExprList(Node):568 __slots__ = ('exprs', 'coord', '__weakref__')569 def __init__(self, exprs, coord=None):570 self.exprs = exprs571 self.coord = coord572 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)578 579 def __iter__(self):580 for child in (self.exprs or []):581 yield child582 583 attr_names = ()584 585class FileAST(Node):586 __slots__ = ('ext', 'coord', '__weakref__')587 def __init__(self, ext, coord=None):588 self.ext = ext589 self.coord = coord590 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)596 597 def __iter__(self):598 for child in (self.ext or []):599 yield child600 601 attr_names = ()602 603class For(Node):604 __slots__ = ('init', 'cond', 'next', 'stmt', 'coord', '__weakref__')605 def __init__(self, init, cond, next, stmt, coord=None):606 self.init = init607 self.cond = cond608 self.next = next609 self.stmt = stmt610 self.coord = coord611 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)619 620 def __iter__(self):621 if self.init is not None:622 yield self.init623 if self.cond is not None:624 yield self.cond625 if self.next is not None:626 yield self.next627 if self.stmt is not None:628 yield self.stmt629 630 attr_names = ()631 632class FuncCall(Node):633 __slots__ = ('name', 'args', 'coord', '__weakref__')634 def __init__(self, name, args, coord=None):635 self.name = name636 self.args = args637 self.coord = coord638 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)644 645 def __iter__(self):646 if self.name is not None:647 yield self.name648 if self.args is not None:649 yield self.args650 651 attr_names = ()652 653class FuncDecl(Node):654 __slots__ = ('args', 'type', 'coord', '__weakref__')655 def __init__(self, args, type, coord=None):656 self.args = args657 self.type = type658 self.coord = coord659 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)665 666 def __iter__(self):667 if self.args is not None:668 yield self.args669 if self.type is not None:670 yield self.type671 672 attr_names = ()673 674class FuncDef(Node):675 __slots__ = ('decl', 'param_decls', 'body', 'coord', '__weakref__')676 def __init__(self, decl, param_decls, body, coord=None):677 self.decl = decl678 self.param_decls = param_decls679 self.body = body680 self.coord = coord681 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)689 690 def __iter__(self):691 if self.decl is not None:692 yield self.decl693 if self.body is not None:694 yield self.body695 for child in (self.param_decls or []):696 yield child697 698 attr_names = ()699 700class Goto(Node):701 __slots__ = ('name', 'coord', '__weakref__')702 def __init__(self, name, coord=None):703 self.name = name704 self.coord = coord705 706 def children(self):707 nodelist = []708 return tuple(nodelist)709 710 def __iter__(self):711 return712 yield713 714 attr_names = ('name', )715 716class ID(Node):717 __slots__ = ('name', 'coord', '__weakref__')718 def __init__(self, name, coord=None):719 self.name = name720 self.coord = coord721 722 def children(self):723 nodelist = []724 return tuple(nodelist)725 726 def __iter__(self):727 return728 yield729 730 attr_names = ('name', )731 732class IdentifierType(Node):733 __slots__ = ('names', 'coord', '__weakref__')734 def __init__(self, names, coord=None):735 self.names = names736 self.coord = coord737 738 def children(self):739 nodelist = []740 return tuple(nodelist)741 742 def __iter__(self):743 return744 yield745 746 attr_names = ('names', )747 748class If(Node):749 __slots__ = ('cond', 'iftrue', 'iffalse', 'coord', '__weakref__')750 def __init__(self, cond, iftrue, iffalse, coord=None):751 self.cond = cond752 self.iftrue = iftrue753 self.iffalse = iffalse754 self.coord = coord755 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)762 763 def __iter__(self):764 if self.cond is not None:765 yield self.cond766 if self.iftrue is not None:767 yield self.iftrue768 if self.iffalse is not None:769 yield self.iffalse770 771 attr_names = ()772 773class InitList(Node):774 __slots__ = ('exprs', 'coord', '__weakref__')775 def __init__(self, exprs, coord=None):776 self.exprs = exprs777 self.coord = coord778 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)784 785 def __iter__(self):786 for child in (self.exprs or []):787 yield child788 789 attr_names = ()790 791class Label(Node):792 __slots__ = ('name', 'stmt', 'coord', '__weakref__')793 def __init__(self, name, stmt, coord=None):794 self.name = name795 self.stmt = stmt796 self.coord = coord797 798 def children(self):799 nodelist = []800 if self.stmt is not None: nodelist.append(("stmt", self.stmt))801 return tuple(nodelist)802 803 def __iter__(self):804 if self.stmt is not None:805 yield self.stmt806 807 attr_names = ('name', )808 809class NamedInitializer(Node):810 __slots__ = ('name', 'expr', 'coord', '__weakref__')811 def __init__(self, name, expr, coord=None):812 self.name = name813 self.expr = expr814 self.coord = coord815 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)822 823 def __iter__(self):824 if self.expr is not None:825 yield self.expr826 for child in (self.name or []):827 yield child828 829 attr_names = ()830 831class ParamList(Node):832 __slots__ = ('params', 'coord', '__weakref__')833 def __init__(self, params, coord=None):834 self.params = params835 self.coord = coord836 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)842 843 def __iter__(self):844 for child in (self.params or []):845 yield child846 847 attr_names = ()848 849class PtrDecl(Node):850 __slots__ = ('quals', 'type', 'coord', '__weakref__')851 def __init__(self, quals, type, coord=None):852 self.quals = quals853 self.type = type854 self.coord = coord855 856 def children(self):857 nodelist = []858 if self.type is not None: nodelist.append(("type", self.type))859 return tuple(nodelist)860 861 def __iter__(self):862 if self.type is not None:863 yield self.type864 865 attr_names = ('quals', )866 867class Return(Node):868 __slots__ = ('expr', 'coord', '__weakref__')869 def __init__(self, expr, coord=None):870 self.expr = expr871 self.coord = coord872 873 def children(self):874 nodelist = []875 if self.expr is not None: nodelist.append(("expr", self.expr))876 return tuple(nodelist)877 878 def __iter__(self):879 if self.expr is not None:880 yield self.expr881 882 attr_names = ()883 884class StaticAssert(Node):885 __slots__ = ('cond', 'message', 'coord', '__weakref__')886 def __init__(self, cond, message, coord=None):887 self.cond = cond888 self.message = message889 self.coord = coord890 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)896 897 def __iter__(self):898 if self.cond is not None:899 yield self.cond900 if self.message is not None:901 yield self.message902 903 attr_names = ()904 905class Struct(Node):906 __slots__ = ('name', 'decls', 'coord', '__weakref__')907 def __init__(self, name, decls, coord=None):908 self.name = name909 self.decls = decls910 self.coord = coord911 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)917 918 def __iter__(self):919 for child in (self.decls or []):920 yield child921 922 attr_names = ('name', )923 924class StructRef(Node):925 __slots__ = ('name', 'type', 'field', 'coord', '__weakref__')926 def __init__(self, name, type, field, coord=None):927 self.name = name928 self.type = type929 self.field = field930 self.coord = coord931 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)937 938 def __iter__(self):939 if self.name is not None:940 yield self.name941 if self.field is not None:942 yield self.field943 944 attr_names = ('type', )945 946class Switch(Node):947 __slots__ = ('cond', 'stmt', 'coord', '__weakref__')948 def __init__(self, cond, stmt, coord=None):949 self.cond = cond950 self.stmt = stmt951 self.coord = coord952 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)958 959 def __iter__(self):960 if self.cond is not None:961 yield self.cond962 if self.stmt is not None:963 yield self.stmt964 965 attr_names = ()966 967class TernaryOp(Node):968 __slots__ = ('cond', 'iftrue', 'iffalse', 'coord', '__weakref__')969 def __init__(self, cond, iftrue, iffalse, coord=None):970 self.cond = cond971 self.iftrue = iftrue972 self.iffalse = iffalse973 self.coord = coord974 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)981 982 def __iter__(self):983 if self.cond is not None:984 yield self.cond985 if self.iftrue is not None:986 yield self.iftrue987 if self.iffalse is not None:988 yield self.iffalse989 990 attr_names = ()991 992class TypeDecl(Node):993 __slots__ = ('declname', 'quals', 'align', 'type', 'coord', '__weakref__')994 def __init__(self, declname, quals, align, type, coord=None):995 self.declname = declname996 self.quals = quals997 self.align = align998 self.type = type999 self.coord = coord1000 1001 def children(self):1002 nodelist = []1003 if self.type is not None: nodelist.append(("type", self.type))1004 return tuple(nodelist)1005 1006 def __iter__(self):1007 if self.type is not None:1008 yield self.type1009 1010 attr_names = ('declname', 'quals', 'align', )1011 1012class Typedef(Node):1013 __slots__ = ('name', 'quals', 'storage', 'type', 'coord', '__weakref__')1014 def __init__(self, name, quals, storage, type, coord=None):1015 self.name = name1016 self.quals = quals1017 self.storage = storage1018 self.type = type1019 self.coord = coord1020 1021 def children(self):1022 nodelist = []1023 if self.type is not None: nodelist.append(("type", self.type))1024 return tuple(nodelist)1025 1026 def __iter__(self):1027 if self.type is not None:1028 yield self.type1029 1030 attr_names = ('name', 'quals', 'storage', )1031 1032class Typename(Node):1033 __slots__ = ('name', 'quals', 'align', 'type', 'coord', '__weakref__')1034 def __init__(self, name, quals, align, type, coord=None):1035 self.name = name1036 self.quals = quals1037 self.align = align1038 self.type = type1039 self.coord = coord1040 1041 def children(self):1042 nodelist = []1043 if self.type is not None: nodelist.append(("type", self.type))1044 return tuple(nodelist)1045 1046 def __iter__(self):1047 if self.type is not None:1048 yield self.type1049 1050 attr_names = ('name', 'quals', 'align', )1051 1052class UnaryOp(Node):1053 __slots__ = ('op', 'expr', 'coord', '__weakref__')1054 def __init__(self, op, expr, coord=None):1055 self.op = op1056 self.expr = expr1057 self.coord = coord1058 1059 def children(self):1060 nodelist = []1061 if self.expr is not None: nodelist.append(("expr", self.expr))1062 return tuple(nodelist)1063 1064 def __iter__(self):1065 if self.expr is not None:1066 yield self.expr1067 1068 attr_names = ('op', )1069 1070class Union(Node):1071 __slots__ = ('name', 'decls', 'coord', '__weakref__')1072 def __init__(self, name, decls, coord=None):1073 self.name = name1074 self.decls = decls1075 self.coord = coord1076 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)1082 1083 def __iter__(self):1084 for child in (self.decls or []):1085 yield child1086 1087 attr_names = ('name', )1088 1089class While(Node):1090 __slots__ = ('cond', 'stmt', 'coord', '__weakref__')1091 def __init__(self, cond, stmt, coord=None):1092 self.cond = cond1093 self.stmt = stmt1094 self.coord = coord1095 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)1101 1102 def __iter__(self):1103 if self.cond is not None:1104 yield self.cond1105 if self.stmt is not None:1106 yield self.stmt1107 1108 attr_names = ()1109 1110class Pragma(Node):1111 __slots__ = ('string', 'coord', '__weakref__')1112 def __init__(self, string, coord=None):1113 self.string = string1114 self.coord = coord1115 1116 def children(self):1117 nodelist = []1118 return tuple(nodelist)1119 1120 def __iter__(self):1121 return1122 yield1123 1124 attr_names = ('string', )1125 1126 