1 #!/usr/bin/env python 2 3 """ 4 Simplify AST structures for easier type propagation and analysis. 5 6 Copyright (C) 2006 Paul Boddie <paul@boddie.org.uk> 7 8 This software is free software; you can redistribute it and/or 9 modify it under the terms of the GNU General Public License as 10 published by the Free Software Foundation; either version 2 of 11 the License, or (at your option) any later version. 12 13 This software is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public 19 License along with this library; see the file LICENCE.txt 20 If not, write to the Free Software Foundation, Inc., 21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 22 """ 23 24 from compiler.visitor import ASTVisitor 25 import compiler.ast 26 from simplified import * 27 28 class Simplifier(ASTVisitor): 29 30 """ 31 A simplifying visitor for AST nodes. 32 33 Covered: And, AssAttr, AssList, AssName, AssTuple, Assign, AugAssign, Break, 34 CallFunc, Class, Const, Continue, Dict, Discard, For, From, 35 Function, Getattr, Global, If, Import, Invert, Keyword, Lambda, 36 List, Module, Name, Not, Or, Pass, Raise, Return, Stmt, TryExcept, 37 TryFinally, Tuple, While, UnaryAdd, UnarySub. 38 39 Missing: Add, Assert, Backquote, Bitand, Bitor, Bitxor, Compare, Decorators, 40 Div, Ellipsis, Exec, FloorDiv, LeftShift, ListComp, ListCompFor, 41 ListCompIf, Mod, Mul, Power, Print, Printnl, RightShift, 42 Slice, Sliceobj, Sub, Subscript, Yield. 43 """ 44 45 def __init__(self): 46 ASTVisitor.__init__(self) 47 self.result = None # The resulting tree. 48 self.subprograms = [] # Subprograms outside the tree. 49 self.current_subprograms = [] # Current subprograms being processed. 50 51 # Generic visitor methods. 52 53 def default(self, node, *args): 54 raise ValueError, node.__class__ 55 56 def dispatch(self, node, *args): 57 return ASTVisitor.dispatch(self, node, *args) 58 59 def dispatches(self, nodes, *args): 60 results = [] 61 for node in nodes: 62 results.append(self.dispatch(node, *args)) 63 return results 64 65 def dispatch_or_none(self, node, *args): 66 if node is not None: 67 return self.dispatch(node, *args) 68 else: 69 return LoadName(name="None") 70 71 # Placeholder or deletion transformations. 72 73 def visitStmt(self, stmt): 74 return self.dispatches(stmt.nodes) 75 76 def visitPass(self, pass_): 77 return Pass(pass_) 78 79 def visitDiscard(self, discard): 80 return self.dispatch(discard.expr) 81 82 # Relatively trivial transformations. 83 84 def visitModule(self, module): 85 self.result = Module(module) 86 self.result.code = self.dispatch(module.node) 87 return self.result 88 89 def visitClass(self, class_): 90 result = Class(class_, name=class_.name, bases=class_.bases) 91 result.code = self.dispatch(class_.code) 92 return result 93 94 def visitGetattr(self, getattr): 95 result = LoadAttr(getattr, name=getattr.attrname) 96 result.expr = self.dispatch(getattr.expr) 97 return result 98 99 def visitKeyword(self, keyword): 100 result = Keyword(keyword, name=keyword.name) 101 result.expr = self.dispatch(keyword.expr) 102 return result 103 104 def visitGlobal(self, global_): 105 result = Global(global_, names=global_.names) 106 return result 107 108 def visitImport(self, import_): 109 result = Assign(import_) 110 code = [] 111 for path, alias in import_.names: 112 importer = Import(name=path) 113 top = alias or path.split(".")[0] 114 code.append(StoreName(expr=importer, name=top)) 115 result.code = code 116 return result 117 118 def visitFrom(self, from_): 119 result = Assign(from_) 120 code = [] 121 code.append(StoreTemp(expr=Import(name=from_.modname))) 122 for name, alias in from_.names: 123 code.append(StoreName(expr=LoadAttr(expr=LoadTemp(), name=name), name=(alias or name))) 124 result.code = code 125 return result 126 127 def visitName(self, name): 128 result = LoadName(name, name=name.name) 129 return result 130 131 def visitConst(self, const): 132 result = LoadConst(const, value=const.value) 133 return result 134 135 def visitReturn(self, return_): 136 result = Return(return_) 137 result.expr = self.dispatch(return_.value) 138 return result 139 140 def visitBreak(self, break_): 141 result = Return(break_) 142 return result 143 144 def visitContinue(self, continue_): 145 result = Invoke(continue_, same_frame=1, produces_result=0, star=None, dstar=None, args=[]) 146 result.expr = LoadRef(ref=self.current_subprograms[-1]) 147 return result 148 149 def visitRaise(self, raise_): 150 result = Raise(raise_, expr=self.dispatch(raise_.expr1), traceback=None) 151 if raise_.expr2 is not None: 152 result.args = [self.dispatch(raise_.expr2)] 153 if raise_.expr3 is not None: 154 result.traceback = self.dispatch(raise_.expr3) 155 return result 156 157 def visitIf(self, if_): 158 result = If(if_, else_=[]) 159 tests = [] 160 for compare, stmt in if_.tests: 161 # Produce something like... 162 # expr.__true__() ? body 163 test = Conditional(else_=[], test=Invoke( 164 expr=LoadAttr(expr=self.dispatch(compare), name="__true__"), 165 params=[], star=None, dstar=None)) 166 test.body = self.dispatch(stmt) 167 tests.append(test) 168 result.tests = tests 169 if if_.else_ is not None: 170 result.else_ = self.dispatch(if_.else_) 171 return result 172 173 def _visitBuiltin(self, builtin, name): 174 result = Invoke(builtin, expr=LoadName(name=name)) 175 result.args = self.dispatches(builtin.nodes) 176 return result 177 178 def visitTuple(self, tuple): 179 return self._visitBuiltin(tuple, "Tuple") 180 181 def visitList(self, list): 182 return self._visitBuiltin(list, "List") 183 184 def visitDict(self, dict): 185 result = Invoke(dict, expr=LoadName(name="Dict")) 186 args = [] 187 for key, value in dict.items: 188 tuple = Invoke(expr=LoadName(name="Tuple"), star=None, dstar=None) 189 tuple.args = [self.dispatch(key), self.dispatch(value)] 190 args.append(tuple) 191 result.args = args 192 return result 193 194 # Logical operators. 195 196 def visitAnd(self, and_): 197 198 # Make a subprogram for the expression and record it outside the main tree. 199 200 subprogram = Subprogram(name=hex(id(and_)), acquire_locals=1, returns_value=1, params=[], star=None, dstar=None) 201 self.current_subprograms.append(subprogram) 202 203 nodes = [] 204 last = and_.nodes[-1] 205 for node in and_.nodes: 206 expr = self.dispatch(node) 207 if node is not last: 208 invocation = Not(expr=Invoke(expr=LoadAttr(expr=StoreTemp(expr=expr), name="__true__"), 209 params=[], star=None, dstar=None)) 210 nodes.append(Conditional(test=invocation, body=[Return(expr=LoadTemp())])) 211 nodes.append(ReleaseTemp()) 212 else: 213 nodes.append(Return(expr=expr)) 214 subprogram.code = nodes 215 216 self.current_subprograms.pop() 217 self.subprograms.append(subprogram) 218 219 # Make an invocation of the subprogram. 220 221 result = Invoke(and_, same_frame=1, star=None, dstar=None, args=[]) 222 result.expr = LoadRef(ref=subprogram) 223 return result 224 225 def visitOr(self, or_): 226 227 # Make a subprogram for the expression and record it outside the main tree. 228 229 subprogram = Subprogram(name=hex(id(or_)), acquire_locals=1, returns_value=1, params=[], star=None, dstar=None) 230 self.current_subprograms.append(subprogram) 231 232 nodes = [] 233 last = or_.nodes[-1] 234 for node in or_.nodes: 235 expr = self.dispatch(node) 236 if node is not last: 237 invocation = Invoke(expr=LoadAttr(expr=StoreTemp(expr=expr), name="__true__"), 238 params=[], star=None, dstar=None) 239 nodes.append(Conditional(test=invocation, body=[Return(expr=LoadTemp())])) 240 nodes.append(ReleaseTemp()) 241 else: 242 nodes.append(Return(expr=expr)) 243 subprogram.code = nodes 244 245 self.current_subprograms.pop() 246 self.subprograms.append(subprogram) 247 248 # Make an invocation of the subprogram. 249 250 result = Invoke(or_, same_frame=1, star=None, dstar=None, args=[]) 251 result.expr = LoadRef(ref=subprogram) 252 return result 253 254 def visitNot(self, not_): 255 result = Not(not_, expr=Invoke(expr=LoadAttr(expr=self.dispatch(not_.expr), name="__true__"), 256 params=[], star=None, dstar=None)) 257 return result 258 259 # Operators. 260 261 def visitUnaryAdd(self, unaryadd): 262 return Invoke(unaryadd, expr=LoadAttr(expr=self.dispatch(unaryadd.expr), name="__pos__"), args=[]) 263 264 def visitUnarySub(self, unarysub): 265 return Invoke(unarysub, expr=LoadAttr(expr=self.dispatch(unarysub.expr), name="__neg__"), args=[]) 266 267 def visitInvert(self, invert): 268 return Invoke(invert, expr=LoadAttr(expr=self.dispatch(invert.expr), name="__invert__"), args=[]) 269 270 # Assignments. 271 272 augassign_methods = { 273 "+=" : "__iadd__", "-=" : "__isub__", "*=" : "__imul__", "/=" : "__idiv__", 274 "%=" : "__imod__", "**=" : "__ipow__", "<<=" : "__ilshift__", ">>=" : "__irshift__", 275 "&=" : "__iand__", "^=" : "__ixor__", "|=" : "__ior__" 276 } 277 278 def visitAugAssign(self, augassign): 279 result = Assign(augassign) 280 expr = self.dispatch(augassign.expr) 281 282 # Simple augmented assignment: name += expr 283 284 if isinstance(augassign.node, compiler.ast.Name): 285 name = augassign.node 286 node = self.dispatch(name) 287 get_incremented = StoreTemp( 288 expr=Invoke(expr=LoadAttr(expr=node, name=self.augassign_methods[augassign.op]), args=[expr]) 289 ) 290 store = StoreName(expr=LoadTemp(), name=name.name) 291 result.code = [get_incremented, store, ReleaseTemp()] 292 293 # Complicated augmented assignment: lvalue.attr += expr 294 295 elif isinstance(augassign.node, compiler.ast.Getattr): 296 297 # <lvalue> -> setattr(<lvalue>, getattr(<lvalue>, "attr").__xxx__(expr)) 298 299 getattr = augassign.node 300 store_expr = StoreTemp(index="expr", expr=self.dispatch(getattr.expr)) 301 node_attr = LoadAttr(expr=LoadTemp(index="expr"), name=getattr.attrname) 302 get_incremented = StoreTemp( 303 expr=Invoke(expr=LoadAttr(expr=node_attr, name=self.augassign_methods[augassign.op]), args=[expr]) 304 ) 305 store = StoreAttr(expr=LoadTemp(), lvalue=LoadTemp(index="expr"), name=getattr.attrname) 306 result.code = [store_expr, get_incremented, store, ReleaseTemp(index="expr"), ReleaseTemp()] 307 308 # Complicated augassign using slices: lvalue[lower:upper] += expr 309 310 elif isinstance(augassign.node, compiler.ast.Slice): 311 312 # <lvalue>, <lower>, <upper> -> <lvalue>.__setslice__(<lower>, <upper>, <lvalue>.__getslice__(<lower>, <upper>).__xxx__(expr)) 313 314 slice = augassign.node 315 store_expr = StoreTemp(index="expr", expr=self.dispatch(slice.expr)) 316 store_lower = StoreTemp(index="lower", expr=self.dispatch_or_none(slice.lower)) 317 store_upper = StoreTemp(index="upper", expr=self.dispatch_or_none(slice.upper)) 318 node_slice = self._visitSlice(slice, LoadTemp(index="expr"), LoadTemp(index="lower"), LoadTemp(index="upper"), "OP_APPLY") 319 get_incremented = StoreTemp( 320 expr=Invoke(expr=LoadAttr(expr=node_slice, name=self.augassign_methods[augassign.op]), args=[expr]) 321 ) 322 store = self._visitSlice(slice, LoadTemp(index="expr"), LoadTemp(index="lower"), LoadTemp(index="upper"), "OP_ASSIGN", LoadTemp()) 323 result.code = [store_expr, store_lower, store_upper, get_incremented, store, 324 ReleaseTemp(index="expr"), ReleaseTemp(index="lower"), ReleaseTemp(index="upper"), ReleaseTemp()] 325 326 # Complicated augassign using subscripts: lvalue[subs] += expr 327 328 elif isinstance(augassign.node, compiler.ast.Subscript): 329 330 # <lvalue>, <subs> -> <lvalue>.__setitem__(<subs>, <lvalue>.__getitem__(<subs>).__xxx__(expr)) 331 332 subscript = augassign.node 333 store_expr = StoreTemp(index="expr", expr=self.dispatch(subscript.expr)) 334 subs = self._visitSubscriptSubs(subscript.subs) 335 store_subs = StoreTemp(index="subs", expr=subs) 336 node_subscript = self._visitSubscript(subscript, LoadTemp(index="expr"), LoadTemp(index="subs"), "OP_APPLY") 337 get_incremented = StoreTemp( 338 expr=Invoke(expr=LoadAttr(expr=node_subscript, name=self.augassign_methods[augassign.op]), args=[expr]) 339 ) 340 store = self._visitSubscript(subscript, LoadTemp(index="expr"), LoadTemp(index="subs"), "OP_ASSIGN", LoadTemp()) 341 result.code = [store_expr, store_subs, get_incremented, store, ReleaseTemp(index="expr"), ReleaseTemp(index="subs"), ReleaseTemp()] 342 343 else: 344 raise NotImplementedError, augassign.node.__class__ 345 346 return result 347 348 def visitAssign(self, assign): 349 result = Assign(assign) 350 store = StoreTemp(expr=self.dispatch(assign.expr)) 351 release = ReleaseTemp() 352 result.code = [store] + self.dispatches(assign.nodes, 0) + [release] 353 return result 354 355 def visitAssList(self, asslist, in_sequence=0): 356 if not in_sequence: 357 expr = LoadTemp() 358 else: 359 expr = Invoke(expr=LoadAttr(expr=LoadTemp(), name="next")) 360 result = Assign(asslist) 361 store = StoreTemp(expr=Invoke(expr=LoadAttr(name="__iter__", expr=expr))) 362 release = ReleaseTemp() 363 result.code = [store] + self.dispatches(asslist.nodes, 1) + [release] 364 return result 365 366 visitAssTuple = visitAssList 367 368 def _visitAssNameOrAttr(self, node, in_sequence): 369 if not in_sequence: 370 return LoadTemp() 371 else: 372 return Invoke(expr=LoadAttr(expr=LoadTemp(), name="next")) 373 374 def visitAssName(self, assname, in_sequence=0): 375 expr = self._visitAssNameOrAttr(assname, in_sequence) 376 result = StoreName(assname, name=assname.name, expr=expr) 377 return result 378 379 def visitAssAttr(self, assattr, in_sequence=0): 380 expr = self._visitAssNameOrAttr(assattr, in_sequence) 381 lvalue = self.dispatch(assattr.expr) 382 result = StoreAttr(assattr, name=assattr.attrname, lvalue=lvalue, expr=expr) 383 return result 384 385 def _visitSlice(self, slice, expr, lower, upper, flags, value=None): 386 if flags == "OP_ASSIGN": 387 args = [value] 388 result = Invoke(expr=LoadAttr(expr=expr, name="__setslice__")) 389 elif flags == "OP_APPLY": 390 args = [] 391 result = Invoke(expr=LoadAttr(expr=expr, name="__getslice__")) 392 elif flags == "OP_DELETE": 393 args = [] 394 result = Invoke(expr=LoadAttr(expr=expr, name="__delslice__")) 395 else: 396 raise NotImplementedError, flags 397 398 # Add the dimensions. 399 400 args.insert(0, lower) 401 args.insert(1, upper) 402 403 result.original = slice 404 result.args = args 405 return result 406 407 def visitSlice(self, slice, in_sequence=0): 408 value = self._visitAssNameOrAttr(slice, in_sequence) 409 return self._visitSlice(slice, self.dispatch(slice.expr), self.dispatch_or_none(slice.lower), 410 self.dispatch_or_none(slice.upper), slice.flags, value) 411 412 def _visitSubscript(self, subscript, expr, subs, flags, value=None): 413 if flags == "OP_ASSIGN": 414 args = [value] 415 result = Invoke(expr=LoadAttr(expr=expr, name="__setitem__")) 416 elif flags == "OP_APPLY": 417 args = [] 418 result = Invoke(expr=LoadAttr(expr=expr, name="__getitem__")) 419 elif flags == "OP_DELETE": 420 args = [] 421 result = Invoke(expr=LoadAttr(expr=expr, name="__delitem__")) 422 else: 423 raise NotImplementedError, flags 424 425 # Add the dimensions. 426 427 args.insert(0, subs) 428 429 result.original = subscript 430 result.args = args 431 return result 432 433 def _visitSubscriptSubs(self, subs): 434 if len(subs) == 1: 435 return self.dispatch(subs[0]) 436 else: 437 return Invoke(expr=LoadName(name="Tuple"), args=self.dispatches(subs)) 438 439 def visitSubscript(self, subscript, in_sequence=0): 440 value = self._visitAssNameOrAttr(subscript, in_sequence) 441 subs = self._visitSubscriptSubs(subscript.subs) 442 return self._visitSubscript(subscript, self.dispatch(subscript.expr), subs, subscript.flags, value) 443 444 # Invocation and subprogram transformations. 445 446 def _visitFunction(self, function, subprogram): 447 if function.flags & 4 != 0: has_star = 1 448 else: has_star = 0 449 if function.flags & 8 != 0: has_dstar = 1 450 else: has_dstar = 0 451 ndefaults = len(function.defaults) 452 npositional = len(function.argnames) - has_star - has_dstar 453 if has_star: star = function.argnames[npositional] 454 else: star = None 455 if has_dstar: dstar = function.argnames[npositional + has_star] 456 else: dstar = None 457 458 params = [] 459 for i in range(0, npositional - ndefaults): 460 params.append((function.argnames[i], None)) 461 462 # NOTE: Fix/process defaults. 463 464 for i in range(0, ndefaults): 465 default = function.defaults[i] 466 if default is not None: 467 params.append((function.argnames[npositional - ndefaults + i], self.dispatch(default))) 468 else: 469 params.append((function.argnames[npositional - ndefaults + i], default)) 470 471 subprogram.params = params 472 subprogram.star = star 473 subprogram.dstar = dstar 474 self.subprograms.append(subprogram) 475 476 def visitFunction(self, function): 477 478 # Make a subprogram for the function and record it outside the main 479 # tree. 480 481 subprogram = Subprogram(name=function.name, returns_value=1, star=None, dstar=None) 482 self.current_subprograms.append(subprogram) 483 subprogram.code = self.dispatch(function.code) 484 self.current_subprograms.pop() 485 self._visitFunction(function, subprogram) 486 487 # Make a definition of the function associating it with a name. 488 489 result = Assign(function) 490 load = LoadRef(ref=subprogram) 491 store = StoreName(name=function.name) 492 result.code = [load, store] 493 return result 494 495 def visitLambda(self, lambda_): 496 497 # Make a subprogram for the function and record it outside the main 498 # tree. 499 500 subprogram = Subprogram(name=hex(id(lambda_)), returns_value=1, star=None, dstar=None) 501 self.current_subprograms.append(subprogram) 502 subprogram.code = [Return(expr=self.dispatch(lambda_.code))] 503 self.current_subprograms.pop() 504 self._visitFunction(lambda_, subprogram) 505 506 # Get the subprogram reference to the lambda. 507 508 return LoadRef(lambda_, ref=subprogram) 509 510 def visitCallFunc(self, callfunc): 511 result = Invoke(callfunc, same_frame=0, star=None, dstar=None) 512 result.args = self.dispatches(callfunc.args) 513 if callfunc.star_args is not None: 514 result.star = self.dispatch(callfunc.star_args) 515 if callfunc.dstar_args is not None: 516 result.dstar = self.dispatch(callfunc.dstar_args) 517 result.expr = self.dispatch(callfunc.node) 518 return result 519 520 def visitWhile(self, while_): 521 522 # Make a subprogram for the block and record it outside the main tree. 523 524 subprogram = Subprogram(name=hex(id(while_)), acquire_locals=1, returns_value=0, params=[], star=None, dstar=None) 525 self.current_subprograms.append(subprogram) 526 527 # Include a conditional statement in the subprogram. 528 529 test = Conditional(else_=[]) 530 test.test = Invoke(expr=LoadAttr(expr=self.dispatch(while_.test), name="__true__"), 531 params=[], star=None, dstar=None) 532 533 # Inside the conditional, add a recursive invocation to the subprogram 534 # if the test condition was satisfied. 535 536 continuation = Invoke(same_frame=1, star=None, dstar=None, args=[]) 537 continuation.expr = LoadRef(ref=subprogram) 538 test.body = self.dispatch(while_.body) + [continuation] 539 if while_.else_ is not None: 540 test.else_ = self.dispatch(while_.else_) 541 subprogram.code = [test] 542 543 self.current_subprograms.pop() 544 self.subprograms.append(subprogram) 545 546 # Make an invocation of the subprogram. 547 548 result = Invoke(while_, same_frame=1, produces_result=0, star=None, dstar=None, args=[]) 549 result.expr = LoadRef(ref=subprogram) 550 return result 551 552 def visitFor(self, for_): 553 554 # Make a subprogram for the block and record it outside the main tree. 555 556 subprogram = Subprogram(name=hex(id(for_)), acquire_locals=1, returns_value=0, params=[], star=None, dstar=None) 557 self.current_subprograms.append(subprogram) 558 559 # Wrap the assignment in a try...except statement. 560 561 try_except = Try(body=[], handlers=[], else_=[], finally_=[]) 562 except_spec = Invoke(expr=LoadName(name="Tuple"), params=[LoadName(name="StopIteration")]) 563 stopiteration = Except(spec=except_spec) 564 stopiteration.code = self.dispatch(for_.else_) 565 try_except.handlers = [stopiteration] 566 567 assign = Assign() 568 assign.code = [ 569 StoreTemp(expr=Invoke(expr=LoadAttr(expr=LoadTemp(), name="next"))), 570 self.dispatch(for_.assign), 571 ReleaseTemp() 572 ] 573 574 # Inside the conditional, add a recursive invocation to the subprogram 575 # if the test condition was satisfied. 576 577 continuation = Invoke(same_frame=1, produces_result=0, star=None, dstar=None, args=[]) 578 continuation.expr = LoadRef(ref=subprogram) 579 try_except.body = [assign] + self.dispatch(for_.body) + [continuation] 580 subprogram.code = [try_except] 581 582 self.subprograms.append(subprogram) 583 self.current_subprograms.pop() 584 585 # Obtain an iterator for the sequence involved. 586 # Then, make an invocation of the subprogram. 587 588 result = Assign(for_) 589 result.code = [ 590 StoreTemp(expr=Invoke(expr=LoadAttr(name="__iter__", expr=self.dispatch(for_.list)))), 591 Invoke(expr=LoadRef(ref=subprogram), same_frame=1, produces_result=0, star=None, dstar=None, args=[]), 592 ReleaseTemp() 593 ] 594 return result 595 596 # Exception node transformations. 597 598 def visitTryExcept(self, tryexcept): 599 result = Try(tryexcept, body=[], handlers=[], else_=[], finally_=[]) 600 if tryexcept.body is not None: 601 result.body = self.dispatch(tryexcept.body) 602 if tryexcept.else_ is not None: 603 result.else_ = self.dispatch(tryexcept.else_) 604 handlers = [] 605 for spec, assign, stmt in tryexcept.handlers: 606 get_exc = Assign() 607 get_exc.code = [StoreTemp(expr=LoadExc())] 608 if assign is not None: 609 get_exc.code.append(self.dispatch(assign)) 610 get_exc.code.append(ReleaseTemp()) 611 handler = Except() 612 if spec is not None: 613 handler.spec = self.dispatch(spec) 614 handler.code = [get_exc] + self.dispatch(stmt) 615 handlers.append(handler) 616 result.handlers = handlers 617 return result 618 619 def visitTryFinally(self, tryfinally): 620 result = Try(tryfinally, body=[], handlers=[], else_=[], finally_=[]) 621 if tryfinally.body is not None: 622 result.body = self.dispatch(tryfinally.body) 623 if tryfinally.final is not None: 624 result.finally_ = self.dispatch(tryfinally.final) 625 return result 626 627 # vim: tabstop=4 expandtab shiftwidth=4