From 722bdbe17d0192baf72978f88069d12a921e9bfb Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 28 Sep 2017 13:53:29 -0300 Subject: no more 'getBMode'-'getCMode' (imprecise + we will need more space for op mode) + better control of op modes --- lcode.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'lcode.c') diff --git a/lcode.c b/lcode.c index 775a22c3..1f6e9c11 100644 --- a/lcode.c +++ b/lcode.c @@ -1,5 +1,5 @@ /* -** $Id: lcode.c,v 2.124 2017/09/26 17:10:49 roberto Exp roberto $ +** $Id: lcode.c,v 2.125 2017/09/26 18:14:45 roberto Exp roberto $ ** Code generator for Lua ** See Copyright Notice in lua.h */ @@ -367,8 +367,6 @@ static int luaK_code (FuncState *fs, Instruction i) { */ int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) { lua_assert(getOpMode(o) == iABC); - lua_assert(getBMode(o) != OpArgN || b == 0); - lua_assert(getCMode(o) != OpArgN || c == 0); lua_assert(a <= MAXARG_A && b <= MAXARG_B && c <= MAXARG_C); return luaK_code(fs, CREATE_ABC(o, a, b, c)); } @@ -378,13 +376,23 @@ int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) { ** Format and emit an 'iABx' instruction. */ int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { - lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx); - lua_assert(getCMode(o) == OpArgN); + lua_assert(getOpMode(o) == iABx); lua_assert(a <= MAXARG_A && bc <= MAXARG_Bx); return luaK_code(fs, CREATE_ABx(o, a, bc)); } +/* +** Format and emit an 'iAsBx' instruction. +*/ +int luaK_codeAsBx (FuncState *fs, OpCode o, int a, int bc) { + unsigned int b = bc + MAXARG_sBx; + lua_assert(getOpMode(o) == iAsBx); + lua_assert(a <= MAXARG_A && b <= MAXARG_Bx); + return luaK_code(fs, CREATE_ABx(o, a, b)); +} + + /* ** Emit an "extra argument" instruction (format 'iAx') */ -- cgit v1.2.3-55-g6feb