Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
c_ast.py1342 linesDownload Raw Back to pycparser
1# -----------------------------------------------------------------2# ** ATTENTION **3# This code was automatically generated from _c_ast.cfg4#5# Do not modify it directly. Modify the configuration file and6# run the generator again.7# ** ** *** ** **8#9# pycparser: c_ast.py10#11# AST Node classes.12#13# Eli Bendersky [https://eli.thegreenplace.net/]14# License: BSD15# -----------------------------------------------------------------16 17 18import sys19from typing import Any, ClassVar, IO, Optional20 21 22def _repr(obj):23    """24    Get the representation of an object, with dedicated pprint-like format for lists.25    """26    if isinstance(obj, list):27        return "[" + (",\n ".join((_repr(e).replace("\n", "\n ") for e in obj))) + "\n]"28    else:29        return repr(obj)30 31 32class Node:33    __slots__ = ()34    """ Abstract base class for AST nodes.35    """36    attr_names: ClassVar[tuple[str, ...]] = ()37    coord: Optional[Any]38 39    def __repr__(self):40        """Generates a python representation of the current node"""41        result = self.__class__.__name__ + "("42 43        indent = ""44        separator = ""45        for name in self.__slots__[:-2]:46            result += separator47            result += indent48            result += (49                name50                + "="51                + (52                    _repr(getattr(self, name)).replace(53                        "\n",54                        "\n  " + (" " * (len(name) + len(self.__class__.__name__))),55                    )56                )57            )58 59            separator = ","60            indent = "\n " + (" " * len(self.__class__.__name__))61 62        result += indent + ")"63 64        return result65 66    def children(self):67        """A sequence of all children that are Nodes"""68        pass69 70    def show(71        self,72        buf: IO[str] = sys.stdout,73        offset: int = 0,74        attrnames: bool = False,75        showemptyattrs: bool = True,76        nodenames: bool = False,77        showcoord: bool = False,78        _my_node_name: Optional[str] = None,79    ):80        """Pretty print the Node and all its attributes and81        children (recursively) to a buffer.82 83        buf:84            Open IO buffer into which the Node is printed.85 86        offset:87            Initial offset (amount of leading spaces)88 89        attrnames:90            True if you want to see the attribute names in91            name=value pairs. False to only see the values.92 93        showemptyattrs:94            False if you want to suppress printing empty attributes.95 96        nodenames:97            True if you want to see the actual node names98            within their parents.99 100        showcoord:101            Do you want the coordinates of each Node to be102            displayed.103        """104        lead = " " * offset105        if nodenames and _my_node_name is not None:106            buf.write(lead + self.__class__.__name__ + " <" + _my_node_name + ">: ")107        else:108            buf.write(lead + self.__class__.__name__ + ": ")109 110        if self.attr_names:111 112            def is_empty(v):113                v is None or (hasattr(v, "__len__") and len(v) == 0)114 115            nvlist = [116                (n, getattr(self, n))117                for n in self.attr_names118                if showemptyattrs or not is_empty(getattr(self, n))119            ]120            if attrnames:121                attrstr = ", ".join(f"{name}={value}" for name, value in nvlist)122            else:123                attrstr = ", ".join(f"{value}" for _, value in nvlist)124            buf.write(attrstr)125 126        if showcoord:127            buf.write(f" (at {self.coord})")128        buf.write("\n")129 130        for child_name, child in self.children():131            child.show(132                buf,133                offset=offset + 2,134                attrnames=attrnames,135                showemptyattrs=showemptyattrs,136                nodenames=nodenames,137                showcoord=showcoord,138                _my_node_name=child_name,139            )140 141 142class NodeVisitor:143    """A base NodeVisitor class for visiting c_ast nodes.144    Subclass it and define your own visit_XXX methods, where145    XXX is the class name you want to visit with these146    methods.147 148    For example:149 150    class ConstantVisitor(NodeVisitor):151        def __init__(self):152            self.values = []153 154        def visit_Constant(self, node):155            self.values.append(node.value)156 157    Creates a list of values of all the constant nodes158    encountered below the given node. To use it:159 160    cv = ConstantVisitor()161    cv.visit(node)162 163    Notes:164 165    *   generic_visit() will be called for AST nodes for which166        no visit_XXX method was defined.167    *   The children of nodes for which a visit_XXX was168        defined will not be visited - if you need this, call169        generic_visit() on the node.170        You can use:171            NodeVisitor.generic_visit(self, node)172    *   Modeled after Python's own AST visiting facilities173        (the ast module of Python 3.0)174    """175 176    _method_cache = None177 178    def visit(self, node: Node):179        """Visit a node."""180 181        if self._method_cache is None:182            self._method_cache = {}183 184        visitor = self._method_cache.get(node.__class__.__name__, None)185        if visitor is None:186            method = "visit_" + node.__class__.__name__187            visitor = getattr(self, method, self.generic_visit)188            self._method_cache[node.__class__.__name__] = visitor189 190        return visitor(node)191 192    def generic_visit(self, node: Node):193        """Called if no explicit visitor function exists for a194        node. Implements preorder visiting of the node.195        """196        for _, c in node.children():197            self.visit(c)198 199 200class ArrayDecl(Node):201    __slots__ = ("type", "dim", "dim_quals", "coord", "__weakref__")202 203    def __init__(self, type, dim, dim_quals, coord=None):204        self.type = type205        self.dim = dim206        self.dim_quals = dim_quals207        self.coord = coord208 209    def children(self):210        nodelist = []211        if self.type is not None:212            nodelist.append(("type", self.type))213        if self.dim is not None:214            nodelist.append(("dim", self.dim))215        return tuple(nodelist)216 217    def __iter__(self):218        if self.type is not None:219            yield self.type220        if self.dim is not None:221            yield self.dim222 223    attr_names = ("dim_quals",)224 225 226class ArrayRef(Node):227    __slots__ = ("name", "subscript", "coord", "__weakref__")228 229    def __init__(self, name, subscript, coord=None):230        self.name = name231        self.subscript = subscript232        self.coord = coord233 234    def children(self):235        nodelist = []236        if self.name is not None:237            nodelist.append(("name", self.name))238        if self.subscript is not None:239            nodelist.append(("subscript", self.subscript))240        return tuple(nodelist)241 242    def __iter__(self):243        if self.name is not None:244            yield self.name245        if self.subscript is not None:246            yield self.subscript247 248    attr_names = ()249 250 251class Assignment(Node):252    __slots__ = ("op", "lvalue", "rvalue", "coord", "__weakref__")253 254    def __init__(self, op, lvalue, rvalue, coord=None):255        self.op = op256        self.lvalue = lvalue257        self.rvalue = rvalue258        self.coord = coord259 260    def children(self):261        nodelist = []262        if self.lvalue is not None:263            nodelist.append(("lvalue", self.lvalue))264        if self.rvalue is not None:265            nodelist.append(("rvalue", self.rvalue))266        return tuple(nodelist)267 268    def __iter__(self):269        if self.lvalue is not None:270            yield self.lvalue271        if self.rvalue is not None:272            yield self.rvalue273 274    attr_names = ("op",)275 276 277class Alignas(Node):278    __slots__ = ("alignment", "coord", "__weakref__")279 280    def __init__(self, alignment, coord=None):281        self.alignment = alignment282        self.coord = coord283 284    def children(self):285        nodelist = []286        if self.alignment is not None:287            nodelist.append(("alignment", self.alignment))288        return tuple(nodelist)289 290    def __iter__(self):291        if self.alignment is not None:292            yield self.alignment293 294    attr_names = ()295 296 297class BinaryOp(Node):298    __slots__ = ("op", "left", "right", "coord", "__weakref__")299 300    def __init__(self, op, left, right, coord=None):301        self.op = op302        self.left = left303        self.right = right304        self.coord = coord305 306    def children(self):307        nodelist = []308        if self.left is not None:309            nodelist.append(("left", self.left))310        if self.right is not None:311            nodelist.append(("right", self.right))312        return tuple(nodelist)313 314    def __iter__(self):315        if self.left is not None:316            yield self.left317        if self.right is not None:318            yield self.right319 320    attr_names = ("op",)321 322 323class Break(Node):324    __slots__ = ("coord", "__weakref__")325 326    def __init__(self, coord=None):327        self.coord = coord328 329    def children(self):330        return ()331 332    def __iter__(self):333        return334        yield335 336    attr_names = ()337 338 339class Case(Node):340    __slots__ = ("expr", "stmts", "coord", "__weakref__")341 342    def __init__(self, expr, stmts, coord=None):343        self.expr = expr344        self.stmts = stmts345        self.coord = coord346 347    def children(self):348        nodelist = []349        if self.expr is not None:350            nodelist.append(("expr", self.expr))351        for i, child in enumerate(self.stmts or []):352            nodelist.append((f"stmts[{i}]", child))353        return tuple(nodelist)354 355    def __iter__(self):356        if self.expr is not None:357            yield self.expr358        for child in self.stmts or []:359            yield child360 361    attr_names = ()362 363 364class Cast(Node):365    __slots__ = ("to_type", "expr", "coord", "__weakref__")366 367    def __init__(self, to_type, expr, coord=None):368        self.to_type = to_type369        self.expr = expr370        self.coord = coord371 372    def children(self):373        nodelist = []374        if self.to_type is not None:375            nodelist.append(("to_type", self.to_type))376        if self.expr is not None:377            nodelist.append(("expr", self.expr))378        return tuple(nodelist)379 380    def __iter__(self):381        if self.to_type is not None:382            yield self.to_type383        if self.expr is not None:384            yield self.expr385 386    attr_names = ()387 388 389class Compound(Node):390    __slots__ = ("block_items", "coord", "__weakref__")391 392    def __init__(self, block_items, coord=None):393        self.block_items = block_items394        self.coord = coord395 396    def children(self):397        nodelist = []398        for i, child in enumerate(self.block_items or []):399            nodelist.append((f"block_items[{i}]", child))400        return tuple(nodelist)401 402    def __iter__(self):403        for child in self.block_items or []:404            yield child405 406    attr_names = ()407 408 409class CompoundLiteral(Node):410    __slots__ = ("type", "init", "coord", "__weakref__")411 412    def __init__(self, type, init, coord=None):413        self.type = type414        self.init = init415        self.coord = coord416 417    def children(self):418        nodelist = []419        if self.type is not None:420            nodelist.append(("type", self.type))421        if self.init is not None:422            nodelist.append(("init", self.init))423        return tuple(nodelist)424 425    def __iter__(self):426        if self.type is not None:427            yield self.type428        if self.init is not None:429            yield self.init430 431    attr_names = ()432 433 434class Constant(Node):435    __slots__ = ("type", "value", "coord", "__weakref__")436 437    def __init__(self, type, value, coord=None):438        self.type = type439        self.value = value440        self.coord = coord441 442    def children(self):443        nodelist = []444        return tuple(nodelist)445 446    def __iter__(self):447        return448        yield449 450    attr_names = (451        "type",452        "value",453    )454 455 456class Continue(Node):457    __slots__ = ("coord", "__weakref__")458 459    def __init__(self, coord=None):460        self.coord = coord461 462    def children(self):463        return ()464 465    def __iter__(self):466        return467        yield468 469    attr_names = ()470 471 472class Decl(Node):473    __slots__ = (474        "name",475        "quals",476        "align",477        "storage",478        "funcspec",479        "type",480        "init",481        "bitsize",482        "coord",483        "__weakref__",484    )485 486    def __init__(487        self, name, quals, align, storage, funcspec, type, init, bitsize, coord=None488    ):489        self.name = name490        self.quals = quals491        self.align = align492        self.storage = storage493        self.funcspec = funcspec494        self.type = type495        self.init = init496        self.bitsize = bitsize497        self.coord = coord498 499    def children(self):500        nodelist = []501        if self.type is not None:502            nodelist.append(("type", self.type))503        if self.init is not None:504            nodelist.append(("init", self.init))505        if self.bitsize is not None:506            nodelist.append(("bitsize", self.bitsize))507        return tuple(nodelist)508 509    def __iter__(self):510        if self.type is not None:511            yield self.type512        if self.init is not None:513            yield self.init514        if self.bitsize is not None:515            yield self.bitsize516 517    attr_names = (518        "name",519        "quals",520        "align",521        "storage",522        "funcspec",523    )524 525 526class DeclList(Node):527    __slots__ = ("decls", "coord", "__weakref__")528 529    def __init__(self, decls, coord=None):530        self.decls = decls531        self.coord = coord532 533    def children(self):534        nodelist = []535        for i, child in enumerate(self.decls or []):536            nodelist.append((f"decls[{i}]", child))537        return tuple(nodelist)538 539    def __iter__(self):540        for child in self.decls or []:541            yield child542 543    attr_names = ()544 545 546class Default(Node):547    __slots__ = ("stmts", "coord", "__weakref__")548 549    def __init__(self, stmts, coord=None):550        self.stmts = stmts551        self.coord = coord552 553    def children(self):554        nodelist = []555        for i, child in enumerate(self.stmts or []):556            nodelist.append((f"stmts[{i}]", child))557        return tuple(nodelist)558 559    def __iter__(self):560        for child in self.stmts or []:561            yield child562 563    attr_names = ()564 565 566class DoWhile(Node):567    __slots__ = ("cond", "stmt", "coord", "__weakref__")568 569    def __init__(self, cond, stmt, coord=None):570        self.cond = cond571        self.stmt = stmt572        self.coord = coord573 574    def children(self):575        nodelist = []576        if self.cond is not None:577            nodelist.append(("cond", self.cond))578        if self.stmt is not None:579            nodelist.append(("stmt", self.stmt))580        return tuple(nodelist)581 582    def __iter__(self):583        if self.cond is not None:584            yield self.cond585        if self.stmt is not None:586            yield self.stmt587 588    attr_names = ()589 590 591class EllipsisParam(Node):592    __slots__ = ("coord", "__weakref__")593 594    def __init__(self, coord=None):595        self.coord = coord596 597    def children(self):598        return ()599 600    def __iter__(self):601        return602        yield603 604    attr_names = ()605 606 607class EmptyStatement(Node):608    __slots__ = ("coord", "__weakref__")609 610    def __init__(self, coord=None):611        self.coord = coord612 613    def children(self):614        return ()615 616    def __iter__(self):617        return618        yield619 620    attr_names = ()621 622 623class Enum(Node):624    __slots__ = ("name", "values", "coord", "__weakref__")625 626    def __init__(self, name, values, coord=None):627        self.name = name628        self.values = values629        self.coord = coord630 631    def children(self):632        nodelist = []633        if self.values is not None:634            nodelist.append(("values", self.values))635        return tuple(nodelist)636 637    def __iter__(self):638        if self.values is not None:639            yield self.values640 641    attr_names = ("name",)642 643 644class Enumerator(Node):645    __slots__ = ("name", "value", "coord", "__weakref__")646 647    def __init__(self, name, value, coord=None):648        self.name = name649        self.value = value650        self.coord = coord651 652    def children(self):653        nodelist = []654        if self.value is not None:655            nodelist.append(("value", self.value))656        return tuple(nodelist)657 658    def __iter__(self):659        if self.value is not None:660            yield self.value661 662    attr_names = ("name",)663 664 665class EnumeratorList(Node):666    __slots__ = ("enumerators", "coord", "__weakref__")667 668    def __init__(self, enumerators, coord=None):669        self.enumerators = enumerators670        self.coord = coord671 672    def children(self):673        nodelist = []674        for i, child in enumerate(self.enumerators or []):675            nodelist.append((f"enumerators[{i}]", child))676        return tuple(nodelist)677 678    def __iter__(self):679        for child in self.enumerators or []:680            yield child681 682    attr_names = ()683 684 685class ExprList(Node):686    __slots__ = ("exprs", "coord", "__weakref__")687 688    def __init__(self, exprs, coord=None):689        self.exprs = exprs690        self.coord = coord691 692    def children(self):693        nodelist = []694        for i, child in enumerate(self.exprs or []):695            nodelist.append((f"exprs[{i}]", child))696        return tuple(nodelist)697 698    def __iter__(self):699        for child in self.exprs or []:700            yield child701 702    attr_names = ()703 704 705class FileAST(Node):706    __slots__ = ("ext", "coord", "__weakref__")707 708    def __init__(self, ext, coord=None):709        self.ext = ext710        self.coord = coord711 712    def children(self):713        nodelist = []714        for i, child in enumerate(self.ext or []):715            nodelist.append((f"ext[{i}]", child))716        return tuple(nodelist)717 718    def __iter__(self):719        for child in self.ext or []:720            yield child721 722    attr_names = ()723 724 725class For(Node):726    __slots__ = ("init", "cond", "next", "stmt", "coord", "__weakref__")727 728    def __init__(self, init, cond, next, stmt, coord=None):729        self.init = init730        self.cond = cond731        self.next = next732        self.stmt = stmt733        self.coord = coord734 735    def children(self):736        nodelist = []737        if self.init is not None:738            nodelist.append(("init", self.init))739        if self.cond is not None:740            nodelist.append(("cond", self.cond))741        if self.next is not None:742            nodelist.append(("next", self.next))743        if self.stmt is not None:744            nodelist.append(("stmt", self.stmt))745        return tuple(nodelist)746 747    def __iter__(self):748        if self.init is not None:749            yield self.init750        if self.cond is not None:751            yield self.cond752        if self.next is not None:753            yield self.next754        if self.stmt is not None:755            yield self.stmt756 757    attr_names = ()758 759 760class FuncCall(Node):761    __slots__ = ("name", "args", "coord", "__weakref__")762 763    def __init__(self, name, args, coord=None):764        self.name = name765        self.args = args766        self.coord = coord767 768    def children(self):769        nodelist = []770        if self.name is not None:771            nodelist.append(("name", self.name))772        if self.args is not None:773            nodelist.append(("args", self.args))774        return tuple(nodelist)775 776    def __iter__(self):777        if self.name is not None:778            yield self.name779        if self.args is not None:780            yield self.args781 782    attr_names = ()783 784 785class FuncDecl(Node):786    __slots__ = ("args", "type", "coord", "__weakref__")787 788    def __init__(self, args, type, coord=None):789        self.args = args790        self.type = type791        self.coord = coord792 793    def children(self):794        nodelist = []795        if self.args is not None:796            nodelist.append(("args", self.args))797        if self.type is not None:798            nodelist.append(("type", self.type))799        return tuple(nodelist)800 801    def __iter__(self):802        if self.args is not None:803            yield self.args804        if self.type is not None:805            yield self.type806 807    attr_names = ()808 809 810class FuncDef(Node):811    __slots__ = ("decl", "param_decls", "body", "coord", "__weakref__")812 813    def __init__(self, decl, param_decls, body, coord=None):814        self.decl = decl815        self.param_decls = param_decls816        self.body = body817        self.coord = coord818 819    def children(self):820        nodelist = []821        if self.decl is not None:822            nodelist.append(("decl", self.decl))823        if self.body is not None:824            nodelist.append(("body", self.body))825        for i, child in enumerate(self.param_decls or []):826            nodelist.append((f"param_decls[{i}]", child))827        return tuple(nodelist)828 829    def __iter__(self):830        if self.decl is not None:831            yield self.decl832        if self.body is not None:833            yield self.body834        for child in self.param_decls or []:835            yield child836 837    attr_names = ()838 839 840class Goto(Node):841    __slots__ = ("name", "coord", "__weakref__")842 843    def __init__(self, name, coord=None):844        self.name = name845        self.coord = coord846 847    def children(self):848        nodelist = []849        return tuple(nodelist)850 851    def __iter__(self):852        return853        yield854 855    attr_names = ("name",)856 857 858class ID(Node):859    __slots__ = ("name", "coord", "__weakref__")860 861    def __init__(self, name, coord=None):862        self.name = name863        self.coord = coord864 865    def children(self):866        nodelist = []867        return tuple(nodelist)868 869    def __iter__(self):870        return871        yield872 873    attr_names = ("name",)874 875 876class IdentifierType(Node):877    __slots__ = ("names", "coord", "__weakref__")878 879    def __init__(self, names, coord=None):880        self.names = names881        self.coord = coord882 883    def children(self):884        nodelist = []885        return tuple(nodelist)886 887    def __iter__(self):888        return889        yield890 891    attr_names = ("names",)892 893 894class If(Node):895    __slots__ = ("cond", "iftrue", "iffalse", "coord", "__weakref__")896 897    def __init__(self, cond, iftrue, iffalse, coord=None):898        self.cond = cond899        self.iftrue = iftrue900        self.iffalse = iffalse901        self.coord = coord902 903    def children(self):904        nodelist = []905        if self.cond is not None:906            nodelist.append(("cond", self.cond))907        if self.iftrue is not None:908            nodelist.append(("iftrue", self.iftrue))909        if self.iffalse is not None:910            nodelist.append(("iffalse", self.iffalse))911        return tuple(nodelist)912 913    def __iter__(self):914        if self.cond is not None:915            yield self.cond916        if self.iftrue is not None:917            yield self.iftrue918        if self.iffalse is not None:919            yield self.iffalse920 921    attr_names = ()922 923 924class InitList(Node):925    __slots__ = ("exprs", "coord", "__weakref__")926 927    def __init__(self, exprs, coord=None):928        self.exprs = exprs929        self.coord = coord930 931    def children(self):932        nodelist = []933        for i, child in enumerate(self.exprs or []):934            nodelist.append((f"exprs[{i}]", child))935        return tuple(nodelist)936 937    def __iter__(self):938        for child in self.exprs or []:939            yield child940 941    attr_names = ()942 943 944class Label(Node):945    __slots__ = ("name", "stmt", "coord", "__weakref__")946 947    def __init__(self, name, stmt, coord=None):948        self.name = name949        self.stmt = stmt950        self.coord = coord951 952    def children(self):953        nodelist = []954        if self.stmt is not None:955            nodelist.append(("stmt", self.stmt))956        return tuple(nodelist)957 958    def __iter__(self):959        if self.stmt is not None:960            yield self.stmt961 962    attr_names = ("name",)963 964 965class NamedInitializer(Node):966    __slots__ = ("name", "expr", "coord", "__weakref__")967 968    def __init__(self, name, expr, coord=None):969        self.name = name970        self.expr = expr971        self.coord = coord972 973    def children(self):974        nodelist = []975        if self.expr is not None:976            nodelist.append(("expr", self.expr))977        for i, child in enumerate(self.name or []):978            nodelist.append((f"name[{i}]", child))979        return tuple(nodelist)980 981    def __iter__(self):982        if self.expr is not None:983            yield self.expr984        for child in self.name or []:985            yield child986 987    attr_names = ()988 989 990class ParamList(Node):991    __slots__ = ("params", "coord", "__weakref__")992 993    def __init__(self, params, coord=None):994        self.params = params995        self.coord = coord996 997    def children(self):998        nodelist = []999        for i, child in enumerate(self.params or []):1000            nodelist.append((f"params[{i}]", child))1001        return tuple(nodelist)1002 1003    def __iter__(self):1004        for child in self.params or []:1005            yield child1006 1007    attr_names = ()1008 1009 1010class PtrDecl(Node):1011    __slots__ = ("quals", "type", "coord", "__weakref__")1012 1013    def __init__(self, quals, type, coord=None):1014        self.quals = quals1015        self.type = type1016        self.coord = coord1017 1018    def children(self):1019        nodelist = []1020        if self.type is not None:1021            nodelist.append(("type", self.type))1022        return tuple(nodelist)1023 1024    def __iter__(self):1025        if self.type is not None:1026            yield self.type1027 1028    attr_names = ("quals",)1029 1030 1031class Return(Node):1032    __slots__ = ("expr", "coord", "__weakref__")1033 1034    def __init__(self, expr, coord=None):1035        self.expr = expr1036        self.coord = coord1037 1038    def children(self):1039        nodelist = []1040        if self.expr is not None:1041            nodelist.append(("expr", self.expr))1042        return tuple(nodelist)1043 1044    def __iter__(self):1045        if self.expr is not None:1046            yield self.expr1047 1048    attr_names = ()1049 1050 1051class StaticAssert(Node):1052    __slots__ = ("cond", "message", "coord", "__weakref__")1053 1054    def __init__(self, cond, message, coord=None):1055        self.cond = cond1056        self.message = message1057        self.coord = coord1058 1059    def children(self):1060        nodelist = []1061        if self.cond is not None:1062            nodelist.append(("cond", self.cond))1063        if self.message is not None:1064            nodelist.append(("message", self.message))1065        return tuple(nodelist)1066 1067    def __iter__(self):1068        if self.cond is not None:1069            yield self.cond1070        if self.message is not None:1071            yield self.message1072 1073    attr_names = ()1074 1075 1076class Struct(Node):1077    __slots__ = ("name", "decls", "coord", "__weakref__")1078 1079    def __init__(self, name, decls, coord=None):1080        self.name = name1081        self.decls = decls1082        self.coord = coord1083 1084    def children(self):1085        nodelist = []1086        for i, child in enumerate(self.decls or []):1087            nodelist.append((f"decls[{i}]", child))1088        return tuple(nodelist)1089 1090    def __iter__(self):1091        for child in self.decls or []:1092            yield child1093 1094    attr_names = ("name",)1095 1096 1097class StructRef(Node):1098    __slots__ = ("name", "type", "field", "coord", "__weakref__")1099 1100    def __init__(self, name, type, field, coord=None):1101        self.name = name1102        self.type = type1103        self.field = field1104        self.coord = coord1105 1106    def children(self):1107        nodelist = []1108        if self.name is not None:1109            nodelist.append(("name", self.name))1110        if self.field is not None:1111            nodelist.append(("field", self.field))1112        return tuple(nodelist)1113 1114    def __iter__(self):1115        if self.name is not None:1116            yield self.name1117        if self.field is not None:1118            yield self.field1119 1120    attr_names = ("type",)1121 1122 1123class Switch(Node):1124    __slots__ = ("cond", "stmt", "coord", "__weakref__")1125 1126    def __init__(self, cond, stmt, coord=None):1127        self.cond = cond1128        self.stmt = stmt1129        self.coord = coord1130 1131    def children(self):1132        nodelist = []1133        if self.cond is not None:1134            nodelist.append(("cond", self.cond))1135        if self.stmt is not None:1136            nodelist.append(("stmt", self.stmt))1137        return tuple(nodelist)1138 1139    def __iter__(self):1140        if self.cond is not None:1141            yield self.cond1142        if self.stmt is not None:1143            yield self.stmt1144 1145    attr_names = ()1146 1147 1148class TernaryOp(Node):1149    __slots__ = ("cond", "iftrue", "iffalse", "coord", "__weakref__")1150 1151    def __init__(self, cond, iftrue, iffalse, coord=None):1152        self.cond = cond1153        self.iftrue = iftrue1154        self.iffalse = iffalse1155        self.coord = coord1156 1157    def children(self):1158        nodelist = []1159        if self.cond is not None:1160            nodelist.append(("cond", self.cond))1161        if self.iftrue is not None:1162            nodelist.append(("iftrue", self.iftrue))1163        if self.iffalse is not None:1164            nodelist.append(("iffalse", self.iffalse))1165        return tuple(nodelist)1166 1167    def __iter__(self):1168        if self.cond is not None:1169            yield self.cond1170        if self.iftrue is not None:1171            yield self.iftrue1172        if self.iffalse is not None:1173            yield self.iffalse1174 1175    attr_names = ()1176 1177 1178class TypeDecl(Node):1179    __slots__ = ("declname", "quals", "align", "type", "coord", "__weakref__")1180 1181    def __init__(self, declname, quals, align, type, coord=None):1182        self.declname = declname1183        self.quals = quals1184        self.align = align1185        self.type = type1186        self.coord = coord1187 1188    def children(self):1189        nodelist = []1190        if self.type is not None:1191            nodelist.append(("type", self.type))1192        return tuple(nodelist)1193 1194    def __iter__(self):1195        if self.type is not None:1196            yield self.type1197 1198    attr_names = (1199        "declname",1200        "quals",

Showing the first 1,200 of 1342 lines. Download the file for the rest.

codekingpro/portable-devtools · Team Ai