1.1 --- a/micropython/rsvp.py Sun Feb 20 19:31:50 2011 +0100
1.2 +++ b/micropython/rsvp.py Fri Feb 25 01:45:02 2011 +0100
1.3 @@ -158,6 +158,10 @@
1.4 item = self.item
1.5 classcode = objtable.as_list().get_code(item.value_type_name())
1.6 attrcode = objtable.get_index(item.value_type_name())
1.7 + name_parts = item.value_type_name_parts()
1.8 + attr = objtable.access(*name_parts)
1.9 + cls = attr.get_value()
1.10 +
1.11 return [
1.12 DataObject(
1.13 classcode,
1.14 @@ -171,7 +175,7 @@
1.15
1.16 DataValue(
1.17 PlaceholderContext,
1.18 - item.location
1.19 + cls.location
1.20 )
1.21
1.22 # NOTE: The RSVP library needs changing if more attributes are added
1.23 @@ -202,23 +206,27 @@
1.24 if not self.is_generated(with_builtins):
1.25 item.code_location = item.full_name()
1.26
1.27 - # Skip any defaults for static functions.
1.28 + # Skip __class__ plus any defaults for static functions.
1.29
1.30 elif not item.is_dynamic():
1.31 - item.code_location = location + len(item.defaults)
1.32 + item.code_location = location + 1 + len(item.defaults)
1.33
1.34 - # Skip any defaults for dynamic functions.
1.35 + # Skip __class__ plus any defaults for dynamic functions.
1.36
1.37 else:
1.38 - item.code_location = location
1.39 + item.code_location = location + 1
1.40
1.41 - return location
1.42 + # Include the __class__ attribute.
1.43 +
1.44 + return location + 1
1.45
1.46 def finalise_location(self, with_builtins):
1.47 self._finalise_location(with_builtins)
1.48
1.49 def as_raw(self, objtable, paramtable, with_builtins):
1.50 item = self.item
1.51 + attr = objtable.access("__builtins__", "function")
1.52 + cls = attr.get_value()
1.53 # NOTE: Need class and parameter details! Should arguably be an instance of types.FunctionType.
1.54 return [
1.55 DataObject(
1.56 @@ -228,6 +236,13 @@
1.57 "__builtins__.function",
1.58 len(item.defaults) + 1, # size (not accurate for lambda functions before instantiation)
1.59 paramtable.as_list().get_code(item.full_name()) # funccode
1.60 + ),
1.61 +
1.62 + # The __class__ attribute for functions.
1.63 +
1.64 + DataValue(
1.65 + PlaceholderContext,
1.66 + cls.location
1.67 )
1.68 ]
1.69