[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.3.0 (work1) now available
- From: Tony Finch <dot@...>
- Date: Mon, 8 Jul 2013 10:46:04 +0100
Miles Bader <miles@gnu.org> wrote:
>
> I haven't looked at the implementation, but I suppose it may simply
> use C unsigned values to represent integers, or when doing arithmetic
> on them ...
Yes. In lvm.h:
#define intop(op,v1,v2) \
cast_integer(cast_unsigned(v1) op cast_unsigned(v2))
In lvm.c:
vmcase(OP_ADD,
TValue *rb = RKB(i);
TValue *rc = RKC(i);
lua_Number nb; lua_Number nc;
if (ttisinteger(rb) && ttisinteger(rc)) {
lua_Integer ib = ivalue(rb); lua_Integer ic = ivalue(rc);
setivalue(ra, intop(+, ib, ic));
}
else if (tonumber(rb, &nb) && tonumber(rc, &nc)) {
setnvalue(ra, luai_numadd(L, nb, nc));
}
else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_ADD)); }
)
Tony.
--
f.anthony.n.finch <dot@dotat.at> http://dotat.at/
Forties, Cromarty: East, veering southeast, 4 or 5, occasionally 6 at first.
Rough, becoming slight or moderate. Showers, rain at first. Moderate or good,
occasionally poor at first.