diff options
Diffstat (limited to 'src/lj_meta.c')
-rw-r--r-- | src/lj_meta.c | 12 |
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) | |||
44 | cTValue *mo = lj_tab_getstr(mt, name); | 44 | cTValue *mo = lj_tab_getstr(mt, name); |
45 | lua_assert(mm <= MM_FAST); | 45 | lua_assert(mm <= MM_FAST); |
46 | if (!mo || tvisnil(mo)) { /* No metamethod? */ | 46 | if (!mo || tvisnil(mo)) { /* No metamethod? */ |
47 | mt->nomm |= cast_byte(1u<<mm); /* Set negative cache flag. */ | 47 | mt->nomm |= (uint8_t)(1u<<mm); /* Set negative cache flag. */ |
48 | return NULL; | 48 | return NULL; |
49 | } | 49 | } |
50 | return mo; | 50 | return mo; |
@@ -156,6 +156,8 @@ static cTValue *str2num(cTValue *o, TValue *n) | |||
156 | { | 156 | { |
157 | if (tvisnum(o)) | 157 | if (tvisnum(o)) |
158 | return o; | 158 | return o; |
159 | else if (tvisint(o)) | ||
160 | return (setnumV(n, (lua_Number)intV(o)), n); | ||
159 | else if (tvisstr(o) && lj_str_tonum(strV(o), n)) | 161 | else if (tvisstr(o) && lj_str_tonum(strV(o), n)) |
160 | return n; | 162 | return n; |
161 | else | 163 | else |
@@ -192,8 +194,8 @@ static LJ_AINLINE int tostring(lua_State *L, TValue *o) | |||
192 | { | 194 | { |
193 | if (tvisstr(o)) { | 195 | if (tvisstr(o)) { |
194 | return 1; | 196 | return 1; |
195 | } else if (tvisnum(o)) { | 197 | } else if (tvisnumber(o)) { |
196 | setstrV(L, o, lj_str_fromnum(L, &o->n)); | 198 | setstrV(L, o, lj_str_fromnumber(L, o)); |
197 | return 1; | 199 | return 1; |
198 | } else { | 200 | } else { |
199 | return 0; | 201 | return 0; |
@@ -205,12 +207,12 @@ TValue *lj_meta_cat(lua_State *L, TValue *top, int left) | |||
205 | { | 207 | { |
206 | do { | 208 | do { |
207 | int n = 1; | 209 | int n = 1; |
208 | if (!(tvisstr(top-1) || tvisnum(top-1)) || !tostring(L, top)) { | 210 | if (!(tvisstr(top-1) || tvisnumber(top-1)) || !tostring(L, top)) { |
209 | cTValue *mo = lj_meta_lookup(L, top-1, MM_concat); | 211 | cTValue *mo = lj_meta_lookup(L, top-1, MM_concat); |
210 | if (tvisnil(mo)) { | 212 | if (tvisnil(mo)) { |
211 | mo = lj_meta_lookup(L, top, MM_concat); | 213 | mo = lj_meta_lookup(L, top, MM_concat); |
212 | if (tvisnil(mo)) { | 214 | if (tvisnil(mo)) { |
213 | if (tvisstr(top-1) || tvisnum(top-1)) top++; | 215 | if (tvisstr(top-1) || tvisnumber(top-1)) top++; |
214 | lj_err_optype(L, top-1, LJ_ERR_OPCAT); | 216 | lj_err_optype(L, top-1, LJ_ERR_OPCAT); |
215 | return NULL; /* unreachable */ | 217 | return NULL; /* unreachable */ |
216 | } | 218 | } |