Leopold Toetsch <[EMAIL PROTECTED]> wrote:
> Sam Ruby <[EMAIL PROTECTED]> wrote:

>> How should the following be handled:

>>    f = "parrot".index

> The CPython code is:

>   1           0 LOAD_CONST               0 ('parrot')
>               3 LOAD_ATTR                0 (index)
>               6 STORE_NAME               1 (f)

> The interesting thing is hidden in LOAD_ATTR. It seems that it creates a
> call stub for the given (object, method) pair.

Thinking a bit further about that: we have one part of the method call,
i.e. the method lookup thingy:

  str = new String
  str = "parrot"
  meth = find_method str, "index"       # [1]

Now we'd have to associate the invocable PMC with the object, e.g.

  assign meth, str         # set an object slot inside the invocable

or maybe more explicit with a distinct PMC class:

  func = new MethStub, meth    # create a new PMC for invocable meth
  assign func, object          # associate object with it

Calling this PMC then has to shift up arguments by one and place the
remembered object as current_invocant and P5.

[1] The find_method is probaly just getattribute or whatever the HLL
compiler emits.

Comments?

leo

Reply via email to