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