diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-11-29 14:57:36 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-11-29 14:57:36 -0200 |
| commit | 745eb4199333f153a28c75837b6a1addf614f4a9 (patch) | |
| tree | 9eb2cfe63700db8e2102d980d603ee294111cb14 /lcode.c | |
| parent | c766e4103db888063c4f928747afd6eb448e306f (diff) | |
| download | lua-745eb4199333f153a28c75837b6a1addf614f4a9.tar.gz lua-745eb4199333f153a28c75837b6a1addf614f4a9.tar.bz2 lua-745eb4199333f153a28c75837b6a1addf614f4a9.zip | |
new opcodes OP_RETURN0/OP_RETURN1
Diffstat (limited to 'lcode.c')
| -rw-r--r-- | lcode.c | 14 |
1 files changed, 12 insertions, 2 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lcode.c,v 2.137 2017/11/28 12:58:18 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 2.138 2017/11/28 15:26:15 roberto Exp roberto $ |
| 3 | ** Code generator for Lua | 3 | ** Code generator for Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -152,7 +152,17 @@ int luaK_jump (FuncState *fs) { | |||
| 152 | ** Code a 'return' instruction | 152 | ** Code a 'return' instruction |
| 153 | */ | 153 | */ |
| 154 | void luaK_ret (FuncState *fs, int first, int nret) { | 154 | void luaK_ret (FuncState *fs, int first, int nret) { |
| 155 | luaK_codeABC(fs, OP_RETURN, first, nret+1, 0); | 155 | switch (nret) { |
| 156 | case 0: | ||
| 157 | luaK_codeABC(fs, OP_RETURN0, 0, 0, 0); | ||
| 158 | break; | ||
| 159 | case 1: | ||
| 160 | luaK_codeABC(fs, OP_RETURN1, first, 0, 0); | ||
| 161 | break; | ||
| 162 | default: | ||
| 163 | luaK_codeABC(fs, OP_RETURN, first, nret + 1, 0); | ||
| 164 | break; | ||
| 165 | } | ||
| 156 | } | 166 | } |
| 157 | 167 | ||
| 158 | 168 | ||
