diff options
-rw-r--r-- | lvm.c | 17 |
1 files changed, 8 insertions, 9 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 1.38 1999/01/13 19:09:04 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.39 1999/01/15 13:14:24 roberto Exp roberto $ |
3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -187,13 +187,13 @@ void luaV_rawsettable (TObject *t) { | |||
187 | 187 | ||
188 | 188 | ||
189 | void luaV_getglobal (TaggedString *ts) { | 189 | void luaV_getglobal (TaggedString *ts) { |
190 | /* WARNING: caller must assure stack space */ | ||
190 | /* only userdata, tables and nil can have getglobal tag methods */ | 191 | /* only userdata, tables and nil can have getglobal tag methods */ |
191 | static char valid_getglobals[] = {1, 0, 0, 1, 0, 0, 1, 0}; /* ORDER LUA_T */ | 192 | static char valid_getglobals[] = {1, 0, 0, 1, 0, 0, 1, 0}; /* ORDER LUA_T */ |
192 | TObject *value = &ts->u.s.globalval; | 193 | TObject *value = &ts->u.s.globalval; |
193 | if (valid_getglobals[-ttype(value)]) { | 194 | if (valid_getglobals[-ttype(value)]) { |
194 | TObject *im = luaT_getimbyObj(value, IM_GETGLOBAL); | 195 | TObject *im = luaT_getimbyObj(value, IM_GETGLOBAL); |
195 | if (ttype(im) != LUA_T_NIL) { /* is there a tag method? */ | 196 | if (ttype(im) != LUA_T_NIL) { /* is there a tag method? */ |
196 | /* WARNING: caller must assure stack space */ | ||
197 | struct Stack *S = &L->stack; | 197 | struct Stack *S = &L->stack; |
198 | ttype(S->top) = LUA_T_STRING; | 198 | ttype(S->top) = LUA_T_STRING; |
199 | tsvalue(S->top) = ts; | 199 | tsvalue(S->top) = ts; |
@@ -248,7 +248,7 @@ static void call_arith (IMS event) | |||
248 | } | 248 | } |
249 | 249 | ||
250 | 250 | ||
251 | static int strcomp (char *l, long ll, char *r, long lr) | 251 | static int luaV_strcomp (char *l, long ll, char *r, long lr) |
252 | { | 252 | { |
253 | for (;;) { | 253 | for (;;) { |
254 | long temp = strcoll(l, r); | 254 | long temp = strcoll(l, r); |
@@ -266,17 +266,16 @@ static int strcomp (char *l, long ll, char *r, long lr) | |||
266 | } | 266 | } |
267 | 267 | ||
268 | void luaV_comparison (lua_Type ttype_less, lua_Type ttype_equal, | 268 | void luaV_comparison (lua_Type ttype_less, lua_Type ttype_equal, |
269 | lua_Type ttype_great, IMS op) | 269 | lua_Type ttype_great, IMS op) { |
270 | { | ||
271 | struct Stack *S = &L->stack; | 270 | struct Stack *S = &L->stack; |
272 | TObject *l = S->top-2; | 271 | TObject *l = S->top-2; |
273 | TObject *r = S->top-1; | 272 | TObject *r = S->top-1; |
274 | int result; | 273 | real result; |
275 | if (ttype(l) == LUA_T_NUMBER && ttype(r) == LUA_T_NUMBER) | 274 | if (ttype(l) == LUA_T_NUMBER && ttype(r) == LUA_T_NUMBER) |
276 | result = (nvalue(l) < nvalue(r)) ? -1 : (nvalue(l) == nvalue(r)) ? 0 : 1; | 275 | result = nvalue(l)-nvalue(r); |
277 | else if (ttype(l) == LUA_T_STRING && ttype(r) == LUA_T_STRING) | 276 | else if (ttype(l) == LUA_T_STRING && ttype(r) == LUA_T_STRING) |
278 | result = strcomp(svalue(l), tsvalue(l)->u.s.len, | 277 | result = luaV_strcomp(svalue(l), tsvalue(l)->u.s.len, |
279 | svalue(r), tsvalue(r)->u.s.len); | 278 | svalue(r), tsvalue(r)->u.s.len); |
280 | else { | 279 | else { |
281 | call_binTM(op, "unexpected type in comparison"); | 280 | call_binTM(op, "unexpected type in comparison"); |
282 | return; | 281 | return; |