paul@0 | 1 | #!/usr/bin/env python |
paul@0 | 2 | |
paul@0 | 3 | """ |
paul@0 | 4 | Inspect source files, obtaining details of classes and attributes. |
paul@0 | 5 | |
paul@299 | 6 | Copyright (C) 2007, 2008, 2009, 2010 Paul Boddie <paul@boddie.org.uk> |
paul@0 | 7 | |
paul@0 | 8 | This program is free software; you can redistribute it and/or modify it under |
paul@0 | 9 | the terms of the GNU General Public License as published by the Free Software |
paul@0 | 10 | Foundation; either version 3 of the License, or (at your option) any later |
paul@0 | 11 | version. |
paul@0 | 12 | |
paul@0 | 13 | This program is distributed in the hope that it will be useful, but WITHOUT |
paul@0 | 14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
paul@0 | 15 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
paul@0 | 16 | details. |
paul@0 | 17 | |
paul@0 | 18 | You should have received a copy of the GNU General Public License along with |
paul@0 | 19 | this program. If not, see <http://www.gnu.org/licenses/>. |
paul@91 | 20 | |
paul@91 | 21 | -------- |
paul@91 | 22 | |
paul@91 | 23 | The results of inspecting a module are as follows: |
paul@91 | 24 | |
paul@91 | 25 | Constants |
paul@91 | 26 | --------- |
paul@91 | 27 | |
paul@91 | 28 | All constants identified within the code shall be registered. |
paul@91 | 29 | |
paul@91 | 30 | Classes |
paul@91 | 31 | ------- |
paul@91 | 32 | |
paul@91 | 33 | All global classes shall be registered; local classes (within functions) or |
paul@91 | 34 | nested classes (within classes) are not currently registered. |
paul@91 | 35 | |
paul@91 | 36 | Base classes must be detected and constant. |
paul@91 | 37 | |
paul@91 | 38 | All classes without bases are made to inherit from __builtins__.object in order |
paul@91 | 39 | to support some standard methods. |
paul@91 | 40 | |
paul@91 | 41 | Functions |
paul@91 | 42 | --------- |
paul@91 | 43 | |
paul@91 | 44 | All functions and lambda definitions shall be registered. |
paul@91 | 45 | |
paul@91 | 46 | Namespaces |
paul@91 | 47 | ---------- |
paul@91 | 48 | |
paul@91 | 49 | Modules define their own "global" namespace, within which classes, functions |
paul@91 | 50 | and lambda definitions establish a hierarchy of namespaces. |
paul@91 | 51 | |
paul@91 | 52 | Only local, global and built-in namespaces are recognised; closures are not |
paul@91 | 53 | supported. |
paul@91 | 54 | |
paul@91 | 55 | Assignments |
paul@91 | 56 | ----------- |
paul@91 | 57 | |
paul@91 | 58 | Name assignment and attribute assignment involving modules and classes cause |
paul@91 | 59 | names to be associated with values within namespaces. |
paul@91 | 60 | |
paul@91 | 61 | Any assignments within loops are considered to cause the targets of such |
paul@91 | 62 | assignments to provide non-constant values. |
paul@91 | 63 | |
paul@91 | 64 | Assignments to names are only really considered to cause the targets of such |
paul@91 | 65 | assignments to provide constant values if the targets reside in the module |
paul@91 | 66 | namespace or in class namespaces, subject to the above conditions. |
paul@91 | 67 | |
paul@91 | 68 | Assignments to names within functions are not generally considered to cause the |
paul@91 | 69 | targets of such assignments to provide constant values since functions can be |
paul@91 | 70 | invoked many times with different inputs. However, there may be benefits in |
paul@91 | 71 | considering a local to be constant within a single invocation. |
paul@0 | 72 | """ |
paul@0 | 73 | |
paul@39 | 74 | from micropython.common import * |
paul@83 | 75 | from micropython.data import * |
paul@0 | 76 | import compiler.ast |
paul@0 | 77 | from compiler.visitor import ASTVisitor |
paul@15 | 78 | |
paul@21 | 79 | # Program visitors. |
paul@21 | 80 | |
paul@15 | 81 | class InspectedModule(ASTVisitor, Module): |
paul@15 | 82 | |
paul@20 | 83 | """ |
paul@20 | 84 | An inspected module, providing core details via the Module superclass, but |
paul@20 | 85 | capable of being used as an AST visitor. |
paul@20 | 86 | """ |
paul@15 | 87 | |
paul@71 | 88 | def __init__(self, name, importer): |
paul@71 | 89 | |
paul@71 | 90 | """ |
paul@71 | 91 | Initialise this visitor with a module 'name' and an 'importer' which is |
paul@71 | 92 | used to provide access to other modules when required. |
paul@71 | 93 | """ |
paul@71 | 94 | |
paul@15 | 95 | ASTVisitor.__init__(self) |
paul@15 | 96 | Module.__init__(self, name) |
paul@15 | 97 | self.visitor = self |
paul@15 | 98 | |
paul@91 | 99 | # Import machinery links. |
paul@91 | 100 | |
paul@15 | 101 | self.importer = importer |
paul@167 | 102 | self.optimisations = importer.optimisations |
paul@61 | 103 | self.builtins = self.importer.modules.get("__builtins__") |
paul@15 | 104 | self.loaded = 0 |
paul@15 | 105 | |
paul@1 | 106 | # Current expression state. |
paul@1 | 107 | |
paul@1 | 108 | self.expr = None |
paul@1 | 109 | |
paul@1 | 110 | # Namespace state. |
paul@1 | 111 | |
paul@34 | 112 | self.in_init = 0 # Find instance attributes in __init__ methods. |
paul@91 | 113 | self.in_method = 0 # Find instance attributes in all methods. |
paul@34 | 114 | self.in_loop = 0 # Note loop "membership", affecting assignments. |
paul@12 | 115 | self.namespaces = [] |
paul@0 | 116 | self.module = None |
paul@235 | 117 | self.functions = [] |
paul@0 | 118 | |
paul@0 | 119 | def parse(self, filename): |
paul@9 | 120 | |
paul@9 | 121 | "Parse the file having the given 'filename'." |
paul@9 | 122 | |
paul@0 | 123 | module = compiler.parseFile(filename) |
paul@0 | 124 | self.process(module) |
paul@0 | 125 | |
paul@0 | 126 | def process(self, module): |
paul@9 | 127 | |
paul@9 | 128 | "Process the given 'module'." |
paul@9 | 129 | |
paul@91 | 130 | self.astnode = self.module = module |
paul@236 | 131 | |
paul@260 | 132 | # Add __name__ to the namespace by adding an explicit assignment to the |
paul@260 | 133 | # module. |
paul@260 | 134 | |
paul@260 | 135 | module.node.nodes.insert(0, compiler.ast.Assign( |
paul@260 | 136 | [compiler.ast.AssName("__name__", 0)], |
paul@260 | 137 | compiler.ast.Const(self.full_name()) |
paul@260 | 138 | )) |
paul@260 | 139 | |
paul@236 | 140 | # First, visit module-level code, recording global names. |
paul@236 | 141 | |
paul@1 | 142 | processed = self.dispatch(module) |
paul@235 | 143 | |
paul@236 | 144 | # Then, for each function, detect and record globals declared in those |
paul@236 | 145 | # functions. |
paul@236 | 146 | |
paul@236 | 147 | for node, namespaces in self.functions: |
paul@236 | 148 | self.process_globals(node) |
paul@236 | 149 | |
paul@284 | 150 | self.finalise_namespace(self) |
paul@284 | 151 | |
paul@236 | 152 | # Then, visit each function, recording other names. |
paul@236 | 153 | |
paul@235 | 154 | for node, namespaces in self.functions: |
paul@235 | 155 | self._visitFunctionBody(node, namespaces) |
paul@280 | 156 | self.finalise_namespace(namespaces[-1]) |
paul@280 | 157 | |
paul@236 | 158 | # Add references to other modules declared using the __all__ global. |
paul@236 | 159 | |
paul@13 | 160 | if self.has_key("__all__"): |
paul@12 | 161 | all = self["__all__"] |
paul@1 | 162 | if isinstance(all, compiler.ast.List): |
paul@1 | 163 | for n in all.nodes: |
paul@167 | 164 | self.store(n.value, self.importer.add_module(self.name + "." + n.value)) |
paul@235 | 165 | |
paul@1 | 166 | return processed |
paul@0 | 167 | |
paul@236 | 168 | def process_globals(self, node): |
paul@236 | 169 | |
paul@236 | 170 | """ |
paul@236 | 171 | Within the given 'node', process global declarations, adjusting the |
paul@236 | 172 | module namespace. |
paul@236 | 173 | """ |
paul@236 | 174 | |
paul@236 | 175 | for n in node.getChildNodes(): |
paul@236 | 176 | if isinstance(n, compiler.ast.Global): |
paul@236 | 177 | for name in n.names: |
paul@236 | 178 | if not self.has_key(name): |
paul@236 | 179 | self[name] = None |
paul@236 | 180 | else: |
paul@236 | 181 | self.process_globals(n) |
paul@236 | 182 | |
paul@280 | 183 | def finalise_namespace(self, namespace): |
paul@280 | 184 | |
paul@280 | 185 | "Finalise the given 'namespace'." |
paul@280 | 186 | |
paul@280 | 187 | for names in namespace.get_all_attribute_usage(): |
paul@280 | 188 | self.importer.use_names(names, namespace.full_name()) |
paul@280 | 189 | |
paul@3 | 190 | def vacuum(self): |
paul@9 | 191 | |
paul@171 | 192 | """ |
paul@171 | 193 | Vacuum the module namespace, removing unreferenced objects and unused |
paul@171 | 194 | names. |
paul@171 | 195 | """ |
paul@9 | 196 | |
paul@241 | 197 | if self.should_optimise_unused_objects(): |
paul@252 | 198 | self.vacuum_object(self) |
paul@0 | 199 | |
paul@167 | 200 | all_objects = list(self.all_objects) |
paul@167 | 201 | |
paul@167 | 202 | for obj in all_objects: |
paul@252 | 203 | if isinstance(obj, Class): |
paul@252 | 204 | self.vacuum_object(obj) |
paul@171 | 205 | |
paul@252 | 206 | def vacuum_object(self, obj, delete_all=0): |
paul@241 | 207 | |
paul@252 | 208 | "Vacuum the given object 'obj'." |
paul@171 | 209 | |
paul@252 | 210 | for name, attr in obj.items(): |
paul@270 | 211 | |
paul@270 | 212 | # Only consider deleting entire unused objects or things accessible |
paul@270 | 213 | # via names which are never used. |
paul@270 | 214 | |
paul@280 | 215 | if delete_all or not self.importer.uses_attribute(obj, name): |
paul@252 | 216 | del obj[name] |
paul@270 | 217 | |
paul@270 | 218 | # Delete any unambiguous attribute value. Such values can only |
paul@270 | 219 | # have been defined within the object and therefore are not |
paul@270 | 220 | # redefined by other code regions. |
paul@270 | 221 | |
paul@252 | 222 | if attr.assignments == 1: |
paul@252 | 223 | value = attr.get_value() |
paul@171 | 224 | |
paul@252 | 225 | if value is not obj and value in self.all_objects: |
paul@252 | 226 | self.all_objects.remove(value) |
paul@171 | 227 | |
paul@252 | 228 | # Delete class contents. |
paul@241 | 229 | |
paul@252 | 230 | if isinstance(value, Class): |
paul@252 | 231 | self.vacuum_object(value, 1) |
paul@171 | 232 | |
paul@287 | 233 | def unfinalise(self): |
paul@287 | 234 | |
paul@287 | 235 | "Reset finalised information for the module." |
paul@287 | 236 | |
paul@287 | 237 | for obj in self.all_objects: |
paul@287 | 238 | obj.unfinalise_attributes() |
paul@287 | 239 | |
paul@171 | 240 | def finalise(self): |
paul@171 | 241 | |
paul@171 | 242 | "Finalise the module." |
paul@171 | 243 | |
paul@171 | 244 | for obj in self.all_objects: |
paul@287 | 245 | obj.finalise_attributes() |
paul@171 | 246 | |
paul@167 | 247 | def add_object(self, obj, any_scope=0): |
paul@167 | 248 | |
paul@167 | 249 | """ |
paul@167 | 250 | Record 'obj' if non-local or if the optional 'any_scope' is set to a |
paul@167 | 251 | true value. |
paul@167 | 252 | """ |
paul@167 | 253 | |
paul@167 | 254 | if any_scope or not (self.namespaces and isinstance(self.namespaces[-1], Function)): |
paul@167 | 255 | self.all_objects.add(obj) |
paul@167 | 256 | |
paul@167 | 257 | # Optimisation tests. |
paul@167 | 258 | |
paul@167 | 259 | def should_optimise_unused_objects(self): |
paul@167 | 260 | return "unused_objects" in self.optimisations |
paul@167 | 261 | |
paul@3 | 262 | # Namespace methods. |
paul@0 | 263 | |
paul@330 | 264 | def in_class(self, namespaces=None): |
paul@330 | 265 | namespaces = namespaces or self.namespaces |
paul@330 | 266 | return len(namespaces) > 1 and isinstance(namespaces[-2], Class) |
paul@330 | 267 | |
paul@0 | 268 | def store(self, name, obj): |
paul@12 | 269 | |
paul@12 | 270 | "Record attribute or local 'name', storing 'obj'." |
paul@12 | 271 | |
paul@12 | 272 | if not self.namespaces: |
paul@34 | 273 | self.set(name, obj, not self.in_loop) |
paul@12 | 274 | else: |
paul@34 | 275 | self.namespaces[-1].set(name, obj, not self.in_loop) |
paul@12 | 276 | |
paul@85 | 277 | def store_lambda(self, obj): |
paul@91 | 278 | |
paul@91 | 279 | "Store a lambda function 'obj'." |
paul@91 | 280 | |
paul@167 | 281 | self.add_object(obj) |
paul@85 | 282 | |
paul@94 | 283 | def store_module_attr(self, name, module): |
paul@94 | 284 | |
paul@94 | 285 | """ |
paul@94 | 286 | Record module attribute 'name' in the given 'module' using the current |
paul@94 | 287 | expression. |
paul@94 | 288 | """ |
paul@94 | 289 | |
paul@192 | 290 | module.set(name, self.expr, 0) |
paul@94 | 291 | |
paul@91 | 292 | def store_class_attr(self, name): |
paul@91 | 293 | |
paul@94 | 294 | """ |
paul@94 | 295 | Record class attribute 'name' in the current class using the current |
paul@94 | 296 | expression. |
paul@94 | 297 | """ |
paul@91 | 298 | |
paul@91 | 299 | if self.in_method and self.namespaces[-2].has_key(name): |
paul@192 | 300 | self.namespaces[-2].set(name, self.expr, 0) |
paul@91 | 301 | return 1 |
paul@91 | 302 | |
paul@91 | 303 | return 0 |
paul@91 | 304 | |
paul@34 | 305 | def store_instance_attr(self, name): |
paul@12 | 306 | |
paul@12 | 307 | "Record instance attribute 'name' in the current class." |
paul@12 | 308 | |
paul@91 | 309 | if self.in_method: |
paul@15 | 310 | |
paul@12 | 311 | # Current namespace is the function. |
paul@12 | 312 | # Previous namespace is the class. |
paul@15 | 313 | |
paul@12 | 314 | self.namespaces[-2].add_instance_attribute(name) |
paul@0 | 315 | |
paul@272 | 316 | def get_namespace(self): |
paul@71 | 317 | |
paul@71 | 318 | "Return the parent (or most recent) namespace currently exposed." |
paul@71 | 319 | |
paul@12 | 320 | return (self.namespaces[-1:] or [self])[0] |
paul@7 | 321 | |
paul@323 | 322 | def use_name(self, name, node=None): |
paul@323 | 323 | |
paul@323 | 324 | """ |
paul@323 | 325 | Use the given 'name' within the current namespace/unit, either in |
paul@323 | 326 | conjunction with a particular object (if 'node' is specified and not |
paul@323 | 327 | None) or unconditionally. |
paul@323 | 328 | """ |
paul@250 | 329 | |
paul@323 | 330 | if node is not None and isinstance(node, compiler.ast.Name): |
paul@323 | 331 | self.use_attribute(node.name, name) |
paul@250 | 332 | |
paul@323 | 333 | # For general name usage, declare usage of the given name from this |
paul@323 | 334 | # particular unit. |
paul@323 | 335 | |
paul@323 | 336 | else: |
paul@323 | 337 | unit = self.get_namespace() |
paul@323 | 338 | self.importer.use_name(name, unit.full_name()) |
paul@250 | 339 | |
paul@279 | 340 | # Attribute usage methods. |
paul@279 | 341 | # These are convenience methods which refer to the specific namespace's |
paul@279 | 342 | # implementation of these operations. |
paul@279 | 343 | |
paul@272 | 344 | def new_branchpoint(self): |
paul@272 | 345 | self.get_namespace()._new_branchpoint() |
paul@272 | 346 | |
paul@311 | 347 | def new_branch(self, loop_node=None): |
paul@311 | 348 | self.get_namespace()._new_branch(loop_node) |
paul@272 | 349 | |
paul@299 | 350 | def abandon_branch(self): |
paul@299 | 351 | self.get_namespace()._abandon_branch() |
paul@299 | 352 | |
paul@272 | 353 | def shelve_branch(self): |
paul@272 | 354 | self.get_namespace()._shelve_branch() |
paul@272 | 355 | |
paul@272 | 356 | def merge_branches(self): |
paul@272 | 357 | self.get_namespace()._merge_branches() |
paul@272 | 358 | |
paul@278 | 359 | def define_attribute_user(self, node): |
paul@279 | 360 | |
paul@279 | 361 | """ |
paul@279 | 362 | Define 'node' as the user of attributes, indicating the point where the |
paul@279 | 363 | user is defined. |
paul@279 | 364 | """ |
paul@279 | 365 | |
paul@278 | 366 | self.get_namespace()._define_attribute_user(node) |
paul@272 | 367 | |
paul@280 | 368 | def use_attribute(self, name, attrname): |
paul@323 | 369 | |
paul@323 | 370 | "Note usage on the attribute user 'name' of the attribute 'attrname'." |
paul@323 | 371 | |
paul@280 | 372 | return self.get_namespace()._use_attribute(name, attrname) |
paul@272 | 373 | |
paul@323 | 374 | def use_specific_attribute(self, objname, attrname): |
paul@285 | 375 | |
paul@323 | 376 | """ |
paul@323 | 377 | Note attribute usage specifically on 'objname' - an object which is |
paul@323 | 378 | known at inspection time - or in the current unit if 'objname' is None, |
paul@323 | 379 | nominating a specific attribute 'attrname'. |
paul@323 | 380 | |
paul@323 | 381 | This bypasses attribute user mechanisms. |
paul@323 | 382 | """ |
paul@323 | 383 | |
paul@285 | 384 | from_name = self.get_namespace().full_name() |
paul@285 | 385 | objname = objname or from_name |
paul@285 | 386 | self.importer.use_specific_name(objname, attrname, from_name) |
paul@285 | 387 | |
paul@3 | 388 | # Visitor methods. |
paul@3 | 389 | |
paul@3 | 390 | def default(self, node, *args): |
paul@39 | 391 | raise InspectError(self.full_name(), node, "Node class %r is not supported." % node.__class__) |
paul@3 | 392 | |
paul@0 | 393 | def NOP(self, node): |
paul@21 | 394 | for n in node.getChildNodes(): |
paul@21 | 395 | self.dispatch(n) |
paul@19 | 396 | return None |
paul@0 | 397 | |
paul@299 | 398 | def NOP_ABANDON(self, node): |
paul@302 | 399 | self.NOP(node) |
paul@299 | 400 | self.abandon_branch() |
paul@299 | 401 | |
paul@82 | 402 | def OP(self, node): |
paul@82 | 403 | for n in node.getChildNodes(): |
paul@82 | 404 | self.dispatch(n) |
paul@82 | 405 | return Instance() |
paul@1 | 406 | |
paul@314 | 407 | # Generic support for classes of operations. |
paul@314 | 408 | |
paul@172 | 409 | def _visitUnary(self, node): |
paul@172 | 410 | |
paul@172 | 411 | "Accounting method for the unary operator 'node'." |
paul@172 | 412 | |
paul@172 | 413 | method = unary_methods[node.__class__.__name__] |
paul@323 | 414 | self.use_name(method, node) |
paul@172 | 415 | return self.OP(node) |
paul@172 | 416 | |
paul@172 | 417 | def _visitBinary(self, node): |
paul@172 | 418 | |
paul@172 | 419 | "Accounting method for the binary operator 'node'." |
paul@172 | 420 | |
paul@172 | 421 | left_method, right_method = binary_methods[node.__class__.__name__] |
paul@323 | 422 | self.use_name(left_method, node) |
paul@323 | 423 | self.use_name(right_method, node) |
paul@172 | 424 | return self.OP(node) |
paul@172 | 425 | |
paul@85 | 426 | def _visitFunction(self, node, name): |
paul@85 | 427 | |
paul@85 | 428 | """ |
paul@85 | 429 | Return a function object for the function defined by 'node' with the |
paul@85 | 430 | given 'name'. If a lambda expression is being visited, 'name' should be |
paul@85 | 431 | None. |
paul@85 | 432 | """ |
paul@85 | 433 | |
paul@233 | 434 | # Define the function object. |
paul@233 | 435 | |
paul@85 | 436 | function = Function( |
paul@85 | 437 | name, |
paul@272 | 438 | self.get_namespace(), |
paul@85 | 439 | node.argnames, |
paul@85 | 440 | node.defaults, |
paul@85 | 441 | (node.flags & 4 != 0), |
paul@85 | 442 | (node.flags & 8 != 0), |
paul@85 | 443 | self, |
paul@85 | 444 | node |
paul@85 | 445 | ) |
paul@85 | 446 | |
paul@233 | 447 | self.add_object(function, any_scope=1) |
paul@233 | 448 | |
paul@85 | 449 | # Make a back reference from the node for code generation. |
paul@85 | 450 | |
paul@85 | 451 | node.unit = function |
paul@85 | 452 | |
paul@85 | 453 | # Process the defaults. |
paul@85 | 454 | |
paul@85 | 455 | for n in node.defaults: |
paul@85 | 456 | self.expr = self.dispatch(n) |
paul@192 | 457 | function.store_default(self.expr) |
paul@85 | 458 | |
paul@235 | 459 | self.functions.append((node, self.namespaces + [function])) |
paul@85 | 460 | |
paul@330 | 461 | # Store the function. |
paul@330 | 462 | |
paul@85 | 463 | if name is not None: |
paul@85 | 464 | self.store(name, function) |
paul@85 | 465 | else: |
paul@85 | 466 | self.store_lambda(function) |
paul@167 | 467 | |
paul@330 | 468 | # Test the defaults and assess whether an dynamic object will result. |
paul@330 | 469 | |
paul@330 | 470 | if function.make_dynamic(): |
paul@330 | 471 | |
paul@330 | 472 | # Forbid dynamic methods, since the context of methods is the |
paul@330 | 473 | # instance itself. |
paul@167 | 474 | |
paul@330 | 475 | if self.in_class(): |
paul@330 | 476 | raise InspectError(self.full_name(), node, "Methods cannot define dynamic defaults.") |
paul@85 | 477 | |
paul@330 | 478 | result = Instance() # indicates no known target |
paul@330 | 479 | else: |
paul@330 | 480 | result = function |
paul@330 | 481 | |
paul@330 | 482 | return result |
paul@85 | 483 | |
paul@235 | 484 | def _visitFunctionBody(self, node, namespaces): |
paul@235 | 485 | |
paul@235 | 486 | "Enter the function." |
paul@235 | 487 | |
paul@235 | 488 | # Current namespace is the function. |
paul@235 | 489 | # Previous namespace is the class. |
paul@235 | 490 | |
paul@330 | 491 | if self.in_class(namespaces): |
paul@235 | 492 | if namespaces[-1].name == "__init__": |
paul@235 | 493 | self.in_init = 1 |
paul@235 | 494 | self.in_method = 1 |
paul@235 | 495 | |
paul@235 | 496 | self.namespaces = namespaces |
paul@235 | 497 | self.dispatch(node.code) |
paul@235 | 498 | |
paul@235 | 499 | self.in_init = 0 |
paul@235 | 500 | self.in_method = 0 |
paul@235 | 501 | |
paul@172 | 502 | # Specific handler methods. |
paul@172 | 503 | |
paul@172 | 504 | visitAdd = _visitBinary |
paul@82 | 505 | |
paul@82 | 506 | visitAnd = OP |
paul@0 | 507 | |
paul@4 | 508 | visitAssert = NOP |
paul@4 | 509 | |
paul@0 | 510 | def visitAssign(self, node): |
paul@0 | 511 | self.expr = self.dispatch(node.expr) |
paul@0 | 512 | for n in node.nodes: |
paul@0 | 513 | self.dispatch(n) |
paul@0 | 514 | return None |
paul@0 | 515 | |
paul@0 | 516 | def visitAssAttr(self, node): |
paul@0 | 517 | expr = self.dispatch(node.expr) |
paul@272 | 518 | |
paul@272 | 519 | # Record the attribute on the presumed target. |
paul@272 | 520 | |
paul@94 | 521 | if isinstance(expr, Attr): |
paul@94 | 522 | if expr.name == "self": |
paul@94 | 523 | if not self.store_class_attr(node.attrname): |
paul@94 | 524 | self.store_instance_attr(node.attrname) |
paul@192 | 525 | elif isinstance(expr.get_value(), Module): |
paul@192 | 526 | self.store_module_attr(node.attrname, expr.get_value()) |
paul@192 | 527 | print "Warning: attribute %r of module %r set outside the module." % (node.attrname, expr.get_value().name) |
paul@272 | 528 | |
paul@285 | 529 | # Note usage of the attribute where a local is involved. |
paul@272 | 530 | |
paul@272 | 531 | if expr.parent is self.get_namespace(): |
paul@309 | 532 | node._attrusers = self.use_attribute(expr.name, node.attrname) |
paul@309 | 533 | node._username = expr.name |
paul@272 | 534 | |
paul@0 | 535 | return None |
paul@0 | 536 | |
paul@0 | 537 | def visitAssList(self, node): |
paul@204 | 538 | |
paul@204 | 539 | # Declare names which will be used by generated code. |
paul@204 | 540 | |
paul@323 | 541 | self.use_name("__getitem__", node) |
paul@204 | 542 | |
paul@204 | 543 | # Process the assignment. |
paul@204 | 544 | |
paul@139 | 545 | for i, n in enumerate(node.nodes): |
paul@0 | 546 | self.dispatch(n) |
paul@168 | 547 | self.importer.make_constant(i) # for __getitem__(i) at run-time |
paul@0 | 548 | return None |
paul@0 | 549 | |
paul@0 | 550 | def visitAssName(self, node): |
paul@289 | 551 | if hasattr(node, "flags") and node.flags == "OP_DELETE": |
paul@298 | 552 | print "Warning: deletion of attribute %r in %r is not supported." % (node.name, self.full_name()) |
paul@298 | 553 | #raise InspectError(self.full_name(), node, "Deletion of attribute %r is not supported." % node.name) |
paul@274 | 554 | |
paul@120 | 555 | self.store(node.name, self.expr) |
paul@278 | 556 | self.define_attribute_user(node) |
paul@285 | 557 | |
paul@285 | 558 | # Ensure the presence of the given name in this namespace. |
paul@285 | 559 | |
paul@285 | 560 | self.use_specific_attribute(None, node.name) |
paul@0 | 561 | return None |
paul@0 | 562 | |
paul@0 | 563 | visitAssTuple = visitAssList |
paul@0 | 564 | |
paul@172 | 565 | def visitAugAssign(self, node): |
paul@172 | 566 | |
paul@172 | 567 | # Accounting. |
paul@172 | 568 | |
paul@172 | 569 | aug_method, (left_method, right_method) = augassign_methods[node.op] |
paul@323 | 570 | self.use_name(aug_method, node) |
paul@323 | 571 | self.use_name(left_method, node) |
paul@323 | 572 | self.use_name(right_method, node) |
paul@244 | 573 | |
paul@244 | 574 | # Process the assignment. |
paul@244 | 575 | |
paul@244 | 576 | self.expr = self.dispatch(node.expr) |
paul@244 | 577 | |
paul@244 | 578 | # NOTE: Similar to micropython.ast handler code. |
paul@244 | 579 | # NOTE: Slices and subscripts not supported. |
paul@244 | 580 | |
paul@244 | 581 | if isinstance(node.node, compiler.ast.Name): |
paul@244 | 582 | self.visitAssName(node.node) |
paul@244 | 583 | elif isinstance(node.node, compiler.ast.Getattr): |
paul@244 | 584 | self.visitAssAttr(node.node) |
paul@244 | 585 | else: |
paul@244 | 586 | raise InspectError(self.full_name(), node, "AugAssign(Slice or Subscript)") |
paul@244 | 587 | |
paul@244 | 588 | return None |
paul@2 | 589 | |
paul@82 | 590 | visitBackquote = OP |
paul@4 | 591 | |
paul@172 | 592 | visitBitand = _visitBinary |
paul@2 | 593 | |
paul@172 | 594 | visitBitor = _visitBinary |
paul@2 | 595 | |
paul@172 | 596 | visitBitxor = _visitBinary |
paul@4 | 597 | |
paul@299 | 598 | visitBreak = NOP_ABANDON |
paul@4 | 599 | |
paul@82 | 600 | visitCallFunc = OP |
paul@0 | 601 | |
paul@0 | 602 | def visitClass(self, node): |
paul@91 | 603 | |
paul@91 | 604 | """ |
paul@91 | 605 | Register the class at the given 'node' subject to the restrictions |
paul@91 | 606 | mentioned in the module docstring. |
paul@91 | 607 | """ |
paul@91 | 608 | |
paul@12 | 609 | if self.namespaces: |
paul@41 | 610 | print "Class %r in %r is not global: ignored." % (node.name, self.namespaces[-1].full_name()) |
paul@82 | 611 | return None |
paul@0 | 612 | else: |
paul@272 | 613 | cls = Class(node.name, self.get_namespace(), self, node) |
paul@37 | 614 | |
paul@37 | 615 | # Visit the base class expressions, attempting to find concrete |
paul@37 | 616 | # definitions of classes. |
paul@37 | 617 | |
paul@0 | 618 | for base in node.bases: |
paul@36 | 619 | expr = self.dispatch(base) |
paul@36 | 620 | if isinstance(expr, Attr): |
paul@36 | 621 | if expr.assignments != 1: |
paul@39 | 622 | raise InspectError(self.full_name(), node, |
paul@40 | 623 | "Base class %r for %r is not constant." % (base, cls.full_name())) |
paul@36 | 624 | else: |
paul@192 | 625 | cls.add_base(expr.get_value()) |
paul@36 | 626 | else: # if expr is None: |
paul@39 | 627 | raise InspectError(self.full_name(), node, |
paul@40 | 628 | "Base class %r for %r is not found: it may be hidden in some way." % (base, cls.full_name())) |
paul@0 | 629 | |
paul@59 | 630 | # NOTE: Potentially dubious measure to permit __init__ availability. |
paul@59 | 631 | # If no bases exist, adopt the 'object' class. |
paul@59 | 632 | |
paul@61 | 633 | if not node.bases and not (self.name == "__builtins__" and node.name == "object") : |
paul@59 | 634 | expr = self.dispatch(compiler.ast.Name("object")) |
paul@192 | 635 | cls.add_base(expr.get_value()) |
paul@59 | 636 | |
paul@21 | 637 | # Make a back reference from the node for code generation. |
paul@21 | 638 | |
paul@39 | 639 | node.unit = cls |
paul@21 | 640 | |
paul@0 | 641 | # Make an entry for the class. |
paul@0 | 642 | |
paul@0 | 643 | self.store(node.name, cls) |
paul@167 | 644 | self.add_object(cls) |
paul@0 | 645 | |
paul@59 | 646 | # Process the class body. |
paul@59 | 647 | |
paul@12 | 648 | self.namespaces.append(cls) |
paul@0 | 649 | self.dispatch(node.code) |
paul@284 | 650 | self.finalise_namespace(cls) |
paul@12 | 651 | self.namespaces.pop() |
paul@0 | 652 | |
paul@82 | 653 | return cls |
paul@0 | 654 | |
paul@172 | 655 | def visitCompare(self, node): |
paul@172 | 656 | |
paul@172 | 657 | # Accounting. |
paul@172 | 658 | # NOTE: Replicates some code in micropython.ast.visitCompare. |
paul@172 | 659 | |
paul@323 | 660 | this_node = node |
paul@323 | 661 | |
paul@172 | 662 | for op in node.ops: |
paul@172 | 663 | op_name, next_node = op |
paul@323 | 664 | |
paul@323 | 665 | # Get the applicable methods. |
paul@323 | 666 | |
paul@172 | 667 | methods = comparison_methods[op_name] |
paul@323 | 668 | |
paul@323 | 669 | # Define name/attribute usage. |
paul@323 | 670 | |
paul@172 | 671 | if methods is not None: |
paul@323 | 672 | self.use_name(methods[0], this_node) |
paul@323 | 673 | self.use_name(methods[1], next_node) |
paul@172 | 674 | elif op_name.endswith("in"): |
paul@323 | 675 | self.use_name("__contains__", next_node) |
paul@323 | 676 | |
paul@323 | 677 | this_node = next_node |
paul@172 | 678 | |
paul@172 | 679 | return self.OP(node) |
paul@4 | 680 | |
paul@21 | 681 | def visitConst(self, node): |
paul@177 | 682 | |
paul@177 | 683 | # Register the constant, if necessary, returning the resulting object. |
paul@177 | 684 | |
paul@323 | 685 | self.use_name(self.importer.get_constant_type_name(node.value), node) |
paul@168 | 686 | return self.importer.make_constant(node.value) |
paul@0 | 687 | |
paul@299 | 688 | visitContinue = NOP_ABANDON |
paul@4 | 689 | |
paul@4 | 690 | visitDecorators = NOP |
paul@4 | 691 | |
paul@82 | 692 | visitDict = OP |
paul@0 | 693 | |
paul@0 | 694 | visitDiscard = NOP |
paul@0 | 695 | |
paul@172 | 696 | visitDiv = _visitBinary |
paul@4 | 697 | |
paul@4 | 698 | visitEllipsis = NOP |
paul@4 | 699 | |
paul@4 | 700 | visitExec = NOP |
paul@4 | 701 | |
paul@82 | 702 | visitExpression = OP |
paul@4 | 703 | |
paul@172 | 704 | visitFloorDiv = _visitBinary |
paul@4 | 705 | |
paul@34 | 706 | def visitFor(self, node): |
paul@272 | 707 | self.new_branchpoint() |
paul@204 | 708 | |
paul@204 | 709 | # Declare names which will be used by generated code. |
paul@204 | 710 | |
paul@323 | 711 | self.use_name("__iter__", node.list) |
paul@250 | 712 | self.use_name("next") |
paul@204 | 713 | |
paul@289 | 714 | self.in_loop = 1 |
paul@272 | 715 | self.dispatch(node.assign) |
paul@272 | 716 | self.dispatch(node.list) |
paul@272 | 717 | |
paul@204 | 718 | # Enter the loop. |
paul@275 | 719 | # Propagate attribute usage to branches. |
paul@204 | 720 | |
paul@272 | 721 | self.new_branch() |
paul@272 | 722 | self.dispatch(node.body) |
paul@272 | 723 | self.shelve_branch() |
paul@34 | 724 | self.in_loop = 0 |
paul@272 | 725 | |
paul@275 | 726 | # Maintain a branch for the else clause or the current retained usage |
paul@275 | 727 | # where execution avoids the conditional clauses. |
paul@275 | 728 | |
paul@275 | 729 | self.new_branch() |
paul@272 | 730 | if node.else_ is not None: |
paul@272 | 731 | self.dispatch(node.else_) |
paul@275 | 732 | self.shelve_branch() |
paul@272 | 733 | |
paul@272 | 734 | self.merge_branches() |
paul@82 | 735 | return None |
paul@0 | 736 | |
paul@0 | 737 | def visitFrom(self, node): |
paul@0 | 738 | module = self.importer.load(node.modname, 1) |
paul@0 | 739 | |
paul@35 | 740 | #if module is None: |
paul@35 | 741 | # print "Warning:", node.modname, "not imported." |
paul@0 | 742 | |
paul@0 | 743 | for name, alias in node.names: |
paul@0 | 744 | if name != "*": |
paul@285 | 745 | if module is not None and module.has_key(name): |
paul@24 | 746 | attr = module[name] |
paul@192 | 747 | self.store(alias or name, attr) |
paul@192 | 748 | if isinstance(attr.get_value(), Module) and not attr.get_value().loaded: |
paul@192 | 749 | self.importer.load(attr.get_value().name) |
paul@24 | 750 | |
paul@24 | 751 | # Support the import of names from missing modules. |
paul@24 | 752 | |
paul@3 | 753 | else: |
paul@24 | 754 | self.store(alias or name, UnresolvedName(name, node.modname, self)) |
paul@3 | 755 | else: |
paul@3 | 756 | if module is not None: |
paul@285 | 757 | for n in module.keys(): |
paul@24 | 758 | attr = module[n] |
paul@192 | 759 | self.store(n, attr) |
paul@192 | 760 | if isinstance(attr.get_value(), Module) and not attr.get_value().loaded: |
paul@192 | 761 | self.importer.load(attr.get_value().name) |
paul@0 | 762 | |
paul@0 | 763 | return None |
paul@0 | 764 | |
paul@0 | 765 | def visitFunction(self, node): |
paul@85 | 766 | return self._visitFunction(node, node.name) |
paul@0 | 767 | |
paul@82 | 768 | visitGenExpr = OP |
paul@4 | 769 | |
paul@4 | 770 | visitGenExprFor = NOP |
paul@4 | 771 | |
paul@4 | 772 | visitGenExprIf = NOP |
paul@4 | 773 | |
paul@4 | 774 | visitGenExprInner = NOP |
paul@4 | 775 | |
paul@0 | 776 | def visitGetattr(self, node): |
paul@0 | 777 | expr = self.dispatch(node.expr) |
paul@169 | 778 | attrname = node.attrname |
paul@169 | 779 | |
paul@272 | 780 | # Attempt to identify the nature of the attribute. |
paul@272 | 781 | |
paul@36 | 782 | if isinstance(expr, Attr): |
paul@192 | 783 | value = expr.get_value() |
paul@285 | 784 | |
paul@285 | 785 | # Get the attribute and record its usage. |
paul@285 | 786 | |
paul@87 | 787 | if isinstance(value, (Class, Module)): |
paul@285 | 788 | attr = value.get(attrname) |
paul@285 | 789 | self.use_specific_attribute(value.full_name(), attrname) |
paul@285 | 790 | |
paul@36 | 791 | elif isinstance(value, UnresolvedName): |
paul@169 | 792 | attr = UnresolvedName(attrname, value.full_name(), self) |
paul@285 | 793 | |
paul@87 | 794 | else: |
paul@167 | 795 | attr = None |
paul@272 | 796 | |
paul@285 | 797 | # Note usage of the attribute where a local is involved. |
paul@272 | 798 | |
paul@285 | 799 | if expr.parent is self.get_namespace(): |
paul@309 | 800 | node._attrusers = self.use_attribute(expr.name, attrname) |
paul@309 | 801 | node._username = expr.name |
paul@285 | 802 | else: |
paul@323 | 803 | self.use_name(attrname, node.expr) |
paul@272 | 804 | |
paul@167 | 805 | elif self.builtins is not None: |
paul@169 | 806 | attr = self.builtins.get(attrname) |
paul@285 | 807 | self.use_specific_attribute(self.builtins.full_name(), attrname) |
paul@280 | 808 | |
paul@61 | 809 | else: |
paul@169 | 810 | attr = UnresolvedName(attrname, value.full_name(), self) |
paul@169 | 811 | |
paul@167 | 812 | return attr |
paul@4 | 813 | |
paul@12 | 814 | def visitGlobal(self, node): |
paul@12 | 815 | if self.namespaces: |
paul@12 | 816 | for name in node.names: |
paul@178 | 817 | ns = self.namespaces[-1] |
paul@178 | 818 | if not ns.make_global(name): |
paul@178 | 819 | raise InspectError(ns.full_name(), node, "Name %r is global and local in %r" % (name, ns.full_name())) |
paul@37 | 820 | |
paul@236 | 821 | # The name is recorded in an earlier process. |
paul@0 | 822 | |
paul@0 | 823 | def visitIf(self, node): |
paul@272 | 824 | self.new_branchpoint() |
paul@272 | 825 | |
paul@275 | 826 | # Propagate attribute usage to branches. |
paul@275 | 827 | |
paul@0 | 828 | for test, body in node.tests: |
paul@202 | 829 | self.dispatch(test) |
paul@272 | 830 | |
paul@272 | 831 | self.new_branch() |
paul@0 | 832 | self.dispatch(body) |
paul@272 | 833 | self.shelve_branch() |
paul@272 | 834 | |
paul@275 | 835 | # Maintain a branch for the else clause or the current retained usage |
paul@275 | 836 | # where execution avoids the conditional clauses. |
paul@275 | 837 | |
paul@275 | 838 | self.new_branch() |
paul@0 | 839 | if node.else_ is not None: |
paul@0 | 840 | self.dispatch(node.else_) |
paul@275 | 841 | self.shelve_branch() |
paul@272 | 842 | |
paul@272 | 843 | self.merge_branches() |
paul@0 | 844 | return None |
paul@0 | 845 | |
paul@12 | 846 | visitIfExp = NOP |
paul@12 | 847 | |
paul@0 | 848 | def visitImport(self, node): |
paul@0 | 849 | for name, alias in node.names: |
paul@2 | 850 | if alias is not None: |
paul@167 | 851 | module = self.importer.load(name, 1) or UnresolvedName(None, name, self) |
paul@167 | 852 | self.store(alias, module) |
paul@2 | 853 | else: |
paul@167 | 854 | module = self.importer.load(name) or UnresolvedName(None, name.split(".")[0], self) |
paul@167 | 855 | self.store(name.split(".")[0], module) |
paul@0 | 856 | |
paul@0 | 857 | return None |
paul@0 | 858 | |
paul@172 | 859 | visitInvert = _visitUnary |
paul@4 | 860 | |
paul@59 | 861 | def visitKeyword(self, node): |
paul@59 | 862 | self.dispatch(node.expr) |
paul@168 | 863 | self.importer.make_constant(node.name) |
paul@71 | 864 | self.keyword_names.add(node.name) |
paul@59 | 865 | return None |
paul@4 | 866 | |
paul@85 | 867 | def visitLambda(self, node): |
paul@252 | 868 | self.use_name(None) # lambda functions have no names but are assumed to be invoked |
paul@85 | 869 | return self._visitFunction(node, None) |
paul@4 | 870 | |
paul@172 | 871 | visitLeftShift = _visitBinary |
paul@1 | 872 | |
paul@82 | 873 | visitList = OP |
paul@0 | 874 | |
paul@82 | 875 | visitListComp = OP |
paul@4 | 876 | |
paul@4 | 877 | visitListCompFor = NOP |
paul@4 | 878 | |
paul@4 | 879 | visitListCompIf = NOP |
paul@4 | 880 | |
paul@172 | 881 | visitMod = _visitBinary |
paul@4 | 882 | |
paul@0 | 883 | def visitModule(self, node): |
paul@143 | 884 | |
paul@143 | 885 | # Make a back reference from the node for code generation. |
paul@143 | 886 | |
paul@143 | 887 | node.unit = self |
paul@0 | 888 | return self.dispatch(node.node) |
paul@0 | 889 | |
paul@172 | 890 | visitMul = _visitBinary |
paul@2 | 891 | |
paul@0 | 892 | def visitName(self, node): |
paul@0 | 893 | name = node.name |
paul@169 | 894 | |
paul@280 | 895 | # Constants. |
paul@280 | 896 | |
paul@168 | 897 | if self.importer.predefined_constants.has_key(name): |
paul@168 | 898 | attr = self.importer.get_predefined_constant(name) |
paul@280 | 899 | |
paul@280 | 900 | # Locals. |
paul@280 | 901 | |
paul@82 | 902 | elif self.namespaces and self.namespaces[-1].has_key(name): |
paul@167 | 903 | attr = self.namespaces[-1][name] |
paul@280 | 904 | |
paul@280 | 905 | # Note usage of the local (potentially a class attribute). |
paul@280 | 906 | |
paul@285 | 907 | self.use_specific_attribute(None, name) |
paul@280 | 908 | |
paul@280 | 909 | # Globals. |
paul@280 | 910 | |
paul@13 | 911 | elif self.has_key(name): |
paul@167 | 912 | attr = self[name] |
paul@280 | 913 | |
paul@280 | 914 | # Note usage of the module attribute. |
paul@280 | 915 | |
paul@285 | 916 | self.use_specific_attribute(self.full_name(), name) |
paul@280 | 917 | |
paul@280 | 918 | # Builtins. |
paul@280 | 919 | |
paul@61 | 920 | elif self.builtins is not None and self.builtins.has_key(name): |
paul@167 | 921 | attr = self.builtins[name] |
paul@285 | 922 | self.use_specific_attribute(self.builtins.full_name(), name) |
paul@280 | 923 | |
paul@280 | 924 | # Unknown. |
paul@280 | 925 | |
paul@0 | 926 | else: |
paul@167 | 927 | attr = None |
paul@280 | 928 | self.use_name(name) |
paul@167 | 929 | |
paul@167 | 930 | return attr |
paul@0 | 931 | |
paul@82 | 932 | visitNot = OP |
paul@0 | 933 | |
paul@82 | 934 | visitOr = OP |
paul@0 | 935 | |
paul@0 | 936 | visitPass = NOP |
paul@0 | 937 | |
paul@172 | 938 | visitPower = _visitBinary |
paul@4 | 939 | |
paul@4 | 940 | visitPrint = NOP |
paul@4 | 941 | |
paul@4 | 942 | visitPrintnl = NOP |
paul@4 | 943 | |
paul@299 | 944 | visitRaise = NOP_ABANDON |
paul@0 | 945 | |
paul@299 | 946 | visitReturn = NOP_ABANDON |
paul@4 | 947 | |
paul@172 | 948 | visitRightShift = _visitBinary |
paul@1 | 949 | |
paul@82 | 950 | visitSlice = OP |
paul@4 | 951 | |
paul@82 | 952 | visitSliceobj = OP |
paul@23 | 953 | |
paul@0 | 954 | def visitStmt(self, node): |
paul@0 | 955 | for n in node.nodes: |
paul@0 | 956 | self.dispatch(n) |
paul@0 | 957 | return None |
paul@0 | 958 | |
paul@172 | 959 | visitSub = _visitBinary |
paul@4 | 960 | |
paul@216 | 961 | def visitSubscript(self, node): |
paul@323 | 962 | self.use_name("__getitem__", node) |
paul@216 | 963 | self.OP(node) |
paul@0 | 964 | |
paul@0 | 965 | def visitTryExcept(self, node): |
paul@0 | 966 | self.dispatch(node.body) |
paul@272 | 967 | |
paul@272 | 968 | self.new_branchpoint() |
paul@272 | 969 | |
paul@0 | 970 | for name, var, n in node.handlers: |
paul@272 | 971 | self.new_branch() |
paul@97 | 972 | |
paul@97 | 973 | # Establish the local for the handler. |
paul@97 | 974 | |
paul@99 | 975 | if var is not None: |
paul@99 | 976 | self.dispatch(var) |
paul@99 | 977 | if n is not None: |
paul@99 | 978 | self.dispatch(n) |
paul@272 | 979 | |
paul@272 | 980 | self.shelve_branch() |
paul@272 | 981 | |
paul@0 | 982 | if node.else_ is not None: |
paul@272 | 983 | self.new_branch() |
paul@0 | 984 | self.dispatch(node.else_) |
paul@272 | 985 | self.shelve_branch() |
paul@272 | 986 | |
paul@272 | 987 | self.merge_branches() |
paul@0 | 988 | return None |
paul@0 | 989 | |
paul@4 | 990 | visitTryFinally = NOP |
paul@4 | 991 | |
paul@82 | 992 | visitTuple = OP |
paul@1 | 993 | |
paul@172 | 994 | visitUnaryAdd = _visitUnary |
paul@4 | 995 | |
paul@172 | 996 | visitUnarySub = _visitUnary |
paul@4 | 997 | |
paul@34 | 998 | def visitWhile(self, node): |
paul@272 | 999 | self.new_branchpoint() |
paul@272 | 1000 | |
paul@275 | 1001 | # Propagate attribute usage to branches. |
paul@275 | 1002 | |
paul@34 | 1003 | self.in_loop = 1 |
paul@272 | 1004 | self.dispatch(node.test) |
paul@311 | 1005 | self.new_branch(node) |
paul@272 | 1006 | self.dispatch(node.body) |
paul@272 | 1007 | self.shelve_branch() |
paul@34 | 1008 | self.in_loop = 0 |
paul@272 | 1009 | |
paul@275 | 1010 | # Maintain a branch for the else clause or the current retained usage |
paul@275 | 1011 | # where execution avoids the conditional clauses. |
paul@311 | 1012 | # NOTE: Consider merging here before the else clause. |
paul@275 | 1013 | |
paul@275 | 1014 | self.new_branch() |
paul@272 | 1015 | if node.else_ is not None: |
paul@272 | 1016 | self.dispatch(node.else_) |
paul@275 | 1017 | self.shelve_branch() |
paul@272 | 1018 | |
paul@272 | 1019 | self.merge_branches() |
paul@82 | 1020 | return None |
paul@4 | 1021 | |
paul@4 | 1022 | visitWith = NOP |
paul@4 | 1023 | |
paul@4 | 1024 | visitYield = NOP |
paul@4 | 1025 | |
paul@0 | 1026 | # vim: tabstop=4 expandtab shiftwidth=4 |