Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/pycparser/c_ast.py: 52%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

851 statements  

1# ----------------------------------------------------------------- 

2# ** ATTENTION ** 

3# This code was automatically generated from _c_ast.cfg 

4# 

5# Do not modify it directly. Modify the configuration file and 

6# run the generator again. 

7# ** ** *** ** ** 

8# 

9# The order of generated __slots__ is significant to Node.__repr__. 

10# ruff: noqa: RUF023 

11# 

12# pycparser: c_ast.py 

13# 

14# AST Node classes. 

15# 

16# Eli Bendersky [https://eli.thegreenplace.net/] 

17# License: BSD 

18# ----------------------------------------------------------------- 

19 

20 

21import sys 

22from typing import IO, Any, ClassVar 

23 

24 

25def _repr(obj): 

26 """ 

27 Get the representation of an object, with dedicated pprint-like format for lists. 

28 """ 

29 if isinstance(obj, list): 

30 return "[" + (",\n ".join(_repr(e).replace("\n", "\n ") for e in obj)) + "\n]" 

31 else: 

32 return repr(obj) 

33 

34 

35class Node: 

36 __slots__ = () 

37 """ Abstract base class for AST nodes. 

38 """ 

39 attr_names: ClassVar[tuple[str, ...]] = () 

40 coord: Any | None 

41 

42 def __repr__(self): 

43 """Generates a python representation of the current node""" 

44 result = self.__class__.__name__ + "(" 

45 

46 indent = "" 

47 separator = "" 

48 for name in self.__slots__[:-2]: 

49 result += separator 

50 result += indent 

51 result += ( 

52 name 

53 + "=" 

54 + ( 

55 _repr(getattr(self, name)).replace( 

56 "\n", 

57 "\n " + (" " * (len(name) + len(self.__class__.__name__))), 

58 ) 

59 ) 

60 ) 

61 

62 separator = "," 

63 indent = "\n " + (" " * len(self.__class__.__name__)) 

64 

65 result += indent + ")" 

66 

67 return result 

68 

69 def children(self): 

70 """A sequence of all children that are Nodes""" 

71 

72 def show( 

73 self, 

74 buf: IO[str] = sys.stdout, 

75 offset: int = 0, 

76 attrnames: bool = False, 

77 showemptyattrs: bool = True, 

78 nodenames: bool = False, 

79 showcoord: bool = False, 

80 _my_node_name: str | None = None, 

81 ): 

82 """Pretty print the Node and all its attributes and 

83 children (recursively) to a buffer. 

84 

85 buf: 

86 Open IO buffer into which the Node is printed. 

87 

88 offset: 

89 Initial offset (amount of leading spaces) 

90 

91 attrnames: 

92 True if you want to see the attribute names in 

93 name=value pairs. False to only see the values. 

94 

95 showemptyattrs: 

96 False if you want to suppress printing empty attributes. 

97 

98 nodenames: 

99 True if you want to see the actual node names 

100 within their parents. 

101 

102 showcoord: 

103 Do you want the coordinates of each Node to be 

104 displayed. 

105 """ 

106 lead = " " * offset 

107 if nodenames and _my_node_name is not None: 

108 buf.write(lead + self.__class__.__name__ + " <" + _my_node_name + ">: ") 

109 else: 

110 buf.write(lead + self.__class__.__name__ + ": ") 

111 

112 if self.attr_names: 

113 

114 def is_empty(v): 

115 return v is None or (hasattr(v, "__len__") and len(v) == 0) 

116 

117 nvlist = [ 

118 (n, getattr(self, n)) 

119 for n in self.attr_names 

120 if showemptyattrs or not is_empty(getattr(self, n)) 

121 ] 

122 if attrnames: 

123 attrstr = ", ".join(f"{name}={value}" for name, value in nvlist) 

124 else: 

125 attrstr = ", ".join(f"{value}" for _, value in nvlist) 

126 buf.write(attrstr) 

127 

128 if showcoord: 

129 buf.write(f" (at {self.coord})") 

130 buf.write("\n") 

131 

132 for child_name, child in self.children(): 

133 child.show( 

134 buf, 

135 offset=offset + 2, 

136 attrnames=attrnames, 

137 showemptyattrs=showemptyattrs, 

138 nodenames=nodenames, 

139 showcoord=showcoord, 

140 _my_node_name=child_name, 

141 ) 

142 

143 

144class NodeVisitor: 

145 """A base NodeVisitor class for visiting c_ast nodes. 

146 Subclass it and define your own visit_XXX methods, where 

147 XXX is the class name you want to visit with these 

148 methods. 

149 

150 For example: 

151 

152 class ConstantVisitor(NodeVisitor): 

153 def __init__(self): 

154 self.values = [] 

155 

156 def visit_Constant(self, node): 

157 self.values.append(node.value) 

158 

159 Creates a list of values of all the constant nodes 

160 encountered below the given node. To use it: 

161 

162 cv = ConstantVisitor() 

163 cv.visit(node) 

164 

165 Notes: 

166 

167 * generic_visit() will be called for AST nodes for which 

168 no visit_XXX method was defined. 

169 * The children of nodes for which a visit_XXX was 

170 defined will not be visited - if you need this, call 

171 generic_visit() on the node. 

172 You can use: 

173 NodeVisitor.generic_visit(self, node) 

174 * Modeled after Python's own AST visiting facilities 

175 (the ast module of Python 3.0) 

176 """ 

177 

178 _method_cache = None 

179 

180 def visit(self, node: Node): 

181 """Visit a node.""" 

182 

183 if self._method_cache is None: 

184 self._method_cache = {} 

185 

186 visitor = self._method_cache.get(node.__class__.__name__, None) 

187 if visitor is None: 

188 method = "visit_" + node.__class__.__name__ 

189 visitor = getattr(self, method, self.generic_visit) 

190 self._method_cache[node.__class__.__name__] = visitor 

191 

192 return visitor(node) 

193 

194 def generic_visit(self, node: Node): 

195 """Called if no explicit visitor function exists for a 

196 node. Implements preorder visiting of the node. 

197 """ 

198 for _, c in node.children(): 

199 self.visit(c) 

200 

201 

202class ArrayDecl(Node): 

203 __slots__ = ("type", "dim", "dim_quals", "coord", "__weakref__") 

204 

205 def __init__(self, type, dim, dim_quals, coord=None): 

206 self.type = type 

207 self.dim = dim 

208 self.dim_quals = dim_quals 

209 self.coord = coord 

210 

211 def children(self): 

212 nodelist = [] 

213 if self.type is not None: 

214 nodelist.append(("type", self.type)) 

215 if self.dim is not None: 

216 nodelist.append(("dim", self.dim)) 

217 return tuple(nodelist) 

218 

219 def __iter__(self): 

220 if self.type is not None: 

221 yield self.type 

222 if self.dim is not None: 

223 yield self.dim 

224 

225 attr_names = ("dim_quals",) 

226 

227 

228class ArrayRef(Node): 

229 __slots__ = ("name", "subscript", "coord", "__weakref__") 

230 

231 def __init__(self, name, subscript, coord=None): 

232 self.name = name 

233 self.subscript = subscript 

234 self.coord = coord 

235 

236 def children(self): 

237 nodelist = [] 

238 if self.name is not None: 

239 nodelist.append(("name", self.name)) 

240 if self.subscript is not None: 

241 nodelist.append(("subscript", self.subscript)) 

242 return tuple(nodelist) 

243 

244 def __iter__(self): 

245 if self.name is not None: 

246 yield self.name 

247 if self.subscript is not None: 

248 yield self.subscript 

249 

250 attr_names = () 

251 

252 

253class Assignment(Node): 

254 __slots__ = ("op", "lvalue", "rvalue", "coord", "__weakref__") 

255 

256 def __init__(self, op, lvalue, rvalue, coord=None): 

257 self.op = op 

258 self.lvalue = lvalue 

259 self.rvalue = rvalue 

260 self.coord = coord 

261 

262 def children(self): 

263 nodelist = [] 

264 if self.lvalue is not None: 

265 nodelist.append(("lvalue", self.lvalue)) 

266 if self.rvalue is not None: 

267 nodelist.append(("rvalue", self.rvalue)) 

268 return tuple(nodelist) 

269 

270 def __iter__(self): 

271 if self.lvalue is not None: 

272 yield self.lvalue 

273 if self.rvalue is not None: 

274 yield self.rvalue 

275 

276 attr_names = ("op",) 

277 

278 

279class Alignas(Node): 

280 __slots__ = ("alignment", "coord", "__weakref__") 

281 

282 def __init__(self, alignment, coord=None): 

283 self.alignment = alignment 

284 self.coord = coord 

285 

286 def children(self): 

287 nodelist = [] 

288 if self.alignment is not None: 

289 nodelist.append(("alignment", self.alignment)) 

290 return tuple(nodelist) 

291 

292 def __iter__(self): 

293 if self.alignment is not None: 

294 yield self.alignment 

295 

296 attr_names = () 

297 

298 

299class BinaryOp(Node): 

300 __slots__ = ("op", "left", "right", "coord", "__weakref__") 

301 

302 def __init__(self, op, left, right, coord=None): 

303 self.op = op 

304 self.left = left 

305 self.right = right 

306 self.coord = coord 

307 

308 def children(self): 

309 nodelist = [] 

310 if self.left is not None: 

311 nodelist.append(("left", self.left)) 

312 if self.right is not None: 

313 nodelist.append(("right", self.right)) 

314 return tuple(nodelist) 

315 

316 def __iter__(self): 

317 if self.left is not None: 

318 yield self.left 

319 if self.right is not None: 

320 yield self.right 

321 

322 attr_names = ("op",) 

323 

324 

325class Break(Node): 

326 __slots__ = ("coord", "__weakref__") 

327 

328 def __init__(self, coord=None): 

329 self.coord = coord 

330 

331 def children(self): 

332 return () 

333 

334 def __iter__(self): 

335 return 

336 yield 

337 

338 attr_names = () 

339 

340 

341class Case(Node): 

342 __slots__ = ("expr", "stmts", "coord", "__weakref__") 

343 

344 def __init__(self, expr, stmts, coord=None): 

345 self.expr = expr 

346 self.stmts = stmts 

347 self.coord = coord 

348 

349 def children(self): 

350 nodelist = [] 

351 if self.expr is not None: 

352 nodelist.append(("expr", self.expr)) 

353 for i, child in enumerate(self.stmts or []): 

354 nodelist.append((f"stmts[{i}]", child)) 

355 return tuple(nodelist) 

356 

357 def __iter__(self): 

358 if self.expr is not None: 

359 yield self.expr 

360 yield from self.stmts or [] 

361 

362 attr_names = () 

363 

364 

365class Cast(Node): 

366 __slots__ = ("to_type", "expr", "coord", "__weakref__") 

367 

368 def __init__(self, to_type, expr, coord=None): 

369 self.to_type = to_type 

370 self.expr = expr 

371 self.coord = coord 

372 

373 def children(self): 

374 nodelist = [] 

375 if self.to_type is not None: 

376 nodelist.append(("to_type", self.to_type)) 

377 if self.expr is not None: 

378 nodelist.append(("expr", self.expr)) 

379 return tuple(nodelist) 

380 

381 def __iter__(self): 

382 if self.to_type is not None: 

383 yield self.to_type 

384 if self.expr is not None: 

385 yield self.expr 

386 

387 attr_names = () 

388 

389 

390class Compound(Node): 

391 __slots__ = ("block_items", "coord", "__weakref__") 

392 

393 def __init__(self, block_items, coord=None): 

394 self.block_items = block_items 

395 self.coord = coord 

396 

397 def children(self): 

398 nodelist = [] 

399 for i, child in enumerate(self.block_items or []): 

400 nodelist.append((f"block_items[{i}]", child)) 

401 return tuple(nodelist) 

402 

403 def __iter__(self): 

404 yield from self.block_items or [] 

405 

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 = type 

414 self.init = init 

415 self.coord = coord 

416 

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.type 

428 if self.init is not None: 

429 yield self.init 

430 

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 = type 

439 self.value = value 

440 self.coord = coord 

441 

442 def children(self): 

443 nodelist = [] 

444 return tuple(nodelist) 

445 

446 def __iter__(self): 

447 return 

448 yield 

449 

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 = coord 

461 

462 def children(self): 

463 return () 

464 

465 def __iter__(self): 

466 return 

467 yield 

468 

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=None 

488 ): 

489 self.name = name 

490 self.quals = quals 

491 self.align = align 

492 self.storage = storage 

493 self.funcspec = funcspec 

494 self.type = type 

495 self.init = init 

496 self.bitsize = bitsize 

497 self.coord = coord 

498 

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.type 

512 if self.init is not None: 

513 yield self.init 

514 if self.bitsize is not None: 

515 yield self.bitsize 

516 

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 = decls 

531 self.coord = coord 

532 

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 yield from self.decls or [] 

541 

542 attr_names = () 

543 

544 

545class Default(Node): 

546 __slots__ = ("stmts", "coord", "__weakref__") 

547 

548 def __init__(self, stmts, coord=None): 

549 self.stmts = stmts 

550 self.coord = coord 

551 

552 def children(self): 

553 nodelist = [] 

554 for i, child in enumerate(self.stmts or []): 

555 nodelist.append((f"stmts[{i}]", child)) 

556 return tuple(nodelist) 

557 

558 def __iter__(self): 

559 yield from self.stmts or [] 

560 

561 attr_names = () 

562 

563 

564class DoWhile(Node): 

565 __slots__ = ("cond", "stmt", "coord", "__weakref__") 

566 

567 def __init__(self, cond, stmt, coord=None): 

568 self.cond = cond 

569 self.stmt = stmt 

570 self.coord = coord 

571 

572 def children(self): 

573 nodelist = [] 

574 if self.cond is not None: 

575 nodelist.append(("cond", self.cond)) 

576 if self.stmt is not None: 

577 nodelist.append(("stmt", self.stmt)) 

578 return tuple(nodelist) 

579 

580 def __iter__(self): 

581 if self.cond is not None: 

582 yield self.cond 

583 if self.stmt is not None: 

584 yield self.stmt 

585 

586 attr_names = () 

587 

588 

589class EllipsisParam(Node): 

590 __slots__ = ("coord", "__weakref__") 

591 

592 def __init__(self, coord=None): 

593 self.coord = coord 

594 

595 def children(self): 

596 return () 

597 

598 def __iter__(self): 

599 return 

600 yield 

601 

602 attr_names = () 

603 

604 

605class EmptyStatement(Node): 

606 __slots__ = ("coord", "__weakref__") 

607 

608 def __init__(self, coord=None): 

609 self.coord = coord 

610 

611 def children(self): 

612 return () 

613 

614 def __iter__(self): 

615 return 

616 yield 

617 

618 attr_names = () 

619 

620 

621class Enum(Node): 

622 __slots__ = ("name", "values", "coord", "__weakref__") 

623 

624 def __init__(self, name, values, coord=None): 

625 self.name = name 

626 self.values = values 

627 self.coord = coord 

628 

629 def children(self): 

630 nodelist = [] 

631 if self.values is not None: 

632 nodelist.append(("values", self.values)) 

633 return tuple(nodelist) 

634 

635 def __iter__(self): 

636 if self.values is not None: 

637 yield self.values 

638 

639 attr_names = ("name",) 

640 

641 

642class Enumerator(Node): 

643 __slots__ = ("name", "value", "coord", "__weakref__") 

644 

645 def __init__(self, name, value, coord=None): 

646 self.name = name 

647 self.value = value 

648 self.coord = coord 

649 

650 def children(self): 

651 nodelist = [] 

652 if self.value is not None: 

653 nodelist.append(("value", self.value)) 

654 return tuple(nodelist) 

655 

656 def __iter__(self): 

657 if self.value is not None: 

658 yield self.value 

659 

660 attr_names = ("name",) 

661 

662 

663class EnumeratorList(Node): 

664 __slots__ = ("enumerators", "coord", "__weakref__") 

665 

666 def __init__(self, enumerators, coord=None): 

667 self.enumerators = enumerators 

668 self.coord = coord 

669 

670 def children(self): 

671 nodelist = [] 

672 for i, child in enumerate(self.enumerators or []): 

673 nodelist.append((f"enumerators[{i}]", child)) 

674 return tuple(nodelist) 

675 

676 def __iter__(self): 

677 yield from self.enumerators or [] 

678 

679 attr_names = () 

680 

681 

682class ExprList(Node): 

683 __slots__ = ("exprs", "coord", "__weakref__") 

684 

685 def __init__(self, exprs, coord=None): 

686 self.exprs = exprs 

687 self.coord = coord 

688 

689 def children(self): 

690 nodelist = [] 

691 for i, child in enumerate(self.exprs or []): 

692 nodelist.append((f"exprs[{i}]", child)) 

693 return tuple(nodelist) 

694 

695 def __iter__(self): 

696 yield from self.exprs or [] 

697 

698 attr_names = () 

699 

700 

701class FileAST(Node): 

702 __slots__ = ("ext", "coord", "__weakref__") 

703 

704 def __init__(self, ext, coord=None): 

705 self.ext = ext 

706 self.coord = coord 

707 

708 def children(self): 

709 nodelist = [] 

710 for i, child in enumerate(self.ext or []): 

711 nodelist.append((f"ext[{i}]", child)) 

712 return tuple(nodelist) 

713 

714 def __iter__(self): 

715 yield from self.ext or [] 

716 

717 attr_names = () 

718 

719 

720class For(Node): 

721 __slots__ = ("init", "cond", "next", "stmt", "coord", "__weakref__") 

722 

723 def __init__(self, init, cond, next, stmt, coord=None): 

724 self.init = init 

725 self.cond = cond 

726 self.next = next 

727 self.stmt = stmt 

728 self.coord = coord 

729 

730 def children(self): 

731 nodelist = [] 

732 if self.init is not None: 

733 nodelist.append(("init", self.init)) 

734 if self.cond is not None: 

735 nodelist.append(("cond", self.cond)) 

736 if self.next is not None: 

737 nodelist.append(("next", self.next)) 

738 if self.stmt is not None: 

739 nodelist.append(("stmt", self.stmt)) 

740 return tuple(nodelist) 

741 

742 def __iter__(self): 

743 if self.init is not None: 

744 yield self.init 

745 if self.cond is not None: 

746 yield self.cond 

747 if self.next is not None: 

748 yield self.next 

749 if self.stmt is not None: 

750 yield self.stmt 

751 

752 attr_names = () 

753 

754 

755class FuncCall(Node): 

756 __slots__ = ("name", "args", "coord", "__weakref__") 

757 

758 def __init__(self, name, args, coord=None): 

759 self.name = name 

760 self.args = args 

761 self.coord = coord 

762 

763 def children(self): 

764 nodelist = [] 

765 if self.name is not None: 

766 nodelist.append(("name", self.name)) 

767 if self.args is not None: 

768 nodelist.append(("args", self.args)) 

769 return tuple(nodelist) 

770 

771 def __iter__(self): 

772 if self.name is not None: 

773 yield self.name 

774 if self.args is not None: 

775 yield self.args 

776 

777 attr_names = () 

778 

779 

780class FuncDecl(Node): 

781 __slots__ = ("args", "type", "coord", "__weakref__") 

782 

783 def __init__(self, args, type, coord=None): 

784 self.args = args 

785 self.type = type 

786 self.coord = coord 

787 

788 def children(self): 

789 nodelist = [] 

790 if self.args is not None: 

791 nodelist.append(("args", self.args)) 

792 if self.type is not None: 

793 nodelist.append(("type", self.type)) 

794 return tuple(nodelist) 

795 

796 def __iter__(self): 

797 if self.args is not None: 

798 yield self.args 

799 if self.type is not None: 

800 yield self.type 

801 

802 attr_names = () 

803 

804 

805class FuncDef(Node): 

806 __slots__ = ("decl", "param_decls", "body", "coord", "__weakref__") 

807 

808 def __init__(self, decl, param_decls, body, coord=None): 

809 self.decl = decl 

810 self.param_decls = param_decls 

811 self.body = body 

812 self.coord = coord 

813 

814 def children(self): 

815 nodelist = [] 

816 if self.decl is not None: 

817 nodelist.append(("decl", self.decl)) 

818 if self.body is not None: 

819 nodelist.append(("body", self.body)) 

820 for i, child in enumerate(self.param_decls or []): 

821 nodelist.append((f"param_decls[{i}]", child)) 

822 return tuple(nodelist) 

823 

824 def __iter__(self): 

825 if self.decl is not None: 

826 yield self.decl 

827 if self.body is not None: 

828 yield self.body 

829 yield from self.param_decls or [] 

830 

831 attr_names = () 

832 

833 

834class Goto(Node): 

835 __slots__ = ("name", "coord", "__weakref__") 

836 

837 def __init__(self, name, coord=None): 

838 self.name = name 

839 self.coord = coord 

840 

841 def children(self): 

842 nodelist = [] 

843 return tuple(nodelist) 

844 

845 def __iter__(self): 

846 return 

847 yield 

848 

849 attr_names = ("name",) 

850 

851 

852class ID(Node): 

853 __slots__ = ("name", "coord", "__weakref__") 

854 

855 def __init__(self, name, coord=None): 

856 self.name = name 

857 self.coord = coord 

858 

859 def children(self): 

860 nodelist = [] 

861 return tuple(nodelist) 

862 

863 def __iter__(self): 

864 return 

865 yield 

866 

867 attr_names = ("name",) 

868 

869 

870class IdentifierType(Node): 

871 __slots__ = ("names", "coord", "__weakref__") 

872 

873 def __init__(self, names, coord=None): 

874 self.names = names 

875 self.coord = coord 

876 

877 def children(self): 

878 nodelist = [] 

879 return tuple(nodelist) 

880 

881 def __iter__(self): 

882 return 

883 yield 

884 

885 attr_names = ("names",) 

886 

887 

888class If(Node): 

889 __slots__ = ("cond", "iftrue", "iffalse", "coord", "__weakref__") 

890 

891 def __init__(self, cond, iftrue, iffalse, coord=None): 

892 self.cond = cond 

893 self.iftrue = iftrue 

894 self.iffalse = iffalse 

895 self.coord = coord 

896 

897 def children(self): 

898 nodelist = [] 

899 if self.cond is not None: 

900 nodelist.append(("cond", self.cond)) 

901 if self.iftrue is not None: 

902 nodelist.append(("iftrue", self.iftrue)) 

903 if self.iffalse is not None: 

904 nodelist.append(("iffalse", self.iffalse)) 

905 return tuple(nodelist) 

906 

907 def __iter__(self): 

908 if self.cond is not None: 

909 yield self.cond 

910 if self.iftrue is not None: 

911 yield self.iftrue 

912 if self.iffalse is not None: 

913 yield self.iffalse 

914 

915 attr_names = () 

916 

917 

918class InitList(Node): 

919 __slots__ = ("exprs", "coord", "__weakref__") 

920 

921 def __init__(self, exprs, coord=None): 

922 self.exprs = exprs 

923 self.coord = coord 

924 

925 def children(self): 

926 nodelist = [] 

927 for i, child in enumerate(self.exprs or []): 

928 nodelist.append((f"exprs[{i}]", child)) 

929 return tuple(nodelist) 

930 

931 def __iter__(self): 

932 yield from self.exprs or [] 

933 

934 attr_names = () 

935 

936 

937class Label(Node): 

938 __slots__ = ("name", "stmt", "coord", "__weakref__") 

939 

940 def __init__(self, name, stmt, coord=None): 

941 self.name = name 

942 self.stmt = stmt 

943 self.coord = coord 

944 

945 def children(self): 

946 nodelist = [] 

947 if self.stmt is not None: 

948 nodelist.append(("stmt", self.stmt)) 

949 return tuple(nodelist) 

950 

951 def __iter__(self): 

952 if self.stmt is not None: 

953 yield self.stmt 

954 

955 attr_names = ("name",) 

956 

957 

958class NamedInitializer(Node): 

959 __slots__ = ("name", "expr", "coord", "__weakref__") 

960 

961 def __init__(self, name, expr, coord=None): 

962 self.name = name 

963 self.expr = expr 

964 self.coord = coord 

965 

966 def children(self): 

967 nodelist = [] 

968 if self.expr is not None: 

969 nodelist.append(("expr", self.expr)) 

970 for i, child in enumerate(self.name or []): 

971 nodelist.append((f"name[{i}]", child)) 

972 return tuple(nodelist) 

973 

974 def __iter__(self): 

975 if self.expr is not None: 

976 yield self.expr 

977 yield from self.name or [] 

978 

979 attr_names = () 

980 

981 

982class ParamList(Node): 

983 __slots__ = ("params", "coord", "__weakref__") 

984 

985 def __init__(self, params, coord=None): 

986 self.params = params 

987 self.coord = coord 

988 

989 def children(self): 

990 nodelist = [] 

991 for i, child in enumerate(self.params or []): 

992 nodelist.append((f"params[{i}]", child)) 

993 return tuple(nodelist) 

994 

995 def __iter__(self): 

996 yield from self.params or [] 

997 

998 attr_names = () 

999 

1000 

1001class PtrDecl(Node): 

1002 __slots__ = ("quals", "type", "coord", "__weakref__") 

1003 

1004 def __init__(self, quals, type, coord=None): 

1005 self.quals = quals 

1006 self.type = type 

1007 self.coord = coord 

1008 

1009 def children(self): 

1010 nodelist = [] 

1011 if self.type is not None: 

1012 nodelist.append(("type", self.type)) 

1013 return tuple(nodelist) 

1014 

1015 def __iter__(self): 

1016 if self.type is not None: 

1017 yield self.type 

1018 

1019 attr_names = ("quals",) 

1020 

1021 

1022class Return(Node): 

1023 __slots__ = ("expr", "coord", "__weakref__") 

1024 

1025 def __init__(self, expr, coord=None): 

1026 self.expr = expr 

1027 self.coord = coord 

1028 

1029 def children(self): 

1030 nodelist = [] 

1031 if self.expr is not None: 

1032 nodelist.append(("expr", self.expr)) 

1033 return tuple(nodelist) 

1034 

1035 def __iter__(self): 

1036 if self.expr is not None: 

1037 yield self.expr 

1038 

1039 attr_names = () 

1040 

1041 

1042class StaticAssert(Node): 

1043 __slots__ = ("cond", "message", "coord", "__weakref__") 

1044 

1045 def __init__(self, cond, message, coord=None): 

1046 self.cond = cond 

1047 self.message = message 

1048 self.coord = coord 

1049 

1050 def children(self): 

1051 nodelist = [] 

1052 if self.cond is not None: 

1053 nodelist.append(("cond", self.cond)) 

1054 if self.message is not None: 

1055 nodelist.append(("message", self.message)) 

1056 return tuple(nodelist) 

1057 

1058 def __iter__(self): 

1059 if self.cond is not None: 

1060 yield self.cond 

1061 if self.message is not None: 

1062 yield self.message 

1063 

1064 attr_names = () 

1065 

1066 

1067class Struct(Node): 

1068 __slots__ = ("name", "decls", "coord", "__weakref__") 

1069 

1070 def __init__(self, name, decls, coord=None): 

1071 self.name = name 

1072 self.decls = decls 

1073 self.coord = coord 

1074 

1075 def children(self): 

1076 nodelist = [] 

1077 for i, child in enumerate(self.decls or []): 

1078 nodelist.append((f"decls[{i}]", child)) 

1079 return tuple(nodelist) 

1080 

1081 def __iter__(self): 

1082 yield from self.decls or [] 

1083 

1084 attr_names = ("name",) 

1085 

1086 

1087class StructRef(Node): 

1088 __slots__ = ("name", "type", "field", "coord", "__weakref__") 

1089 

1090 def __init__(self, name, type, field, coord=None): 

1091 self.name = name 

1092 self.type = type 

1093 self.field = field 

1094 self.coord = coord 

1095 

1096 def children(self): 

1097 nodelist = [] 

1098 if self.name is not None: 

1099 nodelist.append(("name", self.name)) 

1100 if self.field is not None: 

1101 nodelist.append(("field", self.field)) 

1102 return tuple(nodelist) 

1103 

1104 def __iter__(self): 

1105 if self.name is not None: 

1106 yield self.name 

1107 if self.field is not None: 

1108 yield self.field 

1109 

1110 attr_names = ("type",) 

1111 

1112 

1113class Switch(Node): 

1114 __slots__ = ("cond", "stmt", "coord", "__weakref__") 

1115 

1116 def __init__(self, cond, stmt, coord=None): 

1117 self.cond = cond 

1118 self.stmt = stmt 

1119 self.coord = coord 

1120 

1121 def children(self): 

1122 nodelist = [] 

1123 if self.cond is not None: 

1124 nodelist.append(("cond", self.cond)) 

1125 if self.stmt is not None: 

1126 nodelist.append(("stmt", self.stmt)) 

1127 return tuple(nodelist) 

1128 

1129 def __iter__(self): 

1130 if self.cond is not None: 

1131 yield self.cond 

1132 if self.stmt is not None: 

1133 yield self.stmt 

1134 

1135 attr_names = () 

1136 

1137 

1138class TernaryOp(Node): 

1139 __slots__ = ("cond", "iftrue", "iffalse", "coord", "__weakref__") 

1140 

1141 def __init__(self, cond, iftrue, iffalse, coord=None): 

1142 self.cond = cond 

1143 self.iftrue = iftrue 

1144 self.iffalse = iffalse 

1145 self.coord = coord 

1146 

1147 def children(self): 

1148 nodelist = [] 

1149 if self.cond is not None: 

1150 nodelist.append(("cond", self.cond)) 

1151 if self.iftrue is not None: 

1152 nodelist.append(("iftrue", self.iftrue)) 

1153 if self.iffalse is not None: 

1154 nodelist.append(("iffalse", self.iffalse)) 

1155 return tuple(nodelist) 

1156 

1157 def __iter__(self): 

1158 if self.cond is not None: 

1159 yield self.cond 

1160 if self.iftrue is not None: 

1161 yield self.iftrue 

1162 if self.iffalse is not None: 

1163 yield self.iffalse 

1164 

1165 attr_names = () 

1166 

1167 

1168class TypeDecl(Node): 

1169 __slots__ = ("declname", "quals", "align", "type", "coord", "__weakref__") 

1170 

1171 def __init__(self, declname, quals, align, type, coord=None): 

1172 self.declname = declname 

1173 self.quals = quals 

1174 self.align = align 

1175 self.type = type 

1176 self.coord = coord 

1177 

1178 def children(self): 

1179 nodelist = [] 

1180 if self.type is not None: 

1181 nodelist.append(("type", self.type)) 

1182 return tuple(nodelist) 

1183 

1184 def __iter__(self): 

1185 if self.type is not None: 

1186 yield self.type 

1187 

1188 attr_names = ( 

1189 "declname", 

1190 "quals", 

1191 "align", 

1192 ) 

1193 

1194 

1195class Typedef(Node): 

1196 __slots__ = ("name", "quals", "storage", "type", "coord", "__weakref__") 

1197 

1198 def __init__(self, name, quals, storage, type, coord=None): 

1199 self.name = name 

1200 self.quals = quals 

1201 self.storage = storage 

1202 self.type = type 

1203 self.coord = coord 

1204 

1205 def children(self): 

1206 nodelist = [] 

1207 if self.type is not None: 

1208 nodelist.append(("type", self.type)) 

1209 return tuple(nodelist) 

1210 

1211 def __iter__(self): 

1212 if self.type is not None: 

1213 yield self.type 

1214 

1215 attr_names = ( 

1216 "name", 

1217 "quals", 

1218 "storage", 

1219 ) 

1220 

1221 

1222class Typename(Node): 

1223 __slots__ = ("name", "quals", "align", "type", "coord", "__weakref__") 

1224 

1225 def __init__(self, name, quals, align, type, coord=None): 

1226 self.name = name 

1227 self.quals = quals 

1228 self.align = align 

1229 self.type = type 

1230 self.coord = coord 

1231 

1232 def children(self): 

1233 nodelist = [] 

1234 if self.type is not None: 

1235 nodelist.append(("type", self.type)) 

1236 return tuple(nodelist) 

1237 

1238 def __iter__(self): 

1239 if self.type is not None: 

1240 yield self.type 

1241 

1242 attr_names = ( 

1243 "name", 

1244 "quals", 

1245 "align", 

1246 ) 

1247 

1248 

1249class UnaryOp(Node): 

1250 __slots__ = ("op", "expr", "coord", "__weakref__") 

1251 

1252 def __init__(self, op, expr, coord=None): 

1253 self.op = op 

1254 self.expr = expr 

1255 self.coord = coord 

1256 

1257 def children(self): 

1258 nodelist = [] 

1259 if self.expr is not None: 

1260 nodelist.append(("expr", self.expr)) 

1261 return tuple(nodelist) 

1262 

1263 def __iter__(self): 

1264 if self.expr is not None: 

1265 yield self.expr 

1266 

1267 attr_names = ("op",) 

1268 

1269 

1270class Union(Node): 

1271 __slots__ = ("name", "decls", "coord", "__weakref__") 

1272 

1273 def __init__(self, name, decls, coord=None): 

1274 self.name = name 

1275 self.decls = decls 

1276 self.coord = coord 

1277 

1278 def children(self): 

1279 nodelist = [] 

1280 for i, child in enumerate(self.decls or []): 

1281 nodelist.append((f"decls[{i}]", child)) 

1282 return tuple(nodelist) 

1283 

1284 def __iter__(self): 

1285 yield from self.decls or [] 

1286 

1287 attr_names = ("name",) 

1288 

1289 

1290class While(Node): 

1291 __slots__ = ("cond", "stmt", "coord", "__weakref__") 

1292 

1293 def __init__(self, cond, stmt, coord=None): 

1294 self.cond = cond 

1295 self.stmt = stmt 

1296 self.coord = coord 

1297 

1298 def children(self): 

1299 nodelist = [] 

1300 if self.cond is not None: 

1301 nodelist.append(("cond", self.cond)) 

1302 if self.stmt is not None: 

1303 nodelist.append(("stmt", self.stmt)) 

1304 return tuple(nodelist) 

1305 

1306 def __iter__(self): 

1307 if self.cond is not None: 

1308 yield self.cond 

1309 if self.stmt is not None: 

1310 yield self.stmt 

1311 

1312 attr_names = () 

1313 

1314 

1315class Pragma(Node): 

1316 __slots__ = ("string", "coord", "__weakref__") 

1317 

1318 def __init__(self, string, coord=None): 

1319 self.string = string 

1320 self.coord = coord 

1321 

1322 def children(self): 

1323 nodelist = [] 

1324 return tuple(nodelist) 

1325 

1326 def __iter__(self): 

1327 return 

1328 yield 

1329 

1330 attr_names = ("string",)