paul@0 | 1 | #!/usr/bin/env python |
paul@0 | 2 | |
paul@0 | 3 | """ |
paul@0 | 4 | The micropython package for processing Python source code. The code originates |
paul@0 | 5 | from the simplify package but has had various details related to that package |
paul@0 | 6 | removed. |
paul@0 | 7 | |
paul@394 | 8 | Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Paul Boddie <paul@boddie.org.uk> |
paul@0 | 9 | |
paul@0 | 10 | This program is free software; you can redistribute it and/or modify it under |
paul@0 | 11 | the terms of the GNU General Public License as published by the Free Software |
paul@0 | 12 | Foundation; either version 3 of the License, or (at your option) any later |
paul@0 | 13 | version. |
paul@0 | 14 | |
paul@0 | 15 | This program is distributed in the hope that it will be useful, but WITHOUT |
paul@0 | 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
paul@0 | 17 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
paul@0 | 18 | details. |
paul@0 | 19 | |
paul@0 | 20 | You should have received a copy of the GNU General Public License along with |
paul@0 | 21 | this program. If not, see <http://www.gnu.org/licenses/>. |
paul@0 | 22 | |
paul@0 | 23 | -------- |
paul@0 | 24 | |
paul@280 | 25 | To use this module, an importer should be constructed. Here, the standard path |
paul@280 | 26 | for module searching is employed: |
paul@0 | 27 | |
paul@0 | 28 | importer = Importer(sys.path) |
paul@0 | 29 | |
paul@189 | 30 | To generate programs, the above importer should be supplied in the |
paul@189 | 31 | initialisation of a program instance, and then various methods are called: |
paul@189 | 32 | |
paul@189 | 33 | program = Program(importer) |
paul@189 | 34 | image = program.get_raw_image() |
paul@189 | 35 | |
paul@189 | 36 | Such importer and program objects are the most convenient mechanism through |
paul@189 | 37 | which the functionality of the micropython package may be accessed. |
paul@0 | 38 | """ |
paul@0 | 39 | |
paul@437 | 40 | from micropython.common import * |
paul@470 | 41 | from micropython.data import * |
paul@17 | 42 | import micropython.ast |
paul@154 | 43 | import micropython.opt |
paul@0 | 44 | import micropython.inspect |
paul@7 | 45 | import micropython.table |
paul@149 | 46 | import os |
paul@228 | 47 | |
paul@0 | 48 | try: |
paul@0 | 49 | set |
paul@0 | 50 | except NameError: |
paul@0 | 51 | from sets import Set as set |
paul@0 | 52 | |
paul@175 | 53 | class Program: |
paul@0 | 54 | |
paul@175 | 55 | "This class supports the generation of a program image." |
paul@0 | 56 | |
paul@154 | 57 | supported_optimisations = micropython.opt.Optimiser.supported_optimisations |
paul@63 | 58 | |
paul@175 | 59 | def __init__(self, importer, optimisations=None): |
paul@0 | 60 | |
paul@0 | 61 | """ |
paul@175 | 62 | Initialise the program representation with an 'importer' which is able |
paul@175 | 63 | to locate and load Python modules. |
paul@35 | 64 | |
paul@167 | 65 | The optional 'optimisations' cause certain techniques to be used in |
paul@167 | 66 | reducing program size and improving program efficiency. |
paul@0 | 67 | """ |
paul@0 | 68 | |
paul@175 | 69 | self.importer = importer |
paul@175 | 70 | self.optimisations = optimisations or set() |
paul@0 | 71 | |
paul@60 | 72 | # Remember the tables once generated. |
paul@60 | 73 | |
paul@60 | 74 | self.objtable = None |
paul@60 | 75 | self.paramtable = None |
paul@60 | 76 | |
paul@93 | 77 | # Main program information. |
paul@93 | 78 | |
paul@93 | 79 | self.code = None |
paul@93 | 80 | self.code_location = None |
paul@93 | 81 | |
paul@175 | 82 | def get_importer(self): |
paul@175 | 83 | return self.importer |
paul@137 | 84 | |
paul@169 | 85 | # Access to finalised program information. |
paul@169 | 86 | |
paul@353 | 87 | def finalise(self): |
paul@353 | 88 | |
paul@353 | 89 | "Finalise the program." |
paul@353 | 90 | |
paul@353 | 91 | # Need the tables to finalise. |
paul@353 | 92 | |
paul@353 | 93 | objtable = self.get_object_table() |
paul@353 | 94 | self.get_parameter_table() |
paul@353 | 95 | |
paul@353 | 96 | self.importer.vacuum(objtable) |
paul@353 | 97 | |
paul@353 | 98 | # Now remove unneeded things from the tables. |
paul@353 | 99 | |
paul@437 | 100 | objtable = self.get_object_table(reset=1) |
paul@353 | 101 | self.get_parameter_table(reset=1) |
paul@353 | 102 | |
paul@437 | 103 | self.importer.finalise(objtable) |
paul@437 | 104 | |
paul@167 | 105 | def get_image(self, with_builtins=0): |
paul@9 | 106 | |
paul@265 | 107 | """ |
paul@265 | 108 | Return the program image including built-in objects if 'with_builtins' |
paul@265 | 109 | is specified and set to a true value. |
paul@265 | 110 | """ |
paul@9 | 111 | |
paul@137 | 112 | if self.code is not None: |
paul@137 | 113 | return self.code |
paul@137 | 114 | |
paul@280 | 115 | # Optimise and regenerate the object table. |
paul@280 | 116 | |
paul@353 | 117 | self.finalise() |
paul@173 | 118 | self.code = [] |
paul@18 | 119 | |
paul@82 | 120 | # Append constants to the image. |
paul@82 | 121 | |
paul@265 | 122 | for const in self.importer.constants(): |
paul@173 | 123 | self.code.append(const) |
paul@82 | 124 | |
paul@175 | 125 | last_module = self.importer.modules_ordered[-1] |
paul@139 | 126 | |
paul@175 | 127 | for module in self.importer.modules_ordered: |
paul@431 | 128 | suppress_builtins = not with_builtins and module.name in ("__builtins__", "native") |
paul@15 | 129 | |
paul@55 | 130 | # Position the module in the image and make a translation. |
paul@55 | 131 | |
paul@167 | 132 | trans = micropython.ast.Translation(module, self) |
paul@55 | 133 | |
paul@37 | 134 | # Add header details. |
paul@37 | 135 | |
paul@173 | 136 | self.code.append(module) |
paul@37 | 137 | |
paul@15 | 138 | # Append module attributes to the image. |
paul@15 | 139 | |
paul@9 | 140 | attributes = module.module_attributes() |
paul@173 | 141 | self.code += module.attributes_as_list() |
paul@9 | 142 | |
paul@15 | 143 | # Append classes and functions to the image. |
paul@15 | 144 | |
paul@9 | 145 | for obj in module.all_objects: |
paul@470 | 146 | if isinstance(obj, Class): |
paul@54 | 147 | |
paul@22 | 148 | # Add header details. |
paul@22 | 149 | |
paul@173 | 150 | self.code.append(obj) |
paul@15 | 151 | |
paul@15 | 152 | # Append class attributes to the image. |
paul@15 | 153 | |
paul@9 | 154 | attributes = obj.class_attributes() |
paul@173 | 155 | self.code += obj.attributes_as_list() |
paul@9 | 156 | |
paul@203 | 157 | # Omit built-in function code where requested. |
paul@203 | 158 | |
paul@253 | 159 | if suppress_builtins and obj.astnode.doc is None: |
paul@203 | 160 | continue |
paul@203 | 161 | |
paul@137 | 162 | # Generate the instantiator/initialiser. |
paul@137 | 163 | # Append the function code to the image. |
paul@15 | 164 | |
paul@137 | 165 | code = trans.get_instantiator_code(obj) |
paul@173 | 166 | self.code += code |
paul@137 | 167 | |
paul@137 | 168 | # Class-level code is generated separately at the module |
paul@137 | 169 | # level, and the code location is set within the code |
paul@137 | 170 | # generation process for the module. |
paul@9 | 171 | |
paul@470 | 172 | elif isinstance(obj, Function): |
paul@15 | 173 | |
paul@22 | 174 | # Add header details. |
paul@22 | 175 | |
paul@173 | 176 | self.code.append(obj) |
paul@9 | 177 | |
paul@66 | 178 | # Append any default values to the image. |
paul@331 | 179 | # Only do this for functions which are not dynamic. |
paul@66 | 180 | |
paul@331 | 181 | if not obj.is_dynamic(): |
paul@173 | 182 | self.code += obj.default_attrs |
paul@66 | 183 | |
paul@180 | 184 | # Omit built-in function code where requested. |
paul@180 | 185 | |
paul@253 | 186 | if suppress_builtins and obj.astnode.doc is None: |
paul@180 | 187 | pass |
paul@180 | 188 | |
paul@15 | 189 | # Append the function code to the image. |
paul@15 | 190 | |
paul@180 | 191 | else: |
paul@180 | 192 | code = trans.get_code(obj) |
paul@180 | 193 | self.code += code |
paul@180 | 194 | |
paul@180 | 195 | # Omit built-in module code where requested. |
paul@180 | 196 | |
paul@205 | 197 | if suppress_builtins: |
paul@180 | 198 | pass |
paul@15 | 199 | |
paul@15 | 200 | # Append the module top-level code to the image. |
paul@15 | 201 | |
paul@180 | 202 | else: |
paul@242 | 203 | code = trans.get_module_code() |
paul@180 | 204 | self.code += code |
paul@15 | 205 | |
paul@173 | 206 | return self.code |
paul@173 | 207 | |
paul@265 | 208 | def get_raw_image(self, architecture=None, with_builtins=0): |
paul@173 | 209 | |
paul@173 | 210 | "Return the raw image representation of the program." |
paul@173 | 211 | |
paul@265 | 212 | architecture = architecture or micropython.rsvp |
paul@265 | 213 | |
paul@173 | 214 | self.get_image(with_builtins) |
paul@173 | 215 | |
paul@173 | 216 | objtable = self.get_object_table() |
paul@173 | 217 | paramtable = self.get_parameter_table() |
paul@173 | 218 | |
paul@173 | 219 | # Position the objects. |
paul@173 | 220 | |
paul@173 | 221 | pos = 0 |
paul@215 | 222 | |
paul@173 | 223 | for item in self.code: |
paul@265 | 224 | arch_item = architecture.get_object(item) |
paul@180 | 225 | |
paul@265 | 226 | # Get the raw version for the architecture. |
paul@183 | 227 | |
paul@265 | 228 | if arch_item is not None: |
paul@412 | 229 | pos = arch_item.set_location(pos, objtable, with_builtins) |
paul@173 | 230 | else: |
paul@173 | 231 | pos += 1 |
paul@173 | 232 | |
paul@173 | 233 | # Generate the raw code. |
paul@173 | 234 | |
paul@173 | 235 | self.raw_code = [] |
paul@173 | 236 | |
paul@173 | 237 | for item in self.code: |
paul@265 | 238 | arch_item = architecture.get_object(item) |
paul@173 | 239 | |
paul@265 | 240 | # Get the raw version for the architecture. |
paul@139 | 241 | |
paul@265 | 242 | if arch_item is not None: |
paul@265 | 243 | self.raw_code += arch_item.as_raw(objtable, paramtable, with_builtins) |
paul@265 | 244 | arch_item.finalise_location(with_builtins) |
paul@173 | 245 | else: |
paul@173 | 246 | self.raw_code.append(item) |
paul@173 | 247 | |
paul@173 | 248 | # Fix the module locations. |
paul@173 | 249 | |
paul@175 | 250 | for module in self.importer.modules_ordered: |
paul@173 | 251 | |
paul@431 | 252 | if not with_builtins and module.name in ("__builtins__", "native"): |
paul@173 | 253 | continue |
paul@173 | 254 | |
paul@173 | 255 | module.code_location = module.blocks[0].location |
paul@173 | 256 | |
paul@175 | 257 | self.code_location = self.importer.modules["__main__"].code_location |
paul@173 | 258 | return self.raw_code |
paul@173 | 259 | |
paul@280 | 260 | def get_object_table(self, reset=0): |
paul@7 | 261 | |
paul@7 | 262 | "Return a table with details of attributes for classes and modules." |
paul@7 | 263 | |
paul@280 | 264 | if self.objtable is None or reset: |
paul@171 | 265 | |
paul@132 | 266 | t = self.objtable = micropython.table.ObjectTable() |
paul@470 | 267 | |
paul@470 | 268 | # First, get all active modules and classes. |
paul@470 | 269 | |
paul@470 | 270 | all_objects = set() |
paul@470 | 271 | |
paul@175 | 272 | for module in self.importer.get_modules(): |
paul@470 | 273 | all_objects.add(module) |
paul@470 | 274 | for obj in module.all_objects: |
paul@470 | 275 | if isinstance(obj, Class): |
paul@470 | 276 | all_objects.add(obj) |
paul@470 | 277 | |
paul@470 | 278 | # Then, visit the modules and classes. |
paul@470 | 279 | |
paul@470 | 280 | for obj in all_objects: |
paul@418 | 281 | |
paul@418 | 282 | # Add module attributes and module identity information. |
paul@418 | 283 | |
paul@470 | 284 | if isinstance(obj, Module): |
paul@470 | 285 | full_name = obj.full_name() |
paul@470 | 286 | attributes = {full_name : obj} |
paul@470 | 287 | attributes.update(obj.module_attributes()) |
paul@470 | 288 | t.add(full_name, attributes) |
paul@135 | 289 | |
paul@135 | 290 | # Add class and instance attributes for all classes, together |
paul@135 | 291 | # with descendant information. |
paul@135 | 292 | |
paul@470 | 293 | elif isinstance(obj, Class): |
paul@470 | 294 | |
paul@470 | 295 | # Prevent ambiguous classes. |
paul@243 | 296 | |
paul@470 | 297 | full_name = obj.full_name() |
paul@243 | 298 | |
paul@470 | 299 | #if obj.module.has_key(name) and obj.module[name].defines_ambiguous_class(): |
paul@470 | 300 | # raise TableGenerationError, "Class %r in module %r is ambiguously defined." % (name, obj.module.full_name()) |
paul@470 | 301 | |
paul@470 | 302 | # Define a table entry for the class. |
paul@243 | 303 | |
paul@470 | 304 | attributes = {full_name : obj} |
paul@470 | 305 | attributes.update(obj.all_attributes()) |
paul@470 | 306 | |
paul@470 | 307 | # Filter out unused classes. |
paul@243 | 308 | |
paul@470 | 309 | for name, descendant in obj.all_descendants().items(): |
paul@470 | 310 | if descendant in all_objects: |
paul@470 | 311 | attributes[name] = descendant |
paul@243 | 312 | |
paul@470 | 313 | t.add(full_name, attributes) |
paul@60 | 314 | |
paul@60 | 315 | return self.objtable |
paul@7 | 316 | |
paul@286 | 317 | def get_parameter_table(self, reset=0): |
paul@7 | 318 | |
paul@7 | 319 | "Return a table with details of parameters for functions and methods." |
paul@7 | 320 | |
paul@60 | 321 | # Need the object table to get at class details. |
paul@60 | 322 | |
paul@286 | 323 | if self.paramtable is None or reset: |
paul@132 | 324 | t = self.paramtable = micropython.table.ParameterTable() |
paul@71 | 325 | |
paul@71 | 326 | # Visit each module, getting function and method details. |
paul@71 | 327 | |
paul@175 | 328 | for module in self.importer.get_modules(): |
paul@60 | 329 | for obj in module.all_objects: |
paul@470 | 330 | if isinstance(obj, Function): |
paul@60 | 331 | t.add(obj.full_name(), obj.parameters()) |
paul@60 | 332 | |
paul@60 | 333 | # Classes are callable, too. |
paul@61 | 334 | # Take details of the appropriate __init__ method to make an |
paul@61 | 335 | # entry for an instantiation function for the class. |
paul@60 | 336 | |
paul@470 | 337 | elif isinstance(obj, Class): |
paul@212 | 338 | t.add(obj.get_instantiator().full_name(), obj.get_instantiator().parameters()) |
paul@60 | 339 | |
paul@71 | 340 | # Filter out all parameter table entries not referenced by keyword |
paul@71 | 341 | # arguments. |
paul@71 | 342 | |
paul@71 | 343 | keyword_names = set() |
paul@71 | 344 | |
paul@175 | 345 | for module in self.importer.get_modules(): |
paul@71 | 346 | keyword_names.update(module.keyword_names) |
paul@71 | 347 | |
paul@71 | 348 | for function_name, parameters in t.table.items(): |
paul@71 | 349 | for name in parameters.keys(): |
paul@71 | 350 | if name in keyword_names: |
paul@71 | 351 | break |
paul@71 | 352 | else: |
paul@71 | 353 | del t.table[function_name] |
paul@71 | 354 | |
paul@60 | 355 | return self.paramtable |
paul@7 | 356 | |
paul@175 | 357 | class Importer: |
paul@175 | 358 | |
paul@175 | 359 | "An import machine, searching for and loading modules." |
paul@175 | 360 | |
paul@175 | 361 | predefined_constants = { |
paul@175 | 362 | "None" : None, |
paul@175 | 363 | "True" : True, |
paul@175 | 364 | "False" : False, |
paul@203 | 365 | #"Ellipsis" : Ellipsis, |
paul@175 | 366 | "NotImplemented" : NotImplemented |
paul@175 | 367 | } |
paul@175 | 368 | |
paul@280 | 369 | names_always_used = [ |
paul@463 | 370 | "__call__" |
paul@280 | 371 | ] |
paul@280 | 372 | |
paul@175 | 373 | def __init__(self, path=None, verbose=0, optimisations=None): |
paul@175 | 374 | |
paul@175 | 375 | """ |
paul@175 | 376 | Initialise the importer with the given search 'path' - a list of |
paul@175 | 377 | directories to search for Python modules. |
paul@175 | 378 | |
paul@175 | 379 | The optional 'verbose' parameter causes output concerning the activities |
paul@175 | 380 | of the object to be produced if set to a true value (not the default). |
paul@175 | 381 | |
paul@175 | 382 | The optional 'optimisations' cause certain techniques to be used in |
paul@175 | 383 | reducing program size and improving program efficiency. |
paul@175 | 384 | """ |
paul@175 | 385 | |
paul@175 | 386 | self.path = path or [os.getcwd()] |
paul@175 | 387 | self.verbose = verbose |
paul@175 | 388 | self.optimisations = optimisations or set() |
paul@175 | 389 | |
paul@175 | 390 | self.modules = {} |
paul@175 | 391 | self.modules_ordered = [] |
paul@175 | 392 | self.loading = set() |
paul@175 | 393 | |
paul@175 | 394 | # Constant records. |
paul@175 | 395 | |
paul@175 | 396 | self.constant_values = {} |
paul@440 | 397 | self.constants_used = set() |
paul@440 | 398 | self.constant_references = {} |
paul@175 | 399 | self.init_predefined_constants() |
paul@175 | 400 | |
paul@280 | 401 | # Attribute usage. |
paul@175 | 402 | |
paul@344 | 403 | self.attributes_used = set() |
paul@250 | 404 | self.name_references = {} |
paul@281 | 405 | self.specific_name_references = {} |
paul@403 | 406 | |
paul@403 | 407 | # Attribute coverage calculated during collection. |
paul@403 | 408 | |
paul@403 | 409 | self.inferred_name_references = {} |
paul@403 | 410 | |
paul@403 | 411 | # Attribute coverage status during collection. |
paul@403 | 412 | |
paul@289 | 413 | self.attribute_users_visited = set() |
paul@345 | 414 | self.attributes_to_visit = {} |
paul@175 | 415 | |
paul@175 | 416 | # Status information. |
paul@175 | 417 | |
paul@175 | 418 | self.vacuumed = 0 |
paul@175 | 419 | self.finalised = 0 |
paul@175 | 420 | |
paul@175 | 421 | def get_modules(self): |
paul@175 | 422 | |
paul@175 | 423 | "Return all modules known to the importer." |
paul@175 | 424 | |
paul@175 | 425 | return self.modules.values() |
paul@175 | 426 | |
paul@228 | 427 | def get_module(self, name): |
paul@228 | 428 | |
paul@228 | 429 | "Return the module with the given 'name'." |
paul@228 | 430 | |
paul@228 | 431 | return self.modules[name] |
paul@228 | 432 | |
paul@175 | 433 | # General maintenance. |
paul@175 | 434 | |
paul@280 | 435 | def vacuum(self, objtable): |
paul@175 | 436 | |
paul@175 | 437 | "Tidy up the modules." |
paul@175 | 438 | |
paul@175 | 439 | if self.vacuumed: |
paul@175 | 440 | return |
paul@175 | 441 | |
paul@280 | 442 | # Complete the list of attribute names used in the program. |
paul@280 | 443 | |
paul@280 | 444 | self.collect_attributes(objtable) |
paul@280 | 445 | |
paul@175 | 446 | for name, module in self.modules.items(): |
paul@175 | 447 | if module.loaded: |
paul@175 | 448 | module.vacuum() |
paul@175 | 449 | else: |
paul@175 | 450 | del self.modules[name] |
paul@175 | 451 | |
paul@175 | 452 | self.vacuumed = 1 |
paul@175 | 453 | |
paul@437 | 454 | def finalise(self, objtable): |
paul@175 | 455 | |
paul@280 | 456 | "Finalise the program (which should have been vacuumed first)." |
paul@175 | 457 | |
paul@175 | 458 | if self.finalised: |
paul@175 | 459 | return |
paul@175 | 460 | |
paul@287 | 461 | # Reset any previously compiled information. |
paul@287 | 462 | |
paul@287 | 463 | for module in self.get_modules(): |
paul@287 | 464 | module.unfinalise() |
paul@287 | 465 | |
paul@287 | 466 | # Prepare module information again. |
paul@287 | 467 | |
paul@175 | 468 | for module in self.get_modules(): |
paul@437 | 469 | module.finalise(objtable) |
paul@175 | 470 | |
paul@175 | 471 | self.finalised = 1 |
paul@175 | 472 | |
paul@175 | 473 | # Name accounting. |
paul@175 | 474 | |
paul@404 | 475 | def use_name(self, name, from_name, value=None): |
paul@250 | 476 | |
paul@250 | 477 | """ |
paul@250 | 478 | Register the given 'name' as being used in the program from within an |
paul@404 | 479 | object with the specified 'from_name'. If the optional 'value' is given, |
paul@404 | 480 | note an assignment. |
paul@250 | 481 | """ |
paul@250 | 482 | |
paul@250 | 483 | if not self.name_references.has_key(from_name): |
paul@250 | 484 | self.name_references[from_name] = set() |
paul@280 | 485 | |
paul@404 | 486 | attrnames = ObjectSet([name]) |
paul@382 | 487 | usage = (attrnames,) |
paul@382 | 488 | self.name_references[from_name].add((None, None, usage)) |
paul@381 | 489 | |
paul@381 | 490 | def use_names(self, user, name, usage, from_name): |
paul@280 | 491 | |
paul@280 | 492 | """ |
paul@381 | 493 | For the given attribute 'user' (which may be None if no specific user is |
paul@381 | 494 | given), register for the given 'name' the given attribute 'usage' |
paul@381 | 495 | (combinations of attribute names), noting the scope of this usage as |
paul@381 | 496 | being the program object with the specified 'from_name'. |
paul@280 | 497 | """ |
paul@280 | 498 | |
paul@280 | 499 | if not self.name_references.has_key(from_name): |
paul@280 | 500 | self.name_references[from_name] = set() |
paul@381 | 501 | |
paul@382 | 502 | self.name_references[from_name].add((user, name, usage)) |
paul@280 | 503 | |
paul@285 | 504 | def use_specific_name(self, objname, attrname, from_name): |
paul@281 | 505 | |
paul@281 | 506 | """ |
paul@285 | 507 | Register the given 'objname' (for an object) whose 'attrname' is being |
paul@285 | 508 | used in the program from within an object with the specified |
paul@285 | 509 | 'from_name'. |
paul@281 | 510 | """ |
paul@281 | 511 | |
paul@281 | 512 | if not self.specific_name_references.has_key(from_name): |
paul@281 | 513 | self.specific_name_references[from_name] = set() |
paul@285 | 514 | self.specific_name_references[from_name].add((objname, attrname)) |
paul@281 | 515 | |
paul@281 | 516 | # Name accounting products. |
paul@281 | 517 | |
paul@344 | 518 | def uses_attribute(self, objname, name): |
paul@250 | 519 | |
paul@280 | 520 | """ |
paul@344 | 521 | Return whether the attribute of the object with the given 'objname' |
paul@344 | 522 | having the given 'name' is used as an attribute in the program. |
paul@280 | 523 | """ |
paul@280 | 524 | |
paul@344 | 525 | return (objname + "." + name) in self.attributes_used |
paul@280 | 526 | |
paul@280 | 527 | def use_attribute(self, objname, name): |
paul@175 | 528 | |
paul@280 | 529 | """ |
paul@280 | 530 | Indicate that in the object with the given 'objname', the attribute of |
paul@280 | 531 | the given 'name' is used. |
paul@280 | 532 | """ |
paul@280 | 533 | |
paul@344 | 534 | self.attributes_used.add(objname + "." + name) |
paul@250 | 535 | |
paul@345 | 536 | def use_object(self, objname): |
paul@345 | 537 | |
paul@345 | 538 | "Indicate that the object with the given 'objname' is used." |
paul@345 | 539 | |
paul@345 | 540 | self.attributes_used.add(objname) |
paul@345 | 541 | |
paul@280 | 542 | def collect_attributes(self, objtable): |
paul@280 | 543 | |
paul@280 | 544 | "Collect attribute references for the entire program." |
paul@280 | 545 | |
paul@345 | 546 | # Include names which may not be explicitly used in programs. |
paul@345 | 547 | # NOTE: Potentially declare these when inspecting. |
paul@345 | 548 | |
paul@345 | 549 | for attrname in self.names_always_used: |
paul@345 | 550 | for objname in objtable.all_possible_objects([attrname]): |
paul@345 | 551 | |
paul@345 | 552 | # Record attributes of objects for potential visiting. |
paul@345 | 553 | |
paul@345 | 554 | self.add_attribute_to_visit(objname, attrname) |
paul@345 | 555 | |
paul@367 | 556 | # Visit all modules, since some may employ initialisation code which has |
paul@367 | 557 | # some kind of side-effect. |
paul@283 | 558 | |
paul@367 | 559 | for name in self.modules.keys(): |
paul@367 | 560 | self._collect_attributes(name, objtable) |
paul@283 | 561 | |
paul@345 | 562 | def add_attribute_to_visit(self, objname, attrname): |
paul@351 | 563 | |
paul@351 | 564 | """ |
paul@351 | 565 | Queue an attribute of the object with the given 'objname', having the |
paul@351 | 566 | given 'attrname', to the list for potential visiting if the specified |
paul@351 | 567 | object is actually referenced. |
paul@351 | 568 | """ |
paul@351 | 569 | |
paul@345 | 570 | if not self.attributes_to_visit.has_key(objname): |
paul@345 | 571 | self.attributes_to_visit[objname] = set() |
paul@345 | 572 | self.attributes_to_visit[objname].add(attrname) |
paul@280 | 573 | |
paul@403 | 574 | def _collect_attributes_from(self, from_name, objname, attrname, objtable): |
paul@403 | 575 | |
paul@403 | 576 | """ |
paul@403 | 577 | Record the association between 'from_name' and the attribute of |
paul@403 | 578 | 'objname' with the given 'attrname'. Then collect attributes for the |
paul@403 | 579 | referenced attribute using 'objtable'. |
paul@403 | 580 | """ |
paul@403 | 581 | |
paul@403 | 582 | if not self.inferred_name_references.has_key(from_name): |
paul@403 | 583 | self.inferred_name_references[from_name] = set() |
paul@403 | 584 | |
paul@403 | 585 | self.inferred_name_references[from_name].add((objname, attrname)) |
paul@403 | 586 | self._collect_attributes(objname + "." + attrname, objtable) |
paul@403 | 587 | |
paul@280 | 588 | def _collect_attributes(self, from_name, objtable): |
paul@250 | 589 | |
paul@280 | 590 | """ |
paul@280 | 591 | Given an object called 'from_name', find all names referenced from such |
paul@403 | 592 | an object according to the register of names, using 'objtable' to infer |
paul@403 | 593 | types. |
paul@280 | 594 | """ |
paul@280 | 595 | |
paul@289 | 596 | if from_name in self.attribute_users_visited: |
paul@280 | 597 | return |
paul@280 | 598 | |
paul@301 | 599 | self.attribute_users_visited.add(from_name) |
paul@301 | 600 | |
paul@440 | 601 | # Get constant references. |
paul@440 | 602 | |
paul@440 | 603 | for const in self.constant_references.get(from_name, []): |
paul@440 | 604 | self.constants_used.add(const) |
paul@440 | 605 | |
paul@416 | 606 | # The getattr function is a special case: it can potentially reference |
paul@416 | 607 | # any known attribute. Since accessor attributes must be known |
paul@416 | 608 | # constants, the intersection of known constants and attributes is used |
paul@416 | 609 | # to build a set of objects that might be referenced by getattr. |
paul@416 | 610 | |
paul@416 | 611 | if from_name == "__builtins__.getattr": |
paul@416 | 612 | all_attributes = set(objtable.attribute_names()) |
paul@416 | 613 | all_string_constants = set([const.get_value() for const in self.constants() if const.value_type_name() == "__builtins__.str"]) |
paul@416 | 614 | all_attribute_constants = all_attributes.intersection(all_string_constants) |
paul@416 | 615 | |
paul@416 | 616 | # Get the types supporting each attribute and visit the referenced |
paul@416 | 617 | # objects. |
paul@416 | 618 | |
paul@416 | 619 | all_objtypes = set() |
paul@416 | 620 | |
paul@416 | 621 | for attrname in all_attribute_constants: |
paul@416 | 622 | objtypes = objtable.any_possible_objects_plus_status([attrname]) |
paul@416 | 623 | all_objtypes.update(objtypes) |
paul@416 | 624 | |
paul@416 | 625 | # Attribute assignment does not take place, so an empty list of |
paul@416 | 626 | # values is given. |
paul@416 | 627 | |
paul@416 | 628 | self._collect_attributes_for_types(from_name, objtable, all_objtypes, |
paul@416 | 629 | [{attrname : []} for attrname in all_attribute_constants]) |
paul@416 | 630 | |
paul@281 | 631 | # Get name references and find possible objects which support such |
paul@281 | 632 | # combinations of attribute names. |
paul@281 | 633 | |
paul@382 | 634 | for user, name, usage in self.name_references.get(from_name, []): |
paul@381 | 635 | |
paul@381 | 636 | # Using all attribute names for a particular name, attempt to get |
paul@381 | 637 | # specific object types. |
paul@381 | 638 | |
paul@437 | 639 | all_objtypes = get_object_types_for_usage(usage, objtable, name, from_name) |
paul@382 | 640 | |
paul@466 | 641 | # Where the name through which the attributes are accessed is the |
paul@466 | 642 | # special "self" name, restrict the possibilities to types |
paul@466 | 643 | # appropriate for the method involved. |
paul@466 | 644 | |
paul@466 | 645 | if name == "self" and user and user.unit and user.unit.is_method(): |
paul@466 | 646 | cls = user.unit.parent |
paul@466 | 647 | descendants = cls.all_descendants() |
paul@466 | 648 | valid_objtypes = [] |
paul@466 | 649 | for objname, is_static in all_objtypes: |
paul@466 | 650 | if objname == cls.full_name() or objname in descendants: |
paul@466 | 651 | valid_objtypes.append((objname, is_static)) |
paul@466 | 652 | else: |
paul@466 | 653 | valid_objtypes = all_objtypes |
paul@466 | 654 | |
paul@437 | 655 | # Investigate the object types. |
paul@420 | 656 | |
paul@466 | 657 | self._collect_attributes_for_types(from_name, objtable, valid_objtypes, usage) |
paul@175 | 658 | |
paul@281 | 659 | # Get specific name references and visit the referenced objects. |
paul@281 | 660 | |
paul@285 | 661 | for objname, attrname in self.specific_name_references.get(from_name, []): |
paul@285 | 662 | self.use_attribute(objname, attrname) |
paul@403 | 663 | self._collect_attributes_from(from_name, objname, attrname, objtable) |
paul@281 | 664 | |
paul@332 | 665 | # Where the object has an __init__ attribute, assume that it is an |
paul@332 | 666 | # initialiser which is called at some point, and collect attributes used |
paul@332 | 667 | # in this initialiser. |
paul@332 | 668 | |
paul@332 | 669 | if "__init__" in objtable.table.get(from_name, []): |
paul@338 | 670 | self.use_attribute(from_name, "__init__") |
paul@403 | 671 | self._collect_attributes_from(from_name, from_name, "__init__", objtable) |
paul@332 | 672 | |
paul@384 | 673 | # Visit attributes on this object that were queued in case of the object |
paul@384 | 674 | # being referenced. |
paul@345 | 675 | |
paul@345 | 676 | attributes_to_visit = self.attributes_to_visit.get(from_name, []) |
paul@345 | 677 | |
paul@345 | 678 | if attributes_to_visit: |
paul@345 | 679 | del self.attributes_to_visit[from_name] |
paul@345 | 680 | |
paul@345 | 681 | for attrname in attributes_to_visit: |
paul@345 | 682 | self.use_attribute(from_name, attrname) |
paul@403 | 683 | self._collect_attributes_from(from_name, from_name, attrname, objtable) |
paul@345 | 684 | |
paul@416 | 685 | def _collect_attributes_for_types(self, from_name, objtable, objtypes, usage): |
paul@416 | 686 | |
paul@416 | 687 | """ |
paul@416 | 688 | For the unit known as 'from_name' and using the 'objtable' to validate |
paul@416 | 689 | each attribute, identify and attempt to visit attributes found for each |
paul@416 | 690 | of the suggested object types given by 'objtypes' and the 'usage' |
paul@416 | 691 | provided. |
paul@416 | 692 | """ |
paul@416 | 693 | |
paul@416 | 694 | for objname, is_static in objtypes: |
paul@416 | 695 | for attrnames in usage: |
paul@416 | 696 | for attrname, attrvalues in attrnames.items(): |
paul@416 | 697 | |
paul@416 | 698 | # Test for the presence of an attribute on the suggested |
paul@416 | 699 | # object type. |
paul@416 | 700 | |
paul@416 | 701 | try: |
paul@416 | 702 | attr = objtable.access(objname, attrname) |
paul@416 | 703 | except TableError: |
paul@416 | 704 | #print "Warning: object type %r does not support attribute %r" % (objname, attrname) |
paul@416 | 705 | continue |
paul@416 | 706 | |
paul@416 | 707 | # Get the real identity of the attribute in order to |
paul@416 | 708 | # properly collect usage from it. |
paul@416 | 709 | |
paul@416 | 710 | parent = attr.parent |
paul@421 | 711 | if parent is None: |
paul@421 | 712 | continue |
paul@470 | 713 | elif isinstance(parent, Instance): |
paul@416 | 714 | parentname = objname |
paul@416 | 715 | else: |
paul@416 | 716 | parentname = parent.full_name() |
paul@416 | 717 | |
paul@416 | 718 | # Test for assignment. |
paul@416 | 719 | |
paul@416 | 720 | if attrvalues: |
paul@427 | 721 | |
paul@427 | 722 | # Instance-related accesses may involve any type |
paul@427 | 723 | # supporting the attribute. |
paul@427 | 724 | # NOTE: Here, an instance actually represents any kind |
paul@427 | 725 | # NOTE: of object. |
paul@427 | 726 | |
paul@470 | 727 | if isinstance(parent, Instance): |
paul@427 | 728 | for attrvalue in attrvalues: |
paul@427 | 729 | for name in objtable.any_possible_objects([attrname]): |
paul@427 | 730 | parent = objtable.access(name, name) |
paul@470 | 731 | if not isinstance(parent, Class) or \ |
paul@444 | 732 | not parent.instance_attributes().has_key(attrname): |
paul@427 | 733 | parent.set(attrname, attrvalue, 0) |
paul@427 | 734 | else: |
paul@427 | 735 | for attrvalue in attrvalues: |
paul@427 | 736 | parent.set(attrname, attrvalue, 0) |
paul@416 | 737 | |
paul@416 | 738 | # Visit attributes of objects known to be used. |
paul@416 | 739 | |
paul@416 | 740 | if parentname in self.attributes_used: |
paul@416 | 741 | self.use_attribute(parentname, attrname) |
paul@416 | 742 | self._collect_attributes_from(from_name, parentname, attrname, objtable) |
paul@416 | 743 | |
paul@416 | 744 | # Record attributes of other objects for potential visiting. |
paul@416 | 745 | |
paul@416 | 746 | else: |
paul@416 | 747 | self.add_attribute_to_visit(parentname, attrname) |
paul@416 | 748 | |
paul@175 | 749 | # Constant accounting. |
paul@175 | 750 | |
paul@440 | 751 | def use_constant(self, const, from_name): |
paul@440 | 752 | |
paul@440 | 753 | """ |
paul@440 | 754 | Register the given 'const' as being used in the program from within an |
paul@440 | 755 | object with the specified 'from_name'. |
paul@440 | 756 | """ |
paul@440 | 757 | |
paul@440 | 758 | if not self.constant_references.has_key(from_name): |
paul@440 | 759 | self.constant_references[from_name] = set() |
paul@440 | 760 | |
paul@440 | 761 | self.constant_references[from_name].add(const) |
paul@440 | 762 | |
paul@175 | 763 | def init_predefined_constants(self): |
paul@175 | 764 | |
paul@175 | 765 | "Ensure the predefined constants." |
paul@175 | 766 | |
paul@175 | 767 | for name, value in self.predefined_constants.items(): |
paul@440 | 768 | self.constants_used.add(self.make_constant(value)) |
paul@175 | 769 | |
paul@175 | 770 | def get_predefined_constant(self, name): |
paul@175 | 771 | |
paul@175 | 772 | "Return the predefined constant for the given 'name'." |
paul@175 | 773 | |
paul@175 | 774 | return self.make_constant(self.predefined_constants[name]) |
paul@175 | 775 | |
paul@175 | 776 | def get_constant(self, value): |
paul@175 | 777 | |
paul@175 | 778 | "Return a constant for the given 'value'." |
paul@175 | 779 | |
paul@470 | 780 | const = Const(value) |
paul@176 | 781 | return self.constant_values[const] |
paul@175 | 782 | |
paul@252 | 783 | def get_constant_type_name(self, value): |
paul@415 | 784 | |
paul@415 | 785 | "Return the type name for the given constant 'value'." |
paul@415 | 786 | |
paul@252 | 787 | return value.__class__.__name__ |
paul@252 | 788 | |
paul@175 | 789 | def make_constant(self, value): |
paul@175 | 790 | |
paul@175 | 791 | "Make and return a constant for the given 'value'." |
paul@175 | 792 | |
paul@219 | 793 | # Make a constant object and return it. |
paul@219 | 794 | |
paul@470 | 795 | const = Const(value) |
paul@176 | 796 | if not self.constant_values.has_key(const): |
paul@176 | 797 | self.constant_values[const] = const |
paul@176 | 798 | return self.constant_values[const] |
paul@175 | 799 | |
paul@175 | 800 | def constants(self): |
paul@175 | 801 | |
paul@175 | 802 | "Return a list of constants." |
paul@175 | 803 | |
paul@440 | 804 | return self.constants_used |
paul@175 | 805 | |
paul@9 | 806 | # Import methods. |
paul@9 | 807 | |
paul@0 | 808 | def find_in_path(self, name): |
paul@0 | 809 | |
paul@0 | 810 | """ |
paul@0 | 811 | Find the given module 'name' in the search path, returning None where no |
paul@0 | 812 | such module could be found, or a 2-tuple from the 'find' method |
paul@0 | 813 | otherwise. |
paul@0 | 814 | """ |
paul@0 | 815 | |
paul@0 | 816 | for d in self.path: |
paul@0 | 817 | m = self.find(d, name) |
paul@0 | 818 | if m: return m |
paul@0 | 819 | return None |
paul@0 | 820 | |
paul@0 | 821 | def find(self, d, name): |
paul@0 | 822 | |
paul@0 | 823 | """ |
paul@0 | 824 | In the directory 'd', find the given module 'name', where 'name' can |
paul@0 | 825 | either refer to a single file module or to a package. Return None if the |
paul@0 | 826 | 'name' cannot be associated with either a file or a package directory, |
paul@0 | 827 | or a 2-tuple from '_find_package' or '_find_module' otherwise. |
paul@0 | 828 | """ |
paul@0 | 829 | |
paul@0 | 830 | m = self._find_package(d, name) |
paul@0 | 831 | if m: return m |
paul@0 | 832 | m = self._find_module(d, name) |
paul@0 | 833 | if m: return m |
paul@0 | 834 | return None |
paul@0 | 835 | |
paul@0 | 836 | def _find_module(self, d, name): |
paul@0 | 837 | |
paul@0 | 838 | """ |
paul@0 | 839 | In the directory 'd', find the given module 'name', returning None where |
paul@0 | 840 | no suitable file exists in the directory, or a 2-tuple consisting of |
paul@0 | 841 | None (indicating that no package directory is involved) and a filename |
paul@0 | 842 | indicating the location of the module. |
paul@0 | 843 | """ |
paul@0 | 844 | |
paul@0 | 845 | name_py = name + os.extsep + "py" |
paul@0 | 846 | filename = self._find_file(d, name_py) |
paul@0 | 847 | if filename: |
paul@0 | 848 | return None, filename |
paul@0 | 849 | return None |
paul@0 | 850 | |
paul@0 | 851 | def _find_package(self, d, name): |
paul@0 | 852 | |
paul@0 | 853 | """ |
paul@0 | 854 | In the directory 'd', find the given package 'name', returning None |
paul@0 | 855 | where no suitable package directory exists, or a 2-tuple consisting of |
paul@0 | 856 | a directory (indicating the location of the package directory itself) |
paul@0 | 857 | and a filename indicating the location of the __init__.py module which |
paul@0 | 858 | declares the package's top-level contents. |
paul@0 | 859 | """ |
paul@0 | 860 | |
paul@0 | 861 | filename = self._find_file(d, name) |
paul@0 | 862 | if filename: |
paul@0 | 863 | init_py = "__init__" + os.path.extsep + "py" |
paul@0 | 864 | init_py_filename = self._find_file(filename, init_py) |
paul@0 | 865 | if init_py_filename: |
paul@0 | 866 | return filename, init_py_filename |
paul@0 | 867 | return None |
paul@0 | 868 | |
paul@0 | 869 | def _find_file(self, d, filename): |
paul@0 | 870 | |
paul@0 | 871 | """ |
paul@0 | 872 | Return the filename obtained when searching the directory 'd' for the |
paul@0 | 873 | given 'filename', or None if no actual file exists for the filename. |
paul@0 | 874 | """ |
paul@0 | 875 | |
paul@0 | 876 | filename = os.path.join(d, filename) |
paul@0 | 877 | if os.path.exists(filename): |
paul@0 | 878 | return filename |
paul@0 | 879 | else: |
paul@0 | 880 | return None |
paul@0 | 881 | |
paul@0 | 882 | def load(self, name, return_leaf=0): |
paul@0 | 883 | |
paul@0 | 884 | """ |
paul@0 | 885 | Load the module or package with the given 'name'. Return an object |
paul@0 | 886 | referencing the loaded module or package, or None if no such module or |
paul@0 | 887 | package exists. |
paul@0 | 888 | """ |
paul@0 | 889 | |
paul@363 | 890 | if return_leaf: |
paul@363 | 891 | name_for_return = name |
paul@363 | 892 | else: |
paul@363 | 893 | name_for_return = name.split(".")[0] |
paul@363 | 894 | |
paul@4 | 895 | if self.modules.has_key(name) and self.modules[name].loaded: |
paul@4 | 896 | #print "Cached (%s)" % name |
paul@363 | 897 | return self.modules[name_for_return] |
paul@363 | 898 | |
paul@35 | 899 | if self.verbose: |
paul@35 | 900 | print "Loading", name |
paul@0 | 901 | |
paul@0 | 902 | # Split the name into path components, and try to find the uppermost in |
paul@0 | 903 | # the search path. |
paul@0 | 904 | |
paul@0 | 905 | path = name.split(".") |
paul@0 | 906 | m = self.find_in_path(path[0]) |
paul@0 | 907 | if not m: |
paul@35 | 908 | if self.verbose: |
paul@35 | 909 | print "Not found (%s)" % path[0] |
paul@0 | 910 | return None # NOTE: Import error. |
paul@0 | 911 | d, filename = m |
paul@0 | 912 | |
paul@0 | 913 | # Either acquire a reference to an already-imported module, or load the |
paul@0 | 914 | # module from a file. |
paul@0 | 915 | |
paul@2 | 916 | top = module = self.load_from_file(filename, path[0]) |
paul@0 | 917 | |
paul@0 | 918 | # For hierarchical names, traverse each path component... |
paul@0 | 919 | |
paul@0 | 920 | if len(path) > 1: |
paul@0 | 921 | if not d: |
paul@35 | 922 | if self.verbose: |
paul@35 | 923 | print "No package (%s)" % filename |
paul@0 | 924 | return None # NOTE: Import error (package not found). |
paul@1 | 925 | else: |
paul@1 | 926 | self.add_submodules(d, module) |
paul@0 | 927 | |
paul@0 | 928 | path_so_far = path[:1] |
paul@0 | 929 | for p in path[1:]: |
paul@0 | 930 | path_so_far.append(p) |
paul@0 | 931 | |
paul@0 | 932 | # Find the package or module concerned. |
paul@0 | 933 | |
paul@0 | 934 | m = self.find(d, p) |
paul@0 | 935 | if not m: |
paul@35 | 936 | if self.verbose: |
paul@35 | 937 | print "Not found (%s)" % p |
paul@0 | 938 | return None # NOTE: Import error. |
paul@0 | 939 | d, filename = m |
paul@0 | 940 | module_name = ".".join(path_so_far) |
paul@0 | 941 | |
paul@0 | 942 | # Either reference an imported module or load one from a file. |
paul@0 | 943 | |
paul@2 | 944 | submodule = self.load_from_file(filename, module_name) |
paul@0 | 945 | |
paul@1 | 946 | if d: |
paul@1 | 947 | self.add_submodules(d, module) |
paul@1 | 948 | |
paul@0 | 949 | # Store the submodule within its parent module. |
paul@0 | 950 | |
paul@32 | 951 | module.set_module(p, submodule) |
paul@0 | 952 | module = submodule |
paul@0 | 953 | |
paul@0 | 954 | # Return either the deepest or the uppermost module. |
paul@0 | 955 | |
paul@0 | 956 | if return_leaf: |
paul@0 | 957 | return module |
paul@0 | 958 | else: |
paul@0 | 959 | return top |
paul@0 | 960 | |
paul@0 | 961 | def load_from_file(self, name, module_name=None): |
paul@0 | 962 | |
paul@0 | 963 | """ |
paul@0 | 964 | Load the module with the given 'name' (which may be a full module path). |
paul@0 | 965 | """ |
paul@0 | 966 | |
paul@0 | 967 | if module_name is None: |
paul@0 | 968 | module_name = "__main__" |
paul@0 | 969 | |
paul@1 | 970 | module = self.add_module(module_name) |
paul@2 | 971 | if not module.loaded and module not in self.loading: |
paul@2 | 972 | self.loading.add(module) |
paul@4 | 973 | #print "Parsing", name |
paul@2 | 974 | module.parse(name) |
paul@4 | 975 | #print "Done", name |
paul@2 | 976 | self.loading.remove(module) |
paul@2 | 977 | module.loaded = 1 |
paul@0 | 978 | |
paul@0 | 979 | # Record the module. |
paul@0 | 980 | |
paul@345 | 981 | self.use_object(module.full_name()) |
paul@4 | 982 | #print "Loaded", module_name, "with namespace", module.namespace.keys() |
paul@0 | 983 | return module |
paul@0 | 984 | |
paul@1 | 985 | def add_module(self, module_name): |
paul@1 | 986 | |
paul@1 | 987 | """ |
paul@1 | 988 | Return the module with the given 'module_name', adding a new module |
paul@1 | 989 | object if one does not already exist. |
paul@1 | 990 | """ |
paul@1 | 991 | |
paul@1 | 992 | if not self.modules.has_key(module_name): |
paul@15 | 993 | self.modules[module_name] = module = micropython.inspect.InspectedModule(module_name, self) |
paul@128 | 994 | self.modules_ordered.append(module) |
paul@1 | 995 | else: |
paul@1 | 996 | module = self.modules[module_name] |
paul@1 | 997 | return module |
paul@1 | 998 | |
paul@1 | 999 | def add_submodules(self, pathname, module): |
paul@1 | 1000 | |
paul@1 | 1001 | """ |
paul@1 | 1002 | Work around insufficient __all__ declarations and examine the directory |
paul@1 | 1003 | with the given 'pathname', adding submodules to the given 'module'. |
paul@1 | 1004 | """ |
paul@1 | 1005 | |
paul@1 | 1006 | for filename in os.listdir(pathname): |
paul@50 | 1007 | submodule, ext = os.path.splitext(filename) |
paul@50 | 1008 | if ext not in ("", ".py"): |
paul@50 | 1009 | continue |
paul@32 | 1010 | module.set_module(submodule, self.add_module(module.name + "." + submodule)) |
paul@1 | 1011 | |
paul@0 | 1012 | # vim: tabstop=4 expandtab shiftwidth=4 |