diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-03-11 15:44:28 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-03-11 15:44:28 -0300 |
| commit | b6d91e24e23edfe98ad732660fd456e91658edb9 (patch) | |
| tree | a66fb8348758f32df6c5d5ab1af1aece2a63009f /opcode.c | |
| parent | a82ab0852eaca43cb56be5134833c97e6bb7ac98 (diff) | |
| download | lua-b6d91e24e23edfe98ad732660fd456e91658edb9.tar.gz lua-b6d91e24e23edfe98ad732660fd456e91658edb9.tar.bz2 lua-b6d91e24e23edfe98ad732660fd456e91658edb9.zip | |
"tag" changed to "ttype" (since now tag has other meaning)
Diffstat (limited to 'opcode.c')
| -rw-r--r-- | opcode.c | 149 |
1 files changed, 75 insertions, 74 deletions
| @@ -3,7 +3,7 @@ | |||
| 3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | char *rcs_opcode="$Id: opcode.c,v 3.82 1997/02/26 17:38:41 roberto Unstable roberto $"; | 6 | char *rcs_opcode="$Id: opcode.c,v 3.83 1997/03/06 17:30:55 roberto Exp roberto $"; |
| 7 | 7 | ||
| 8 | #include <setjmp.h> | 8 | #include <setjmp.h> |
| 9 | #include <stdio.h> | 9 | #include <stdio.h> |
| @@ -20,8 +20,8 @@ char *rcs_opcode="$Id: opcode.c,v 3.82 1997/02/26 17:38:41 roberto Unstable robe | |||
| 20 | #include "fallback.h" | 20 | #include "fallback.h" |
| 21 | #include "undump.h" | 21 | #include "undump.h" |
| 22 | 22 | ||
| 23 | #define tonumber(o) ((tag(o) != LUA_T_NUMBER) && (lua_tonumber(o) != 0)) | 23 | #define tonumber(o) ((ttype(o) != LUA_T_NUMBER) && (lua_tonumber(o) != 0)) |
| 24 | #define tostring(o) ((tag(o) != LUA_T_STRING) && (lua_tostring(o) != 0)) | 24 | #define tostring(o) ((ttype(o) != LUA_T_STRING) && (lua_tostring(o) != 0)) |
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | #define STACK_SIZE 128 | 27 | #define STACK_SIZE 128 |
| @@ -138,12 +138,12 @@ static int lua_tonumber (Object *obj) | |||
| 138 | { | 138 | { |
| 139 | float t; | 139 | float t; |
| 140 | char c; | 140 | char c; |
| 141 | if (tag(obj) != LUA_T_STRING) | 141 | if (ttype(obj) != LUA_T_STRING) |
| 142 | return 1; | 142 | return 1; |
| 143 | else if (sscanf(svalue(obj), "%f %c",&t, &c) == 1) | 143 | else if (sscanf(svalue(obj), "%f %c",&t, &c) == 1) |
| 144 | { | 144 | { |
| 145 | nvalue(obj) = t; | 145 | nvalue(obj) = t; |
| 146 | tag(obj) = LUA_T_NUMBER; | 146 | ttype(obj) = LUA_T_NUMBER; |
| 147 | return 0; | 147 | return 0; |
| 148 | } | 148 | } |
| 149 | else | 149 | else |
| @@ -152,12 +152,12 @@ static int lua_tonumber (Object *obj) | |||
| 152 | 152 | ||
| 153 | 153 | ||
| 154 | /* | 154 | /* |
| 155 | ** Convert, if possible, to a string tag | 155 | ** Convert, if possible, to a string ttype |
| 156 | ** Return 0 in success or not 0 on error. | 156 | ** Return 0 in success or not 0 on error. |
| 157 | */ | 157 | */ |
| 158 | static int lua_tostring (Object *obj) | 158 | static int lua_tostring (Object *obj) |
| 159 | { | 159 | { |
| 160 | if (tag(obj) != LUA_T_NUMBER) | 160 | if (ttype(obj) != LUA_T_NUMBER) |
| 161 | return 1; | 161 | return 1; |
| 162 | else { | 162 | else { |
| 163 | char s[60]; | 163 | char s[60]; |
| @@ -168,7 +168,7 @@ static int lua_tostring (Object *obj) | |||
| 168 | else | 168 | else |
| 169 | sprintf (s, "%g", nvalue(obj)); | 169 | sprintf (s, "%g", nvalue(obj)); |
| 170 | tsvalue(obj) = lua_createstring(s); | 170 | tsvalue(obj) = lua_createstring(s); |
| 171 | tag(obj) = LUA_T_STRING; | 171 | ttype(obj) = LUA_T_STRING; |
| 172 | return 0; | 172 | return 0; |
| 173 | } | 173 | } |
| 174 | } | 174 | } |
| @@ -182,7 +182,7 @@ static void adjust_top (StkId newtop) | |||
| 182 | Object *nt; | 182 | Object *nt; |
| 183 | lua_checkstack(stack+newtop); | 183 | lua_checkstack(stack+newtop); |
| 184 | nt = stack+newtop; /* warning: previous call may change stack */ | 184 | nt = stack+newtop; /* warning: previous call may change stack */ |
| 185 | while (top < nt) tag(top++) = LUA_T_NIL; | 185 | while (top < nt) ttype(top++) = LUA_T_NIL; |
| 186 | top = nt; /* top could be bigger than newtop */ | 186 | top = nt; /* top could be bigger than newtop */ |
| 187 | } | 187 | } |
| 188 | 188 | ||
| @@ -289,14 +289,14 @@ static void do_call (StkId base, int nResults) | |||
| 289 | StkId firstResult; | 289 | StkId firstResult; |
| 290 | Object *func = stack+base-1; | 290 | Object *func = stack+base-1; |
| 291 | int i; | 291 | int i; |
| 292 | if (tag(func) == LUA_T_CFUNCTION) | 292 | if (ttype(func) == LUA_T_CFUNCTION) |
| 293 | { | 293 | { |
| 294 | tag(func) = LUA_T_CMARK; | 294 | ttype(func) = LUA_T_CMARK; |
| 295 | firstResult = callC(fvalue(func), base); | 295 | firstResult = callC(fvalue(func), base); |
| 296 | } | 296 | } |
| 297 | else if (tag(func) == LUA_T_FUNCTION) | 297 | else if (ttype(func) == LUA_T_FUNCTION) |
| 298 | { | 298 | { |
| 299 | tag(func) = LUA_T_MARK; | 299 | ttype(func) = LUA_T_MARK; |
| 300 | firstResult = lua_execute(func->value.tf->code, base); | 300 | firstResult = lua_execute(func->value.tf->code, base); |
| 301 | } | 301 | } |
| 302 | else | 302 | else |
| @@ -327,9 +327,9 @@ static void pushsubscript (void) | |||
| 327 | { | 327 | { |
| 328 | int tg = luaI_tag(top-2); | 328 | int tg = luaI_tag(top-2); |
| 329 | Object *im = luaI_getim(tg, FB_GETTABLE); | 329 | Object *im = luaI_getim(tg, FB_GETTABLE); |
| 330 | if (tag(top-2) == LUA_T_ARRAY && im == NULL) { | 330 | if (ttype(top-2) == LUA_T_ARRAY && im == NULL) { |
| 331 | Object *h = lua_hashget(avalue(top-2), top-1); | 331 | Object *h = lua_hashget(avalue(top-2), top-1); |
| 332 | if (h != NULL && tag(h) != LUA_T_NIL) { | 332 | if (h != NULL && ttype(h) != LUA_T_NIL) { |
| 333 | --top; | 333 | --top; |
| 334 | *(top-1) = *h; | 334 | *(top-1) = *h; |
| 335 | } | 335 | } |
| @@ -338,7 +338,7 @@ static void pushsubscript (void) | |||
| 338 | callIM(im, 2, 1); | 338 | callIM(im, 2, 1); |
| 339 | else { | 339 | else { |
| 340 | --top; | 340 | --top; |
| 341 | tag(top-1) = LUA_T_NIL; | 341 | ttype(top-1) = LUA_T_NIL; |
| 342 | } | 342 | } |
| 343 | } | 343 | } |
| 344 | else { /* object is not a table, and/or has a specific "gettable" method */ | 344 | else { /* object is not a table, and/or has a specific "gettable" method */ |
| @@ -353,7 +353,7 @@ static void pushsubscript (void) | |||
| 353 | lua_Object lua_basicindex (void) | 353 | lua_Object lua_basicindex (void) |
| 354 | { | 354 | { |
| 355 | adjustC(2); | 355 | adjustC(2); |
| 356 | if (tag(top-2) != LUA_T_ARRAY) | 356 | if (ttype(top-2) != LUA_T_ARRAY) |
| 357 | lua_error("indexed expression not a table in basic indexing"); | 357 | lua_error("indexed expression not a table in basic indexing"); |
| 358 | else { | 358 | else { |
| 359 | Object *h = lua_hashget(avalue(top-2), top-1); | 359 | Object *h = lua_hashget(avalue(top-2), top-1); |
| @@ -361,7 +361,7 @@ lua_Object lua_basicindex (void) | |||
| 361 | if (h != NULL) | 361 | if (h != NULL) |
| 362 | *(top-1) = *h; | 362 | *(top-1) = *h; |
| 363 | else | 363 | else |
| 364 | tag(top-1) = LUA_T_NIL; | 364 | ttype(top-1) = LUA_T_NIL; |
| 365 | } | 365 | } |
| 366 | CLS_current.base++; /* incorporate object in the stack */ | 366 | CLS_current.base++; /* incorporate object in the stack */ |
| 367 | return (Ref(top-1)); | 367 | return (Ref(top-1)); |
| @@ -377,7 +377,7 @@ lua_Object lua_basicindex (void) | |||
| 377 | static void storesubscript (Object *t, int mode) | 377 | static void storesubscript (Object *t, int mode) |
| 378 | { | 378 | { |
| 379 | Object *im = (mode == 0) ? NULL : luaI_getim(luaI_tag(t), FB_SETTABLE); | 379 | Object *im = (mode == 0) ? NULL : luaI_getim(luaI_tag(t), FB_SETTABLE); |
| 380 | if (tag(t) == LUA_T_ARRAY && im == NULL) { | 380 | if (ttype(t) == LUA_T_ARRAY && im == NULL) { |
| 381 | Object *h = lua_hashdefine(avalue(t), t+1); | 381 | Object *h = lua_hashdefine(avalue(t), t+1); |
| 382 | *h = *(top-1); | 382 | *h = *(top-1); |
| 383 | top -= (mode == 2) ? 1 : 3; | 383 | top -= (mode == 2) ? 1 : 3; |
| @@ -403,9 +403,9 @@ static void getglobal (Word n) | |||
| 403 | { | 403 | { |
| 404 | *top = lua_table[n].object; | 404 | *top = lua_table[n].object; |
| 405 | incr_top; | 405 | incr_top; |
| 406 | if (tag(top-1) == LUA_T_NIL) | 406 | if (ttype(top-1) == LUA_T_NIL) |
| 407 | { /* must call getglobal fallback */ | 407 | { /* must call getglobal fallback */ |
| 408 | tag(top-1) = LUA_T_STRING; | 408 | ttype(top-1) = LUA_T_STRING; |
| 409 | tsvalue(top-1) = lua_table[n].varname; | 409 | tsvalue(top-1) = lua_table[n].varname; |
| 410 | callFB(FB_GETGLOBAL); | 410 | callFB(FB_GETGLOBAL); |
| 411 | } | 411 | } |
| @@ -452,7 +452,7 @@ lua_Function lua_stackedfunction (int level) | |||
| 452 | { | 452 | { |
| 453 | StkId i; | 453 | StkId i; |
| 454 | for (i = (top-1)-stack; i>=0; i--) | 454 | for (i = (top-1)-stack; i>=0; i--) |
| 455 | if (stack[i].tag == LUA_T_MARK || stack[i].tag == LUA_T_CMARK) | 455 | if (stack[i].ttype == LUA_T_MARK || stack[i].ttype == LUA_T_CMARK) |
| 456 | if (level-- == 0) | 456 | if (level-- == 0) |
| 457 | return Ref(stack+i); | 457 | return Ref(stack+i); |
| 458 | return LUA_NOOBJECT; | 458 | return LUA_NOOBJECT; |
| @@ -462,7 +462,7 @@ lua_Function lua_stackedfunction (int level) | |||
| 462 | int lua_currentline (lua_Function func) | 462 | int lua_currentline (lua_Function func) |
| 463 | { | 463 | { |
| 464 | Object *f = Address(func); | 464 | Object *f = Address(func); |
| 465 | return (f+1 < top && (f+1)->tag == LUA_T_LINE) ? (f+1)->value.i : -1; | 465 | return (f+1 < top && (f+1)->ttype == LUA_T_LINE) ? (f+1)->value.i : -1; |
| 466 | } | 466 | } |
| 467 | 467 | ||
| 468 | 468 | ||
| @@ -512,7 +512,7 @@ static void do_unprotectedrun (lua_CFunction f, int nParams, int nResults) | |||
| 512 | { | 512 | { |
| 513 | adjustC(nParams); | 513 | adjustC(nParams); |
| 514 | open_stack((top-stack)-CLS_current.base); | 514 | open_stack((top-stack)-CLS_current.base); |
| 515 | stack[CLS_current.base].tag = LUA_T_CFUNCTION; | 515 | stack[CLS_current.base].ttype = LUA_T_CFUNCTION; |
| 516 | stack[CLS_current.base].value.f = f; | 516 | stack[CLS_current.base].value.f = f; |
| 517 | do_callinc(nResults); | 517 | do_callinc(nResults); |
| 518 | } | 518 | } |
| @@ -546,7 +546,7 @@ int luaI_dorun (TFunc *tf) | |||
| 546 | { | 546 | { |
| 547 | int status; | 547 | int status; |
| 548 | adjustC(1); /* one slot for the pseudo-function */ | 548 | adjustC(1); /* one slot for the pseudo-function */ |
| 549 | stack[CLS_current.base].tag = LUA_T_FUNCTION; | 549 | stack[CLS_current.base].ttype = LUA_T_FUNCTION; |
| 550 | stack[CLS_current.base].value.tf = tf; | 550 | stack[CLS_current.base].value.tf = tf; |
| 551 | status = do_protectedrun(MULT_RET); | 551 | status = do_protectedrun(MULT_RET); |
| 552 | return status; | 552 | return status; |
| @@ -731,7 +731,7 @@ lua_Object lua_createtable (void) | |||
| 731 | { | 731 | { |
| 732 | adjustC(0); | 732 | adjustC(0); |
| 733 | avalue(top) = lua_createarray(0); | 733 | avalue(top) = lua_createarray(0); |
| 734 | tag(top) = LUA_T_ARRAY; | 734 | ttype(top) = LUA_T_ARRAY; |
| 735 | incr_top; | 735 | incr_top; |
| 736 | CLS_current.base++; /* incorporate object in the stack */ | 736 | CLS_current.base++; /* incorporate object in the stack */ |
| 737 | return Ref(top-1); | 737 | return Ref(top-1); |
| @@ -751,17 +751,17 @@ lua_Object lua_getparam (int number) | |||
| 751 | 751 | ||
| 752 | int lua_isnil (lua_Object o) | 752 | int lua_isnil (lua_Object o) |
| 753 | { | 753 | { |
| 754 | return (o!= LUA_NOOBJECT) && (tag(Address(o)) == LUA_T_NIL); | 754 | return (o!= LUA_NOOBJECT) && (ttype(Address(o)) == LUA_T_NIL); |
| 755 | } | 755 | } |
| 756 | 756 | ||
| 757 | int lua_istable (lua_Object o) | 757 | int lua_istable (lua_Object o) |
| 758 | { | 758 | { |
| 759 | return (o!= LUA_NOOBJECT) && (tag(Address(o)) == LUA_T_ARRAY); | 759 | return (o!= LUA_NOOBJECT) && (ttype(Address(o)) == LUA_T_ARRAY); |
| 760 | } | 760 | } |
| 761 | 761 | ||
| 762 | int lua_isuserdata (lua_Object o) | 762 | int lua_isuserdata (lua_Object o) |
| 763 | { | 763 | { |
| 764 | return (o!= LUA_NOOBJECT) && (tag(Address(o)) == LUA_T_USERDATA); | 764 | return (o!= LUA_NOOBJECT) && (ttype(Address(o)) == LUA_T_USERDATA); |
| 765 | } | 765 | } |
| 766 | 766 | ||
| 767 | int lua_iscfunction (lua_Object o) | 767 | int lua_iscfunction (lua_Object o) |
| @@ -810,14 +810,14 @@ char *lua_getstring (lua_Object object) | |||
| 810 | 810 | ||
| 811 | void *lua_getbinarydata (lua_Object object) | 811 | void *lua_getbinarydata (lua_Object object) |
| 812 | { | 812 | { |
| 813 | if (object == LUA_NOOBJECT || tag(Address(object)) != LUA_T_USERDATA) | 813 | if (object == LUA_NOOBJECT || ttype(Address(object)) != LUA_T_USERDATA) |
| 814 | lua_error("getbinarydata: object is not binary data"); | 814 | lua_error("getbinarydata: object is not binary data"); |
| 815 | return svalue(Address(object)); | 815 | return svalue(Address(object)); |
| 816 | } | 816 | } |
| 817 | 817 | ||
| 818 | int lua_getbindatasize (lua_Object object) | 818 | int lua_getbindatasize (lua_Object object) |
| 819 | { | 819 | { |
| 820 | if (object == LUA_NOOBJECT || tag(Address(object)) != LUA_T_USERDATA) | 820 | if (object == LUA_NOOBJECT || ttype(Address(object)) != LUA_T_USERDATA) |
| 821 | return 0; | 821 | return 0; |
| 822 | else return (Address(object))->value.ts->size; | 822 | else return (Address(object))->value.ts->size; |
| 823 | } | 823 | } |
| @@ -827,8 +827,8 @@ int lua_getbindatasize (lua_Object object) | |||
| 827 | */ | 827 | */ |
| 828 | lua_CFunction lua_getcfunction (lua_Object object) | 828 | lua_CFunction lua_getcfunction (lua_Object object) |
| 829 | { | 829 | { |
| 830 | if (object == LUA_NOOBJECT || ((tag(Address(object)) != LUA_T_CFUNCTION) && | 830 | if (object == LUA_NOOBJECT || ((ttype(Address(object)) != LUA_T_CFUNCTION) && |
| 831 | (tag(Address(object)) != LUA_T_CMARK))) | 831 | (ttype(Address(object)) != LUA_T_CMARK))) |
| 832 | return NULL; | 832 | return NULL; |
| 833 | else return (fvalue(Address(object))); | 833 | else return (fvalue(Address(object))); |
| 834 | } | 834 | } |
| @@ -889,30 +889,30 @@ void lua_storeglobal (char *name) | |||
| 889 | */ | 889 | */ |
| 890 | void lua_pushnil (void) | 890 | void lua_pushnil (void) |
| 891 | { | 891 | { |
| 892 | tag(top) = LUA_T_NIL; | 892 | ttype(top) = LUA_T_NIL; |
| 893 | incr_top; | 893 | incr_top; |
| 894 | } | 894 | } |
| 895 | 895 | ||
| 896 | /* | 896 | /* |
| 897 | ** Push an object (tag=number) to stack. | 897 | ** Push an object (ttype=number) to stack. |
| 898 | */ | 898 | */ |
| 899 | void lua_pushnumber (real n) | 899 | void lua_pushnumber (real n) |
| 900 | { | 900 | { |
| 901 | tag(top) = LUA_T_NUMBER; nvalue(top) = n; | 901 | ttype(top) = LUA_T_NUMBER; nvalue(top) = n; |
| 902 | incr_top; | 902 | incr_top; |
| 903 | } | 903 | } |
| 904 | 904 | ||
| 905 | /* | 905 | /* |
| 906 | ** Push an object (tag=string) to stack. | 906 | ** Push an object (ttype=string) to stack. |
| 907 | */ | 907 | */ |
| 908 | void lua_pushstring (char *s) | 908 | void lua_pushstring (char *s) |
| 909 | { | 909 | { |
| 910 | if (s == NULL) | 910 | if (s == NULL) |
| 911 | tag(top) = LUA_T_NIL; | 911 | ttype(top) = LUA_T_NIL; |
| 912 | else | 912 | else |
| 913 | { | 913 | { |
| 914 | tsvalue(top) = lua_createstring(s); | 914 | tsvalue(top) = lua_createstring(s); |
| 915 | tag(top) = LUA_T_STRING; | 915 | ttype(top) = LUA_T_STRING; |
| 916 | } | 916 | } |
| 917 | incr_top; | 917 | incr_top; |
| 918 | } | 918 | } |
| @@ -920,27 +920,27 @@ void lua_pushstring (char *s) | |||
| 920 | void lua_pushliteral(char *s) { lua_pushstring(s); }*/ | 920 | void lua_pushliteral(char *s) { lua_pushstring(s); }*/ |
| 921 | 921 | ||
| 922 | /* | 922 | /* |
| 923 | ** Push an object (tag=cfunction) to stack. | 923 | ** Push an object (ttype=cfunction) to stack. |
| 924 | */ | 924 | */ |
| 925 | void lua_pushcfunction (lua_CFunction fn) | 925 | void lua_pushcfunction (lua_CFunction fn) |
| 926 | { | 926 | { |
| 927 | tag(top) = LUA_T_CFUNCTION; fvalue(top) = fn; | 927 | ttype(top) = LUA_T_CFUNCTION; fvalue(top) = fn; |
| 928 | incr_top; | 928 | incr_top; |
| 929 | } | 929 | } |
| 930 | 930 | ||
| 931 | void lua_pushbinarydata (void *buff, int size, int tag) | 931 | void lua_pushbinarydata (void *buff, int size, int tag) |
| 932 | { | 932 | { |
| 933 | if (buff == NULL) | 933 | if (buff == NULL) |
| 934 | tag(top) = LUA_T_NIL; | 934 | ttype(top) = LUA_T_NIL; |
| 935 | else { | 935 | else { |
| 936 | tsvalue(top) = luaI_createuserdata(buff, size, tag); | 936 | tsvalue(top) = luaI_createuserdata(buff, size, tag); |
| 937 | tag(top) = LUA_T_USERDATA; | 937 | ttype(top) = LUA_T_USERDATA; |
| 938 | } | 938 | } |
| 939 | incr_top; | 939 | incr_top; |
| 940 | } | 940 | } |
| 941 | 941 | ||
| 942 | /* | 942 | /* |
| 943 | ** Push an object (tag=userdata) to stack. | 943 | ** Push an object (ttype=userdata) to stack. |
| 944 | */ | 944 | */ |
| 945 | void lua_pushusertag (void *u, int tag) | 945 | void lua_pushusertag (void *u, int tag) |
| 946 | { | 946 | { |
| @@ -966,8 +966,8 @@ void lua_pushobject (lua_Object o) | |||
| 966 | if (o == LUA_NOOBJECT) | 966 | if (o == LUA_NOOBJECT) |
| 967 | lua_error("attempt to push a NOOBJECT"); | 967 | lua_error("attempt to push a NOOBJECT"); |
| 968 | *top = *Address(o); | 968 | *top = *Address(o); |
| 969 | if (tag(top) == LUA_T_MARK) tag(top) = LUA_T_FUNCTION; | 969 | if (ttype(top) == LUA_T_MARK) ttype(top) = LUA_T_FUNCTION; |
| 970 | else if (tag(top) == LUA_T_CMARK) tag(top) = LUA_T_CFUNCTION; | 970 | else if (ttype(top) == LUA_T_CMARK) ttype(top) = LUA_T_CFUNCTION; |
| 971 | incr_top; | 971 | incr_top; |
| 972 | } | 972 | } |
| 973 | 973 | ||
| @@ -991,13 +991,13 @@ static void call_arith (char *op) | |||
| 991 | callFB(FB_ARITH); | 991 | callFB(FB_ARITH); |
| 992 | } | 992 | } |
| 993 | 993 | ||
| 994 | static void comparison (lua_Type tag_less, lua_Type tag_equal, | 994 | static void comparison (lua_Type ttype_less, lua_Type ttype_equal, |
| 995 | lua_Type tag_great, char *op) | 995 | lua_Type ttype_great, char *op) |
| 996 | { | 996 | { |
| 997 | Object *l = top-2; | 997 | Object *l = top-2; |
| 998 | Object *r = top-1; | 998 | Object *r = top-1; |
| 999 | int result; | 999 | int result; |
| 1000 | if (tag(l) == LUA_T_NUMBER && tag(r) == LUA_T_NUMBER) | 1000 | if (ttype(l) == LUA_T_NUMBER && ttype(r) == LUA_T_NUMBER) |
| 1001 | result = (nvalue(l) < nvalue(r)) ? -1 : (nvalue(l) == nvalue(r)) ? 0 : 1; | 1001 | result = (nvalue(l) < nvalue(r)) ? -1 : (nvalue(l) == nvalue(r)) ? 0 : 1; |
| 1002 | else if (tostring(l) || tostring(r)) | 1002 | else if (tostring(l) || tostring(r)) |
| 1003 | { | 1003 | { |
| @@ -1009,7 +1009,8 @@ static void comparison (lua_Type tag_less, lua_Type tag_equal, | |||
| 1009 | result = strcmp(svalue(l), svalue(r)); | 1009 | result = strcmp(svalue(l), svalue(r)); |
| 1010 | top--; | 1010 | top--; |
| 1011 | nvalue(top-1) = 1; | 1011 | nvalue(top-1) = 1; |
| 1012 | tag(top-1) = (result < 0) ? tag_less : (result == 0) ? tag_equal : tag_great; | 1012 | ttype(top-1) = (result < 0) ? ttype_less : |
| 1013 | (result == 0) ? ttype_equal : ttype_great; | ||
| 1013 | } | 1014 | } |
| 1014 | 1015 | ||
| 1015 | 1016 | ||
| @@ -1021,18 +1022,18 @@ static void adjust_varargs (StkId first_extra_arg) | |||
| 1021 | int i; | 1022 | int i; |
| 1022 | if (nvararg < 0) nvararg = 0; | 1023 | if (nvararg < 0) nvararg = 0; |
| 1023 | avalue(&arg) = lua_createarray(nvararg+1); /* +1 for field 'n' */ | 1024 | avalue(&arg) = lua_createarray(nvararg+1); /* +1 for field 'n' */ |
| 1024 | tag(&arg) = LUA_T_ARRAY; | 1025 | ttype(&arg) = LUA_T_ARRAY; |
| 1025 | for (i=0; i<nvararg; i++) { | 1026 | for (i=0; i<nvararg; i++) { |
| 1026 | Object index; | 1027 | Object index; |
| 1027 | tag(&index) = LUA_T_NUMBER; | 1028 | ttype(&index) = LUA_T_NUMBER; |
| 1028 | nvalue(&index) = i+1; | 1029 | nvalue(&index) = i+1; |
| 1029 | *(lua_hashdefine(avalue(&arg), &index)) = *(firstelem+i); | 1030 | *(lua_hashdefine(avalue(&arg), &index)) = *(firstelem+i); |
| 1030 | } | 1031 | } |
| 1031 | /* store counter in field "n" */ { | 1032 | /* store counter in field "n" */ { |
| 1032 | Object index, extra; | 1033 | Object index, extra; |
| 1033 | tag(&index) = LUA_T_STRING; | 1034 | ttype(&index) = LUA_T_STRING; |
| 1034 | tsvalue(&index) = lua_createstring("n"); | 1035 | tsvalue(&index) = lua_createstring("n"); |
| 1035 | tag(&extra) = LUA_T_NUMBER; | 1036 | ttype(&extra) = LUA_T_NUMBER; |
| 1036 | nvalue(&extra) = nvararg; | 1037 | nvalue(&extra) = nvararg; |
| 1037 | *(lua_hashdefine(avalue(&arg), &index)) = extra; | 1038 | *(lua_hashdefine(avalue(&arg), &index)) = extra; |
| 1038 | } | 1039 | } |
| @@ -1056,22 +1057,22 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1056 | OpCode opcode; | 1057 | OpCode opcode; |
| 1057 | switch (opcode = (OpCode)*pc++) | 1058 | switch (opcode = (OpCode)*pc++) |
| 1058 | { | 1059 | { |
| 1059 | case PUSHNIL: tag(top) = LUA_T_NIL; incr_top; break; | 1060 | case PUSHNIL: ttype(top) = LUA_T_NIL; incr_top; break; |
| 1060 | 1061 | ||
| 1061 | case PUSH0: case PUSH1: case PUSH2: | 1062 | case PUSH0: case PUSH1: case PUSH2: |
| 1062 | tag(top) = LUA_T_NUMBER; | 1063 | ttype(top) = LUA_T_NUMBER; |
| 1063 | nvalue(top) = opcode-PUSH0; | 1064 | nvalue(top) = opcode-PUSH0; |
| 1064 | incr_top; | 1065 | incr_top; |
| 1065 | break; | 1066 | break; |
| 1066 | 1067 | ||
| 1067 | case PUSHBYTE: | 1068 | case PUSHBYTE: |
| 1068 | tag(top) = LUA_T_NUMBER; nvalue(top) = *pc++; incr_top; break; | 1069 | ttype(top) = LUA_T_NUMBER; nvalue(top) = *pc++; incr_top; break; |
| 1069 | 1070 | ||
| 1070 | case PUSHWORD: | 1071 | case PUSHWORD: |
| 1071 | { | 1072 | { |
| 1072 | Word w; | 1073 | Word w; |
| 1073 | get_word(w,pc); | 1074 | get_word(w,pc); |
| 1074 | tag(top) = LUA_T_NUMBER; nvalue(top) = w; | 1075 | ttype(top) = LUA_T_NUMBER; nvalue(top) = w; |
| 1075 | incr_top; | 1076 | incr_top; |
| 1076 | } | 1077 | } |
| 1077 | break; | 1078 | break; |
| @@ -1080,7 +1081,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1080 | { | 1081 | { |
| 1081 | real num; | 1082 | real num; |
| 1082 | get_float(num,pc); | 1083 | get_float(num,pc); |
| 1083 | tag(top) = LUA_T_NUMBER; nvalue(top) = num; | 1084 | ttype(top) = LUA_T_NUMBER; nvalue(top) = num; |
| 1084 | incr_top; | 1085 | incr_top; |
| 1085 | } | 1086 | } |
| 1086 | break; | 1087 | break; |
| @@ -1089,7 +1090,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1089 | { | 1090 | { |
| 1090 | Word w; | 1091 | Word w; |
| 1091 | get_word(w,pc); | 1092 | get_word(w,pc); |
| 1092 | tag(top) = LUA_T_STRING; tsvalue(top) = lua_constant[w]; | 1093 | ttype(top) = LUA_T_STRING; tsvalue(top) = lua_constant[w]; |
| 1093 | incr_top; | 1094 | incr_top; |
| 1094 | } | 1095 | } |
| 1095 | break; | 1096 | break; |
| @@ -1099,7 +1100,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1099 | TFunc *f; | 1100 | TFunc *f; |
| 1100 | get_code(f,pc); | 1101 | get_code(f,pc); |
| 1101 | luaI_insertfunction(f); /* may take part in GC */ | 1102 | luaI_insertfunction(f); /* may take part in GC */ |
| 1102 | top->tag = LUA_T_FUNCTION; | 1103 | top->ttype = LUA_T_FUNCTION; |
| 1103 | top->value.tf = f; | 1104 | top->value.tf = f; |
| 1104 | incr_top; | 1105 | incr_top; |
| 1105 | } | 1106 | } |
| @@ -1130,7 +1131,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1130 | Object receiver = *(top-1); | 1131 | Object receiver = *(top-1); |
| 1131 | Word w; | 1132 | Word w; |
| 1132 | get_word(w,pc); | 1133 | get_word(w,pc); |
| 1133 | tag(top) = LUA_T_STRING; tsvalue(top) = lua_constant[w]; | 1134 | ttype(top) = LUA_T_STRING; tsvalue(top) = lua_constant[w]; |
| 1134 | incr_top; | 1135 | incr_top; |
| 1135 | pushsubscript(); | 1136 | pushsubscript(); |
| 1136 | *top = receiver; | 1137 | *top = receiver; |
| @@ -1176,7 +1177,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1176 | arr = top-n-1; | 1177 | arr = top-n-1; |
| 1177 | while (n) | 1178 | while (n) |
| 1178 | { | 1179 | { |
| 1179 | tag(top) = LUA_T_NUMBER; nvalue(top) = n+m; | 1180 | ttype(top) = LUA_T_NUMBER; nvalue(top) = n+m; |
| 1180 | *(lua_hashdefine (avalue(arr), top)) = *(top-1); | 1181 | *(lua_hashdefine (avalue(arr), top)) = *(top-1); |
| 1181 | top--; | 1182 | top--; |
| 1182 | n--; | 1183 | n--; |
| @@ -1192,7 +1193,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1192 | { | 1193 | { |
| 1193 | Word w; | 1194 | Word w; |
| 1194 | get_word(w,pc); | 1195 | get_word(w,pc); |
| 1195 | tag(top) = LUA_T_STRING; tsvalue(top) = lua_constant[w]; | 1196 | ttype(top) = LUA_T_STRING; tsvalue(top) = lua_constant[w]; |
| 1196 | *(lua_hashdefine (avalue(arr), top)) = *(top-1); | 1197 | *(lua_hashdefine (avalue(arr), top)) = *(top-1); |
| 1197 | top--; | 1198 | top--; |
| 1198 | n--; | 1199 | n--; |
| @@ -1227,7 +1228,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1227 | Word size; | 1228 | Word size; |
| 1228 | get_word(size,pc); | 1229 | get_word(size,pc); |
| 1229 | avalue(top) = lua_createarray(size); | 1230 | avalue(top) = lua_createarray(size); |
| 1230 | tag(top) = LUA_T_ARRAY; | 1231 | ttype(top) = LUA_T_ARRAY; |
| 1231 | incr_top; | 1232 | incr_top; |
| 1232 | } | 1233 | } |
| 1233 | break; | 1234 | break; |
| @@ -1236,7 +1237,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1236 | { | 1237 | { |
| 1237 | int res = lua_equalObj(top-2, top-1); | 1238 | int res = lua_equalObj(top-2, top-1); |
| 1238 | --top; | 1239 | --top; |
| 1239 | tag(top-1) = res ? LUA_T_NUMBER : LUA_T_NIL; | 1240 | ttype(top-1) = res ? LUA_T_NUMBER : LUA_T_NIL; |
| 1240 | nvalue(top-1) = 1; | 1241 | nvalue(top-1) = 1; |
| 1241 | } | 1242 | } |
| 1242 | break; | 1243 | break; |
| @@ -1334,7 +1335,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1334 | case MINUSOP: | 1335 | case MINUSOP: |
| 1335 | if (tonumber(top-1)) | 1336 | if (tonumber(top-1)) |
| 1336 | { | 1337 | { |
| 1337 | tag(top) = LUA_T_NIL; | 1338 | ttype(top) = LUA_T_NIL; |
| 1338 | incr_top; | 1339 | incr_top; |
| 1339 | call_arith("unm"); | 1340 | call_arith("unm"); |
| 1340 | } | 1341 | } |
| @@ -1343,7 +1344,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1343 | break; | 1344 | break; |
| 1344 | 1345 | ||
| 1345 | case NOTOP: | 1346 | case NOTOP: |
| 1346 | tag(top-1) = (tag(top-1) == LUA_T_NIL) ? LUA_T_NUMBER : LUA_T_NIL; | 1347 | ttype(top-1) = (ttype(top-1) == LUA_T_NIL) ? LUA_T_NUMBER : LUA_T_NIL; |
| 1347 | nvalue(top-1) = 1; | 1348 | nvalue(top-1) = 1; |
| 1348 | break; | 1349 | break; |
| 1349 | 1350 | ||
| @@ -1351,7 +1352,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1351 | { | 1352 | { |
| 1352 | Word w; | 1353 | Word w; |
| 1353 | get_word(w,pc); | 1354 | get_word(w,pc); |
| 1354 | if (tag(top-1) != LUA_T_NIL) pc += w; | 1355 | if (ttype(top-1) != LUA_T_NIL) pc += w; |
| 1355 | } | 1356 | } |
| 1356 | break; | 1357 | break; |
| 1357 | 1358 | ||
| @@ -1359,7 +1360,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1359 | { | 1360 | { |
| 1360 | Word w; | 1361 | Word w; |
| 1361 | get_word(w,pc); | 1362 | get_word(w,pc); |
| 1362 | if (tag(top-1) == LUA_T_NIL) pc += w; | 1363 | if (ttype(top-1) == LUA_T_NIL) pc += w; |
| 1363 | } | 1364 | } |
| 1364 | break; | 1365 | break; |
| 1365 | 1366 | ||
| @@ -1384,7 +1385,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1384 | Word w; | 1385 | Word w; |
| 1385 | get_word(w,pc); | 1386 | get_word(w,pc); |
| 1386 | top--; | 1387 | top--; |
| 1387 | if (tag(top) == LUA_T_NIL) pc += w; | 1388 | if (ttype(top) == LUA_T_NIL) pc += w; |
| 1388 | } | 1389 | } |
| 1389 | break; | 1390 | break; |
| 1390 | 1391 | ||
| @@ -1393,7 +1394,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1393 | Word w; | 1394 | Word w; |
| 1394 | get_word(w,pc); | 1395 | get_word(w,pc); |
| 1395 | top--; | 1396 | top--; |
| 1396 | if (tag(top) == LUA_T_NIL) pc -= w; | 1397 | if (ttype(top) == LUA_T_NIL) pc -= w; |
| 1397 | } | 1398 | } |
| 1398 | break; | 1399 | break; |
| 1399 | 1400 | ||
| @@ -1418,12 +1419,12 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1418 | { | 1419 | { |
| 1419 | Word line; | 1420 | Word line; |
| 1420 | get_word(line,pc); | 1421 | get_word(line,pc); |
| 1421 | if ((stack+base-1)->tag != LUA_T_LINE) | 1422 | if ((stack+base-1)->ttype != LUA_T_LINE) |
| 1422 | { | 1423 | { |
| 1423 | /* open space for LINE value */ | 1424 | /* open space for LINE value */ |
| 1424 | open_stack((top-stack)-base); | 1425 | open_stack((top-stack)-base); |
| 1425 | base++; | 1426 | base++; |
| 1426 | (stack+base-1)->tag = LUA_T_LINE; | 1427 | (stack+base-1)->ttype = LUA_T_LINE; |
| 1427 | } | 1428 | } |
| 1428 | (stack+base-1)->value.i = line; | 1429 | (stack+base-1)->value.i = line; |
| 1429 | if (lua_linehook) | 1430 | if (lua_linehook) |
