1.1 --- a/micropython/__init__.py Wed Feb 06 01:28:11 2008 +0100
1.2 +++ b/micropython/__init__.py Sat Feb 09 02:35:57 2008 +0100
1.3 @@ -42,6 +42,8 @@
1.4 except NameError:
1.5 from sets import Set as set
1.6
1.7 +InspectError = micropython.inspect.InspectError
1.8 +
1.9 class Importer:
1.10
1.11 "An import machine, searching for and loading modules."
1.12 @@ -94,11 +96,6 @@
1.13 module.location = pos
1.14 trans = micropython.ast.Translation(module, objtable, paramtable)
1.15
1.16 - # Add header details.
1.17 -
1.18 - image.append(module)
1.19 - pos += 1
1.20 -
1.21 # Append constants to the image.
1.22
1.23 for const in module.constants():
1.24 @@ -106,14 +103,16 @@
1.25 image.append(const)
1.26 pos += 1
1.27
1.28 + # Add header details.
1.29 +
1.30 + image.append(module)
1.31 + pos += 1
1.32 +
1.33 # Append module attributes to the image.
1.34
1.35 attributes = module.module_attributes()
1.36 -
1.37 - for name in module.module_attribute_names():
1.38 - attr = attributes[name]
1.39 - image.append(attr)
1.40 - pos += 1
1.41 + image += module.to_list(attributes)
1.42 + pos += len(attributes.keys())
1.43
1.44 # Append classes and functions to the image.
1.45
1.46 @@ -132,11 +131,8 @@
1.47 # Append class attributes to the image.
1.48
1.49 attributes = obj.class_attributes()
1.50 -
1.51 - for name in obj.class_attribute_names():
1.52 - attr = attributes[name]
1.53 - image.append(attr)
1.54 - pos += 1
1.55 + image += module.to_list(attributes)
1.56 + pos += len(attributes.keys())
1.57
1.58 # Append the class-level code to the image.
1.59 # NOTE: An extra optimisation would involve
1.60 @@ -145,7 +141,7 @@
1.61 # NOTE: methods and only other attribute-related code being
1.62 # NOTE: generated here.
1.63
1.64 - obj.code_location = obj.location = pos
1.65 + obj.code_location = pos
1.66 code = trans.get_code(obj)
1.67 image += code
1.68 pos += len(code)