mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Internal tag for iterators
This commit is contained in:
parent
09840f8f32
commit
bdc142e948
5 changed files with 17 additions and 13 deletions
|
@ -71,7 +71,7 @@ bool forgLoopTableIter(lua_State* L, Table* h, int index, TValue* ra)
|
||||||
|
|
||||||
if (!ttisnil(e))
|
if (!ttisnil(e))
|
||||||
{
|
{
|
||||||
setpvalue(ra + 2, reinterpret_cast<void*>(uintptr_t(index + 1)));
|
setpvalue(ra + 2, reinterpret_cast<void*>(uintptr_t(index + 1)), LU_TAG_ITERATOR);
|
||||||
setnvalue(ra + 3, double(index + 1));
|
setnvalue(ra + 3, double(index + 1));
|
||||||
setobj2s(L, ra + 4, e);
|
setobj2s(L, ra + 4, e);
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ bool forgLoopTableIter(lua_State* L, Table* h, int index, TValue* ra)
|
||||||
|
|
||||||
if (!ttisnil(gval(n)))
|
if (!ttisnil(gval(n)))
|
||||||
{
|
{
|
||||||
setpvalue(ra + 2, reinterpret_cast<void*>(uintptr_t(index + 1)));
|
setpvalue(ra + 2, reinterpret_cast<void*>(uintptr_t(index + 1)), LU_TAG_ITERATOR);
|
||||||
getnodekey(L, ra + 3, n);
|
getnodekey(L, ra + 3, n);
|
||||||
setobj(L, ra + 4, gval(n));
|
setobj(L, ra + 4, gval(n));
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ bool forgLoopNodeIter(lua_State* L, Table* h, int index, TValue* ra)
|
||||||
|
|
||||||
if (!ttisnil(gval(n)))
|
if (!ttisnil(gval(n)))
|
||||||
{
|
{
|
||||||
setpvalue(ra + 2, reinterpret_cast<void*>(uintptr_t(index + 1)));
|
setpvalue(ra + 2, reinterpret_cast<void*>(uintptr_t(index + 1)), LU_TAG_ITERATOR);
|
||||||
getnodekey(L, ra + 3, n);
|
getnodekey(L, ra + 3, n);
|
||||||
setobj(L, ra + 4, gval(n));
|
setobj(L, ra + 4, gval(n));
|
||||||
|
|
||||||
|
@ -765,7 +765,7 @@ const Instruction* executeFORGPREP(lua_State* L, const Instruction* pc, StkId ba
|
||||||
{
|
{
|
||||||
// set up registers for builtin iteration
|
// set up registers for builtin iteration
|
||||||
setobj2s(L, ra + 1, ra);
|
setobj2s(L, ra + 1, ra);
|
||||||
setpvalue(ra + 2, reinterpret_cast<void*>(uintptr_t(0)));
|
setpvalue(ra + 2, reinterpret_cast<void*>(uintptr_t(0)), LU_TAG_ITERATOR);
|
||||||
setnilvalue(ra);
|
setnilvalue(ra);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -682,8 +682,7 @@ void lua_pushboolean(lua_State* L, int b)
|
||||||
void lua_pushlightuserdatatagged(lua_State* L, void* p, int tag)
|
void lua_pushlightuserdatatagged(lua_State* L, void* p, int tag)
|
||||||
{
|
{
|
||||||
api_check(L, unsigned(tag) < LUA_LUTAG_LIMIT);
|
api_check(L, unsigned(tag) < LUA_LUTAG_LIMIT);
|
||||||
setpvalue(L->top, p);
|
setpvalue(L->top, p, tag);
|
||||||
L->top->extra[0] = tag;
|
|
||||||
api_incr_top(L);
|
api_incr_top(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,10 @@ typedef struct lua_TValue
|
||||||
|
|
||||||
#define lightuserdatatag(o) check_exp(ttislightuserdata(o), (o)->extra[0])
|
#define lightuserdatatag(o) check_exp(ttislightuserdata(o), (o)->extra[0])
|
||||||
|
|
||||||
|
// Internal tags used by the VM
|
||||||
|
#define LU_TAG_ITERATOR LUA_UTAG_LIMIT
|
||||||
|
#define LU_TAG_COUNT (LUA_UTAG_LIMIT+1)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** for internal debug only
|
** for internal debug only
|
||||||
*/
|
*/
|
||||||
|
@ -122,10 +126,11 @@ typedef struct lua_TValue
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define setpvalue(obj, x) \
|
#define setpvalue(obj, x, tag) \
|
||||||
{ \
|
{ \
|
||||||
TValue* i_o = (obj); \
|
TValue* i_o = (obj); \
|
||||||
i_o->value.p = (x); \
|
i_o->value.p = (x); \
|
||||||
|
i_o->extra[0] = (tag); \
|
||||||
i_o->tt = LUA_TLIGHTUSERDATA; \
|
i_o->tt = LUA_TLIGHTUSERDATA; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,7 @@ typedef struct global_State
|
||||||
struct Table* mt[LUA_T_COUNT]; // metatables for basic types
|
struct Table* mt[LUA_T_COUNT]; // metatables for basic types
|
||||||
TString* ttname[LUA_T_COUNT]; // names for basic types
|
TString* ttname[LUA_T_COUNT]; // names for basic types
|
||||||
TString* tmname[TM_N]; // array with tag-method names
|
TString* tmname[TM_N]; // array with tag-method names
|
||||||
TString* lightuserdataname[LUA_LUTAG_LIMIT]; // names for tagged lightuserdata
|
TString* lightuserdataname[LU_TAG_COUNT]; // names for tagged lightuserdata
|
||||||
|
|
||||||
TValue pseudotemp; // storage for temporary values used in pseudo2addr
|
TValue pseudotemp; // storage for temporary values used in pseudo2addr
|
||||||
|
|
||||||
|
|
|
@ -2302,7 +2302,7 @@ reentry:
|
||||||
{
|
{
|
||||||
// set up registers for builtin iteration
|
// set up registers for builtin iteration
|
||||||
setobj2s(L, ra + 1, ra);
|
setobj2s(L, ra + 1, ra);
|
||||||
setpvalue(ra + 2, reinterpret_cast<void*>(uintptr_t(0)));
|
setpvalue(ra + 2, reinterpret_cast<void*>(uintptr_t(0)), LU_TAG_ITERATOR);
|
||||||
setnilvalue(ra);
|
setnilvalue(ra);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2354,7 +2354,7 @@ reentry:
|
||||||
|
|
||||||
if (!ttisnil(e))
|
if (!ttisnil(e))
|
||||||
{
|
{
|
||||||
setpvalue(ra + 2, reinterpret_cast<void*>(uintptr_t(index + 1)));
|
setpvalue(ra + 2, reinterpret_cast<void*>(uintptr_t(index + 1)), LU_TAG_ITERATOR);
|
||||||
setnvalue(ra + 3, double(index + 1));
|
setnvalue(ra + 3, double(index + 1));
|
||||||
setobj2s(L, ra + 4, e);
|
setobj2s(L, ra + 4, e);
|
||||||
|
|
||||||
|
@ -2375,7 +2375,7 @@ reentry:
|
||||||
|
|
||||||
if (!ttisnil(gval(n)))
|
if (!ttisnil(gval(n)))
|
||||||
{
|
{
|
||||||
setpvalue(ra + 2, reinterpret_cast<void*>(uintptr_t(index + 1)));
|
setpvalue(ra + 2, reinterpret_cast<void*>(uintptr_t(index + 1)), LU_TAG_ITERATOR);
|
||||||
getnodekey(L, ra + 3, n);
|
getnodekey(L, ra + 3, n);
|
||||||
setobj2s(L, ra + 4, gval(n));
|
setobj2s(L, ra + 4, gval(n));
|
||||||
|
|
||||||
|
@ -2427,7 +2427,7 @@ reentry:
|
||||||
{
|
{
|
||||||
setnilvalue(ra);
|
setnilvalue(ra);
|
||||||
// ra+1 is already the table
|
// ra+1 is already the table
|
||||||
setpvalue(ra + 2, reinterpret_cast<void*>(uintptr_t(0)));
|
setpvalue(ra + 2, reinterpret_cast<void*>(uintptr_t(0)), LU_TAG_ITERATOR);
|
||||||
}
|
}
|
||||||
else if (!ttisfunction(ra))
|
else if (!ttisfunction(ra))
|
||||||
{
|
{
|
||||||
|
@ -2456,7 +2456,7 @@ reentry:
|
||||||
{
|
{
|
||||||
setnilvalue(ra);
|
setnilvalue(ra);
|
||||||
// ra+1 is already the table
|
// ra+1 is already the table
|
||||||
setpvalue(ra + 2, reinterpret_cast<void*>(uintptr_t(0)));
|
setpvalue(ra + 2, reinterpret_cast<void*>(uintptr_t(0)), LU_TAG_ITERATOR);
|
||||||
}
|
}
|
||||||
else if (!ttisfunction(ra))
|
else if (!ttisfunction(ra))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue