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

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

808 statements  

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

2# ** ATTENTION ** 

3# This code was automatically generated from the file: 

4# _c_ast.cfg 

5# 

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

7# run the generator again. 

8# ** ** *** ** ** 

9# 

10# pycparser: c_ast.py 

11# 

12# AST Node classes. 

13# 

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

15# License: BSD 

16#----------------------------------------------------------------- 

17 

18 

19import sys 

20 

21def _repr(obj): 

22 """ 

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

24 """ 

25 if isinstance(obj, list): 

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

27 else: 

28 return repr(obj) 

29 

30class Node(object): 

31 __slots__ = () 

32 """ Abstract base class for AST nodes. 

33 """ 

34 def __repr__(self): 

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

36 """ 

37 result = self.__class__.__name__ + '(' 

38 

39 indent = '' 

40 separator = '' 

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

42 result += separator 

43 result += indent 

44 result += name + '=' + (_repr(getattr(self, name)).replace('\n', '\n ' + (' ' * (len(name) + len(self.__class__.__name__))))) 

45 

46 separator = ',' 

47 indent = '\n ' + (' ' * len(self.__class__.__name__)) 

48 

49 result += indent + ')' 

50 

51 return result 

52 

53 def children(self): 

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

55 """ 

56 pass 

57 

58 def show(self, buf=sys.stdout, offset=0, attrnames=False, showemptyattrs=True, nodenames=False, showcoord=False, _my_node_name=None): 

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

60 children (recursively) to a buffer. 

61 

62 buf: 

63 Open IO buffer into which the Node is printed. 

64 

65 offset: 

66 Initial offset (amount of leading spaces) 

67 

68 attrnames: 

69 True if you want to see the attribute names in 

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

71 

72 showemptyattrs: 

73 False if you want to suppress printing empty attributes. 

74 

75 nodenames: 

76 True if you want to see the actual node names 

77 within their parents. 

78 

79 showcoord: 

80 Do you want the coordinates of each Node to be 

81 displayed. 

82 """ 

83 lead = ' ' * offset 

84 if nodenames and _my_node_name is not None: 

85 buf.write(lead + self.__class__.__name__+ ' <' + _my_node_name + '>: ') 

86 else: 

87 buf.write(lead + self.__class__.__name__+ ': ') 

88 

89 if self.attr_names: 

90 is_empty = lambda v: v is None or (hasattr(v, '__len__') and len(v) == 0) 

91 nvlist = [(n, getattr(self,n)) for n in self.attr_names \ 

92 if showemptyattrs or not is_empty(getattr(self,n))] 

93 if attrnames: 

94 attrstr = ', '.join('%s=%s' % nv for nv in nvlist) 

95 else: 

96 attrstr = ', '.join('%s' % v for (_,v) in nvlist) 

97 buf.write(attrstr) 

98 

99 if showcoord: 

100 buf.write(' (at %s)' % self.coord) 

101 buf.write('\n') 

102 

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

104 child.show( 

105 buf, 

106 offset=offset + 2, 

107 attrnames=attrnames, 

108 showemptyattrs=showemptyattrs, 

109 nodenames=nodenames, 

110 showcoord=showcoord, 

111 _my_node_name=child_name) 

112 

113 

114class NodeVisitor(object): 

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

116 Subclass it and define your own visit_XXX methods, where 

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

118 methods. 

119 

120 For example: 

121 

122 class ConstantVisitor(NodeVisitor): 

123 def __init__(self): 

124 self.values = [] 

125 

126 def visit_Constant(self, node): 

127 self.values.append(node.value) 

128 

129 Creates a list of values of all the constant nodes 

130 encountered below the given node. To use it: 

131 

132 cv = ConstantVisitor() 

133 cv.visit(node) 

134 

135 Notes: 

136 

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

138 no visit_XXX method was defined. 

139 * The children of nodes for which a visit_XXX was 

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

141 generic_visit() on the node. 

142 You can use: 

143 NodeVisitor.generic_visit(self, node) 

144 * Modeled after Python's own AST visiting facilities 

145 (the ast module of Python 3.0) 

146 """ 

147 

148 _method_cache = None 

149 

150 def visit(self, node): 

151 """ Visit a node. 

152 """ 

153 

154 if self._method_cache is None: 

155 self._method_cache = {} 

156 

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

158 if visitor is None: 

159 method = 'visit_' + node.__class__.__name__ 

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

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

162 

163 return visitor(node) 

164 

165 def generic_visit(self, node): 

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

167 node. Implements preorder visiting of the node. 

168 """ 

169 for c in node: 

170 self.visit(c) 

171 

172class ArrayDecl(Node): 

173 __slots__ = ('type', 'dim', 'dim_quals', 'coord', '__weakref__') 

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

175 self.type = type 

176 self.dim = dim 

177 self.dim_quals = dim_quals 

178 self.coord = coord 

179 

180 def children(self): 

181 nodelist = [] 

182 if self.type is not None: nodelist.append(("type", self.type)) 

183 if self.dim is not None: nodelist.append(("dim", self.dim)) 

184 return tuple(nodelist) 

185 

186 def __iter__(self): 

187 if self.type is not None: 

188 yield self.type 

189 if self.dim is not None: 

190 yield self.dim 

191 

192 attr_names = ('dim_quals', ) 

193 

194class ArrayRef(Node): 

195 __slots__ = ('name', 'subscript', 'coord', '__weakref__') 

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

197 self.name = name 

198 self.subscript = subscript 

199 self.coord = coord 

200 

201 def children(self): 

202 nodelist = [] 

203 if self.name is not None: nodelist.append(("name", self.name)) 

204 if self.subscript is not None: nodelist.append(("subscript", self.subscript)) 

205 return tuple(nodelist) 

206 

207 def __iter__(self): 

208 if self.name is not None: 

209 yield self.name 

210 if self.subscript is not None: 

211 yield self.subscript 

212 

213 attr_names = () 

214 

215class Assignment(Node): 

216 __slots__ = ('op', 'lvalue', 'rvalue', 'coord', '__weakref__') 

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

218 self.op = op 

219 self.lvalue = lvalue 

220 self.rvalue = rvalue 

221 self.coord = coord 

222 

223 def children(self): 

224 nodelist = [] 

225 if self.lvalue is not None: nodelist.append(("lvalue", self.lvalue)) 

226 if self.rvalue is not None: nodelist.append(("rvalue", self.rvalue)) 

227 return tuple(nodelist) 

228 

229 def __iter__(self): 

230 if self.lvalue is not None: 

231 yield self.lvalue 

232 if self.rvalue is not None: 

233 yield self.rvalue 

234 

235 attr_names = ('op', ) 

236 

237class Alignas(Node): 

238 __slots__ = ('alignment', 'coord', '__weakref__') 

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

240 self.alignment = alignment 

241 self.coord = coord 

242 

243 def children(self): 

244 nodelist = [] 

245 if self.alignment is not None: nodelist.append(("alignment", self.alignment)) 

246 return tuple(nodelist) 

247 

248 def __iter__(self): 

249 if self.alignment is not None: 

250 yield self.alignment 

251 

252 attr_names = () 

253 

254class BinaryOp(Node): 

255 __slots__ = ('op', 'left', 'right', 'coord', '__weakref__') 

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

257 self.op = op 

258 self.left = left 

259 self.right = right 

260 self.coord = coord 

261 

262 def children(self): 

263 nodelist = [] 

264 if self.left is not None: nodelist.append(("left", self.left)) 

265 if self.right is not None: nodelist.append(("right", self.right)) 

266 return tuple(nodelist) 

267 

268 def __iter__(self): 

269 if self.left is not None: 

270 yield self.left 

271 if self.right is not None: 

272 yield self.right 

273 

274 attr_names = ('op', ) 

275 

276class Break(Node): 

277 __slots__ = ('coord', '__weakref__') 

278 def __init__(self, coord=None): 

279 self.coord = coord 

280 

281 def children(self): 

282 return () 

283 

284 def __iter__(self): 

285 return 

286 yield 

287 

288 attr_names = () 

289 

290class Case(Node): 

291 __slots__ = ('expr', 'stmts', 'coord', '__weakref__') 

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

293 self.expr = expr 

294 self.stmts = stmts 

295 self.coord = coord 

296 

297 def children(self): 

298 nodelist = [] 

299 if self.expr is not None: nodelist.append(("expr", self.expr)) 

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

301 nodelist.append(("stmts[%d]" % i, child)) 

302 return tuple(nodelist) 

303 

304 def __iter__(self): 

305 if self.expr is not None: 

306 yield self.expr 

307 for child in (self.stmts or []): 

308 yield child 

309 

310 attr_names = () 

311 

312class Cast(Node): 

313 __slots__ = ('to_type', 'expr', 'coord', '__weakref__') 

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

315 self.to_type = to_type 

316 self.expr = expr 

317 self.coord = coord 

318 

319 def children(self): 

320 nodelist = [] 

321 if self.to_type is not None: nodelist.append(("to_type", self.to_type)) 

322 if self.expr is not None: nodelist.append(("expr", self.expr)) 

323 return tuple(nodelist) 

324 

325 def __iter__(self): 

326 if self.to_type is not None: 

327 yield self.to_type 

328 if self.expr is not None: 

329 yield self.expr 

330 

331 attr_names = () 

332 

333class Compound(Node): 

334 __slots__ = ('block_items', 'coord', '__weakref__') 

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

336 self.block_items = block_items 

337 self.coord = coord 

338 

339 def children(self): 

340 nodelist = [] 

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

342 nodelist.append(("block_items[%d]" % i, child)) 

343 return tuple(nodelist) 

344 

345 def __iter__(self): 

346 for child in (self.block_items or []): 

347 yield child 

348 

349 attr_names = () 

350 

351class CompoundLiteral(Node): 

352 __slots__ = ('type', 'init', 'coord', '__weakref__') 

353 def __init__(self, type, init, coord=None): 

354 self.type = type 

355 self.init = init 

356 self.coord = coord 

357 

358 def children(self): 

359 nodelist = [] 

360 if self.type is not None: nodelist.append(("type", self.type)) 

361 if self.init is not None: nodelist.append(("init", self.init)) 

362 return tuple(nodelist) 

363 

364 def __iter__(self): 

365 if self.type is not None: 

366 yield self.type 

367 if self.init is not None: 

368 yield self.init 

369 

370 attr_names = () 

371 

372class Constant(Node): 

373 __slots__ = ('type', 'value', 'coord', '__weakref__') 

374 def __init__(self, type, value, coord=None): 

375 self.type = type 

376 self.value = value 

377 self.coord = coord 

378 

379 def children(self): 

380 nodelist = [] 

381 return tuple(nodelist) 

382 

383 def __iter__(self): 

384 return 

385 yield 

386 

387 attr_names = ('type', 'value', ) 

388 

389class Continue(Node): 

390 __slots__ = ('coord', '__weakref__') 

391 def __init__(self, coord=None): 

392 self.coord = coord 

393 

394 def children(self): 

395 return () 

396 

397 def __iter__(self): 

398 return 

399 yield 

400 

401 attr_names = () 

402 

403class Decl(Node): 

404 __slots__ = ('name', 'quals', 'align', 'storage', 'funcspec', 'type', 'init', 'bitsize', 'coord', '__weakref__') 

405 def __init__(self, name, quals, align, storage, funcspec, type, init, bitsize, coord=None): 

406 self.name = name 

407 self.quals = quals 

408 self.align = align 

409 self.storage = storage 

410 self.funcspec = funcspec 

411 self.type = type 

412 self.init = init 

413 self.bitsize = bitsize 

414 self.coord = coord 

415 

416 def children(self): 

417 nodelist = [] 

418 if self.type is not None: nodelist.append(("type", self.type)) 

419 if self.init is not None: nodelist.append(("init", self.init)) 

420 if self.bitsize is not None: nodelist.append(("bitsize", self.bitsize)) 

421 return tuple(nodelist) 

422 

423 def __iter__(self): 

424 if self.type is not None: 

425 yield self.type 

426 if self.init is not None: 

427 yield self.init 

428 if self.bitsize is not None: 

429 yield self.bitsize 

430 

431 attr_names = ('name', 'quals', 'align', 'storage', 'funcspec', ) 

432 

433class DeclList(Node): 

434 __slots__ = ('decls', 'coord', '__weakref__') 

435 def __init__(self, decls, coord=None): 

436 self.decls = decls 

437 self.coord = coord 

438 

439 def children(self): 

440 nodelist = [] 

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

442 nodelist.append(("decls[%d]" % i, child)) 

443 return tuple(nodelist) 

444 

445 def __iter__(self): 

446 for child in (self.decls or []): 

447 yield child 

448 

449 attr_names = () 

450 

451class Default(Node): 

452 __slots__ = ('stmts', 'coord', '__weakref__') 

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

454 self.stmts = stmts 

455 self.coord = coord 

456 

457 def children(self): 

458 nodelist = [] 

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

460 nodelist.append(("stmts[%d]" % i, child)) 

461 return tuple(nodelist) 

462 

463 def __iter__(self): 

464 for child in (self.stmts or []): 

465 yield child 

466 

467 attr_names = () 

468 

469class DoWhile(Node): 

470 __slots__ = ('cond', 'stmt', 'coord', '__weakref__') 

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

472 self.cond = cond 

473 self.stmt = stmt 

474 self.coord = coord 

475 

476 def children(self): 

477 nodelist = [] 

478 if self.cond is not None: nodelist.append(("cond", self.cond)) 

479 if self.stmt is not None: nodelist.append(("stmt", self.stmt)) 

480 return tuple(nodelist) 

481 

482 def __iter__(self): 

483 if self.cond is not None: 

484 yield self.cond 

485 if self.stmt is not None: 

486 yield self.stmt 

487 

488 attr_names = () 

489 

490class EllipsisParam(Node): 

491 __slots__ = ('coord', '__weakref__') 

492 def __init__(self, coord=None): 

493 self.coord = coord 

494 

495 def children(self): 

496 return () 

497 

498 def __iter__(self): 

499 return 

500 yield 

501 

502 attr_names = () 

503 

504class EmptyStatement(Node): 

505 __slots__ = ('coord', '__weakref__') 

506 def __init__(self, coord=None): 

507 self.coord = coord 

508 

509 def children(self): 

510 return () 

511 

512 def __iter__(self): 

513 return 

514 yield 

515 

516 attr_names = () 

517 

518class Enum(Node): 

519 __slots__ = ('name', 'values', 'coord', '__weakref__') 

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

521 self.name = name 

522 self.values = values 

523 self.coord = coord 

524 

525 def children(self): 

526 nodelist = [] 

527 if self.values is not None: nodelist.append(("values", self.values)) 

528 return tuple(nodelist) 

529 

530 def __iter__(self): 

531 if self.values is not None: 

532 yield self.values 

533 

534 attr_names = ('name', ) 

535 

536class Enumerator(Node): 

537 __slots__ = ('name', 'value', 'coord', '__weakref__') 

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

539 self.name = name 

540 self.value = value 

541 self.coord = coord 

542 

543 def children(self): 

544 nodelist = [] 

545 if self.value is not None: nodelist.append(("value", self.value)) 

546 return tuple(nodelist) 

547 

548 def __iter__(self): 

549 if self.value is not None: 

550 yield self.value 

551 

552 attr_names = ('name', ) 

553 

554class EnumeratorList(Node): 

555 __slots__ = ('enumerators', 'coord', '__weakref__') 

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

557 self.enumerators = enumerators 

558 self.coord = coord 

559 

560 def children(self): 

561 nodelist = [] 

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

563 nodelist.append(("enumerators[%d]" % i, child)) 

564 return tuple(nodelist) 

565 

566 def __iter__(self): 

567 for child in (self.enumerators or []): 

568 yield child 

569 

570 attr_names = () 

571 

572class ExprList(Node): 

573 __slots__ = ('exprs', 'coord', '__weakref__') 

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

575 self.exprs = exprs 

576 self.coord = coord 

577 

578 def children(self): 

579 nodelist = [] 

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

581 nodelist.append(("exprs[%d]" % i, child)) 

582 return tuple(nodelist) 

583 

584 def __iter__(self): 

585 for child in (self.exprs or []): 

586 yield child 

587 

588 attr_names = () 

589 

590class FileAST(Node): 

591 __slots__ = ('ext', 'coord', '__weakref__') 

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

593 self.ext = ext 

594 self.coord = coord 

595 

596 def children(self): 

597 nodelist = [] 

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

599 nodelist.append(("ext[%d]" % i, child)) 

600 return tuple(nodelist) 

601 

602 def __iter__(self): 

603 for child in (self.ext or []): 

604 yield child 

605 

606 attr_names = () 

607 

608class For(Node): 

609 __slots__ = ('init', 'cond', 'next', 'stmt', 'coord', '__weakref__') 

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

611 self.init = init 

612 self.cond = cond 

613 self.next = next 

614 self.stmt = stmt 

615 self.coord = coord 

616 

617 def children(self): 

618 nodelist = [] 

619 if self.init is not None: nodelist.append(("init", self.init)) 

620 if self.cond is not None: nodelist.append(("cond", self.cond)) 

621 if self.next is not None: nodelist.append(("next", self.next)) 

622 if self.stmt is not None: nodelist.append(("stmt", self.stmt)) 

623 return tuple(nodelist) 

624 

625 def __iter__(self): 

626 if self.init is not None: 

627 yield self.init 

628 if self.cond is not None: 

629 yield self.cond 

630 if self.next is not None: 

631 yield self.next 

632 if self.stmt is not None: 

633 yield self.stmt 

634 

635 attr_names = () 

636 

637class FuncCall(Node): 

638 __slots__ = ('name', 'args', 'coord', '__weakref__') 

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

640 self.name = name 

641 self.args = args 

642 self.coord = coord 

643 

644 def children(self): 

645 nodelist = [] 

646 if self.name is not None: nodelist.append(("name", self.name)) 

647 if self.args is not None: nodelist.append(("args", self.args)) 

648 return tuple(nodelist) 

649 

650 def __iter__(self): 

651 if self.name is not None: 

652 yield self.name 

653 if self.args is not None: 

654 yield self.args 

655 

656 attr_names = () 

657 

658class FuncDecl(Node): 

659 __slots__ = ('args', 'type', 'coord', '__weakref__') 

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

661 self.args = args 

662 self.type = type 

663 self.coord = coord 

664 

665 def children(self): 

666 nodelist = [] 

667 if self.args is not None: nodelist.append(("args", self.args)) 

668 if self.type is not None: nodelist.append(("type", self.type)) 

669 return tuple(nodelist) 

670 

671 def __iter__(self): 

672 if self.args is not None: 

673 yield self.args 

674 if self.type is not None: 

675 yield self.type 

676 

677 attr_names = () 

678 

679class FuncDef(Node): 

680 __slots__ = ('decl', 'param_decls', 'body', 'coord', '__weakref__') 

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

682 self.decl = decl 

683 self.param_decls = param_decls 

684 self.body = body 

685 self.coord = coord 

686 

687 def children(self): 

688 nodelist = [] 

689 if self.decl is not None: nodelist.append(("decl", self.decl)) 

690 if self.body is not None: nodelist.append(("body", self.body)) 

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

692 nodelist.append(("param_decls[%d]" % i, child)) 

693 return tuple(nodelist) 

694 

695 def __iter__(self): 

696 if self.decl is not None: 

697 yield self.decl 

698 if self.body is not None: 

699 yield self.body 

700 for child in (self.param_decls or []): 

701 yield child 

702 

703 attr_names = () 

704 

705class Goto(Node): 

706 __slots__ = ('name', 'coord', '__weakref__') 

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

708 self.name = name 

709 self.coord = coord 

710 

711 def children(self): 

712 nodelist = [] 

713 return tuple(nodelist) 

714 

715 def __iter__(self): 

716 return 

717 yield 

718 

719 attr_names = ('name', ) 

720 

721class ID(Node): 

722 __slots__ = ('name', 'coord', '__weakref__') 

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

724 self.name = name 

725 self.coord = coord 

726 

727 def children(self): 

728 nodelist = [] 

729 return tuple(nodelist) 

730 

731 def __iter__(self): 

732 return 

733 yield 

734 

735 attr_names = ('name', ) 

736 

737class IdentifierType(Node): 

738 __slots__ = ('names', 'coord', '__weakref__') 

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

740 self.names = names 

741 self.coord = coord 

742 

743 def children(self): 

744 nodelist = [] 

745 return tuple(nodelist) 

746 

747 def __iter__(self): 

748 return 

749 yield 

750 

751 attr_names = ('names', ) 

752 

753class If(Node): 

754 __slots__ = ('cond', 'iftrue', 'iffalse', 'coord', '__weakref__') 

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

756 self.cond = cond 

757 self.iftrue = iftrue 

758 self.iffalse = iffalse 

759 self.coord = coord 

760 

761 def children(self): 

762 nodelist = [] 

763 if self.cond is not None: nodelist.append(("cond", self.cond)) 

764 if self.iftrue is not None: nodelist.append(("iftrue", self.iftrue)) 

765 if self.iffalse is not None: nodelist.append(("iffalse", self.iffalse)) 

766 return tuple(nodelist) 

767 

768 def __iter__(self): 

769 if self.cond is not None: 

770 yield self.cond 

771 if self.iftrue is not None: 

772 yield self.iftrue 

773 if self.iffalse is not None: 

774 yield self.iffalse 

775 

776 attr_names = () 

777 

778class InitList(Node): 

779 __slots__ = ('exprs', 'coord', '__weakref__') 

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

781 self.exprs = exprs 

782 self.coord = coord 

783 

784 def children(self): 

785 nodelist = [] 

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

787 nodelist.append(("exprs[%d]" % i, child)) 

788 return tuple(nodelist) 

789 

790 def __iter__(self): 

791 for child in (self.exprs or []): 

792 yield child 

793 

794 attr_names = () 

795 

796class Label(Node): 

797 __slots__ = ('name', 'stmt', 'coord', '__weakref__') 

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

799 self.name = name 

800 self.stmt = stmt 

801 self.coord = coord 

802 

803 def children(self): 

804 nodelist = [] 

805 if self.stmt is not None: nodelist.append(("stmt", self.stmt)) 

806 return tuple(nodelist) 

807 

808 def __iter__(self): 

809 if self.stmt is not None: 

810 yield self.stmt 

811 

812 attr_names = ('name', ) 

813 

814class NamedInitializer(Node): 

815 __slots__ = ('name', 'expr', 'coord', '__weakref__') 

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

817 self.name = name 

818 self.expr = expr 

819 self.coord = coord 

820 

821 def children(self): 

822 nodelist = [] 

823 if self.expr is not None: nodelist.append(("expr", self.expr)) 

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

825 nodelist.append(("name[%d]" % i, child)) 

826 return tuple(nodelist) 

827 

828 def __iter__(self): 

829 if self.expr is not None: 

830 yield self.expr 

831 for child in (self.name or []): 

832 yield child 

833 

834 attr_names = () 

835 

836class ParamList(Node): 

837 __slots__ = ('params', 'coord', '__weakref__') 

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

839 self.params = params 

840 self.coord = coord 

841 

842 def children(self): 

843 nodelist = [] 

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

845 nodelist.append(("params[%d]" % i, child)) 

846 return tuple(nodelist) 

847 

848 def __iter__(self): 

849 for child in (self.params or []): 

850 yield child 

851 

852 attr_names = () 

853 

854class PtrDecl(Node): 

855 __slots__ = ('quals', 'type', 'coord', '__weakref__') 

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

857 self.quals = quals 

858 self.type = type 

859 self.coord = coord 

860 

861 def children(self): 

862 nodelist = [] 

863 if self.type is not None: nodelist.append(("type", self.type)) 

864 return tuple(nodelist) 

865 

866 def __iter__(self): 

867 if self.type is not None: 

868 yield self.type 

869 

870 attr_names = ('quals', ) 

871 

872class Return(Node): 

873 __slots__ = ('expr', 'coord', '__weakref__') 

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

875 self.expr = expr 

876 self.coord = coord 

877 

878 def children(self): 

879 nodelist = [] 

880 if self.expr is not None: nodelist.append(("expr", self.expr)) 

881 return tuple(nodelist) 

882 

883 def __iter__(self): 

884 if self.expr is not None: 

885 yield self.expr 

886 

887 attr_names = () 

888 

889class StaticAssert(Node): 

890 __slots__ = ('cond', 'message', 'coord', '__weakref__') 

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

892 self.cond = cond 

893 self.message = message 

894 self.coord = coord 

895 

896 def children(self): 

897 nodelist = [] 

898 if self.cond is not None: nodelist.append(("cond", self.cond)) 

899 if self.message is not None: nodelist.append(("message", self.message)) 

900 return tuple(nodelist) 

901 

902 def __iter__(self): 

903 if self.cond is not None: 

904 yield self.cond 

905 if self.message is not None: 

906 yield self.message 

907 

908 attr_names = () 

909 

910class Struct(Node): 

911 __slots__ = ('name', 'decls', 'coord', '__weakref__') 

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

913 self.name = name 

914 self.decls = decls 

915 self.coord = coord 

916 

917 def children(self): 

918 nodelist = [] 

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

920 nodelist.append(("decls[%d]" % i, child)) 

921 return tuple(nodelist) 

922 

923 def __iter__(self): 

924 for child in (self.decls or []): 

925 yield child 

926 

927 attr_names = ('name', ) 

928 

929class StructRef(Node): 

930 __slots__ = ('name', 'type', 'field', 'coord', '__weakref__') 

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

932 self.name = name 

933 self.type = type 

934 self.field = field 

935 self.coord = coord 

936 

937 def children(self): 

938 nodelist = [] 

939 if self.name is not None: nodelist.append(("name", self.name)) 

940 if self.field is not None: nodelist.append(("field", self.field)) 

941 return tuple(nodelist) 

942 

943 def __iter__(self): 

944 if self.name is not None: 

945 yield self.name 

946 if self.field is not None: 

947 yield self.field 

948 

949 attr_names = ('type', ) 

950 

951class Switch(Node): 

952 __slots__ = ('cond', 'stmt', 'coord', '__weakref__') 

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

954 self.cond = cond 

955 self.stmt = stmt 

956 self.coord = coord 

957 

958 def children(self): 

959 nodelist = [] 

960 if self.cond is not None: nodelist.append(("cond", self.cond)) 

961 if self.stmt is not None: nodelist.append(("stmt", self.stmt)) 

962 return tuple(nodelist) 

963 

964 def __iter__(self): 

965 if self.cond is not None: 

966 yield self.cond 

967 if self.stmt is not None: 

968 yield self.stmt 

969 

970 attr_names = () 

971 

972class TernaryOp(Node): 

973 __slots__ = ('cond', 'iftrue', 'iffalse', 'coord', '__weakref__') 

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

975 self.cond = cond 

976 self.iftrue = iftrue 

977 self.iffalse = iffalse 

978 self.coord = coord 

979 

980 def children(self): 

981 nodelist = [] 

982 if self.cond is not None: nodelist.append(("cond", self.cond)) 

983 if self.iftrue is not None: nodelist.append(("iftrue", self.iftrue)) 

984 if self.iffalse is not None: nodelist.append(("iffalse", self.iffalse)) 

985 return tuple(nodelist) 

986 

987 def __iter__(self): 

988 if self.cond is not None: 

989 yield self.cond 

990 if self.iftrue is not None: 

991 yield self.iftrue 

992 if self.iffalse is not None: 

993 yield self.iffalse 

994 

995 attr_names = () 

996 

997class TypeDecl(Node): 

998 __slots__ = ('declname', 'quals', 'align', 'type', 'coord', '__weakref__') 

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

1000 self.declname = declname 

1001 self.quals = quals 

1002 self.align = align 

1003 self.type = type 

1004 self.coord = coord 

1005 

1006 def children(self): 

1007 nodelist = [] 

1008 if self.type is not None: nodelist.append(("type", self.type)) 

1009 return tuple(nodelist) 

1010 

1011 def __iter__(self): 

1012 if self.type is not None: 

1013 yield self.type 

1014 

1015 attr_names = ('declname', 'quals', 'align', ) 

1016 

1017class Typedef(Node): 

1018 __slots__ = ('name', 'quals', 'storage', 'type', 'coord', '__weakref__') 

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

1020 self.name = name 

1021 self.quals = quals 

1022 self.storage = storage 

1023 self.type = type 

1024 self.coord = coord 

1025 

1026 def children(self): 

1027 nodelist = [] 

1028 if self.type is not None: nodelist.append(("type", self.type)) 

1029 return tuple(nodelist) 

1030 

1031 def __iter__(self): 

1032 if self.type is not None: 

1033 yield self.type 

1034 

1035 attr_names = ('name', 'quals', 'storage', ) 

1036 

1037class Typename(Node): 

1038 __slots__ = ('name', 'quals', 'align', 'type', 'coord', '__weakref__') 

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

1040 self.name = name 

1041 self.quals = quals 

1042 self.align = align 

1043 self.type = type 

1044 self.coord = coord 

1045 

1046 def children(self): 

1047 nodelist = [] 

1048 if self.type is not None: nodelist.append(("type", self.type)) 

1049 return tuple(nodelist) 

1050 

1051 def __iter__(self): 

1052 if self.type is not None: 

1053 yield self.type 

1054 

1055 attr_names = ('name', 'quals', 'align', ) 

1056 

1057class UnaryOp(Node): 

1058 __slots__ = ('op', 'expr', 'coord', '__weakref__') 

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

1060 self.op = op 

1061 self.expr = expr 

1062 self.coord = coord 

1063 

1064 def children(self): 

1065 nodelist = [] 

1066 if self.expr is not None: nodelist.append(("expr", self.expr)) 

1067 return tuple(nodelist) 

1068 

1069 def __iter__(self): 

1070 if self.expr is not None: 

1071 yield self.expr 

1072 

1073 attr_names = ('op', ) 

1074 

1075class Union(Node): 

1076 __slots__ = ('name', 'decls', 'coord', '__weakref__') 

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

1078 self.name = name 

1079 self.decls = decls 

1080 self.coord = coord 

1081 

1082 def children(self): 

1083 nodelist = [] 

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

1085 nodelist.append(("decls[%d]" % i, child)) 

1086 return tuple(nodelist) 

1087 

1088 def __iter__(self): 

1089 for child in (self.decls or []): 

1090 yield child 

1091 

1092 attr_names = ('name', ) 

1093 

1094class While(Node): 

1095 __slots__ = ('cond', 'stmt', 'coord', '__weakref__') 

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

1097 self.cond = cond 

1098 self.stmt = stmt 

1099 self.coord = coord 

1100 

1101 def children(self): 

1102 nodelist = [] 

1103 if self.cond is not None: nodelist.append(("cond", self.cond)) 

1104 if self.stmt is not None: nodelist.append(("stmt", self.stmt)) 

1105 return tuple(nodelist) 

1106 

1107 def __iter__(self): 

1108 if self.cond is not None: 

1109 yield self.cond 

1110 if self.stmt is not None: 

1111 yield self.stmt 

1112 

1113 attr_names = () 

1114 

1115class Pragma(Node): 

1116 __slots__ = ('string', 'coord', '__weakref__') 

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

1118 self.string = string 

1119 self.coord = coord 

1120 

1121 def children(self): 

1122 nodelist = [] 

1123 return tuple(nodelist) 

1124 

1125 def __iter__(self): 

1126 return 

1127 yield 

1128 

1129 attr_names = ('string', ) 

1130