DUALNUM: Add integer type to core VM.

This commit is contained in:
Mike Pall
2011-02-17 00:44:14 +01:00
parent 963f05c7e1
commit 03946ac978
23 changed files with 403 additions and 189 deletions

View File

@@ -170,10 +170,15 @@ static void lex_number(LexState *ls, TValue *tv)
if (c == 'I') { /* Return cdata holding a complex number. */
GCcdata *cd = lj_cdata_new_(ls->L, CTID_COMPLEX_DOUBLE, 2*sizeof(double));
((double *)cdataptr(cd))[0] = 0;
((double *)cdataptr(cd))[1] = tv->n;
((double *)cdataptr(cd))[1] = numberVnum(tv);
lj_parse_keepcdata(ls, tv, cd);
}
#endif
if (LJ_DUALNUM && tvisnum(tv)) {
int32_t k = lj_num2int(numV(tv));
if ((lua_Number)k == numV(tv)) /* -0 cannot end up here. */
setintV(tv, k);
}
return;
}
lj_lex_error(ls, TK_number, LJ_ERR_XNUMBER);
@@ -506,7 +511,7 @@ void lj_lex_init(lua_State *L)
for (i = 0; i < TK_RESERVED; i++) {
GCstr *s = lj_str_newz(L, tokennames[i]);
fixstring(s); /* Reserved words are never collected. */
s->reserved = cast_byte(i+1);
s->reserved = (uint8_t)(i+1);
}
}