lua-users home
lua-l archive

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


Hi,

I have been playing around with a NaN tagging approach for which I
need to amend TValue structure - the tt_ field is no longer an int,
but is a union of double & a struct. From my preliminary testing the
changes I have made seem to work but I wanted to double check my
understanding here:

The various macros in lobject.h for setting value and type, checking
if a type is a given type, or extracting the value component from
TValue - these are the only ways in which Lua ever manipulates a
TValue object. So changing these macros as I have done, is all that is
needed to support a modified TValue component. I guess I am trying to
understand if there are hidden assumptions elsewhere in the code that
assumes that TValue has a particular structure.

Another observation while making the changes:

There are a couple of macros later on in lobject.h which directly
access the tt_ element in TValue rather than using settt_() and
rttype() - should these be changed to use the macros instead as below:

#define setuservalue(L,u,o) \
{ const TValue *io=(o); Udata *iu = (u); \
 iu->user_ = io->value_; iu->ttuv_ = rttype(io); \
 checkliveness(G(L),io); }


#define getuservalue(L,u,o) \
{ TValue *io=(o); const Udata *iu = (u); \
 io->value_ = iu->user_; settt_(io, iu->ttuv_); \
 checkliveness(G(L),io); }


Thanks and Regards
Dibyendu