lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Sat, Oct 07, 2006 at 05:19:10PM +1000, Nick Gammon wrote:
> From the code it looks to me like it actually looks to see if the  
> most recent instruction (Pcode) is something to do with "push self"  
> so I don't think playing with the stack will do it.

That's how it gets the namewhat "method" string, by looking at how the
function was called.  I'm talking about adding a hint in the stack at
the point the value was removed, so when we see that "method" value,
we can find out whether it was a regular method call (and self is
there), or whether it's our binding and we took self out.  Then we
know whether we need to adjust "narg" or not.

Alternatively, lua_getinfo could detect this, and for function calls
that were made as a method call but had self removed, return "field".
Then, "x:foo(1)" would look like "x.foo(x,1)" to luaL_argerror
after self is removed.  (Note that the OP_GETTABLE and OP_SELF,
which I assume are "x.foo()" and "x:foo()" respectively, are identical
except for the returned string.)

-- 
Glenn Maynard