summaryrefslogtreecommitdiff
path: root/src/lj_meta.c
diff options
context:
space:
mode:
authorMike Pall <mike>2011-02-17 00:44:14 +0100
committerMike Pall <mike>2011-02-17 00:44:14 +0100
commit03946ac978d9a1a3230619e3da048002e5fda2d1 (patch)
treec0a7b8edaccf789f128468320d451d9a1fee1495 /src/lj_meta.c
parent963f05c7e153714921484e0de71a7cb6bab338d9 (diff)
downloadluajit2-03946ac978d9a1a3230619e3da048002e5fda2d1.tar.gz
DUALNUM: Add integer type to core VM.
Diffstat (limited to 'src/lj_meta.c')
-rw-r--r--src/lj_meta.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/lj_meta.c b/src/lj_meta.c
index 0df1de08..32024e85 100644
--- a/src/lj_meta.c
+++ b/src/lj_meta.c
@@ -44,7 +44,7 @@ cTValue *lj_meta_cache(GCtab *mt, MMS mm, GCstr *name)
cTValue *mo = lj_tab_getstr(mt, name);
lua_assert(mm <= MM_FAST);
if (!mo || tvisnil(mo)) { /* No metamethod? */
- mt->nomm |= cast_byte(1u<<mm); /* Set negative cache flag. */
+ mt->nomm |= (uint8_t)(1u<<mm); /* Set negative cache flag. */
return NULL;
}
return mo;
@@ -156,6 +156,8 @@ static cTValue *str2num(cTValue *o, TValue *n)
{
if (tvisnum(o))
return o;
+ else if (tvisint(o))
+ return (setnumV(n, (lua_Number)intV(o)), n);
else if (tvisstr(o) && lj_str_tonum(strV(o), n))
return n;
else
@@ -192,8 +194,8 @@ static LJ_AINLINE int tostring(lua_State *L, TValue *o)
{
if (tvisstr(o)) {
return 1;
- } else if (tvisnum(o)) {
- setstrV(L, o, lj_str_fromnum(L, &o->n));
+ } else if (tvisnumber(o)) {
+ setstrV(L, o, lj_str_fromnumber(L, o));
return 1;
} else {
return 0;
@@ -205,12 +207,12 @@ TValue *lj_meta_cat(lua_State *L, TValue *top, int left)
{
do {
int n = 1;
- if (!(tvisstr(top-1) || tvisnum(top-1)) || !tostring(L, top)) {
+ if (!(tvisstr(top-1) || tvisnumber(top-1)) || !tostring(L, top)) {
cTValue *mo = lj_meta_lookup(L, top-1, MM_concat);
if (tvisnil(mo)) {
mo = lj_meta_lookup(L, top, MM_concat);
if (tvisnil(mo)) {
- if (tvisstr(top-1) || tvisnum(top-1)) top++;
+ if (tvisstr(top-1) || tvisnumber(top-1)) top++;
lj_err_optype(L, top-1, LJ_ERR_OPCAT);
return NULL; /* unreachable */
}