1.1 --- a/docs/concepts.txt Mon Jul 01 12:57:30 2013 +0200
1.2 +++ b/docs/concepts.txt Tue Jul 02 00:51:04 2013 +0200
1.3 @@ -308,11 +308,11 @@
1.4
1.5 This could be given instead as follows:
1.6
1.7 - attrcode, is-class-or-module, location
1.8 + attrcode, is-class-or-module-attribute, location
1.9
1.10 -Since uses-absolute-address corresponds to is-class-or-module, and since there
1.11 -is a need to test for classes and modules to prevent assignment to attributes
1.12 -of such objects, this particular information is always required.
1.13 +Since uses-absolute-address corresponds to is-class-or-module-attribute, and
1.14 +since there is a need to test for classes and modules to prevent assignment to
1.15 +attributes of such objects, this particular information is always required.
1.16
1.17 The __class__ Attribute
1.18 -----------------------
2.1 --- a/micropython/basicdata.py Mon Jul 01 12:57:30 2013 +0200
2.2 +++ b/micropython/basicdata.py Tue Jul 02 00:51:04 2013 +0200
2.3 @@ -3,7 +3,7 @@
2.4 """
2.5 Fundamental program data structure abstractions.
2.6
2.7 -Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 Paul Boddie <paul@boddie.org.uk>
2.8 +Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Paul Boddie <paul@boddie.org.uk>
2.9
2.10 This program is free software; you can redistribute it and/or modify it under
2.11 the terms of the GNU General Public License as published by the Free Software
2.12 @@ -70,10 +70,6 @@
2.13 def __init__(self):
2.14 self.parent = None
2.15
2.16 - # Image generation details.
2.17 -
2.18 - self.location = None
2.19 -
2.20 def __repr__(self):
2.21 return "<instance>"
2.22
2.23 @@ -109,10 +105,7 @@
2.24 return self.value
2.25
2.26 def __repr__(self):
2.27 - if self.location is not None:
2.28 - return "Const(%r, location=%r)" % (self.value, self.location)
2.29 - else:
2.30 - return "Const(%r)" % self.value
2.31 + return "Const(%r)" % self.value
2.32
2.33 __shortrepr__ = __repr__
2.34
3.1 --- a/micropython/data.py Mon Jul 01 12:57:30 2013 +0200
3.2 +++ b/micropython/data.py Tue Jul 02 00:51:04 2013 +0200
3.3 @@ -582,17 +582,9 @@
3.4
3.5 self.reset_caches()
3.6
3.7 - # Image generation details.
3.8 -
3.9 - self.location = None
3.10 - self.code_location = None
3.11 - self.code_body_location = None # corresponds to the instantiator
3.12 + # Program-related details.
3.13
3.14 self.instantiator = None
3.15 - self.instance_template_location = None # for creating instances at run-time
3.16 -
3.17 - # Program-related details.
3.18 -
3.19 self.blocks = None
3.20 self.temp_usage = 0
3.21 self.local_usage = 0
3.22 @@ -622,10 +614,7 @@
3.23 self.allattr_names = None # from allattr
3.24
3.25 def __repr__(self):
3.26 - if self.location is not None:
3.27 - return "<class %s (at %r)>" % (shortrepr(self), self.location)
3.28 - else:
3.29 - return "<class %s>" % shortrepr(self)
3.30 + return "<class %s>" % shortrepr(self)
3.31
3.32 def __shortrepr__(self):
3.33 return "%s.%s" % (shortrepr(self.parent), self.name)
3.34 @@ -823,6 +812,14 @@
3.35 self.finalise_instance_attributes()
3.36 return self.all_instattr
3.37
3.38 + def instance_attributes_as_list(self):
3.39 +
3.40 + "Return instance-only attributes in a list ordered by position."
3.41 +
3.42 + attrs = self.instance_attributes().values()
3.43 + attrs.sort(cmp=lambda x, y: cmp(x.position, y.position))
3.44 + return attrs
3.45 +
3.46 def finalise_instance_attributes(self):
3.47
3.48 "Make sure that the instance attributes are fully defined."
3.49 @@ -1042,9 +1039,6 @@
3.50 # Image generation details.
3.51
3.52 self.dynamic = None
3.53 - self.location = None
3.54 - self.code_location = None
3.55 - self.code_body_location = None
3.56
3.57 # Program-related details.
3.58
3.59 @@ -1076,12 +1070,7 @@
3.60 return l
3.61
3.62 def __repr__(self):
3.63 - if self.location is not None:
3.64 - return "<function %s (at %r, code at %r)>" % (
3.65 - shortrepr(self), self.location, self.code_location
3.66 - )
3.67 - else:
3.68 - return "<function %s>" % shortrepr(self)
3.69 + return "<function %s>" % shortrepr(self)
3.70
3.71 def __shortrepr__(self):
3.72 return "%s.%s(%s)" % (shortrepr(self.parent), self.name, ", ".join(self.argnames))
3.73 @@ -1349,11 +1338,6 @@
3.74
3.75 self.keyword_names = set()
3.76
3.77 - # Image generation details.
3.78 -
3.79 - self.location = None
3.80 - self.code_location = None
3.81 -
3.82 # Program-related details.
3.83
3.84 self.blocks = None
3.85 @@ -1365,10 +1349,7 @@
3.86 return self.name
3.87
3.88 def __repr__(self):
3.89 - if self.location is not None:
3.90 - return "<module %s (at %r)>" % (self.name, self.location)
3.91 - else:
3.92 - return "<module %s>" % shortrepr(self)
3.93 + return "<module %s>" % shortrepr(self)
3.94
3.95 def __shortrepr__(self):
3.96 return self.name
4.1 --- a/micropython/report.py Mon Jul 01 12:57:30 2013 +0200
4.2 +++ b/micropython/report.py Tue Jul 02 00:51:04 2013 +0200
4.3 @@ -568,8 +568,7 @@
4.4
4.5 # ...and instance attribute names in order...
4.6
4.7 - attrs = obj.instance_attributes().values()
4.8 - attrs.sort(cmp=lambda x, y: cmp(x.position, y.position))
4.9 + attrs = obj.instance_attributes_as_list()
4.10
4.11 if attrs:
4.12 for attr in attrs:
4.13 @@ -582,8 +581,7 @@
4.14
4.15 # ...and class attribute names in order.
4.16
4.17 - attrs = obj.class_attributes().values()
4.18 - attrs.sort(cmp=lambda x, y: cmp(x.position, y.position))
4.19 + attrs = obj.attributes_as_list()
4.20
4.21 if attrs:
4.22 for attr in attrs:
5.1 --- a/micropython/syspython.py Mon Jul 01 12:57:30 2013 +0200
5.2 +++ b/micropython/syspython.py Tue Jul 02 00:51:04 2013 +0200
5.3 @@ -96,7 +96,7 @@
5.4 globalnames = module.module_attribute_names() and [
5.5 compiler.ast.CallFunc(
5.6 special_name("__globalnames__"),
5.7 - [special_name(name) for name in module.module_attribute_names()]
5.8 + [special_name(attr.name) for attr in module.attributes_as_list()]
5.9 )
5.10 ] or []
5.11
5.12 @@ -163,14 +163,14 @@
5.13 instattrs = cls.instance_attribute_names() and [
5.14 compiler.ast.CallFunc(
5.15 special_name("__instattrs__"),
5.16 - [special_name(name) for name in cls.instance_attribute_names()]
5.17 + [special_name(attr.name) for attr in cls.instance_attributes_as_list()]
5.18 )
5.19 ] or []
5.20
5.21 clsattrs = cls.class_attribute_names() and [
5.22 compiler.ast.CallFunc(
5.23 special_name("__clsattrs__"),
5.24 - [special_name(name) for name in cls.class_attribute_names()]
5.25 + [special_name(attr.name) for attr in cls.attributes_as_list()]
5.26 )
5.27 ] or []
5.28
6.1 --- a/micropython/table.py Mon Jul 01 12:57:30 2013 +0200
6.2 +++ b/micropython/table.py Tue Jul 02 00:51:04 2013 +0200
6.3 @@ -175,21 +175,9 @@
6.4 if isinstance(attr, (Class, Module)):
6.5 return (attr_index, None, None)
6.6
6.7 - # Get the absolute location for classes and modules.
6.8 -
6.9 - if attr.parent is not None and attr.is_static_attribute():
6.10 - location = attr.parent.location or 0
6.11 - else:
6.12 - location = 0
6.13 + # Attribute index/code, attribute type, position in structure.
6.14
6.15 - if attr.position is not None:
6.16 - position = attr.position + location + 1 # skip structure header
6.17 - else:
6.18 - position = None # NOTE: Should fix unpositioned attributes.
6.19 -
6.20 - # Attribute index/code, attribute type, location/position.
6.21 -
6.22 - return (attr_index, attr.is_static_attribute(), position)
6.23 + return (attr_index, attr.is_static_attribute(), attr.position)
6.24
6.25 class ParameterList(List):
6.26