diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-09-28 13:53:29 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-09-28 13:53:29 -0300 |
commit | 722bdbe17d0192baf72978f88069d12a921e9bfb (patch) | |
tree | 78da619d4799721e67a760bf4220b568f636cb86 /lcode.c | |
parent | 1b100335839e13021b4731f0407b87e4f7544dc0 (diff) | |
download | lua-722bdbe17d0192baf72978f88069d12a921e9bfb.tar.gz lua-722bdbe17d0192baf72978f88069d12a921e9bfb.tar.bz2 lua-722bdbe17d0192baf72978f88069d12a921e9bfb.zip |
no more 'getBMode'-'getCMode' (imprecise + we will need more space
for op mode) + better control of op modes
Diffstat (limited to 'lcode.c')
-rw-r--r-- | lcode.c | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lcode.c,v 2.124 2017/09/26 17:10:49 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 2.125 2017/09/26 18:14:45 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 | */ |
@@ -367,8 +367,6 @@ static int luaK_code (FuncState *fs, Instruction i) { | |||
367 | */ | 367 | */ |
368 | int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) { | 368 | int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) { |
369 | lua_assert(getOpMode(o) == iABC); | 369 | lua_assert(getOpMode(o) == iABC); |
370 | lua_assert(getBMode(o) != OpArgN || b == 0); | ||
371 | lua_assert(getCMode(o) != OpArgN || c == 0); | ||
372 | lua_assert(a <= MAXARG_A && b <= MAXARG_B && c <= MAXARG_C); | 370 | lua_assert(a <= MAXARG_A && b <= MAXARG_B && c <= MAXARG_C); |
373 | return luaK_code(fs, CREATE_ABC(o, a, b, c)); | 371 | return luaK_code(fs, CREATE_ABC(o, a, b, c)); |
374 | } | 372 | } |
@@ -378,14 +376,24 @@ int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) { | |||
378 | ** Format and emit an 'iABx' instruction. | 376 | ** Format and emit an 'iABx' instruction. |
379 | */ | 377 | */ |
380 | int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { | 378 | int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { |
381 | lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx); | 379 | lua_assert(getOpMode(o) == iABx); |
382 | lua_assert(getCMode(o) == OpArgN); | ||
383 | lua_assert(a <= MAXARG_A && bc <= MAXARG_Bx); | 380 | lua_assert(a <= MAXARG_A && bc <= MAXARG_Bx); |
384 | return luaK_code(fs, CREATE_ABx(o, a, bc)); | 381 | return luaK_code(fs, CREATE_ABx(o, a, bc)); |
385 | } | 382 | } |
386 | 383 | ||
387 | 384 | ||
388 | /* | 385 | /* |
386 | ** Format and emit an 'iAsBx' instruction. | ||
387 | */ | ||
388 | int luaK_codeAsBx (FuncState *fs, OpCode o, int a, int bc) { | ||
389 | unsigned int b = bc + MAXARG_sBx; | ||
390 | lua_assert(getOpMode(o) == iAsBx); | ||
391 | lua_assert(a <= MAXARG_A && b <= MAXARG_Bx); | ||
392 | return luaK_code(fs, CREATE_ABx(o, a, b)); | ||
393 | } | ||
394 | |||
395 | |||
396 | /* | ||
389 | ** Emit an "extra argument" instruction (format 'iAx') | 397 | ** Emit an "extra argument" instruction (format 'iAx') |
390 | */ | 398 | */ |
391 | static int codeextraarg (FuncState *fs, int a) { | 399 | static int codeextraarg (FuncState *fs, int a) { |