diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-01-09 20:02:47 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-01-09 20:02:47 -0200 |
commit | f083812c020186d0d919833100c1a0b6eda8c2c0 (patch) | |
tree | 29c2e1d25f05af62277aab03e8e070aaa1a0d664 /lparser.c | |
parent | 3533382a1ed7ba21f0233057c886be2dd8a71d92 (diff) | |
download | lua-f083812c020186d0d919833100c1a0b6eda8c2c0.tar.gz lua-f083812c020186d0d919833100c1a0b6eda8c2c0.tar.bz2 lua-f083812c020186d0d919833100c1a0b6eda8c2c0.zip |
first implementation of coroutines
Diffstat (limited to 'lparser.c')
-rw-r--r-- | lparser.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -335,7 +335,7 @@ static void close_func (LexState *ls) { | |||
335 | FuncState *fs = ls->fs; | 335 | FuncState *fs = ls->fs; |
336 | Proto *f = fs->f; | 336 | Proto *f = fs->f; |
337 | removelocalvars(ls, fs->nactloc, 0); | 337 | removelocalvars(ls, fs->nactloc, 0); |
338 | luaK_codeABC(fs, OP_RETURN, 0, 0, 0); /* final return */ | 338 | luaK_codeABC(fs, OP_RETURN, 0, 1, 0); /* final return */ |
339 | luaK_getlabel(fs); /* close eventual list of pending jumps */ | 339 | luaK_getlabel(fs); /* close eventual list of pending jumps */ |
340 | lua_assert(G(L)->roottable == fs->h); | 340 | lua_assert(G(L)->roottable == fs->h); |
341 | G(L)->roottable = fs->h->next; | 341 | G(L)->roottable = fs->h->next; |
@@ -449,13 +449,13 @@ static void funcargs (LexState *ls, expdesc *f) { | |||
449 | lua_assert(f->k == VNONRELOC); | 449 | lua_assert(f->k == VNONRELOC); |
450 | base = f->u.i.info; /* base register for call */ | 450 | base = f->u.i.info; /* base register for call */ |
451 | if (args.k == VCALL) | 451 | if (args.k == VCALL) |
452 | nparams = NO_REG; /* open call */ | 452 | nparams = LUA_MULTRET; /* open call */ |
453 | else { | 453 | else { |
454 | if (args.k != VVOID) | 454 | if (args.k != VVOID) |
455 | luaK_exp2nextreg(fs, &args); /* close last argument */ | 455 | luaK_exp2nextreg(fs, &args); /* close last argument */ |
456 | nparams = fs->freereg - (base+1); | 456 | nparams = fs->freereg - (base+1); |
457 | } | 457 | } |
458 | init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams, 1)); | 458 | init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2)); |
459 | fs->freereg = base+1; /* call remove function and arguments and leaves | 459 | fs->freereg = base+1; /* call remove function and arguments and leaves |
460 | (unless changed) one result */ | 460 | (unless changed) one result */ |
461 | } | 461 | } |
@@ -1136,7 +1136,7 @@ static void retstat (LexState *ls) { | |||
1136 | if (e.k == VCALL) { | 1136 | if (e.k == VCALL) { |
1137 | luaK_setcallreturns(fs, &e, LUA_MULTRET); | 1137 | luaK_setcallreturns(fs, &e, LUA_MULTRET); |
1138 | first = fs->nactloc; | 1138 | first = fs->nactloc; |
1139 | nret = NO_REG; /* return all values */ | 1139 | nret = LUA_MULTRET; /* return all values */ |
1140 | } | 1140 | } |
1141 | else { | 1141 | else { |
1142 | luaK_exp2nextreg(fs, &e); /* values must go to the `stack' */ | 1142 | luaK_exp2nextreg(fs, &e); /* values must go to the `stack' */ |
@@ -1144,7 +1144,7 @@ static void retstat (LexState *ls) { | |||
1144 | nret = fs->freereg - first; /* return all `active' values */ | 1144 | nret = fs->freereg - first; /* return all `active' values */ |
1145 | } | 1145 | } |
1146 | } | 1146 | } |
1147 | luaK_codeABC(fs, OP_RETURN, first, nret, 0); | 1147 | luaK_codeABC(fs, OP_RETURN, first, nret+1, 0); |
1148 | fs->freereg = fs->nactloc; /* removes all temp values */ | 1148 | fs->freereg = fs->nactloc; /* removes all temp values */ |
1149 | } | 1149 | } |
1150 | 1150 | ||