diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-03-05 18:16:07 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-03-05 18:16:07 -0300 |
| commit | 0870a2d1d8a1434eecae1923886ba219c4e699c7 (patch) | |
| tree | 3ca86564265ec369f3108ac286c61445ad50db14 /lvm.c | |
| parent | 78edc241e95d467e2b6c9a26b5311a62c7b04459 (diff) | |
| download | lua-0870a2d1d8a1434eecae1923886ba219c4e699c7.tar.gz lua-0870a2d1d8a1434eecae1923886ba219c4e699c7.tar.bz2 lua-0870a2d1d8a1434eecae1923886ba219c4e699c7.zip | |
new opcode TAILCALL
Diffstat (limited to 'lvm.c')
| -rw-r--r-- | lvm.c | 32 |
1 files changed, 19 insertions, 13 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 1.51 1999/02/24 17:55:51 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.52 1999/03/04 21:15:50 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 | */ |
| @@ -329,13 +329,22 @@ StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base) { | |||
| 329 | switchentry: | 329 | switchentry: |
| 330 | switch ((OpCode)*pc++) { | 330 | switch ((OpCode)*pc++) { |
| 331 | 331 | ||
| 332 | case ENDCODE: aux = 1; | 332 | case ENDCODE: |
| 333 | S->top = S->stack + base; | 333 | S->top = S->stack + base; |
| 334 | /* goes through */ | 334 | goto ret; |
| 335 | |||
| 335 | case RETCODE: | 336 | case RETCODE: |
| 336 | if (L->callhook) | 337 | base += *pc++; |
| 337 | luaD_callHook(base, NULL, 1); | 338 | goto ret; |
| 338 | return base + (aux ? 0 : *pc); | 339 | |
| 340 | case CALL: aux = *pc++; | ||
| 341 | luaD_call((S->top-S->stack)-(*pc++), aux); | ||
| 342 | break; | ||
| 343 | |||
| 344 | case TAILCALL: aux = *pc++; | ||
| 345 | luaD_call((S->top-S->stack)-(*pc++), MULT_RET); | ||
| 346 | base += aux; | ||
| 347 | goto ret; | ||
| 339 | 348 | ||
| 340 | case PUSHNIL: aux = *pc++; | 349 | case PUSHNIL: aux = *pc++; |
| 341 | do { | 350 | do { |
| @@ -619,12 +628,6 @@ StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base) { | |||
| 619 | luaC_checkGC(); | 628 | luaC_checkGC(); |
| 620 | break; | 629 | break; |
| 621 | 630 | ||
| 622 | case CALL: aux = *pc++; { | ||
| 623 | StkId newBase = (S->top-S->stack)-(*pc++); | ||
| 624 | luaD_call(newBase, aux); | ||
| 625 | break; | ||
| 626 | } | ||
| 627 | |||
| 628 | case SETLINEW: aux += highbyte(*pc++); | 631 | case SETLINEW: aux += highbyte(*pc++); |
| 629 | case SETLINE: aux += *pc++; | 632 | case SETLINE: aux += *pc++; |
| 630 | if ((S->stack+base-1)->ttype != LUA_T_LINE) { | 633 | if ((S->stack+base-1)->ttype != LUA_T_LINE) { |
| @@ -648,6 +651,9 @@ StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base) { | |||
| 648 | break; | 651 | break; |
| 649 | 652 | ||
| 650 | } | 653 | } |
| 651 | } | 654 | } ret: |
| 655 | if (L->callhook) | ||
| 656 | luaD_callHook(0, NULL, 1); | ||
| 657 | return base; | ||
| 652 | } | 658 | } |
| 653 | 659 | ||
