# HG changeset patch # User Paul Boddie # Date 1304981304 -7200 # Node ID 18c62608bfa6ef381fb391afd76a07ae9da0af2f # Parent 6e610d3058f183bc0418c6fcfe8e9bc1cf0f8bf5 Added module identity information to the object table. This permits testing for module object types in guards. diff -r 6e610d3058f1 -r 18c62608bfa6 TO_DO.txt --- a/TO_DO.txt Mon May 09 00:56:35 2011 +0200 +++ b/TO_DO.txt Tue May 10 00:48:24 2011 +0200 @@ -4,8 +4,6 @@ Verify that the context information is correctly set, particularly for the unoptimised cases. - Allow module types to be tested in guards. - Update docs/assignment.txt. Dynamic Attribute Access diff -r 6e610d3058f1 -r 18c62608bfa6 micropython/__init__.py --- a/micropython/__init__.py Mon May 09 00:56:35 2011 +0200 +++ b/micropython/__init__.py Tue May 10 00:48:24 2011 +0200 @@ -265,7 +265,13 @@ t = self.objtable = micropython.table.ObjectTable() for module in self.importer.get_modules(): - t.add(module.full_name(), module.module_attributes()) + + # Add module attributes and module identity information. + + full_name = module.full_name() + attributes = {full_name : module} + attributes.update(module.module_attributes()) + t.add(full_name, attributes) # Add class and instance attributes for all classes, together # with descendant information. @@ -276,8 +282,8 @@ # Prevent ambiguous classes. full_name = obj.full_name() - name = obj.name + #name = obj.name #if module.has_key(name) and module[name].defines_ambiguous_class(): # raise TableGenerationError, "Class %r in module %r is ambiguously defined." % (name, module.full_name()) diff -r 6e610d3058f1 -r 18c62608bfa6 micropython/table.py --- a/micropython/table.py Mon May 09 00:56:35 2011 +0200 +++ b/micropython/table.py Tue May 10 00:48:24 2011 +0200 @@ -172,7 +172,7 @@ # Support descendants. - if isinstance(attr, Class): + if isinstance(attr, (Class, Module)): return (attr_index, None, None) # Get the absolute location for classes and modules.