diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-03-31 11:02:58 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-03-31 11:02:58 -0300 |
| commit | ad5574c4c97af3ef863a6fb4b72142f3780103b2 (patch) | |
| tree | 7ef70322749e3e433321edbea89d61087d820c55 /opcode.c | |
| parent | 264f8c5e7bd168de2f0ca07399e6fc70d5a820d3 (diff) | |
| download | lua-ad5574c4c97af3ef863a6fb4b72142f3780103b2.tar.gz lua-ad5574c4c97af3ef863a6fb4b72142f3780103b2.tar.bz2 lua-ad5574c4c97af3ef863a6fb4b72142f3780103b2.zip | |
"Object" renamed to "TObject" (Tagged Object), to avoid conflicts with
pre-defined names in some C compilers.
Diffstat (limited to 'opcode.c')
| -rw-r--r-- | opcode.c | 118 |
1 files changed, 59 insertions, 59 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.85 1997/03/19 19:41:10 roberto Exp roberto $"; | 6 | char *rcs_opcode="$Id: opcode.c,v 3.86 1997/03/20 19:20:43 roberto Exp roberto $"; |
| 7 | 7 | ||
| 8 | #include <setjmp.h> | 8 | #include <setjmp.h> |
| 9 | #include <stdio.h> | 9 | #include <stdio.h> |
| @@ -32,14 +32,14 @@ char *rcs_opcode="$Id: opcode.c,v 3.85 1997/03/19 19:41:10 roberto Exp roberto $ | |||
| 32 | 32 | ||
| 33 | typedef int StkId; /* index to stack elements */ | 33 | typedef int StkId; /* index to stack elements */ |
| 34 | 34 | ||
| 35 | static Object initial_stack; | 35 | static TObject initial_stack; |
| 36 | 36 | ||
| 37 | static Object *stackLimit = &initial_stack+1; | 37 | static TObject *stackLimit = &initial_stack+1; |
| 38 | static Object *stack = &initial_stack; | 38 | static TObject *stack = &initial_stack; |
| 39 | static Object *top = &initial_stack; | 39 | static TObject *top = &initial_stack; |
| 40 | 40 | ||
| 41 | 41 | ||
| 42 | /* macros to convert from lua_Object to (Object *) and back */ | 42 | /* macros to convert from lua_Object to (TObject *) and back */ |
| 43 | 43 | ||
| 44 | #define Address(lo) ((lo)+stack-1) | 44 | #define Address(lo) ((lo)+stack-1) |
| 45 | #define Ref(st) ((st)-stack+1) | 45 | #define Ref(st) ((st)-stack+1) |
| @@ -72,7 +72,7 @@ static void do_call (StkId base, int nResults); | |||
| 72 | 72 | ||
| 73 | 73 | ||
| 74 | 74 | ||
| 75 | Object *luaI_Address (lua_Object o) | 75 | TObject *luaI_Address (lua_Object o) |
| 76 | { | 76 | { |
| 77 | return Address(o); | 77 | return Address(o); |
| 78 | } | 78 | } |
| @@ -84,7 +84,7 @@ Object *luaI_Address (lua_Object o) | |||
| 84 | static void lua_initstack (void) | 84 | static void lua_initstack (void) |
| 85 | { | 85 | { |
| 86 | Long maxstack = STACK_SIZE; | 86 | Long maxstack = STACK_SIZE; |
| 87 | stack = newvector(maxstack, Object); | 87 | stack = newvector(maxstack, TObject); |
| 88 | stackLimit = stack+maxstack; | 88 | stackLimit = stack+maxstack; |
| 89 | top = stack; | 89 | top = stack; |
| 90 | *(top++) = initial_stack; | 90 | *(top++) = initial_stack; |
| @@ -105,7 +105,7 @@ static void growstack (void) | |||
| 105 | static int limit = STACK_LIMIT; | 105 | static int limit = STACK_LIMIT; |
| 106 | StkId t = top-stack; | 106 | StkId t = top-stack; |
| 107 | Long stacksize = stackLimit - stack; | 107 | Long stacksize = stackLimit - stack; |
| 108 | stacksize = growvector(&stack, stacksize, Object, stackEM, limit+100); | 108 | stacksize = growvector(&stack, stacksize, TObject, stackEM, limit+100); |
| 109 | stackLimit = stack+stacksize; | 109 | stackLimit = stack+stacksize; |
| 110 | top = stack + t; | 110 | top = stack + t; |
| 111 | if (stacksize >= limit) | 111 | if (stacksize >= limit) |
| @@ -134,7 +134,7 @@ static char *lua_strconc (char *l, char *r) | |||
| 134 | ** Convert, if possible, to a number object. | 134 | ** Convert, if possible, to a number object. |
| 135 | ** Return 0 if success, not 0 if error. | 135 | ** Return 0 if success, not 0 if error. |
| 136 | */ | 136 | */ |
| 137 | static int lua_tonumber (Object *obj) | 137 | static int lua_tonumber (TObject *obj) |
| 138 | { | 138 | { |
| 139 | float t; | 139 | float t; |
| 140 | char c; | 140 | char c; |
| @@ -155,7 +155,7 @@ static int lua_tonumber (Object *obj) | |||
| 155 | ** Convert, if possible, to a string ttype | 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 (TObject *obj) |
| 159 | { | 159 | { |
| 160 | if (ttype(obj) != LUA_T_NUMBER) | 160 | if (ttype(obj) != LUA_T_NUMBER) |
| 161 | return 1; | 161 | return 1; |
| @@ -179,7 +179,7 @@ static int lua_tostring (Object *obj) | |||
| 179 | */ | 179 | */ |
| 180 | static void adjust_top (StkId newtop) | 180 | static void adjust_top (StkId newtop) |
| 181 | { | 181 | { |
| 182 | Object *nt; | 182 | TObject *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) ttype(top++) = LUA_T_NIL; | 185 | while (top < nt) ttype(top++) = LUA_T_NIL; |
| @@ -228,7 +228,7 @@ static void callHook (StkId base, lua_Type type, int isreturn) | |||
| 228 | (*lua_callhook)(LUA_NOOBJECT, "(return)", 0); | 228 | (*lua_callhook)(LUA_NOOBJECT, "(return)", 0); |
| 229 | else | 229 | else |
| 230 | { | 230 | { |
| 231 | Object *f = stack+base-1; | 231 | TObject *f = stack+base-1; |
| 232 | if (type == LUA_T_MARK) | 232 | if (type == LUA_T_MARK) |
| 233 | (*lua_callhook)(Ref(f), f->value.tf->fileName, f->value.tf->lineDefined); | 233 | (*lua_callhook)(Ref(f), f->value.tf->fileName, f->value.tf->lineDefined); |
| 234 | else | 234 | else |
| @@ -261,7 +261,7 @@ static StkId callC (lua_CFunction func, StkId base) | |||
| 261 | return firstResult; | 261 | return firstResult; |
| 262 | } | 262 | } |
| 263 | 263 | ||
| 264 | static void callIM (Object *f, int nParams, int nResults) | 264 | static void callIM (TObject *f, int nParams, int nResults) |
| 265 | { | 265 | { |
| 266 | open_stack(nParams); | 266 | open_stack(nParams); |
| 267 | *(top-nParams-1) = *f; | 267 | *(top-nParams-1) = *f; |
| @@ -278,7 +278,7 @@ static void callIM (Object *f, int nParams, int nResults) | |||
| 278 | static void do_call (StkId base, int nResults) | 278 | static void do_call (StkId base, int nResults) |
| 279 | { | 279 | { |
| 280 | StkId firstResult; | 280 | StkId firstResult; |
| 281 | Object *func = stack+base-1; | 281 | TObject *func = stack+base-1; |
| 282 | int i; | 282 | int i; |
| 283 | if (ttype(func) == LUA_T_CFUNCTION) { | 283 | if (ttype(func) == LUA_T_CFUNCTION) { |
| 284 | ttype(func) = LUA_T_CMARK; | 284 | ttype(func) = LUA_T_CMARK; |
| @@ -290,7 +290,7 @@ static void do_call (StkId base, int nResults) | |||
| 290 | } | 290 | } |
| 291 | else { /* func is not a function */ | 291 | else { /* func is not a function */ |
| 292 | /* Check the fallback for invalid functions */ | 292 | /* Check the fallback for invalid functions */ |
| 293 | Object *im = luaI_getimbyObj(func, IM_FUNCTION); | 293 | TObject *im = luaI_getimbyObj(func, IM_FUNCTION); |
| 294 | if (ttype(im) == LUA_T_NIL) | 294 | if (ttype(im) == LUA_T_NIL) |
| 295 | lua_error("call expression not a function"); | 295 | lua_error("call expression not a function"); |
| 296 | open_stack((top-stack)-(base-1)); | 296 | open_stack((top-stack)-(base-1)); |
| @@ -317,9 +317,9 @@ static void do_call (StkId base, int nResults) | |||
| 317 | static void pushsubscript (void) | 317 | static void pushsubscript (void) |
| 318 | { | 318 | { |
| 319 | int tg = luaI_tag(top-2); | 319 | int tg = luaI_tag(top-2); |
| 320 | Object *im = luaI_getim(tg, IM_GETTABLE); | 320 | TObject *im = luaI_getim(tg, IM_GETTABLE); |
| 321 | if (ttype(top-2) == LUA_T_ARRAY && ttype(im) == LUA_T_NIL) { | 321 | if (ttype(top-2) == LUA_T_ARRAY && ttype(im) == LUA_T_NIL) { |
| 322 | Object *h = lua_hashget(avalue(top-2), top-1); | 322 | TObject *h = lua_hashget(avalue(top-2), top-1); |
| 323 | if (h != NULL && ttype(h) != LUA_T_NIL) { | 323 | if (h != NULL && ttype(h) != LUA_T_NIL) { |
| 324 | --top; | 324 | --top; |
| 325 | *(top-1) = *h; | 325 | *(top-1) = *h; |
| @@ -346,7 +346,7 @@ lua_Object lua_basicindex (void) | |||
| 346 | if (ttype(top-2) != LUA_T_ARRAY) | 346 | if (ttype(top-2) != LUA_T_ARRAY) |
| 347 | lua_error("indexed expression not a table in basic indexing"); | 347 | lua_error("indexed expression not a table in basic indexing"); |
| 348 | else { | 348 | else { |
| 349 | Object *h = lua_hashget(avalue(top-2), top-1); | 349 | TObject *h = lua_hashget(avalue(top-2), top-1); |
| 350 | --top; | 350 | --top; |
| 351 | if (h != NULL) | 351 | if (h != NULL) |
| 352 | *(top-1) = *h; | 352 | *(top-1) = *h; |
| @@ -364,11 +364,11 @@ lua_Object lua_basicindex (void) | |||
| 364 | ** mode = 1: normal store (with internal methods) | 364 | ** mode = 1: normal store (with internal methods) |
| 365 | ** mode = 2: "deep stack" store (with internal methods) | 365 | ** mode = 2: "deep stack" store (with internal methods) |
| 366 | */ | 366 | */ |
| 367 | static void storesubscript (Object *t, int mode) | 367 | static void storesubscript (TObject *t, int mode) |
| 368 | { | 368 | { |
| 369 | Object *im = (mode == 0) ? NULL : luaI_getimbyObj(t, IM_SETTABLE); | 369 | TObject *im = (mode == 0) ? NULL : luaI_getimbyObj(t, IM_SETTABLE); |
| 370 | if (ttype(t) == LUA_T_ARRAY && (im == NULL || ttype(im) == LUA_T_NIL)) { | 370 | if (ttype(t) == LUA_T_ARRAY && (im == NULL || ttype(im) == LUA_T_NIL)) { |
| 371 | Object *h = lua_hashdefine(avalue(t), t+1); | 371 | TObject *h = lua_hashdefine(avalue(t), t+1); |
| 372 | *h = *(top-1); | 372 | *h = *(top-1); |
| 373 | top -= (mode == 2) ? 1 : 3; | 373 | top -= (mode == 2) ? 1 : 3; |
| 374 | } | 374 | } |
| @@ -394,7 +394,7 @@ static void getglobal (Word n) | |||
| 394 | *top = lua_table[n].object; | 394 | *top = lua_table[n].object; |
| 395 | incr_top; | 395 | incr_top; |
| 396 | if (ttype(top-1) == LUA_T_NIL) { /* check i.m. */ | 396 | if (ttype(top-1) == LUA_T_NIL) { /* check i.m. */ |
| 397 | Object *im = luaI_getgim(GIM_GETGLOBAL); | 397 | TObject *im = luaI_getgim(GIM_GETGLOBAL); |
| 398 | if (ttype(im) != LUA_T_NIL) { | 398 | if (ttype(im) != LUA_T_NIL) { |
| 399 | ttype(top-1) = LUA_T_STRING; | 399 | ttype(top-1) = LUA_T_STRING; |
| 400 | tsvalue(top-1) = lua_table[n].varname; | 400 | tsvalue(top-1) = lua_table[n].varname; |
| @@ -406,9 +406,9 @@ static void getglobal (Word n) | |||
| 406 | /* | 406 | /* |
| 407 | ** Traverse all objects on stack | 407 | ** Traverse all objects on stack |
| 408 | */ | 408 | */ |
| 409 | void lua_travstack (int (*fn)(Object *)) | 409 | void lua_travstack (int (*fn)(TObject *)) |
| 410 | { | 410 | { |
| 411 | Object *o; | 411 | TObject *o; |
| 412 | for (o = top-1; o >= stack; o--) | 412 | for (o = top-1; o >= stack; o--) |
| 413 | fn (o); | 413 | fn (o); |
| 414 | } | 414 | } |
| @@ -420,7 +420,7 @@ void lua_travstack (int (*fn)(Object *)) | |||
| 420 | 420 | ||
| 421 | static void lua_message (char *s) | 421 | static void lua_message (char *s) |
| 422 | { | 422 | { |
| 423 | Object *im = luaI_getgim(GIM_ERROR); | 423 | TObject *im = luaI_getgim(GIM_ERROR); |
| 424 | if (ttype(im) == LUA_T_NIL) | 424 | if (ttype(im) == LUA_T_NIL) |
| 425 | fprintf(stderr, "lua: %s\n", s); | 425 | fprintf(stderr, "lua: %s\n", s); |
| 426 | else { | 426 | else { |
| @@ -458,14 +458,14 @@ lua_Function lua_stackedfunction (int level) | |||
| 458 | 458 | ||
| 459 | int lua_currentline (lua_Function func) | 459 | int lua_currentline (lua_Function func) |
| 460 | { | 460 | { |
| 461 | Object *f = Address(func); | 461 | TObject *f = Address(func); |
| 462 | return (f+1 < top && (f+1)->ttype == LUA_T_LINE) ? (f+1)->value.i : -1; | 462 | return (f+1 < top && (f+1)->ttype == LUA_T_LINE) ? (f+1)->value.i : -1; |
| 463 | } | 463 | } |
| 464 | 464 | ||
| 465 | 465 | ||
| 466 | lua_Object lua_getlocal (lua_Function func, int local_number, char **name) | 466 | lua_Object lua_getlocal (lua_Function func, int local_number, char **name) |
| 467 | { | 467 | { |
| 468 | Object *f = luaI_Address(func); | 468 | TObject *f = luaI_Address(func); |
| 469 | *name = luaI_getlocalname(f->value.tf, local_number, lua_currentline(func)); | 469 | *name = luaI_getlocalname(f->value.tf, local_number, lua_currentline(func)); |
| 470 | if (*name) | 470 | if (*name) |
| 471 | { | 471 | { |
| @@ -479,7 +479,7 @@ lua_Object lua_getlocal (lua_Function func, int local_number, char **name) | |||
| 479 | 479 | ||
| 480 | int lua_setlocal (lua_Function func, int local_number) | 480 | int lua_setlocal (lua_Function func, int local_number) |
| 481 | { | 481 | { |
| 482 | Object *f = Address(func); | 482 | TObject *f = Address(func); |
| 483 | char *name = luaI_getlocalname(f->value.tf, local_number, lua_currentline(func)); | 483 | char *name = luaI_getlocalname(f->value.tf, local_number, lua_currentline(func)); |
| 484 | adjustC(1); | 484 | adjustC(1); |
| 485 | --top; | 485 | --top; |
| @@ -843,7 +843,7 @@ lua_CFunction lua_getcfunction (lua_Object object) | |||
| 843 | 843 | ||
| 844 | lua_Object lua_getref (int ref) | 844 | lua_Object lua_getref (int ref) |
| 845 | { | 845 | { |
| 846 | Object *o = luaI_getref(ref); | 846 | TObject *o = luaI_getref(ref); |
| 847 | if (o == NULL) | 847 | if (o == NULL) |
| 848 | return LUA_NOOBJECT; | 848 | return LUA_NOOBJECT; |
| 849 | adjustC(0); | 849 | adjustC(0); |
| @@ -855,7 +855,7 @@ lua_Object lua_getref (int ref) | |||
| 855 | 855 | ||
| 856 | void lua_pushref (int ref) | 856 | void lua_pushref (int ref) |
| 857 | { | 857 | { |
| 858 | Object *o = luaI_getref(ref); | 858 | TObject *o = luaI_getref(ref); |
| 859 | if (o == NULL) | 859 | if (o == NULL) |
| 860 | lua_error("access to invalid (possibly garbage collected) reference"); | 860 | lua_error("access to invalid (possibly garbage collected) reference"); |
| 861 | luaI_pushobject(o); | 861 | luaI_pushobject(o); |
| @@ -970,7 +970,7 @@ void lua_pushusertag (void *u, int tag) | |||
| 970 | /* | 970 | /* |
| 971 | ** Push an object on the stack. | 971 | ** Push an object on the stack. |
| 972 | */ | 972 | */ |
| 973 | void luaI_pushobject (Object *o) | 973 | void luaI_pushobject (TObject *o) |
| 974 | { | 974 | { |
| 975 | *top = *o; | 975 | *top = *o; |
| 976 | incr_top; | 976 | incr_top; |
| @@ -995,9 +995,9 @@ int lua_tag (lua_Object o) | |||
| 995 | } | 995 | } |
| 996 | 996 | ||
| 997 | 997 | ||
| 998 | void luaI_gcIM (Object *o) | 998 | void luaI_gcIM (TObject *o) |
| 999 | { | 999 | { |
| 1000 | Object *im = luaI_getimbyObj(o, IM_GC); | 1000 | TObject *im = luaI_getimbyObj(o, IM_GC); |
| 1001 | if (ttype(im) != LUA_T_NIL) { | 1001 | if (ttype(im) != LUA_T_NIL) { |
| 1002 | *top = *o; | 1002 | *top = *o; |
| 1003 | incr_top; | 1003 | incr_top; |
| @@ -1008,7 +1008,7 @@ void luaI_gcIM (Object *o) | |||
| 1008 | 1008 | ||
| 1009 | static void call_arith (IMS event) | 1009 | static void call_arith (IMS event) |
| 1010 | { | 1010 | { |
| 1011 | Object *im = luaI_getimbyObj(top-2, event); /* try first operand */ | 1011 | TObject *im = luaI_getimbyObj(top-2, event); /* try first operand */ |
| 1012 | if (ttype(im) == LUA_T_NIL) { | 1012 | if (ttype(im) == LUA_T_NIL) { |
| 1013 | im = luaI_getimbyObj(top-1, event); /* try second operand */ | 1013 | im = luaI_getimbyObj(top-1, event); /* try second operand */ |
| 1014 | if (ttype(im) == LUA_T_NIL) { | 1014 | if (ttype(im) == LUA_T_NIL) { |
| @@ -1021,17 +1021,17 @@ static void call_arith (IMS event) | |||
| 1021 | callIM(im, 3, 1); | 1021 | callIM(im, 3, 1); |
| 1022 | } | 1022 | } |
| 1023 | 1023 | ||
| 1024 | static void concim (Object *o) | 1024 | static void concim (TObject *o) |
| 1025 | { | 1025 | { |
| 1026 | Object *im = luaI_getimbyObj(o, IM_CONCAT); | 1026 | TObject *im = luaI_getimbyObj(o, IM_CONCAT); |
| 1027 | if (ttype(im) == LUA_T_NIL) | 1027 | if (ttype(im) == LUA_T_NIL) |
| 1028 | lua_error("unexpected type at conversion to string"); | 1028 | lua_error("unexpected type at conversion to string"); |
| 1029 | callIM(im, 2, 1); | 1029 | callIM(im, 2, 1); |
| 1030 | } | 1030 | } |
| 1031 | 1031 | ||
| 1032 | static void ordim (Object *o, IMS event) | 1032 | static void ordim (TObject *o, IMS event) |
| 1033 | { | 1033 | { |
| 1034 | Object *im = luaI_getimbyObj(o, event); | 1034 | TObject *im = luaI_getimbyObj(o, event); |
| 1035 | if (ttype(im) == LUA_T_NIL) | 1035 | if (ttype(im) == LUA_T_NIL) |
| 1036 | lua_error("unexpected type at comparison"); | 1036 | lua_error("unexpected type at comparison"); |
| 1037 | lua_pushstring(luaI_eventname[event]); | 1037 | lua_pushstring(luaI_eventname[event]); |
| @@ -1041,8 +1041,8 @@ static void ordim (Object *o, IMS event) | |||
| 1041 | static void comparison (lua_Type ttype_less, lua_Type ttype_equal, | 1041 | static void comparison (lua_Type ttype_less, lua_Type ttype_equal, |
| 1042 | lua_Type ttype_great, IMS op) | 1042 | lua_Type ttype_great, IMS op) |
| 1043 | { | 1043 | { |
| 1044 | Object *l = top-2; | 1044 | TObject *l = top-2; |
| 1045 | Object *r = top-1; | 1045 | TObject *r = top-1; |
| 1046 | int result; | 1046 | int result; |
| 1047 | if (ttype(l) == LUA_T_NUMBER && ttype(r) == LUA_T_NUMBER) | 1047 | if (ttype(l) == LUA_T_NUMBER && ttype(r) == LUA_T_NUMBER) |
| 1048 | result = (nvalue(l) < nvalue(r)) ? -1 : (nvalue(l) == nvalue(r)) ? 0 : 1; | 1048 | result = (nvalue(l) < nvalue(r)) ? -1 : (nvalue(l) == nvalue(r)) ? 0 : 1; |
| @@ -1065,21 +1065,21 @@ static void comparison (lua_Type ttype_less, lua_Type ttype_equal, | |||
| 1065 | 1065 | ||
| 1066 | static void adjust_varargs (StkId first_extra_arg) | 1066 | static void adjust_varargs (StkId first_extra_arg) |
| 1067 | { | 1067 | { |
| 1068 | Object arg; | 1068 | TObject arg; |
| 1069 | Object *firstelem = stack+first_extra_arg; | 1069 | TObject *firstelem = stack+first_extra_arg; |
| 1070 | int nvararg = top-firstelem; | 1070 | int nvararg = top-firstelem; |
| 1071 | int i; | 1071 | int i; |
| 1072 | if (nvararg < 0) nvararg = 0; | 1072 | if (nvararg < 0) nvararg = 0; |
| 1073 | avalue(&arg) = lua_createarray(nvararg+1); /* +1 for field 'n' */ | 1073 | avalue(&arg) = lua_createarray(nvararg+1); /* +1 for field 'n' */ |
| 1074 | ttype(&arg) = LUA_T_ARRAY; | 1074 | ttype(&arg) = LUA_T_ARRAY; |
| 1075 | for (i=0; i<nvararg; i++) { | 1075 | for (i=0; i<nvararg; i++) { |
| 1076 | Object index; | 1076 | TObject index; |
| 1077 | ttype(&index) = LUA_T_NUMBER; | 1077 | ttype(&index) = LUA_T_NUMBER; |
| 1078 | nvalue(&index) = i+1; | 1078 | nvalue(&index) = i+1; |
| 1079 | *(lua_hashdefine(avalue(&arg), &index)) = *(firstelem+i); | 1079 | *(lua_hashdefine(avalue(&arg), &index)) = *(firstelem+i); |
| 1080 | } | 1080 | } |
| 1081 | /* store counter in field "n" */ { | 1081 | /* store counter in field "n" */ { |
| 1082 | Object index, extra; | 1082 | TObject index, extra; |
| 1083 | ttype(&index) = LUA_T_STRING; | 1083 | ttype(&index) = LUA_T_STRING; |
| 1084 | tsvalue(&index) = lua_createstring("n"); | 1084 | tsvalue(&index) = lua_createstring("n"); |
| 1085 | ttype(&extra) = LUA_T_NUMBER; | 1085 | ttype(&extra) = LUA_T_NUMBER; |
| @@ -1177,7 +1177,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1177 | 1177 | ||
| 1178 | case PUSHSELF: | 1178 | case PUSHSELF: |
| 1179 | { | 1179 | { |
| 1180 | Object receiver = *(top-1); | 1180 | TObject receiver = *(top-1); |
| 1181 | Word w; | 1181 | Word w; |
| 1182 | get_word(w,pc); | 1182 | get_word(w,pc); |
| 1183 | ttype(top) = LUA_T_STRING; tsvalue(top) = lua_constant[w]; | 1183 | ttype(top) = LUA_T_STRING; tsvalue(top) = lua_constant[w]; |
| @@ -1219,7 +1219,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1219 | case STORELIST: | 1219 | case STORELIST: |
| 1220 | { | 1220 | { |
| 1221 | int m, n; | 1221 | int m, n; |
| 1222 | Object *arr; | 1222 | TObject *arr; |
| 1223 | if (opcode == STORELIST0) m = 0; | 1223 | if (opcode == STORELIST0) m = 0; |
| 1224 | else m = *(pc++) * FIELDS_PER_FLUSH; | 1224 | else m = *(pc++) * FIELDS_PER_FLUSH; |
| 1225 | n = *(pc++); | 1225 | n = *(pc++); |
| @@ -1237,7 +1237,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1237 | case STORERECORD: /* opcode obsolete: supersed by STOREMAP */ | 1237 | case STORERECORD: /* opcode obsolete: supersed by STOREMAP */ |
| 1238 | { | 1238 | { |
| 1239 | int n = *(pc++); | 1239 | int n = *(pc++); |
| 1240 | Object *arr = top-n-1; | 1240 | TObject *arr = top-n-1; |
| 1241 | while (n) | 1241 | while (n) |
| 1242 | { | 1242 | { |
| 1243 | Word w; | 1243 | Word w; |
| @@ -1252,7 +1252,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1252 | 1252 | ||
| 1253 | case STOREMAP: { | 1253 | case STOREMAP: { |
| 1254 | int n = *(pc++); | 1254 | int n = *(pc++); |
| 1255 | Object *arr = top-(2*n)-1; | 1255 | TObject *arr = top-(2*n)-1; |
| 1256 | while (n--) { | 1256 | while (n--) { |
| 1257 | *(lua_hashdefine (avalue(arr), top-2)) = *(top-1); | 1257 | *(lua_hashdefine (avalue(arr), top-2)) = *(top-1); |
| 1258 | top-=2; | 1258 | top-=2; |
| @@ -1309,8 +1309,8 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1309 | 1309 | ||
| 1310 | case ADDOP: | 1310 | case ADDOP: |
| 1311 | { | 1311 | { |
| 1312 | Object *l = top-2; | 1312 | TObject *l = top-2; |
| 1313 | Object *r = top-1; | 1313 | TObject *r = top-1; |
| 1314 | if (tonumber(r) || tonumber(l)) | 1314 | if (tonumber(r) || tonumber(l)) |
| 1315 | call_arith(IM_ADD); | 1315 | call_arith(IM_ADD); |
| 1316 | else | 1316 | else |
| @@ -1323,8 +1323,8 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1323 | 1323 | ||
| 1324 | case SUBOP: | 1324 | case SUBOP: |
| 1325 | { | 1325 | { |
| 1326 | Object *l = top-2; | 1326 | TObject *l = top-2; |
| 1327 | Object *r = top-1; | 1327 | TObject *r = top-1; |
| 1328 | if (tonumber(r) || tonumber(l)) | 1328 | if (tonumber(r) || tonumber(l)) |
| 1329 | call_arith(IM_SUB); | 1329 | call_arith(IM_SUB); |
| 1330 | else | 1330 | else |
| @@ -1337,8 +1337,8 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1337 | 1337 | ||
| 1338 | case MULTOP: | 1338 | case MULTOP: |
| 1339 | { | 1339 | { |
| 1340 | Object *l = top-2; | 1340 | TObject *l = top-2; |
| 1341 | Object *r = top-1; | 1341 | TObject *r = top-1; |
| 1342 | if (tonumber(r) || tonumber(l)) | 1342 | if (tonumber(r) || tonumber(l)) |
| 1343 | call_arith(IM_MUL); | 1343 | call_arith(IM_MUL); |
| 1344 | else | 1344 | else |
| @@ -1351,8 +1351,8 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1351 | 1351 | ||
| 1352 | case DIVOP: | 1352 | case DIVOP: |
| 1353 | { | 1353 | { |
| 1354 | Object *l = top-2; | 1354 | TObject *l = top-2; |
| 1355 | Object *r = top-1; | 1355 | TObject *r = top-1; |
| 1356 | if (tonumber(r) || tonumber(l)) | 1356 | if (tonumber(r) || tonumber(l)) |
| 1357 | call_arith(IM_DIV); | 1357 | call_arith(IM_DIV); |
| 1358 | else | 1358 | else |
| @@ -1368,8 +1368,8 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1368 | break; | 1368 | break; |
| 1369 | 1369 | ||
| 1370 | case CONCOP: { | 1370 | case CONCOP: { |
| 1371 | Object *l = top-2; | 1371 | TObject *l = top-2; |
| 1372 | Object *r = top-1; | 1372 | TObject *r = top-1; |
| 1373 | if (tostring(l)) /* first argument is not a string */ | 1373 | if (tostring(l)) /* first argument is not a string */ |
| 1374 | concim(l); | 1374 | concim(l); |
| 1375 | else if (tostring(r)) /* second argument is not a string */ | 1375 | else if (tostring(r)) /* second argument is not a string */ |
