diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-06-10 13:52:03 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-06-10 13:52:03 -0300 |
commit | 2598138eced28b6ff8d4db9550a4e70c26cd4baa (patch) | |
tree | 3af8e254e508a5dc5ce29c16d8197c542582d43d /lcode.c | |
parent | 4a67e48611c1ffaa6d474e443c3c89849c8b6e5f (diff) | |
download | lua-2598138eced28b6ff8d4db9550a4e70c26cd4baa.tar.gz lua-2598138eced28b6ff8d4db9550a4e70c26cd4baa.tar.bz2 lua-2598138eced28b6ff8d4db9550a4e70c26cd4baa.zip |
new function 'luaK_codek' (detail)
Diffstat (limited to 'lcode.c')
-rw-r--r-- | lcode.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lcode.c,v 2.35 2008/04/02 16:16:06 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 2.36 2008/04/07 18:41:47 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 | */ |
@@ -349,11 +349,11 @@ static void discharge2reg (FuncState *fs, expdesc *e, int reg) { | |||
349 | break; | 349 | break; |
350 | } | 350 | } |
351 | case VK: { | 351 | case VK: { |
352 | luaK_codeABx(fs, OP_LOADK, reg, e->u.s.info); | 352 | luaK_codek(fs, reg, e->u.s.info); |
353 | break; | 353 | break; |
354 | } | 354 | } |
355 | case VKNUM: { | 355 | case VKNUM: { |
356 | luaK_codeABx(fs, OP_LOADK, reg, luaK_numberK(fs, e->u.nval)); | 356 | luaK_codek(fs, reg, luaK_numberK(fs, e->u.nval)); |
357 | break; | 357 | break; |
358 | } | 358 | } |
359 | case VRELOCABLE: { | 359 | case VRELOCABLE: { |
@@ -813,6 +813,7 @@ int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) { | |||
813 | lua_assert(getOpMode(o) == iABC); | 813 | lua_assert(getOpMode(o) == iABC); |
814 | lua_assert(getBMode(o) != OpArgN || b == 0); | 814 | lua_assert(getBMode(o) != OpArgN || b == 0); |
815 | lua_assert(getCMode(o) != OpArgN || c == 0); | 815 | lua_assert(getCMode(o) != OpArgN || c == 0); |
816 | lua_assert(a <= MAXARG_A && b <= MAXARG_B && c <= MAXARG_C); | ||
816 | return luaK_code(fs, CREATE_ABC(o, a, b, c)); | 817 | return luaK_code(fs, CREATE_ABC(o, a, b, c)); |
817 | } | 818 | } |
818 | 819 | ||
@@ -820,16 +821,23 @@ int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) { | |||
820 | int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { | 821 | int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { |
821 | lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx); | 822 | lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx); |
822 | lua_assert(getCMode(o) == OpArgN); | 823 | lua_assert(getCMode(o) == OpArgN); |
824 | lua_assert(a <= MAXARG_A && bc <= MAXARG_Bx); | ||
823 | return luaK_code(fs, CREATE_ABx(o, a, bc)); | 825 | return luaK_code(fs, CREATE_ABx(o, a, bc)); |
824 | } | 826 | } |
825 | 827 | ||
826 | 828 | ||
827 | static int luaK_codeAx (FuncState *fs, OpCode o, int a) { | 829 | static int luaK_codeAx (FuncState *fs, OpCode o, int a) { |
828 | lua_assert(getOpMode(o) == iAx); | 830 | lua_assert(getOpMode(o) == iAx); |
831 | lua_assert(a <= MAXARG_Ax); | ||
829 | return luaK_code(fs, CREATE_Ax(o, a)); | 832 | return luaK_code(fs, CREATE_Ax(o, a)); |
830 | } | 833 | } |
831 | 834 | ||
832 | 835 | ||
836 | void luaK_codek (FuncState *fs, int reg, int k) { | ||
837 | luaK_codeABx(fs, OP_LOADK, reg, k); | ||
838 | } | ||
839 | |||
840 | |||
833 | void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) { | 841 | void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) { |
834 | int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1; | 842 | int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1; |
835 | int b = (tostore == LUA_MULTRET) ? 0 : tostore; | 843 | int b = (tostore == LUA_MULTRET) ? 0 : tostore; |