diff options
author | Mike Pall <mike> | 2009-12-08 20:35:29 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2009-12-08 20:35:29 +0100 |
commit | 3f1f9e11f4f699ae94182d4cba158092f434a7f6 (patch) | |
tree | 88fbb674a21a1d554d4b1ee9d4ef2c5fed6a1d88 /src/lib_base.c | |
parent | 5287b9326479ea2b7dddd6f642673e58e5a7f354 (diff) | |
download | luajit-3f1f9e11f4f699ae94182d4cba158092f434a7f6.tar.gz luajit-3f1f9e11f4f699ae94182d4cba158092f434a7f6.tar.bz2 luajit-3f1f9e11f4f699ae94182d4cba158092f434a7f6.zip |
Fast forward to sync public repo.
Compile math.sinh(), math.cosh(), math.tanh() and math.random().
Compile various io.*() functions.
Drive the GC forward on string allocations in the parser.
Improve KNUM fuse vs. load heuristics.
Add abstract C call handling to IR.
Diffstat (limited to 'src/lib_base.c')
-rw-r--r-- | src/lib_base.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/lib_base.c b/src/lib_base.c index 6b9e8eef..821c81b4 100644 --- a/src/lib_base.c +++ b/src/lib_base.c | |||
@@ -183,7 +183,7 @@ LJLIB_ASM(tonumber) LJLIB_REC(.) | |||
183 | int32_t base = lj_lib_optint(L, 2, 10); | 183 | int32_t base = lj_lib_optint(L, 2, 10); |
184 | if (base == 10) { | 184 | if (base == 10) { |
185 | TValue *o = lj_lib_checkany(L, 1); | 185 | TValue *o = lj_lib_checkany(L, 1); |
186 | if (tvisnum(o) || (tvisstr(o) && lj_str_numconv(strVdata(o), o))) { | 186 | if (tvisnum(o) || (tvisstr(o) && lj_str_tonum(strV(o), o))) { |
187 | setnumV(L->base-1, numV(o)); | 187 | setnumV(L->base-1, numV(o)); |
188 | return FFH_RES(1); | 188 | return FFH_RES(1); |
189 | } | 189 | } |
@@ -206,6 +206,9 @@ LJLIB_ASM(tonumber) LJLIB_REC(.) | |||
206 | return FFH_RES(1); | 206 | return FFH_RES(1); |
207 | } | 207 | } |
208 | 208 | ||
209 | LJLIB_PUSH("nil") | ||
210 | LJLIB_PUSH("false") | ||
211 | LJLIB_PUSH("true") | ||
209 | LJLIB_ASM(tostring) LJLIB_REC(.) | 212 | LJLIB_ASM(tostring) LJLIB_REC(.) |
210 | { | 213 | { |
211 | TValue *o = lj_lib_checkany(L, 1); | 214 | TValue *o = lj_lib_checkany(L, 1); |
@@ -218,12 +221,8 @@ LJLIB_ASM(tostring) LJLIB_REC(.) | |||
218 | GCstr *s; | 221 | GCstr *s; |
219 | if (tvisnum(o)) { | 222 | if (tvisnum(o)) { |
220 | s = lj_str_fromnum(L, &o->n); | 223 | s = lj_str_fromnum(L, &o->n); |
221 | } else if (tvisnil(o)) { | 224 | } else if (tvispri(o)) { |
222 | s = lj_str_newlit(L, "nil"); | 225 | s = strV(lj_lib_upvalue(L, -itype(o))); |
223 | } else if (tvisfalse(o)) { | ||
224 | s = lj_str_newlit(L, "false"); | ||
225 | } else if (tvistrue(o)) { | ||
226 | s = lj_str_newlit(L, "true"); | ||
227 | } else { | 226 | } else { |
228 | if (tvisfunc(o) && isffunc(funcV(o))) | 227 | if (tvisfunc(o) && isffunc(funcV(o))) |
229 | lua_pushfstring(L, "function: fast#%d", funcV(o)->c.ffid); | 228 | lua_pushfstring(L, "function: fast#%d", funcV(o)->c.ffid); |