paul@17 | 1 | #!/usr/bin/env python |
paul@17 | 2 | |
paul@17 | 3 | """ |
paul@17 | 4 | Translate the AST of a Python program into a more interpretable representation. |
paul@17 | 5 | |
paul@398 | 6 | Copyright (C) 2007, 2008, 2009, 2010, 2011 Paul Boddie <paul@boddie.org.uk> |
paul@17 | 7 | |
paul@17 | 8 | This program is free software; you can redistribute it and/or modify it under |
paul@17 | 9 | the terms of the GNU General Public License as published by the Free Software |
paul@17 | 10 | Foundation; either version 3 of the License, or (at your option) any later |
paul@17 | 11 | version. |
paul@17 | 12 | |
paul@17 | 13 | This program is distributed in the hope that it will be useful, but WITHOUT |
paul@17 | 14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
paul@17 | 15 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
paul@17 | 16 | details. |
paul@17 | 17 | |
paul@17 | 18 | You should have received a copy of the GNU General Public License along with |
paul@17 | 19 | this program. If not, see <http://www.gnu.org/licenses/>. |
paul@17 | 20 | """ |
paul@17 | 21 | |
paul@154 | 22 | from micropython.opt import Optimiser |
paul@83 | 23 | from micropython.common import * |
paul@83 | 24 | from micropython.data import * |
paul@17 | 25 | from micropython.rsvp import * |
paul@196 | 26 | from micropython.trans import Helper |
paul@17 | 27 | import compiler.ast |
paul@17 | 28 | |
paul@17 | 29 | # Program visitors. |
paul@17 | 30 | |
paul@196 | 31 | class Translation(ASTVisitor, Helper): |
paul@17 | 32 | |
paul@17 | 33 | "A translated module." |
paul@17 | 34 | |
paul@122 | 35 | # Attribute access instructions, for use with the appropriate handlers. |
paul@122 | 36 | |
paul@194 | 37 | attribute_load_instructions = ( |
paul@194 | 38 | LoadAddress, LoadAddressContext, LoadAddressContextCond, |
paul@226 | 39 | LoadAttr, LoadAttrIndex, LoadAttrIndexContextCond |
paul@194 | 40 | ) |
paul@194 | 41 | attribute_store_instructions = ( |
paul@194 | 42 | None, None, None, |
paul@226 | 43 | StoreAttr, StoreAttrIndex, None |
paul@194 | 44 | ) |
paul@122 | 45 | |
paul@122 | 46 | # Name access instructions, for use with the appropriate handlers. |
paul@122 | 47 | |
paul@223 | 48 | name_load_instructions = (LoadName, LoadAddress, None) |
paul@223 | 49 | name_store_instructions = (StoreName, StoreAddress, StoreAddressContext) |
paul@98 | 50 | |
paul@175 | 51 | def __init__(self, module, program): |
paul@18 | 52 | |
paul@21 | 53 | """ |
paul@175 | 54 | Initialise the translation with an inspected 'module' and the 'program' |
paul@175 | 55 | container. |
paul@21 | 56 | """ |
paul@18 | 57 | |
paul@17 | 58 | ASTVisitor.__init__(self) |
paul@17 | 59 | self.visitor = self |
paul@17 | 60 | self.module = module |
paul@72 | 61 | |
paul@72 | 62 | # Global program dependencies. |
paul@72 | 63 | |
paul@175 | 64 | self.program = program |
paul@175 | 65 | self.objtable = self.program.get_object_table() |
paul@175 | 66 | self.paramtable = self.program.get_parameter_table() |
paul@175 | 67 | self.importer = self.program.get_importer() |
paul@72 | 68 | self.builtins = self.importer.modules.get("__builtins__") |
paul@61 | 69 | |
paul@140 | 70 | # Optimisation. |
paul@140 | 71 | |
paul@175 | 72 | self.optimiser = Optimiser(self, program.optimisations) |
paul@62 | 73 | |
paul@61 | 74 | # The current unit being translated. |
paul@61 | 75 | |
paul@17 | 76 | self.unit = None |
paul@17 | 77 | |
paul@103 | 78 | # The temporary storage used by the current assignment expression. |
paul@103 | 79 | |
paul@139 | 80 | self.expr_temp = [] |
paul@103 | 81 | |
paul@19 | 82 | # Wiring within the code. |
paul@19 | 83 | |
paul@19 | 84 | self.labels = {} |
paul@19 | 85 | self.label_number = 0 |
paul@163 | 86 | self.loop_blocks = [] |
paul@163 | 87 | self.exception_blocks = [] |
paul@235 | 88 | self.in_exception_handler = 0 |
paul@374 | 89 | self.in_assignment = 0 # for slicing and subscript |
paul@41 | 90 | |
paul@156 | 91 | self.reset() |
paul@19 | 92 | |
paul@95 | 93 | def __repr__(self): |
paul@95 | 94 | return "Translation(%r)" % self.module |
paul@72 | 95 | |
paul@156 | 96 | def reset(self): |
paul@156 | 97 | |
paul@156 | 98 | "Reset the state of the translator." |
paul@156 | 99 | |
paul@156 | 100 | # The code itself. This is limited to the code for a particular block |
paul@156 | 101 | # being processed. |
paul@156 | 102 | |
paul@163 | 103 | self.blocks = [] |
paul@156 | 104 | |
paul@156 | 105 | # Information about temporary values. |
paul@156 | 106 | |
paul@156 | 107 | self.temp_positions = set() |
paul@156 | 108 | self.max_temp_position = -1 |
paul@156 | 109 | |
paul@156 | 110 | # Information about instructions which construct frames. |
paul@156 | 111 | |
paul@156 | 112 | self.frame_makers = [] |
paul@156 | 113 | |
paul@156 | 114 | # Optimiser state must be reset for each unit. |
paul@156 | 115 | |
paul@156 | 116 | self.optimiser.reset() |
paul@156 | 117 | |
paul@242 | 118 | def get_module_code(self): |
paul@139 | 119 | |
paul@139 | 120 | """ |
paul@242 | 121 | Return the top-level module code. |
paul@139 | 122 | """ |
paul@17 | 123 | |
paul@17 | 124 | self.unit = self.module |
paul@156 | 125 | self.reset() |
paul@398 | 126 | self.add_exception_unit() |
paul@73 | 127 | |
paul@163 | 128 | block = self.new_block() |
paul@163 | 129 | self.set_block(block) |
paul@163 | 130 | |
paul@375 | 131 | # Handle exceptions for the program. |
paul@375 | 132 | |
paul@375 | 133 | if self.module.name == "__main__": |
paul@375 | 134 | handler_block = self.new_block() |
paul@375 | 135 | self.new_op(PushHandler(handler_block)) |
paul@375 | 136 | |
paul@375 | 137 | # Generate code for the module. |
paul@375 | 138 | |
paul@343 | 139 | if self.module.astnode is not None: |
paul@343 | 140 | self.dispatch(self.module.astnode) |
paul@73 | 141 | |
paul@139 | 142 | # Finish off the translated program if appropriate. |
paul@139 | 143 | |
paul@242 | 144 | if self.module.name == "__main__": |
paul@375 | 145 | self.set_block(handler_block) |
paul@398 | 146 | self.new_op(PopHandler(1)) |
paul@139 | 147 | self.new_op(Return()) |
paul@139 | 148 | |
paul@398 | 149 | self.drop_exception_unit() |
paul@116 | 150 | self.unit.temp_usage = self.max_temp_position + 1 |
paul@173 | 151 | self.unit.blocks = self.blocks |
paul@163 | 152 | return self.blocks |
paul@17 | 153 | |
paul@17 | 154 | def get_code(self, unit): |
paul@17 | 155 | |
paul@17 | 156 | "Return the code for the given 'unit'." |
paul@17 | 157 | |
paul@17 | 158 | self.unit = unit |
paul@156 | 159 | self.reset() |
paul@398 | 160 | self.add_exception_unit() |
paul@73 | 161 | |
paul@163 | 162 | block = self.new_block() |
paul@163 | 163 | self.set_block(block) |
paul@163 | 164 | |
paul@91 | 165 | if unit.astnode is not None: |
paul@91 | 166 | self.dispatch(unit.astnode) |
paul@73 | 167 | |
paul@398 | 168 | self.drop_exception_unit() |
paul@208 | 169 | self.unit.temp_usage = self.max_temp_position + 2 # include space for instantiators to expand backwards |
paul@173 | 170 | self.unit.blocks = self.blocks |
paul@163 | 171 | return self.blocks |
paul@17 | 172 | |
paul@137 | 173 | def get_instantiator_code(self, cls): |
paul@137 | 174 | |
paul@137 | 175 | "Return the code for the given class 'cls'." |
paul@137 | 176 | |
paul@137 | 177 | self.unit = cls.get_instantiator() |
paul@156 | 178 | self.reset() |
paul@137 | 179 | |
paul@163 | 180 | block = self.new_block() |
paul@163 | 181 | self.set_block(block) |
paul@163 | 182 | |
paul@137 | 183 | init_method = cls.get_init_method() |
paul@137 | 184 | |
paul@230 | 185 | # Make an object and store it in the unused first slot. |
paul@137 | 186 | |
paul@233 | 187 | self.make_instance(cls, len(cls.instance_attributes())) |
paul@230 | 188 | self.new_op(StoreTemp(0)) |
paul@137 | 189 | |
paul@137 | 190 | # Invoke the appropriate initialiser. |
paul@137 | 191 | |
paul@223 | 192 | self.new_op(LoadFunction(init_method)) |
paul@137 | 193 | self.new_op(LoadCallable()) |
paul@230 | 194 | self.new_op(JumpInFrame()) |
paul@137 | 195 | |
paul@137 | 196 | # Store the object as the result. |
paul@137 | 197 | |
paul@230 | 198 | self.new_op(LoadTemp(0)) # load the context from the locals |
paul@137 | 199 | self.new_op(StoreResult()) |
paul@137 | 200 | self.new_op(Return()) |
paul@137 | 201 | |
paul@173 | 202 | self.unit.blocks = self.blocks |
paul@163 | 203 | return self.blocks |
paul@137 | 204 | |
paul@103 | 205 | # Visitor methods. |
paul@103 | 206 | |
paul@103 | 207 | def default(self, node, *args): |
paul@339 | 208 | raise TranslateError("Node class %r is not supported." % node.__class__) |
paul@103 | 209 | |
paul@103 | 210 | # Concrete visitor methods. |
paul@103 | 211 | |
paul@160 | 212 | # Binary operators. |
paul@160 | 213 | |
paul@196 | 214 | visitAdd = Helper._visitBinary |
paul@259 | 215 | visitBitand = Helper._visitBinaryBit |
paul@259 | 216 | visitBitor = Helper._visitBinaryBit |
paul@259 | 217 | visitBitxor = Helper._visitBinaryBit |
paul@196 | 218 | visitDiv = Helper._visitBinary |
paul@196 | 219 | visitFloorDiv = Helper._visitBinary |
paul@196 | 220 | visitLeftShift = Helper._visitBinary |
paul@196 | 221 | visitMod = Helper._visitBinary |
paul@196 | 222 | visitMul = Helper._visitBinary |
paul@196 | 223 | visitPower = Helper._visitBinary |
paul@196 | 224 | visitRightShift = Helper._visitBinary |
paul@196 | 225 | visitSub = Helper._visitBinary |
paul@160 | 226 | |
paul@160 | 227 | # Unary operators. |
paul@160 | 228 | |
paul@196 | 229 | visitInvert = Helper._visitUnary |
paul@196 | 230 | visitUnaryAdd = Helper._visitUnary |
paul@196 | 231 | visitUnarySub = Helper._visitUnary |
paul@160 | 232 | |
paul@160 | 233 | # Logical operators. |
paul@160 | 234 | |
paul@101 | 235 | def visitAnd(self, node): |
paul@163 | 236 | end_block = self.new_block() |
paul@130 | 237 | temp_pos = self.reserve_temp() |
paul@130 | 238 | temp = LoadTemp(temp_pos) |
paul@101 | 239 | |
paul@101 | 240 | for n in node.nodes[:-1]: |
paul@101 | 241 | self.dispatch(n) |
paul@130 | 242 | self.new_op(StoreTemp(temp_pos)) |
paul@130 | 243 | |
paul@130 | 244 | self._generateTestBoolean(n, temp) |
paul@163 | 245 | self.new_op(JumpIfFalse(end_block)) |
paul@101 | 246 | |
paul@101 | 247 | self.dispatch(node.nodes[-1]) |
paul@130 | 248 | self.new_op(StoreTemp(temp_pos)) |
paul@130 | 249 | |
paul@163 | 250 | self.set_block(end_block) |
paul@130 | 251 | |
paul@130 | 252 | self.new_op(temp) |
paul@130 | 253 | self.discard_temp(temp) |
paul@56 | 254 | |
paul@160 | 255 | def visitNot(self, node): |
paul@160 | 256 | self.dispatch(node.expr) |
paul@160 | 257 | |
paul@160 | 258 | temp = self.optimiser.optimise_temp_storage() |
paul@160 | 259 | self._generateTestBoolean(node.expr, temp) |
paul@160 | 260 | self.discard_temp(temp) |
paul@160 | 261 | |
paul@160 | 262 | self.new_op(InvertBoolean()) |
paul@160 | 263 | self._generateLoadBoolean(node) |
paul@160 | 264 | |
paul@160 | 265 | def visitOr(self, node): |
paul@163 | 266 | end_block = self.new_block() |
paul@160 | 267 | temp_pos = self.reserve_temp() |
paul@160 | 268 | temp = LoadTemp(temp_pos) |
paul@160 | 269 | |
paul@160 | 270 | for n in node.nodes[:-1]: |
paul@160 | 271 | self.dispatch(n) |
paul@160 | 272 | self.new_op(StoreTemp(temp_pos)) |
paul@160 | 273 | |
paul@160 | 274 | self._generateTestBoolean(n, temp) |
paul@163 | 275 | self.new_op(JumpIfTrue(end_block)) |
paul@160 | 276 | |
paul@160 | 277 | self.dispatch(node.nodes[-1]) |
paul@160 | 278 | self.new_op(StoreTemp(temp_pos)) |
paul@160 | 279 | |
paul@163 | 280 | self.set_block(end_block) |
paul@160 | 281 | |
paul@160 | 282 | self.new_op(temp) |
paul@160 | 283 | self.discard_temp(temp) |
paul@160 | 284 | |
paul@160 | 285 | # Comparisons. |
paul@160 | 286 | |
paul@160 | 287 | def visitCompare(self, node): |
paul@160 | 288 | |
paul@160 | 289 | """ |
paul@160 | 290 | _t1 = node.expr |
paul@160 | 291 | _t1 op1 _t2 and _t2 op2 _t3 and ... |
paul@160 | 292 | """ |
paul@160 | 293 | |
paul@163 | 294 | end_block = self.new_block() |
paul@160 | 295 | |
paul@160 | 296 | self.dispatch(node.expr) |
paul@160 | 297 | temp2 = self.optimiser.optimise_temp_storage() |
paul@160 | 298 | |
paul@172 | 299 | # NOTE: Replicated by some code in micropython.inspect.visitCompare. |
paul@172 | 300 | |
paul@160 | 301 | last_op = node.ops[-1] |
paul@160 | 302 | |
paul@160 | 303 | for op in node.ops: |
paul@160 | 304 | op_name, next_node = op |
paul@354 | 305 | operator_fn = operator_functions.get(op_name) |
paul@160 | 306 | |
paul@161 | 307 | # Propagate the arguments as we traverse the construct. |
paul@161 | 308 | |
paul@160 | 309 | temp1 = temp2 |
paul@160 | 310 | self.dispatch(next_node) |
paul@160 | 311 | temp2 = self.optimiser.optimise_temp_storage() |
paul@160 | 312 | |
paul@160 | 313 | # Use the appropriate mechanism, setting the boolean status for the |
paul@160 | 314 | # comparison. |
paul@160 | 315 | |
paul@354 | 316 | if operator_fn is not None: |
paul@354 | 317 | |
paul@354 | 318 | # Generate function call using evaluated argument and next node. |
paul@160 | 319 | |
paul@354 | 320 | temp_fn = self._generateOperatorFunction(op_name) |
paul@354 | 321 | self._generateInvocation(temp_fn, (temp1, temp2)) |
paul@354 | 322 | self.discard_temp(temp_fn) |
paul@160 | 323 | |
paul@354 | 324 | temp_result = self.optimiser.optimise_temp_storage() |
paul@160 | 325 | self._generateTestBoolean(node, temp_result) |
paul@160 | 326 | self.discard_temp(temp_result) |
paul@160 | 327 | |
paul@160 | 328 | else: |
paul@160 | 329 | # Deal with the special operators. |
paul@160 | 330 | |
paul@160 | 331 | if op_name.startswith("is"): |
paul@160 | 332 | self.new_op(temp1) |
paul@160 | 333 | self.record_value() |
paul@160 | 334 | self.new_op(temp2) |
paul@160 | 335 | self.new_op(TestIdentity()) |
paul@160 | 336 | self.set_source() |
paul@160 | 337 | self.discard_value() |
paul@160 | 338 | |
paul@160 | 339 | elif op_name.endswith("in"): |
paul@160 | 340 | self.new_op(temp2) |
paul@160 | 341 | |
paul@160 | 342 | # Get method on temp2. |
paul@160 | 343 | |
paul@160 | 344 | self._generateAttr(node, "__contains__", self.attribute_load_instructions) |
paul@160 | 345 | temp_method = self.optimiser.optimise_temp_storage() |
paul@160 | 346 | |
paul@160 | 347 | # Add arguments. |
paul@160 | 348 | # NOTE: No support for defaults. |
paul@160 | 349 | |
paul@354 | 350 | self._generateInvocation(temp_method, (temp2, temp1)) |
paul@160 | 351 | |
paul@160 | 352 | temp_result = self.get_temp() |
paul@160 | 353 | self._generateTestBoolean(node, temp_result) |
paul@160 | 354 | self.discard_temp(temp_result) |
paul@160 | 355 | |
paul@160 | 356 | if op_name.find("not") != -1: |
paul@160 | 357 | self.new_op(InvertBoolean()) |
paul@160 | 358 | |
paul@163 | 359 | # Test the result and jump to the end block if false. |
paul@160 | 360 | |
paul@160 | 361 | if op is not last_op: |
paul@163 | 362 | self.new_op(JumpIfFalse(end_block)) |
paul@160 | 363 | |
paul@160 | 364 | # Compilation duties... |
paul@160 | 365 | |
paul@160 | 366 | self.discard_temp(temp1) |
paul@160 | 367 | |
paul@160 | 368 | self.discard_temp(temp2) |
paul@161 | 369 | |
paul@161 | 370 | # With the status set above, produce a boolean result. |
paul@161 | 371 | |
paul@163 | 372 | self.set_block(end_block) |
paul@161 | 373 | |
paul@160 | 374 | # Yield the appropriate value. |
paul@160 | 375 | |
paul@160 | 376 | self._generateLoadBoolean(node) |
paul@160 | 377 | |
paul@160 | 378 | # Expressions. |
paul@160 | 379 | |
paul@339 | 380 | def visitBackquote(self, node): raise TranslationNotImplementedError("Backquote") |
paul@160 | 381 | |
paul@160 | 382 | def visitCallFunc(self, node): |
paul@160 | 383 | |
paul@160 | 384 | """ |
paul@160 | 385 | Evaluate positional arguments, evaluate and store keyword arguments in |
paul@160 | 386 | the correct location, then invoke the function. |
paul@160 | 387 | """ |
paul@160 | 388 | |
paul@160 | 389 | # Mark the frame, evaluate the target, generate the call. |
paul@160 | 390 | |
paul@160 | 391 | self._startCallFunc() |
paul@160 | 392 | self.dispatch(node.node) |
paul@234 | 393 | temp_target, target, temp_context = self._generateCallFunc(node.args, node) |
paul@234 | 394 | self._doCallFunc(temp_target, target) |
paul@369 | 395 | self._endCallFunc(temp_target, temp_context) |
paul@160 | 396 | |
paul@160 | 397 | def visitConst(self, node): |
paul@168 | 398 | const = self.importer.get_constant(node.value) |
paul@160 | 399 | self.new_op(LoadConst(const)) |
paul@160 | 400 | |
paul@339 | 401 | def visitDict(self, node): raise TranslationNotImplementedError("Dict") |
paul@160 | 402 | |
paul@339 | 403 | def visitEllipsis(self, node): raise TranslationNotImplementedError("Ellipsis") |
paul@160 | 404 | |
paul@339 | 405 | def visitExec(self, node): raise TranslationNotImplementedError("Exec") |
paul@160 | 406 | |
paul@339 | 407 | def visitExpression(self, node): raise TranslationNotImplementedError("Expression") |
paul@160 | 408 | |
paul@339 | 409 | def visitGenExpr(self, node): raise TranslationNotImplementedError("GenExpr") |
paul@160 | 410 | |
paul@339 | 411 | def visitGenExprFor(self, node): raise TranslationNotImplementedError("GenExprFor") |
paul@160 | 412 | |
paul@339 | 413 | def visitGenExprIf(self, node): raise TranslationNotImplementedError("GenExprIf") |
paul@160 | 414 | |
paul@339 | 415 | def visitGenExprInner(self, node): raise TranslationNotImplementedError("GenExprInner") |
paul@160 | 416 | |
paul@160 | 417 | def visitGetattr(self, node): |
paul@160 | 418 | self._visitAttr(node, self.attribute_load_instructions) |
paul@160 | 419 | |
paul@160 | 420 | def visitList(self, node): |
paul@246 | 421 | self._generateList(node) |
paul@160 | 422 | |
paul@339 | 423 | def visitListComp(self, node): raise TranslationNotImplementedError("ListComp") |
paul@160 | 424 | |
paul@339 | 425 | def visitListCompFor(self, node): raise TranslationNotImplementedError("ListCompFor") |
paul@160 | 426 | |
paul@339 | 427 | def visitListCompIf(self, node): raise TranslationNotImplementedError("ListCompIf") |
paul@160 | 428 | |
paul@160 | 429 | def visitName(self, node): |
paul@343 | 430 | self._visitName(node, self.name_load_instructions) |
paul@160 | 431 | |
paul@342 | 432 | def visitSlice(self, node): |
paul@374 | 433 | args = [node.expr] |
paul@374 | 434 | |
paul@342 | 435 | if node.lower is None: |
paul@374 | 436 | args.append(compiler.ast.Name("None")) |
paul@342 | 437 | if node.upper is None: |
paul@374 | 438 | args.append(compiler.ast.Name("None")) |
paul@342 | 439 | else: |
paul@374 | 440 | args.append(node.upper) |
paul@342 | 441 | else: |
paul@374 | 442 | args.append(node.lower) |
paul@373 | 443 | if node.upper is None: |
paul@373 | 444 | args.append(compiler.ast.Name("None")) |
paul@373 | 445 | else: |
paul@373 | 446 | args.append(node.upper) |
paul@342 | 447 | |
paul@374 | 448 | temp_fn = self._getOperatorFunction(node, self.in_assignment and "AssSlice" or "Slice") |
paul@374 | 449 | self._visitCall(node, temp_fn, args) |
paul@374 | 450 | self.discard_temp(temp_fn) |
paul@160 | 451 | |
paul@216 | 452 | def visitSubscript(self, node): |
paul@374 | 453 | temp_fn = self._getOperatorFunction(node, self.in_assignment and "AssSubscript" or "Subscript") |
paul@374 | 454 | self._visitCall(node, temp_fn, [node.expr] + node.subs) |
paul@374 | 455 | self.discard_temp(temp_fn) |
paul@160 | 456 | |
paul@160 | 457 | def visitTuple(self, node): |
paul@246 | 458 | self._generateTuple(node) |
paul@160 | 459 | |
paul@160 | 460 | # Definitions. |
paul@56 | 461 | |
paul@56 | 462 | def visitAssign(self, node): |
paul@159 | 463 | |
paul@159 | 464 | """ |
paul@159 | 465 | Evaluate the expression from the given 'node' and assign it to the |
paul@159 | 466 | associated recipients. |
paul@159 | 467 | """ |
paul@159 | 468 | |
paul@56 | 469 | self.dispatch(node.expr) |
paul@146 | 470 | |
paul@146 | 471 | # Record the value and then dispatch to the assignment targets. |
paul@146 | 472 | |
paul@159 | 473 | self.record_value(self.has_immediate_usage(node.nodes)) |
paul@101 | 474 | |
paul@374 | 475 | self.in_assignment = 1 |
paul@374 | 476 | |
paul@56 | 477 | for n in node.nodes: |
paul@143 | 478 | self.dispatch(n) |
paul@56 | 479 | |
paul@374 | 480 | self.in_assignment = 0 |
paul@104 | 481 | self.discard_value() |
paul@101 | 482 | |
paul@143 | 483 | def visitAssAttr(self, node): |
paul@159 | 484 | |
paul@159 | 485 | "Assign the assignment expression to the recipient 'node'." |
paul@159 | 486 | |
paul@98 | 487 | self._visitAttr(node, self.attribute_store_instructions) |
paul@104 | 488 | self.set_source() |
paul@56 | 489 | |
paul@143 | 490 | def visitAssList(self, node): |
paul@159 | 491 | |
paul@159 | 492 | """ |
paul@159 | 493 | Assign items from the assignment expression to each of the recipients |
paul@159 | 494 | found within the given 'node'. |
paul@159 | 495 | """ |
paul@159 | 496 | |
paul@368 | 497 | self.new_op(self.expr_temp[-1]) |
paul@368 | 498 | self._generateAttr(node, "__getitem__", self.attribute_load_instructions) |
paul@368 | 499 | temp_getitem = self.optimiser.optimise_temp_storage() |
paul@368 | 500 | |
paul@139 | 501 | for i, n in enumerate(node.nodes): |
paul@139 | 502 | self._startCallFunc() |
paul@368 | 503 | self.new_op(temp_getitem) |
paul@234 | 504 | temp_target, target, temp_context = self._generateCallFunc([compiler.ast.Const(i)], node) |
paul@234 | 505 | self._doCallFunc(temp_target, target) |
paul@369 | 506 | self._endCallFunc() |
paul@139 | 507 | |
paul@139 | 508 | # Provide a different source value. |
paul@159 | 509 | # NOTE: Permitting immediate usage given that neither name nor |
paul@159 | 510 | # NOTE: attribute accesses should involve a function call |
paul@159 | 511 | # NOTE: overwriting the above result. |
paul@159 | 512 | |
paul@159 | 513 | self.record_value(self.is_immediate_user(n)) |
paul@143 | 514 | self.dispatch(n) |
paul@139 | 515 | self.discard_value() |
paul@139 | 516 | |
paul@368 | 517 | self.discard_temp(temp_getitem) |
paul@368 | 518 | |
paul@143 | 519 | def visitAssName(self, node): |
paul@159 | 520 | |
paul@159 | 521 | "Assign the assignment expression to the recipient 'node'." |
paul@159 | 522 | |
paul@289 | 523 | if hasattr(node, "flags") and node.flags == "OP_DELETE": |
paul@339 | 524 | raise TranslationNotImplementedError("AssName(OP_DELETE)") |
paul@271 | 525 | |
paul@106 | 526 | self._visitName(node, self.name_store_instructions) |
paul@143 | 527 | self.set_source() |
paul@56 | 528 | |
paul@279 | 529 | # Add any attribute usage guards. |
paul@279 | 530 | |
paul@381 | 531 | self._generateGuards(node) |
paul@279 | 532 | |
paul@56 | 533 | visitAssTuple = visitAssList |
paul@56 | 534 | |
paul@151 | 535 | def visitAugAssign(self, node): |
paul@151 | 536 | |
paul@354 | 537 | # Find the augmented assignment function and attempt to use it. |
paul@151 | 538 | |
paul@354 | 539 | temp_fn = self._getOperatorAugAssignFunction(node) |
paul@374 | 540 | self._visitCall(node, temp_fn, (node.node, node.expr)) |
paul@354 | 541 | self.discard_temp(temp_fn) |
paul@151 | 542 | |
paul@151 | 543 | # Assign the result to the name. |
paul@151 | 544 | |
paul@151 | 545 | self.record_value(1) |
paul@151 | 546 | |
paul@151 | 547 | if isinstance(node.node, compiler.ast.Name): |
paul@151 | 548 | self.visitAssName(node.node) |
paul@151 | 549 | elif isinstance(node.node, compiler.ast.Getattr): |
paul@151 | 550 | self.visitAssAttr(node.node) |
paul@151 | 551 | else: |
paul@339 | 552 | raise TranslationNotImplementedError("AugAssign(Slice or Subscript)") |
paul@151 | 553 | |
paul@151 | 554 | self.discard_value() |
paul@151 | 555 | |
paul@38 | 556 | def visitClass(self, node): |
paul@353 | 557 | if not used_by_unit(node): |
paul@167 | 558 | return |
paul@90 | 559 | |
paul@90 | 560 | # Store the name. |
paul@90 | 561 | |
paul@237 | 562 | self.new_op(LoadClass(node.unit)) |
paul@104 | 563 | self.record_value() |
paul@106 | 564 | self._visitName(node, self.name_store_instructions) |
paul@104 | 565 | self.set_source() |
paul@104 | 566 | self.discard_value() |
paul@90 | 567 | |
paul@90 | 568 | # Visit the code. |
paul@90 | 569 | |
paul@38 | 570 | unit = self.unit |
paul@39 | 571 | self.unit = node.unit |
paul@38 | 572 | self.dispatch(node.code) |
paul@38 | 573 | self.unit = unit |
paul@17 | 574 | |
paul@339 | 575 | def visitDecorators(self, node): raise TranslationNotImplementedError("Decorators") |
paul@160 | 576 | |
paul@160 | 577 | def visitFrom(self, node): pass |
paul@160 | 578 | |
paul@160 | 579 | def visitFunction(self, node): |
paul@353 | 580 | if not used_by_unit(node): |
paul@167 | 581 | return |
paul@160 | 582 | |
paul@160 | 583 | # Only store the name when visiting this node from outside. |
paul@160 | 584 | |
paul@160 | 585 | if self.unit is not node.unit: |
paul@330 | 586 | self._visitFunctionDeclaration(node) |
paul@330 | 587 | |
paul@330 | 588 | # Record the declared function. |
paul@330 | 589 | |
paul@222 | 590 | self.record_value() |
paul@160 | 591 | |
paul@160 | 592 | self._visitName(node, self.name_store_instructions) # AssName equivalent |
paul@160 | 593 | self.set_source() |
paul@160 | 594 | self.discard_value() |
paul@160 | 595 | |
paul@165 | 596 | # Visiting of the code occurs when get_code is invoked on this node. |
paul@160 | 597 | |
paul@160 | 598 | else: |
paul@330 | 599 | self._visitFunctionDefinition(node) |
paul@160 | 600 | |
paul@160 | 601 | def visitGlobal(self, node): pass |
paul@160 | 602 | |
paul@160 | 603 | def visitImport(self, node): pass |
paul@160 | 604 | |
paul@160 | 605 | def visitKeyword(self, node): pass |
paul@160 | 606 | |
paul@160 | 607 | def visitLambda(self, node): |
paul@21 | 608 | |
paul@21 | 609 | """ |
paul@160 | 610 | Lambda functions can be represented as globally defined functions |
paul@160 | 611 | provided they do not define any default parameter values, since these |
paul@160 | 612 | may defined in a non-global scope. |
paul@160 | 613 | |
paul@160 | 614 | Where defaults are defined, an object must be created and its content |
paul@160 | 615 | defined: the callable member of the object's structure must be set to |
paul@160 | 616 | the lambda function definition; each default must be attached to the |
paul@160 | 617 | object as an attribute, as is the case with normal functions and |
paul@160 | 618 | methods. |
paul@112 | 619 | """ |
paul@112 | 620 | |
paul@160 | 621 | # Produce the reference to this function when visiting this node from |
paul@160 | 622 | # outside. |
paul@160 | 623 | |
paul@160 | 624 | if self.unit is not node.unit: |
paul@160 | 625 | |
paul@330 | 626 | # Provide the declared function. |
paul@160 | 627 | |
paul@330 | 628 | self._visitFunctionDeclaration(node) |
paul@160 | 629 | |
paul@165 | 630 | # Visiting of the code occurs when get_code is invoked on this node. |
paul@160 | 631 | |
paul@160 | 632 | else: |
paul@330 | 633 | self._visitFunctionDefinition(node) |
paul@215 | 634 | |
paul@160 | 635 | def visitModule(self, node): |
paul@160 | 636 | extend = ExtendFrame() |
paul@160 | 637 | self.new_op(extend) |
paul@160 | 638 | self.dispatch(node.node) |
paul@160 | 639 | self.set_frame_usage(node, extend) |
paul@160 | 640 | |
paul@160 | 641 | # Statements. |
paul@160 | 642 | |
paul@160 | 643 | def visitStmt(self, node): |
paul@160 | 644 | |
paul@160 | 645 | "Process the collection of statements provided by 'node'." |
paul@160 | 646 | |
paul@160 | 647 | for n in node.nodes: |
paul@160 | 648 | |
paul@160 | 649 | # Process the statement. |
paul@160 | 650 | |
paul@160 | 651 | self.dispatch(n) |
paul@160 | 652 | |
paul@160 | 653 | # Discard temporary storage. |
paul@160 | 654 | |
paul@160 | 655 | if self.temp_positions: |
paul@160 | 656 | #print "Had temp", self.temp_positions |
paul@160 | 657 | self.temp_positions = set() |
paul@160 | 658 | |
paul@160 | 659 | # Prevent incorrect optimisation by resetting the optimiser after |
paul@160 | 660 | # each statement. |
paul@160 | 661 | |
paul@160 | 662 | self.optimiser.reset() |
paul@160 | 663 | |
paul@339 | 664 | def visitAssert(self, node): raise TranslationNotImplementedError("Assert") |
paul@160 | 665 | |
paul@160 | 666 | def visitBreak(self, node): |
paul@163 | 667 | next_block, exit_block = self.get_loop_blocks() |
paul@163 | 668 | self.new_op(Jump(exit_block)) |
paul@17 | 669 | |
paul@41 | 670 | def visitContinue(self, node): |
paul@163 | 671 | next_block, exit_block = self.get_loop_blocks() |
paul@163 | 672 | self.new_op(Jump(next_block)) |
paul@17 | 673 | |
paul@18 | 674 | def visitDiscard(self, node): |
paul@19 | 675 | self.dispatch(node.expr) |
paul@140 | 676 | self.optimiser.optimise_unused_results() |
paul@17 | 677 | |
paul@44 | 678 | def visitFor(self, node): |
paul@163 | 679 | next_handler_block = self.new_block() |
paul@163 | 680 | end_handler_block = self.new_block() |
paul@163 | 681 | exit_block = self.new_block() |
paul@163 | 682 | next_block = self.new_block() |
paul@163 | 683 | else_block = self.new_block() |
paul@44 | 684 | |
paul@44 | 685 | # Get the "list" to be iterated over, obtain its iterator. |
paul@44 | 686 | |
paul@45 | 687 | self._startCallFunc() |
paul@44 | 688 | self.dispatch(node.list) |
paul@104 | 689 | self._generateAttr(node, "__iter__", self.attribute_load_instructions) |
paul@234 | 690 | temp_target, target, temp_context = self._generateCallFunc([], node) |
paul@234 | 691 | self._doCallFunc(temp_target, target) |
paul@369 | 692 | self._endCallFunc(temp_target, temp_context) |
paul@57 | 693 | |
paul@240 | 694 | # Use a long-lasting temporary storage slot, since any result from the |
paul@240 | 695 | # __iter__ method will not remain around for long. |
paul@240 | 696 | |
paul@240 | 697 | temp_iterator = self.get_temp() |
paul@98 | 698 | |
paul@44 | 699 | # In the loop... |
paul@44 | 700 | |
paul@163 | 701 | self.set_block(next_block) |
paul@44 | 702 | |
paul@146 | 703 | # Handle exceptions when calling "next"... |
paul@146 | 704 | |
paul@398 | 705 | self.add_exception_blocks(next_handler_block, end_handler_block) |
paul@163 | 706 | self.new_op(PushHandler(next_handler_block)) |
paul@146 | 707 | |
paul@44 | 708 | # Use the iterator to get the next value. |
paul@44 | 709 | |
paul@45 | 710 | self._startCallFunc() |
paul@102 | 711 | self.new_op(temp_iterator) |
paul@104 | 712 | self._generateAttr(node, "next", self.attribute_load_instructions) |
paul@234 | 713 | temp_target, target, temp_context = self._generateCallFunc([], node) |
paul@234 | 714 | self._doCallFunc(temp_target, target) |
paul@369 | 715 | self._endCallFunc(temp_target, temp_context) |
paul@44 | 716 | |
paul@139 | 717 | # Record the value to be assigned. |
paul@139 | 718 | |
paul@139 | 719 | self.record_value() |
paul@139 | 720 | |
paul@146 | 721 | # Skip the handler where the call was successful. |
paul@146 | 722 | |
paul@398 | 723 | self.new_op(PopHandler(1)) |
paul@163 | 724 | self.new_op(Jump(end_handler_block)) |
paul@146 | 725 | |
paul@146 | 726 | # Enter the exception handler. |
paul@146 | 727 | |
paul@163 | 728 | self.set_block(next_handler_block) |
paul@398 | 729 | self.new_op(PopHandler(1)) |
paul@398 | 730 | |
paul@398 | 731 | # Disable the handlers. |
paul@398 | 732 | |
paul@398 | 733 | self.drop_exception_blocks() |
paul@146 | 734 | |
paul@44 | 735 | # Test for StopIteration. |
paul@44 | 736 | |
paul@101 | 737 | self.load_builtin("StopIteration", node) |
paul@57 | 738 | self.new_op(CheckException()) |
paul@44 | 739 | if node.else_ is not None: |
paul@163 | 740 | self.new_op(JumpIfTrue(else_block)) |
paul@44 | 741 | else: |
paul@163 | 742 | self.new_op(JumpIfTrue(exit_block)) |
paul@44 | 743 | |
paul@146 | 744 | # Re-raise the exception otherwise. |
paul@146 | 745 | |
paul@146 | 746 | self.new_op(RaiseException()) |
paul@146 | 747 | |
paul@232 | 748 | # After the handler, clear the exception. |
paul@146 | 749 | |
paul@163 | 750 | self.set_block(end_handler_block) |
paul@146 | 751 | |
paul@44 | 752 | # Assign to the target. |
paul@44 | 753 | |
paul@44 | 754 | self.dispatch(node.assign) |
paul@139 | 755 | self.discard_value() |
paul@44 | 756 | |
paul@44 | 757 | # Process the body with the current next and exit points. |
paul@44 | 758 | |
paul@163 | 759 | self.add_loop_blocks(next_block, exit_block) |
paul@44 | 760 | self.dispatch(node.body) |
paul@163 | 761 | self.drop_loop_blocks() |
paul@44 | 762 | |
paul@44 | 763 | # Repeat the loop. |
paul@44 | 764 | |
paul@163 | 765 | self.new_op(Jump(next_block)) |
paul@44 | 766 | |
paul@44 | 767 | # Produce the "else" section. |
paul@44 | 768 | |
paul@44 | 769 | if node.else_ is not None: |
paul@240 | 770 | self.set_block(else_block) |
paul@240 | 771 | self.new_op(ClearException()) |
paul@44 | 772 | self.dispatch(node.else_) |
paul@44 | 773 | |
paul@240 | 774 | # After the loop... |
paul@240 | 775 | |
paul@240 | 776 | self.set_block(exit_block) |
paul@44 | 777 | |
paul@240 | 778 | else: |
paul@240 | 779 | # After the loop... |
paul@240 | 780 | |
paul@240 | 781 | self.set_block(exit_block) |
paul@240 | 782 | self.new_op(ClearException()) |
paul@17 | 783 | |
paul@98 | 784 | # Compilation duties... |
paul@98 | 785 | |
paul@98 | 786 | self.discard_temp(temp_iterator) |
paul@98 | 787 | |
paul@17 | 788 | def visitIf(self, node): |
paul@19 | 789 | first = 1 |
paul@232 | 790 | next_block = None |
paul@163 | 791 | exit_block = self.new_block() |
paul@17 | 792 | |
paul@108 | 793 | clauses = node.tests + [(None, node.else_)] |
paul@108 | 794 | |
paul@108 | 795 | for clause in clauses: |
paul@108 | 796 | test, body = clause |
paul@19 | 797 | if body is None: |
paul@19 | 798 | break |
paul@232 | 799 | |
paul@19 | 800 | if not first: |
paul@232 | 801 | self.new_op(Jump(exit_block)) # finish last body |
paul@232 | 802 | self.set_block(next_block) # start next test |
paul@232 | 803 | next_block = None |
paul@232 | 804 | |
paul@19 | 805 | if test is not None: |
paul@19 | 806 | self.dispatch(test) |
paul@234 | 807 | |
paul@234 | 808 | temp = self.optimiser.optimise_temp_storage() |
paul@234 | 809 | self._generateTestBoolean(node, temp) |
paul@234 | 810 | |
paul@163 | 811 | next_block = self.new_block() |
paul@163 | 812 | self.new_op(JumpIfFalse(next_block)) |
paul@232 | 813 | |
paul@19 | 814 | self.dispatch(body) |
paul@232 | 815 | first = 0 |
paul@160 | 816 | |
paul@232 | 817 | if next_block is not None: |
paul@232 | 818 | self.set_block(next_block) |
paul@17 | 819 | |
paul@163 | 820 | self.set_block(exit_block) |
paul@17 | 821 | |
paul@19 | 822 | def visitPass(self, node): pass |
paul@17 | 823 | |
paul@393 | 824 | def visitPrint(self, node): |
paul@393 | 825 | self._visitPrint(node, "_print") |
paul@17 | 826 | |
paul@393 | 827 | def visitPrintnl(self, node): |
paul@393 | 828 | self._visitPrint(node, "_printnl") |
paul@17 | 829 | |
paul@97 | 830 | def visitRaise(self, node): |
paul@97 | 831 | # NOTE: expr1 only => instance provided |
paul@97 | 832 | self.dispatch(node.expr1) |
paul@97 | 833 | |
paul@97 | 834 | if node.expr2 is not None: |
paul@140 | 835 | temp = self.optimiser.optimise_temp_storage() |
paul@102 | 836 | |
paul@97 | 837 | self.dispatch(node.expr2) |
paul@140 | 838 | temp_arg = self.optimiser.optimise_temp_storage() |
paul@102 | 839 | |
paul@354 | 840 | self._generateInvocation(temp, (temp_arg,)) |
paul@102 | 841 | |
paul@102 | 842 | self.discard_temp(temp_arg) |
paul@97 | 843 | |
paul@105 | 844 | self.new_op(StoreException()) |
paul@97 | 845 | self.new_op(RaiseException()) |
paul@17 | 846 | |
paul@21 | 847 | def visitReturn(self, node): |
paul@21 | 848 | if node.value is not None: |
paul@21 | 849 | self.dispatch(node.value) |
paul@68 | 850 | else: |
paul@68 | 851 | self.dispatch(compiler.ast.Name("None")) |
paul@104 | 852 | |
paul@104 | 853 | self.new_op(StoreResult()) |
paul@235 | 854 | |
paul@235 | 855 | if self.in_exception_handler: |
paul@235 | 856 | self.new_op(ClearException()) |
paul@235 | 857 | |
paul@398 | 858 | # NOTE: Support finally blocks here. |
paul@398 | 859 | |
paul@398 | 860 | if self.exception_blocks[-1]: |
paul@398 | 861 | self.new_op(PopHandler(len(self.exception_blocks[-1]))) |
paul@398 | 862 | |
paul@21 | 863 | self.new_op(Return()) |
paul@17 | 864 | |
paul@57 | 865 | def visitTryExcept(self, node): |
paul@163 | 866 | exit_block = self.new_block() |
paul@163 | 867 | else_block = self.new_block() |
paul@163 | 868 | handler_block = self.new_block() |
paul@163 | 869 | |
paul@163 | 870 | self.add_exception_blocks(handler_block, exit_block) |
paul@57 | 871 | |
paul@68 | 872 | # Try... |
paul@68 | 873 | # Produce the code, then jump to the exit. |
paul@68 | 874 | |
paul@163 | 875 | self.new_op(PushHandler(handler_block)) |
paul@57 | 876 | self.dispatch(node.body) |
paul@398 | 877 | self.new_op(PopHandler(1)) |
paul@160 | 878 | |
paul@160 | 879 | if node.else_ is not None: |
paul@163 | 880 | self.new_op(Jump(else_block)) |
paul@160 | 881 | else: |
paul@163 | 882 | self.new_op(Jump(exit_block)) |
paul@57 | 883 | |
paul@68 | 884 | # Start of handlers. |
paul@68 | 885 | |
paul@163 | 886 | self.set_block(handler_block) |
paul@398 | 887 | self.new_op(PopHandler(1)) |
paul@398 | 888 | |
paul@398 | 889 | # Disable the handlers. |
paul@398 | 890 | |
paul@398 | 891 | self.drop_exception_blocks() |
paul@102 | 892 | |
paul@57 | 893 | for name, assignment, handler in node.handlers: |
paul@163 | 894 | next_block = self.new_block() |
paul@57 | 895 | |
paul@68 | 896 | # Test the given exception against the current exception. |
paul@68 | 897 | |
paul@57 | 898 | if name is not None: |
paul@57 | 899 | self.dispatch(name) |
paul@145 | 900 | |
paul@57 | 901 | self.new_op(CheckException()) |
paul@163 | 902 | self.new_op(JumpIfFalse(next_block)) |
paul@57 | 903 | |
paul@145 | 904 | # Handle assignment to exception variable. |
paul@145 | 905 | |
paul@145 | 906 | if assignment is not None: |
paul@145 | 907 | self.new_op(LoadException()) |
paul@145 | 908 | |
paul@145 | 909 | # Record the value to be assigned. |
paul@145 | 910 | |
paul@145 | 911 | self.record_value() |
paul@145 | 912 | self.dispatch(assignment) |
paul@145 | 913 | self.discard_value() |
paul@57 | 914 | |
paul@68 | 915 | # Produce the handler code, then jump to the exit. |
paul@68 | 916 | |
paul@235 | 917 | self.in_exception_handler = 1 |
paul@57 | 918 | self.dispatch(handler) |
paul@235 | 919 | self.in_exception_handler = 0 |
paul@235 | 920 | |
paul@163 | 921 | self.new_op(Jump(exit_block)) |
paul@163 | 922 | |
paul@163 | 923 | self.set_block(next_block) |
paul@160 | 924 | |
paul@57 | 925 | # Unhandled exceptions. |
paul@57 | 926 | |
paul@57 | 927 | self.new_op(RaiseException()) |
paul@57 | 928 | |
paul@57 | 929 | # Optional else clause. |
paul@57 | 930 | |
paul@57 | 931 | if node.else_ is not None: |
paul@163 | 932 | self.set_block(else_block) |
paul@57 | 933 | self.dispatch(node.else_) |
paul@57 | 934 | |
paul@232 | 935 | # Clear the exception. |
paul@232 | 936 | |
paul@163 | 937 | self.set_block(exit_block) |
paul@232 | 938 | self.new_op(ClearException()) |
paul@17 | 939 | |
paul@262 | 940 | def visitTryFinally(self, node): |
paul@262 | 941 | |
paul@262 | 942 | """ |
paul@262 | 943 | Add finally handler, potentially as an exception handler. |
paul@262 | 944 | Generate body, potentially changing return statements so that they do |
paul@262 | 945 | not return immediately. |
paul@262 | 946 | Generate handler, removing the handler from the active handler list, |
paul@262 | 947 | adding instructions which raise active exceptions. |
paul@262 | 948 | """ |
paul@262 | 949 | |
paul@339 | 950 | raise TranslationNotImplementedError("TryFinally") |
paul@17 | 951 | |
paul@41 | 952 | def visitWhile(self, node): |
paul@163 | 953 | exit_block = self.new_block() |
paul@163 | 954 | next_block = self.new_block() |
paul@163 | 955 | else_block = self.new_block() |
paul@163 | 956 | |
paul@163 | 957 | self.set_block(next_block) |
paul@44 | 958 | self.dispatch(node.test) |
paul@310 | 959 | |
paul@310 | 960 | temp = self.optimiser.optimise_temp_storage() |
paul@310 | 961 | self._generateTestBoolean(node, temp) |
paul@310 | 962 | |
paul@44 | 963 | if node.else_ is not None: |
paul@163 | 964 | self.new_op(JumpIfFalse(else_block)) |
paul@44 | 965 | else: |
paul@163 | 966 | self.new_op(JumpIfFalse(exit_block)) |
paul@163 | 967 | |
paul@163 | 968 | self.add_loop_blocks(next_block, exit_block) |
paul@41 | 969 | |
paul@41 | 970 | self.dispatch(node.body) |
paul@163 | 971 | self.new_op(Jump(next_block)) |
paul@41 | 972 | |
paul@41 | 973 | if node.else_ is not None: |
paul@163 | 974 | self.set_block(else_block) |
paul@160 | 975 | |
paul@41 | 976 | self.dispatch(node.else_) |
paul@41 | 977 | |
paul@163 | 978 | self.set_block(exit_block) |
paul@163 | 979 | |
paul@163 | 980 | self.drop_loop_blocks() |
paul@17 | 981 | |
paul@339 | 982 | def visitWith(self, node): raise TranslationNotImplementedError("With") |
paul@17 | 983 | |
paul@339 | 984 | def visitYield(self, node): raise TranslationNotImplementedError("Yield") |
paul@17 | 985 | |
paul@17 | 986 | # vim: tabstop=4 expandtab shiftwidth=4 |