# HG changeset patch # User Paul Boddie # Date 1234138182 -3600 # Node ID 41f297e7800c84f4607e5b351d86922c290e2b0d # Parent 0442304c5adacc0f04064dfc0708d62e529baaab Speculative adjustment to contexts associated with new instances. Added a more advanced test of instance calling. diff -r 0442304c5ada -r 41f297e7800c docs/structures.txt --- a/docs/structures.txt Sun Feb 08 23:48:47 2009 +0100 +++ b/docs/structures.txt Mon Feb 09 01:09:42 2009 +0100 @@ -13,8 +13,28 @@ object context reference reference -Values and Contexts -------------------- +Such values are used as the stored representations of attributes (of classes, +instances, modules, and other objects supporting attribute-like entities) as +well as the stored values associated with names in functions and methods. + +Stored Values and Contexts +-------------------------- + +In a program image, generated attribute data will employ values, and these +values will generally have the following context definitions according to the +type of the referenced objects: + + Referenced Object Type Context + ---------------------- ------- + + Function None + + Method Parent object (class) + + Class None + +Value and Context Transformations +--------------------------------- Values are acquired through name lookups and attribute access, yielding the appropriate object reference together with a context reference as diff -r 0442304c5ada -r 41f297e7800c rsvp.py --- a/rsvp.py Sun Feb 08 23:48:47 2009 +0100 +++ b/rsvp.py Mon Feb 09 01:09:42 2009 +0100 @@ -332,7 +332,7 @@ # NOTE: Referencing the instance template. addr = self._MakeObject(size, ref - 1) # Introduce object as context for the new object. - self.value = None, addr + self.value = addr, addr def LoadAttr(self): context, ref = self.value diff -r 0442304c5ada -r 41f297e7800c tests/call_instance2.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/call_instance2.py Mon Feb 09 01:09:42 2009 +0100 @@ -0,0 +1,15 @@ +#!/usr/bin/env python + +class C: + def __call__(self): + return "called" + +class D: + def __init__(self, x): + self.x = x + +c = C() +d = D(c) +d.x() + +# vim: tabstop=4 expandtab shiftwidth=4