| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379 |
- # -----------------------------------------------------------------
- # ** ATTENTION **
- # This code was automatically generated from _c_ast.cfg
- #
- # Do not modify it directly. Modify the configuration file and
- # run 'make regen-ast' from the repository root to regenerate and format it.
- # ** ** *** ** **
- #
- # The order of generated __slots__ is significant to Node.__repr__.
- # ruff: noqa: RUF023
- #
- # pycparser: c_ast.py
- #
- # AST Node classes.
- #
- # Eli Bendersky [https://eli.thegreenplace.net/]
- # License: BSD
- # -----------------------------------------------------------------
- import sys
- from typing import IO, Any, ClassVar
- def _repr(obj):
- """
- Get the representation of an object, with dedicated pprint-like format for lists.
- """
- if isinstance(obj, list):
- return "[" + (",\n ".join(_repr(e).replace("\n", "\n ") for e in obj)) + "\n]"
- else:
- return repr(obj)
- class Node:
- __slots__ = ()
- """ Abstract base class for AST nodes.
- """
- attr_names: ClassVar[tuple[str, ...]] = ()
- coord: Any | None
- def __repr__(self):
- """Generates a python representation of the current node"""
- result = self.__class__.__name__ + "("
- indent = ""
- separator = ""
- for name in self.__slots__[:-2]:
- result += separator
- result += indent
- result += (
- name
- + "="
- + (
- _repr(getattr(self, name)).replace(
- "\n",
- "\n " + (" " * (len(name) + len(self.__class__.__name__))),
- )
- )
- )
- separator = ","
- indent = "\n " + (" " * len(self.__class__.__name__))
- result += indent + ")"
- return result
- def children(self):
- """A sequence of all children that are Nodes"""
- def show(
- self,
- buf: IO[str] = sys.stdout,
- offset: int = 0,
- attrnames: bool = False,
- showemptyattrs: bool = True,
- nodenames: bool = False,
- showcoord: bool = False,
- _my_node_name: str | None = None,
- ):
- """Pretty print the Node and all its attributes and
- children (recursively) to a buffer.
- buf:
- Open IO buffer into which the Node is printed.
- offset:
- Initial offset (amount of leading spaces)
- attrnames:
- True if you want to see the attribute names in
- name=value pairs. False to only see the values.
- showemptyattrs:
- False if you want to suppress printing empty attributes.
- nodenames:
- True if you want to see the actual node names
- within their parents.
- showcoord:
- Do you want the coordinates of each Node to be
- displayed.
- """
- lead = " " * offset
- if nodenames and _my_node_name is not None:
- buf.write(lead + self.__class__.__name__ + " <" + _my_node_name + ">: ")
- else:
- buf.write(lead + self.__class__.__name__ + ": ")
- if self.attr_names:
- def is_empty(v):
- return v is None or (hasattr(v, "__len__") and len(v) == 0)
- nvlist = [
- (n, getattr(self, n))
- for n in self.attr_names
- if showemptyattrs or not is_empty(getattr(self, n))
- ]
- if attrnames:
- attrstr = ", ".join(f"{name}={value}" for name, value in nvlist)
- else:
- attrstr = ", ".join(f"{value}" for _, value in nvlist)
- buf.write(attrstr)
- if showcoord:
- buf.write(f" (at {self.coord})")
- buf.write("\n")
- for child_name, child in self.children():
- child.show(
- buf,
- offset=offset + 2,
- attrnames=attrnames,
- showemptyattrs=showemptyattrs,
- nodenames=nodenames,
- showcoord=showcoord,
- _my_node_name=child_name,
- )
- class NodeVisitor:
- """A base NodeVisitor class for visiting c_ast nodes.
- Subclass it and define your own visit_XXX methods, where
- XXX is the class name you want to visit with these
- methods.
- For example:
- class ConstantVisitor(NodeVisitor):
- def __init__(self):
- self.values = []
- def visit_Constant(self, node):
- self.values.append(node.value)
- Creates a list of values of all the constant nodes
- encountered below the given node. To use it:
- cv = ConstantVisitor()
- cv.visit(node)
- Notes:
- * generic_visit() will be called for AST nodes for which
- no visit_XXX method was defined.
- * The children of nodes for which a visit_XXX was
- defined will not be visited - if you need this, call
- generic_visit() on the node.
- You can use:
- NodeVisitor.generic_visit(self, node)
- * Modeled after Python's own AST visiting facilities
- (the ast module of Python 3.0)
- """
- _method_cache = None
- def visit(self, node: Node):
- """Visit a node."""
- if self._method_cache is None:
- self._method_cache = {}
- visitor = self._method_cache.get(node.__class__.__name__, None)
- if visitor is None:
- method = "visit_" + node.__class__.__name__
- visitor = getattr(self, method, self.generic_visit)
- self._method_cache[node.__class__.__name__] = visitor
- return visitor(node)
- def generic_visit(self, node: Node):
- """Called if no explicit visitor function exists for a
- node. Implements preorder visiting of the node.
- """
- for _, c in node.children():
- self.visit(c)
- class ArrayDecl(Node):
- __slots__ = ("type", "dim", "dim_quals", "coord", "__weakref__")
- def __init__(self, type, dim, dim_quals, coord=None):
- self.type = type
- self.dim = dim
- self.dim_quals = dim_quals
- self.coord = coord
- def children(self):
- nodelist = []
- if self.type is not None:
- nodelist.append(("type", self.type))
- if self.dim is not None:
- nodelist.append(("dim", self.dim))
- return tuple(nodelist)
- def __iter__(self):
- if self.type is not None:
- yield self.type
- if self.dim is not None:
- yield self.dim
- attr_names = ("dim_quals",)
- class ArrayRef(Node):
- __slots__ = ("name", "subscript", "coord", "__weakref__")
- def __init__(self, name, subscript, coord=None):
- self.name = name
- self.subscript = subscript
- self.coord = coord
- def children(self):
- nodelist = []
- if self.name is not None:
- nodelist.append(("name", self.name))
- if self.subscript is not None:
- nodelist.append(("subscript", self.subscript))
- return tuple(nodelist)
- def __iter__(self):
- if self.name is not None:
- yield self.name
- if self.subscript is not None:
- yield self.subscript
- attr_names = ()
- class Assignment(Node):
- __slots__ = ("op", "lvalue", "rvalue", "coord", "__weakref__")
- def __init__(self, op, lvalue, rvalue, coord=None):
- self.op = op
- self.lvalue = lvalue
- self.rvalue = rvalue
- self.coord = coord
- def children(self):
- nodelist = []
- if self.lvalue is not None:
- nodelist.append(("lvalue", self.lvalue))
- if self.rvalue is not None:
- nodelist.append(("rvalue", self.rvalue))
- return tuple(nodelist)
- def __iter__(self):
- if self.lvalue is not None:
- yield self.lvalue
- if self.rvalue is not None:
- yield self.rvalue
- attr_names = ("op",)
- class Alignas(Node):
- __slots__ = ("alignment", "coord", "__weakref__")
- def __init__(self, alignment, coord=None):
- self.alignment = alignment
- self.coord = coord
- def children(self):
- nodelist = []
- if self.alignment is not None:
- nodelist.append(("alignment", self.alignment))
- return tuple(nodelist)
- def __iter__(self):
- if self.alignment is not None:
- yield self.alignment
- attr_names = ()
- class BinaryOp(Node):
- __slots__ = ("op", "left", "right", "coord", "__weakref__")
- def __init__(self, op, left, right, coord=None):
- self.op = op
- self.left = left
- self.right = right
- self.coord = coord
- def children(self):
- nodelist = []
- if self.left is not None:
- nodelist.append(("left", self.left))
- if self.right is not None:
- nodelist.append(("right", self.right))
- return tuple(nodelist)
- def __iter__(self):
- if self.left is not None:
- yield self.left
- if self.right is not None:
- yield self.right
- attr_names = ("op",)
- class Break(Node):
- __slots__ = ("coord", "__weakref__")
- def __init__(self, coord=None):
- self.coord = coord
- def children(self):
- return ()
- def __iter__(self):
- return
- yield
- attr_names = ()
- class Case(Node):
- __slots__ = ("expr", "stmts", "coord", "__weakref__")
- def __init__(self, expr, stmts, coord=None):
- self.expr = expr
- self.stmts = stmts
- self.coord = coord
- def children(self):
- nodelist = []
- if self.expr is not None:
- nodelist.append(("expr", self.expr))
- for i, child in enumerate(self.stmts or []):
- nodelist.append((f"stmts[{i}]", child))
- return tuple(nodelist)
- def __iter__(self):
- if self.expr is not None:
- yield self.expr
- yield from self.stmts or []
- attr_names = ()
- class Cast(Node):
- __slots__ = ("to_type", "expr", "coord", "__weakref__")
- def __init__(self, to_type, expr, coord=None):
- self.to_type = to_type
- self.expr = expr
- self.coord = coord
- def children(self):
- nodelist = []
- if self.to_type is not None:
- nodelist.append(("to_type", self.to_type))
- if self.expr is not None:
- nodelist.append(("expr", self.expr))
- return tuple(nodelist)
- def __iter__(self):
- if self.to_type is not None:
- yield self.to_type
- if self.expr is not None:
- yield self.expr
- attr_names = ()
- class Compound(Node):
- __slots__ = ("block_items", "coord", "__weakref__")
- def __init__(self, block_items, coord=None):
- self.block_items = block_items
- self.coord = coord
- def children(self):
- nodelist = []
- for i, child in enumerate(self.block_items or []):
- nodelist.append((f"block_items[{i}]", child))
- return tuple(nodelist)
- def __iter__(self):
- yield from self.block_items or []
- attr_names = ()
- class CompoundLiteral(Node):
- __slots__ = ("type", "init", "coord", "__weakref__")
- def __init__(self, type, init, coord=None):
- self.type = type
- self.init = init
- self.coord = coord
- def children(self):
- nodelist = []
- if self.type is not None:
- nodelist.append(("type", self.type))
- if self.init is not None:
- nodelist.append(("init", self.init))
- return tuple(nodelist)
- def __iter__(self):
- if self.type is not None:
- yield self.type
- if self.init is not None:
- yield self.init
- attr_names = ()
- class Constant(Node):
- __slots__ = ("type", "value", "coord", "__weakref__")
- def __init__(self, type, value, coord=None):
- self.type = type
- self.value = value
- self.coord = coord
- def children(self):
- nodelist = []
- return tuple(nodelist)
- def __iter__(self):
- return
- yield
- attr_names = (
- "type",
- "value",
- )
- class Continue(Node):
- __slots__ = ("coord", "__weakref__")
- def __init__(self, coord=None):
- self.coord = coord
- def children(self):
- return ()
- def __iter__(self):
- return
- yield
- attr_names = ()
- class Decl(Node):
- __slots__ = (
- "name",
- "quals",
- "align",
- "storage",
- "funcspec",
- "type",
- "init",
- "bitsize",
- "coord",
- "__weakref__",
- )
- def __init__(
- self, name, quals, align, storage, funcspec, type, init, bitsize, coord=None
- ):
- self.name = name
- self.quals = quals
- self.align = align
- self.storage = storage
- self.funcspec = funcspec
- self.type = type
- self.init = init
- self.bitsize = bitsize
- self.coord = coord
- def children(self):
- nodelist = []
- if self.type is not None:
- nodelist.append(("type", self.type))
- if self.init is not None:
- nodelist.append(("init", self.init))
- if self.bitsize is not None:
- nodelist.append(("bitsize", self.bitsize))
- return tuple(nodelist)
- def __iter__(self):
- if self.type is not None:
- yield self.type
- if self.init is not None:
- yield self.init
- if self.bitsize is not None:
- yield self.bitsize
- attr_names = (
- "name",
- "quals",
- "align",
- "storage",
- "funcspec",
- )
- class DeclList(Node):
- __slots__ = ("decls", "coord", "__weakref__")
- def __init__(self, decls, coord=None):
- self.decls = decls
- self.coord = coord
- def children(self):
- nodelist = []
- for i, child in enumerate(self.decls or []):
- nodelist.append((f"decls[{i}]", child))
- return tuple(nodelist)
- def __iter__(self):
- yield from self.decls or []
- attr_names = ()
- class Default(Node):
- __slots__ = ("stmts", "coord", "__weakref__")
- def __init__(self, stmts, coord=None):
- self.stmts = stmts
- self.coord = coord
- def children(self):
- nodelist = []
- for i, child in enumerate(self.stmts or []):
- nodelist.append((f"stmts[{i}]", child))
- return tuple(nodelist)
- def __iter__(self):
- yield from self.stmts or []
- attr_names = ()
- class DoWhile(Node):
- __slots__ = ("cond", "stmt", "coord", "__weakref__")
- def __init__(self, cond, stmt, coord=None):
- self.cond = cond
- self.stmt = stmt
- self.coord = coord
- def children(self):
- nodelist = []
- if self.cond is not None:
- nodelist.append(("cond", self.cond))
- if self.stmt is not None:
- nodelist.append(("stmt", self.stmt))
- return tuple(nodelist)
- def __iter__(self):
- if self.cond is not None:
- yield self.cond
- if self.stmt is not None:
- yield self.stmt
- attr_names = ()
- class EllipsisParam(Node):
- __slots__ = ("coord", "__weakref__")
- def __init__(self, coord=None):
- self.coord = coord
- def children(self):
- return ()
- def __iter__(self):
- return
- yield
- attr_names = ()
- class EmptyStatement(Node):
- __slots__ = ("coord", "__weakref__")
- def __init__(self, coord=None):
- self.coord = coord
- def children(self):
- return ()
- def __iter__(self):
- return
- yield
- attr_names = ()
- class Enum(Node):
- __slots__ = ("name", "values", "coord", "__weakref__")
- def __init__(self, name, values, coord=None):
- self.name = name
- self.values = values
- self.coord = coord
- def children(self):
- nodelist = []
- if self.values is not None:
- nodelist.append(("values", self.values))
- return tuple(nodelist)
- def __iter__(self):
- if self.values is not None:
- yield self.values
- attr_names = ("name",)
- class Enumerator(Node):
- __slots__ = ("name", "value", "coord", "__weakref__")
- def __init__(self, name, value, coord=None):
- self.name = name
- self.value = value
- self.coord = coord
- def children(self):
- nodelist = []
- if self.value is not None:
- nodelist.append(("value", self.value))
- return tuple(nodelist)
- def __iter__(self):
- if self.value is not None:
- yield self.value
- attr_names = ("name",)
- class EnumeratorList(Node):
- __slots__ = ("enumerators", "coord", "__weakref__")
- def __init__(self, enumerators, coord=None):
- self.enumerators = enumerators
- self.coord = coord
- def children(self):
- nodelist = []
- for i, child in enumerate(self.enumerators or []):
- nodelist.append((f"enumerators[{i}]", child))
- return tuple(nodelist)
- def __iter__(self):
- yield from self.enumerators or []
- attr_names = ()
- class ExprList(Node):
- __slots__ = ("exprs", "coord", "__weakref__")
- def __init__(self, exprs, coord=None):
- self.exprs = exprs
- self.coord = coord
- def children(self):
- nodelist = []
- for i, child in enumerate(self.exprs or []):
- nodelist.append((f"exprs[{i}]", child))
- return tuple(nodelist)
- def __iter__(self):
- yield from self.exprs or []
- attr_names = ()
- class FileAST(Node):
- __slots__ = ("ext", "coord", "__weakref__")
- def __init__(self, ext, coord=None):
- self.ext = ext
- self.coord = coord
- def children(self):
- nodelist = []
- for i, child in enumerate(self.ext or []):
- nodelist.append((f"ext[{i}]", child))
- return tuple(nodelist)
- def __iter__(self):
- yield from self.ext or []
- attr_names = ()
- class For(Node):
- __slots__ = ("init", "cond", "next", "stmt", "coord", "__weakref__")
- def __init__(self, init, cond, next, stmt, coord=None):
- self.init = init
- self.cond = cond
- self.next = next
- self.stmt = stmt
- self.coord = coord
- def children(self):
- nodelist = []
- if self.init is not None:
- nodelist.append(("init", self.init))
- if self.cond is not None:
- nodelist.append(("cond", self.cond))
- if self.next is not None:
- nodelist.append(("next", self.next))
- if self.stmt is not None:
- nodelist.append(("stmt", self.stmt))
- return tuple(nodelist)
- def __iter__(self):
- if self.init is not None:
- yield self.init
- if self.cond is not None:
- yield self.cond
- if self.next is not None:
- yield self.next
- if self.stmt is not None:
- yield self.stmt
- attr_names = ()
- class FuncCall(Node):
- __slots__ = ("name", "args", "coord", "__weakref__")
- def __init__(self, name, args, coord=None):
- self.name = name
- self.args = args
- self.coord = coord
- def children(self):
- nodelist = []
- if self.name is not None:
- nodelist.append(("name", self.name))
- if self.args is not None:
- nodelist.append(("args", self.args))
- return tuple(nodelist)
- def __iter__(self):
- if self.name is not None:
- yield self.name
- if self.args is not None:
- yield self.args
- attr_names = ()
- class FuncDecl(Node):
- __slots__ = ("args", "type", "coord", "__weakref__")
- def __init__(self, args, type, coord=None):
- self.args = args
- self.type = type
- self.coord = coord
- def children(self):
- nodelist = []
- if self.args is not None:
- nodelist.append(("args", self.args))
- if self.type is not None:
- nodelist.append(("type", self.type))
- return tuple(nodelist)
- def __iter__(self):
- if self.args is not None:
- yield self.args
- if self.type is not None:
- yield self.type
- attr_names = ()
- class FuncDef(Node):
- __slots__ = ("decl", "param_decls", "body", "coord", "__weakref__")
- def __init__(self, decl, param_decls, body, coord=None):
- self.decl = decl
- self.param_decls = param_decls
- self.body = body
- self.coord = coord
- def children(self):
- nodelist = []
- if self.decl is not None:
- nodelist.append(("decl", self.decl))
- if self.body is not None:
- nodelist.append(("body", self.body))
- for i, child in enumerate(self.param_decls or []):
- nodelist.append((f"param_decls[{i}]", child))
- return tuple(nodelist)
- def __iter__(self):
- if self.decl is not None:
- yield self.decl
- if self.body is not None:
- yield self.body
- yield from self.param_decls or []
- attr_names = ()
- class GenericAssociation(Node):
- __slots__ = ("type", "expr", "coord", "__weakref__")
- def __init__(self, type, expr, coord=None):
- self.type = type
- self.expr = expr
- self.coord = coord
- def children(self):
- nodelist = []
- if self.type is not None:
- nodelist.append(("type", self.type))
- if self.expr is not None:
- nodelist.append(("expr", self.expr))
- return tuple(nodelist)
- def __iter__(self):
- if self.type is not None:
- yield self.type
- if self.expr is not None:
- yield self.expr
- attr_names = ()
- class GenericSelection(Node):
- __slots__ = ("expr", "associations", "coord", "__weakref__")
- def __init__(self, expr, associations, coord=None):
- self.expr = expr
- self.associations = associations
- self.coord = coord
- def children(self):
- nodelist = []
- if self.expr is not None:
- nodelist.append(("expr", self.expr))
- for i, child in enumerate(self.associations or []):
- nodelist.append((f"associations[{i}]", child))
- return tuple(nodelist)
- def __iter__(self):
- if self.expr is not None:
- yield self.expr
- yield from self.associations or []
- attr_names = ()
- class Goto(Node):
- __slots__ = ("name", "coord", "__weakref__")
- def __init__(self, name, coord=None):
- self.name = name
- self.coord = coord
- def children(self):
- nodelist = []
- return tuple(nodelist)
- def __iter__(self):
- return
- yield
- attr_names = ("name",)
- class ID(Node):
- __slots__ = ("name", "coord", "__weakref__")
- def __init__(self, name, coord=None):
- self.name = name
- self.coord = coord
- def children(self):
- nodelist = []
- return tuple(nodelist)
- def __iter__(self):
- return
- yield
- attr_names = ("name",)
- class IdentifierType(Node):
- __slots__ = ("names", "coord", "__weakref__")
- def __init__(self, names, coord=None):
- self.names = names
- self.coord = coord
- def children(self):
- nodelist = []
- return tuple(nodelist)
- def __iter__(self):
- return
- yield
- attr_names = ("names",)
- class If(Node):
- __slots__ = ("cond", "iftrue", "iffalse", "coord", "__weakref__")
- def __init__(self, cond, iftrue, iffalse, coord=None):
- self.cond = cond
- self.iftrue = iftrue
- self.iffalse = iffalse
- self.coord = coord
- def children(self):
- nodelist = []
- if self.cond is not None:
- nodelist.append(("cond", self.cond))
- if self.iftrue is not None:
- nodelist.append(("iftrue", self.iftrue))
- if self.iffalse is not None:
- nodelist.append(("iffalse", self.iffalse))
- return tuple(nodelist)
- def __iter__(self):
- if self.cond is not None:
- yield self.cond
- if self.iftrue is not None:
- yield self.iftrue
- if self.iffalse is not None:
- yield self.iffalse
- attr_names = ()
- class InitList(Node):
- __slots__ = ("exprs", "coord", "__weakref__")
- def __init__(self, exprs, coord=None):
- self.exprs = exprs
- self.coord = coord
- def children(self):
- nodelist = []
- for i, child in enumerate(self.exprs or []):
- nodelist.append((f"exprs[{i}]", child))
- return tuple(nodelist)
- def __iter__(self):
- yield from self.exprs or []
- attr_names = ()
- class Label(Node):
- __slots__ = ("name", "stmt", "coord", "__weakref__")
- def __init__(self, name, stmt, coord=None):
- self.name = name
- self.stmt = stmt
- self.coord = coord
- def children(self):
- nodelist = []
- if self.stmt is not None:
- nodelist.append(("stmt", self.stmt))
- return tuple(nodelist)
- def __iter__(self):
- if self.stmt is not None:
- yield self.stmt
- attr_names = ("name",)
- class NamedInitializer(Node):
- __slots__ = ("name", "expr", "coord", "__weakref__")
- def __init__(self, name, expr, coord=None):
- self.name = name
- self.expr = expr
- self.coord = coord
- def children(self):
- nodelist = []
- if self.expr is not None:
- nodelist.append(("expr", self.expr))
- for i, child in enumerate(self.name or []):
- nodelist.append((f"name[{i}]", child))
- return tuple(nodelist)
- def __iter__(self):
- if self.expr is not None:
- yield self.expr
- yield from self.name or []
- attr_names = ()
- class ParamList(Node):
- __slots__ = ("params", "coord", "__weakref__")
- def __init__(self, params, coord=None):
- self.params = params
- self.coord = coord
- def children(self):
- nodelist = []
- for i, child in enumerate(self.params or []):
- nodelist.append((f"params[{i}]", child))
- return tuple(nodelist)
- def __iter__(self):
- yield from self.params or []
- attr_names = ()
- class PtrDecl(Node):
- __slots__ = ("quals", "type", "coord", "__weakref__")
- def __init__(self, quals, type, coord=None):
- self.quals = quals
- self.type = type
- self.coord = coord
- def children(self):
- nodelist = []
- if self.type is not None:
- nodelist.append(("type", self.type))
- return tuple(nodelist)
- def __iter__(self):
- if self.type is not None:
- yield self.type
- attr_names = ("quals",)
- class Return(Node):
- __slots__ = ("expr", "coord", "__weakref__")
- def __init__(self, expr, coord=None):
- self.expr = expr
- self.coord = coord
- def children(self):
- nodelist = []
- if self.expr is not None:
- nodelist.append(("expr", self.expr))
- return tuple(nodelist)
- def __iter__(self):
- if self.expr is not None:
- yield self.expr
- attr_names = ()
- class StaticAssert(Node):
- __slots__ = ("cond", "message", "coord", "__weakref__")
- def __init__(self, cond, message, coord=None):
- self.cond = cond
- self.message = message
- self.coord = coord
- def children(self):
- nodelist = []
- if self.cond is not None:
- nodelist.append(("cond", self.cond))
- if self.message is not None:
- nodelist.append(("message", self.message))
- return tuple(nodelist)
- def __iter__(self):
- if self.cond is not None:
- yield self.cond
- if self.message is not None:
- yield self.message
- attr_names = ()
- class Struct(Node):
- __slots__ = ("name", "decls", "coord", "__weakref__")
- def __init__(self, name, decls, coord=None):
- self.name = name
- self.decls = decls
- self.coord = coord
- def children(self):
- nodelist = []
- for i, child in enumerate(self.decls or []):
- nodelist.append((f"decls[{i}]", child))
- return tuple(nodelist)
- def __iter__(self):
- yield from self.decls or []
- attr_names = ("name",)
- class StructRef(Node):
- __slots__ = ("name", "type", "field", "coord", "__weakref__")
- def __init__(self, name, type, field, coord=None):
- self.name = name
- self.type = type
- self.field = field
- self.coord = coord
- def children(self):
- nodelist = []
- if self.name is not None:
- nodelist.append(("name", self.name))
- if self.field is not None:
- nodelist.append(("field", self.field))
- return tuple(nodelist)
- def __iter__(self):
- if self.name is not None:
- yield self.name
- if self.field is not None:
- yield self.field
- attr_names = ("type",)
- class Switch(Node):
- __slots__ = ("cond", "stmt", "coord", "__weakref__")
- def __init__(self, cond, stmt, coord=None):
- self.cond = cond
- self.stmt = stmt
- self.coord = coord
- def children(self):
- nodelist = []
- if self.cond is not None:
- nodelist.append(("cond", self.cond))
- if self.stmt is not None:
- nodelist.append(("stmt", self.stmt))
- return tuple(nodelist)
- def __iter__(self):
- if self.cond is not None:
- yield self.cond
- if self.stmt is not None:
- yield self.stmt
- attr_names = ()
- class TernaryOp(Node):
- __slots__ = ("cond", "iftrue", "iffalse", "coord", "__weakref__")
- def __init__(self, cond, iftrue, iffalse, coord=None):
- self.cond = cond
- self.iftrue = iftrue
- self.iffalse = iffalse
- self.coord = coord
- def children(self):
- nodelist = []
- if self.cond is not None:
- nodelist.append(("cond", self.cond))
- if self.iftrue is not None:
- nodelist.append(("iftrue", self.iftrue))
- if self.iffalse is not None:
- nodelist.append(("iffalse", self.iffalse))
- return tuple(nodelist)
- def __iter__(self):
- if self.cond is not None:
- yield self.cond
- if self.iftrue is not None:
- yield self.iftrue
- if self.iffalse is not None:
- yield self.iffalse
- attr_names = ()
- class TypeDecl(Node):
- __slots__ = ("declname", "quals", "align", "type", "coord", "__weakref__")
- def __init__(self, declname, quals, align, type, coord=None):
- self.declname = declname
- self.quals = quals
- self.align = align
- self.type = type
- self.coord = coord
- def children(self):
- nodelist = []
- if self.type is not None:
- nodelist.append(("type", self.type))
- return tuple(nodelist)
- def __iter__(self):
- if self.type is not None:
- yield self.type
- attr_names = (
- "declname",
- "quals",
- "align",
- )
- class Typedef(Node):
- __slots__ = ("name", "quals", "storage", "type", "coord", "__weakref__")
- def __init__(self, name, quals, storage, type, coord=None):
- self.name = name
- self.quals = quals
- self.storage = storage
- self.type = type
- self.coord = coord
- def children(self):
- nodelist = []
- if self.type is not None:
- nodelist.append(("type", self.type))
- return tuple(nodelist)
- def __iter__(self):
- if self.type is not None:
- yield self.type
- attr_names = (
- "name",
- "quals",
- "storage",
- )
- class Typename(Node):
- __slots__ = ("name", "quals", "align", "type", "coord", "__weakref__")
- def __init__(self, name, quals, align, type, coord=None):
- self.name = name
- self.quals = quals
- self.align = align
- self.type = type
- self.coord = coord
- def children(self):
- nodelist = []
- if self.type is not None:
- nodelist.append(("type", self.type))
- return tuple(nodelist)
- def __iter__(self):
- if self.type is not None:
- yield self.type
- attr_names = (
- "name",
- "quals",
- "align",
- )
- class UnaryOp(Node):
- __slots__ = ("op", "expr", "coord", "__weakref__")
- def __init__(self, op, expr, coord=None):
- self.op = op
- self.expr = expr
- self.coord = coord
- def children(self):
- nodelist = []
- if self.expr is not None:
- nodelist.append(("expr", self.expr))
- return tuple(nodelist)
- def __iter__(self):
- if self.expr is not None:
- yield self.expr
- attr_names = ("op",)
- class Union(Node):
- __slots__ = ("name", "decls", "coord", "__weakref__")
- def __init__(self, name, decls, coord=None):
- self.name = name
- self.decls = decls
- self.coord = coord
- def children(self):
- nodelist = []
- for i, child in enumerate(self.decls or []):
- nodelist.append((f"decls[{i}]", child))
- return tuple(nodelist)
- def __iter__(self):
- yield from self.decls or []
- attr_names = ("name",)
- class While(Node):
- __slots__ = ("cond", "stmt", "coord", "__weakref__")
- def __init__(self, cond, stmt, coord=None):
- self.cond = cond
- self.stmt = stmt
- self.coord = coord
- def children(self):
- nodelist = []
- if self.cond is not None:
- nodelist.append(("cond", self.cond))
- if self.stmt is not None:
- nodelist.append(("stmt", self.stmt))
- return tuple(nodelist)
- def __iter__(self):
- if self.cond is not None:
- yield self.cond
- if self.stmt is not None:
- yield self.stmt
- attr_names = ()
- class Pragma(Node):
- __slots__ = ("string", "coord", "__weakref__")
- def __init__(self, string, coord=None):
- self.string = string
- self.coord = coord
- def children(self):
- nodelist = []
- return tuple(nodelist)
- def __iter__(self):
- return
- yield
- attr_names = ("string",)
|