aboutsummaryrefslogtreecommitdiff
path: root/lcode.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-09-28 13:53:29 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-09-28 13:53:29 -0300
commit722bdbe17d0192baf72978f88069d12a921e9bfb (patch)
tree78da619d4799721e67a760bf4220b568f636cb86 /lcode.c
parent1b100335839e13021b4731f0407b87e4f7544dc0 (diff)
downloadlua-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.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/lcode.c b/lcode.c
index 775a22c3..1f6e9c11 100644
--- a/lcode.c
+++ b/lcode.c
@@ -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*/
368int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) { 368int 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*/
380int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { 378int 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*/
388int 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*/
391static int codeextraarg (FuncState *fs, int a) { 399static int codeextraarg (FuncState *fs, int a) {