mirror of
https://github.com/lua/lua
synced 2024-11-22 04:41:23 +03:00
Details
This commit is contained in:
parent
108e0bdc84
commit
c31d6774ac
@ -1,4 +0,0 @@
|
||||
collectgarbage("setparam", "minormul", 25)
|
||||
-- collectgarbage("generational")
|
||||
|
||||
|
3
lapi.c
3
lapi.c
@ -1262,9 +1262,8 @@ LUA_API int lua_next (lua_State *L, int idx) {
|
||||
api_checknelems(L, 1);
|
||||
t = gettable(L, idx);
|
||||
more = luaH_next(L, t, L->top.p - 1);
|
||||
if (more) {
|
||||
if (more)
|
||||
api_incr_top(L);
|
||||
}
|
||||
else /* no more elements */
|
||||
L->top.p -= 1; /* remove key */
|
||||
lua_unlock(L);
|
||||
|
5
lapi.h
5
lapi.h
@ -13,9 +13,8 @@
|
||||
|
||||
|
||||
/* Increments 'L->top.p', checking for stack overflows */
|
||||
#define api_incr_top(L) {L->top.p++; \
|
||||
api_check(L, L->top.p <= L->ci->top.p, \
|
||||
"stack overflow");}
|
||||
#define api_incr_top(L) \
|
||||
(L->top.p++, api_check(L, L->top.p <= L->ci->top.p, "stack overflow"))
|
||||
|
||||
|
||||
/*
|
||||
|
26
lobject.c
26
lobject.c
@ -73,17 +73,29 @@ unsigned int luaO_codeparam (unsigned int p) {
|
||||
|
||||
|
||||
/*
|
||||
** Computes 'p' times 'x', where 'p' is a floating-point byte.
|
||||
** Computes 'p' times 'x', where 'p' is a floating-point byte. Roughly,
|
||||
** we have to multiply 'x' by the mantissa and then shift accordingly to
|
||||
** the exponent. If the exponent is positive, both the multiplication
|
||||
** and the shift increase 'x', so we have to care only about overflows.
|
||||
** For negative exponents, however, multiplying before the shift keeps
|
||||
** more significant bits, as long as the multiplication does not
|
||||
** overflow, so we check which order is best.
|
||||
*/
|
||||
l_obj luaO_applyparam (unsigned int p, l_obj x) {
|
||||
unsigned int m = p & 0xF; /* mantissa */
|
||||
int e = (p >> 4); /* exponent */
|
||||
if (e > 0) { /* normalized? */
|
||||
e--;
|
||||
m += 0x10; /* maximum 'm' is 0x1F */
|
||||
e--; /* correct exponent */
|
||||
m += 0x10; /* correct mantissa; maximum value is 0x1F */
|
||||
}
|
||||
e -= 7; /* correct excess-7 */
|
||||
if (e < 0) {
|
||||
if (e >= 0) {
|
||||
if (x < (MAX_LOBJ / 0x1F) >> e) /* no overflow? */
|
||||
return (x * m) << e; /* order doesn't matter here */
|
||||
else /* real overflow */
|
||||
return MAX_LOBJ;
|
||||
}
|
||||
else { /* negative exponent */
|
||||
e = -e;
|
||||
if (x < MAX_LOBJ / 0x1F) /* multiplication cannot overflow? */
|
||||
return (x * m) >> e; /* multiplying first gives more precision */
|
||||
@ -92,12 +104,6 @@ l_obj luaO_applyparam (unsigned int p, l_obj x) {
|
||||
else /* real overflow */
|
||||
return MAX_LOBJ;
|
||||
}
|
||||
else {
|
||||
if (x < (MAX_LOBJ / 0x1F) >> e) /* no overflow? */
|
||||
return (x * m) << e; /* order doesn't matter here */
|
||||
else /* real overflow */
|
||||
return MAX_LOBJ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
7
ltm.c
7
ltm.c
@ -92,10 +92,9 @@ const char *luaT_objtypename (lua_State *L, const TValue *o) {
|
||||
Table *mt;
|
||||
if ((ttistable(o) && (mt = hvalue(o)->metatable) != NULL) ||
|
||||
(ttisfulluserdata(o) && (mt = uvalue(o)->metatable) != NULL)) {
|
||||
TValue name;
|
||||
int hres = luaH_getshortstr(mt, luaS_new(L, "__name"), &name);
|
||||
if (hres == HOK && ttisstring(&name)) /* is '__name' a string? */
|
||||
return getstr(tsvalue(&name)); /* use it as type name */
|
||||
const TValue *name = luaH_Hgetshortstr(mt, luaS_new(L, "__name"));
|
||||
if (ttisstring(name)) /* is '__name' a string? */
|
||||
return getstr(tsvalue(name)); /* use it as type name */
|
||||
}
|
||||
return ttypename(ttype(o)); /* else use standard type name */
|
||||
}
|
||||
|
@ -6473,7 +6473,7 @@ Otherwise, returns the metatable of the given object.
|
||||
|
||||
@LibEntry{ipairs (t)|
|
||||
|
||||
Returns three values (an iterator function, the table @id{t}, and 0)
|
||||
Returns three values (an iterator function, the value @id{t}, and 0)
|
||||
so that the construction
|
||||
@verbatim{
|
||||
for i,v in ipairs(t) do @rep{body} end
|
||||
|
@ -13,6 +13,8 @@ do print "testing 'table.create'"
|
||||
assert(#t == i - 1)
|
||||
t[i] = 0
|
||||
end
|
||||
for i = 1, 20 do t[#t + 1] = i * 10 end
|
||||
assert(#t == 40 and t[39] == 190)
|
||||
assert(not T or T.querytab(t) == 10000)
|
||||
t = nil
|
||||
collectgarbage()
|
||||
|
Loading…
Reference in New Issue
Block a user