diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-01-25 11:57:18 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-01-25 11:57:18 -0200 |
commit | d11e5adf55b11a446671775a6c7803e066fc94e8 (patch) | |
tree | b7881e03e792bcc46f497577e8141b5ecc2e5b17 /lvm.c | |
parent | 99e340b2ba08226f4f7b457b170296af8d82959b (diff) | |
download | lua-d11e5adf55b11a446671775a6c7803e066fc94e8.tar.gz lua-d11e5adf55b11a446671775a6c7803e066fc94e8.tar.bz2 lua-d11e5adf55b11a446671775a6c7803e066fc94e8.zip |
`const' array in protos breaked in 3 arrays (for strings, numbers, and
prototypes).
Diffstat (limited to 'lvm.c')
-rw-r--r-- | lvm.c | 37 |
1 files changed, 21 insertions, 16 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 1.81 2000/01/19 16:50:30 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.82 2000/01/24 20:14:07 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 | */ |
@@ -314,7 +314,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf, | |||
314 | StkId base) { | 314 | StkId base) { |
315 | register StkId top; /* keep top local, for performance */ | 315 | register StkId top; /* keep top local, for performance */ |
316 | register const Byte *pc = tf->code; | 316 | register const Byte *pc = tf->code; |
317 | const TObject *consts = tf->consts; | 317 | TaggedString **strcnst = tf->strcnst; |
318 | if (L->callhook) | 318 | if (L->callhook) |
319 | luaD_callHook(L, base-1, L->callhook, "call"); | 319 | luaD_callHook(L, base-1, L->callhook, "call"); |
320 | luaD_checkstack(L, (*pc++)+EXTRA_STACK); | 320 | luaD_checkstack(L, (*pc++)+EXTRA_STACK); |
@@ -372,9 +372,18 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf, | |||
372 | top++; | 372 | top++; |
373 | break; | 373 | break; |
374 | 374 | ||
375 | case PUSHCONSTANTW: aux += highbyte(L, *pc++); | 375 | case PUSHSTRCNSTW: aux += highbyte(L, *pc++); |
376 | case PUSHCONSTANT: aux += *pc++; | 376 | case PUSHSTRCNST: aux += *pc++; |
377 | *top++ = consts[aux]; | 377 | ttype(top) = LUA_T_STRING; |
378 | tsvalue(top) = strcnst[aux]; | ||
379 | top++; | ||
380 | break; | ||
381 | |||
382 | case PUSHNUMCNSTW: aux += highbyte(L, *pc++); | ||
383 | case PUSHNUMCNST: aux += *pc++; | ||
384 | ttype(top) = LUA_T_NUMBER; | ||
385 | nvalue(top) = tf->numcnst[aux]; | ||
386 | top++; | ||
378 | break; | 387 | break; |
379 | 388 | ||
380 | case PUSHUPVALUE: aux = *pc++; | 389 | case PUSHUPVALUE: aux = *pc++; |
@@ -387,8 +396,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf, | |||
387 | 396 | ||
388 | case GETGLOBALW: aux += highbyte(L, *pc++); | 397 | case GETGLOBALW: aux += highbyte(L, *pc++); |
389 | case GETGLOBAL: aux += *pc++; | 398 | case GETGLOBAL: aux += *pc++; |
390 | LUA_ASSERT(L, ttype(&consts[aux]) == LUA_T_STRING, "unexpected type"); | 399 | luaV_getglobal(L, strcnst[aux]->u.s.gv, top); |
391 | luaV_getglobal(L, tsvalue(&consts[aux])->u.s.gv, top); | ||
392 | top++; | 400 | top++; |
393 | break; | 401 | break; |
394 | 402 | ||
@@ -399,9 +407,8 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf, | |||
399 | 407 | ||
400 | case GETDOTTEDW: aux += highbyte(L, *pc++); | 408 | case GETDOTTEDW: aux += highbyte(L, *pc++); |
401 | case GETDOTTED: aux += *pc++; | 409 | case GETDOTTED: aux += *pc++; |
402 | LUA_ASSERT(L, ttype(&consts[aux]) == LUA_T_STRING, "unexpected type"); | ||
403 | ttype(top) = LUA_T_STRING; | 410 | ttype(top) = LUA_T_STRING; |
404 | tsvalue(top++) = tsvalue(&consts[aux]); | 411 | tsvalue(top++) = strcnst[aux]; |
405 | luaV_gettable(L, top); | 412 | luaV_gettable(L, top); |
406 | top--; | 413 | top--; |
407 | break; | 414 | break; |
@@ -410,9 +417,8 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf, | |||
410 | case PUSHSELF: aux += *pc++; { | 417 | case PUSHSELF: aux += *pc++; { |
411 | TObject receiver; | 418 | TObject receiver; |
412 | receiver = *(top-1); | 419 | receiver = *(top-1); |
413 | LUA_ASSERT(L, ttype(&consts[aux]) == LUA_T_STRING, "unexpected type"); | ||
414 | ttype(top) = LUA_T_STRING; | 420 | ttype(top) = LUA_T_STRING; |
415 | tsvalue(top++) = tsvalue(&consts[aux]); | 421 | tsvalue(top++) = strcnst[aux]; |
416 | luaV_gettable(L, top); | 422 | luaV_gettable(L, top); |
417 | *(top-1) = receiver; | 423 | *(top-1) = receiver; |
418 | break; | 424 | break; |
@@ -433,8 +439,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf, | |||
433 | 439 | ||
434 | case SETGLOBALW: aux += highbyte(L, *pc++); | 440 | case SETGLOBALW: aux += highbyte(L, *pc++); |
435 | case SETGLOBAL: aux += *pc++; | 441 | case SETGLOBAL: aux += *pc++; |
436 | LUA_ASSERT(L, ttype(&consts[aux]) == LUA_T_STRING, "unexpected type"); | 442 | luaV_setglobal(L, strcnst[aux]->u.s.gv, top); |
437 | luaV_setglobal(L, tsvalue(&consts[aux])->u.s.gv, top); | ||
438 | top--; | 443 | top--; |
439 | break; | 444 | break; |
440 | 445 | ||
@@ -626,10 +631,10 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf, | |||
626 | 631 | ||
627 | case CLOSUREW: aux += highbyte(L, *pc++); | 632 | case CLOSUREW: aux += highbyte(L, *pc++); |
628 | case CLOSURE: aux += *pc++; | 633 | case CLOSURE: aux += *pc++; |
629 | *top++ = consts[aux]; | 634 | ttype(top) = LUA_T_LPROTO; |
630 | L->top = top; | 635 | tfvalue(top) = tf->protocnst[aux]; |
636 | L->top = ++top; | ||
631 | aux = *pc++; /* number of upvalues */ | 637 | aux = *pc++; /* number of upvalues */ |
632 | LUA_ASSERT(L, aux>0, "closure with no upvalues"); | ||
633 | luaV_closure(L, aux); | 638 | luaV_closure(L, aux); |
634 | luaC_checkGC(L); | 639 | luaC_checkGC(L); |
635 | top -= aux; | 640 | top -= aux; |