# HG changeset patch # User Paul Boddie # Date 1352068282 -3600 # Node ID 255903924256a7602f0b7e0cd50f384587e24344 # Parent 1788ce04ced0b4448f5e0313e38acea37dab530b Introduced pre-made classes for various built-in types supporting constants. Removed the subclasses of Class, since no distinction was being made between them. diff -r 1788ce04ced0 -r 255903924256 micropython/data.py --- a/micropython/data.py Sat Nov 03 00:35:47 2012 +0100 +++ b/micropython/data.py Sun Nov 04 23:31:22 2012 +0100 @@ -493,7 +493,7 @@ # Collect unfinished contributors and affected nodes. - # Where the contributor is already set to None, a loop has + # Where the contributor is already set to Unset, a loop has # occurred and this node will need to have its usage # recalculated later for the unfinished contributor. @@ -1656,18 +1656,6 @@ self.allattr[name] = attr return self.allattr -class TypeClass(Class): - - "A special class for the type class." - - pass - -class CommonClass(Class): - - "An inspected class." - - pass - class Function(NamespaceDict, Naming, Constant): "An inspected function." @@ -2150,9 +2138,18 @@ else: self.importer.use_name(attrname, self.full_name(), value) -# Pre-made instances. - -type_class = TypeClass("type") # details to be filled in later +# Pre-made class instances. +# For each of these, their details will be filled in later. + +premade = { + "bool" : Class("bool"), + "float" : Class("float"), + "int" : Class("int"), + "long" : Class("long"), + "str" : Class("str"), + "unicode" : Class("unicode"), + "type" : Class("type"), + } # Class construction. @@ -2163,11 +2160,12 @@ 'module' and 'node'. """ - if name == "type" and module.full_name() == "__builtins__": - type_class.set_context(parent, module, node) - return type_class + if premade.has_key(name) and module.full_name() == "__builtins__": + cls = premade[name] + cls.set_context(parent, module, node) + return cls else: - return CommonClass(name, parent, module, node) + return Class(name, parent, module, node) # Lambda sequence numbering.