aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-04-24 17:07:46 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-04-24 17:07:46 -0300
commit9b38a696d5ccd6dd98685a74e8762a69e8722840 (patch)
tree3d9d09465dd7977ef0692091635913aab2fd90a9
parent383e8b9e778d2bed9dc4347f441803e2c4f99d09 (diff)
downloadlua-9b38a696d5ccd6dd98685a74e8762a69e8722840.tar.gz
lua-9b38a696d5ccd6dd98685a74e8762a69e8722840.tar.bz2
lua-9b38a696d5ccd6dd98685a74e8762a69e8722840.zip
avoid names that differ only in capitalization
-rw-r--r--lcode.c34
-rw-r--r--lcode.h6
-rw-r--r--ldebug.c14
-rw-r--r--lopcodes.c18
-rw-r--r--lopcodes.h54
-rw-r--r--lparser.c18
-rw-r--r--ltests.c10
-rw-r--r--lvm.c22
8 files changed, 88 insertions, 88 deletions
diff --git a/lcode.c b/lcode.c
index 2595b958..cdac7554 100644
--- a/lcode.c
+++ b/lcode.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.c,v 1.95 2002/04/09 18:49:30 roberto Exp roberto $ 2** $Id: lcode.c,v 1.96 2002/04/22 14:37:09 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*/
@@ -45,7 +45,7 @@ void luaK_nil (FuncState *fs, int from, int n) {
45 45
46 46
47int luaK_jump (FuncState *fs) { 47int luaK_jump (FuncState *fs) {
48 int j = luaK_codeAsBc(fs, OP_JMP, 0, NO_JUMP); 48 int j = luaK_codeAsBx(fs, OP_JMP, 0, NO_JUMP);
49 if (j == fs->lasttarget) { /* possible jumps to this jump? */ 49 if (j == fs->lasttarget) { /* possible jumps to this jump? */
50 luaK_concat(fs, &j, fs->jlt); /* keep them on hold */ 50 luaK_concat(fs, &j, fs->jlt); /* keep them on hold */
51 fs->jlt = NO_JUMP; 51 fs->jlt = NO_JUMP;
@@ -56,19 +56,19 @@ int luaK_jump (FuncState *fs) {
56 56
57static int luaK_condjump (FuncState *fs, OpCode op, int A, int B, int C) { 57static int luaK_condjump (FuncState *fs, OpCode op, int A, int B, int C) {
58 luaK_codeABC(fs, op, A, B, C); 58 luaK_codeABC(fs, op, A, B, C);
59 return luaK_codeAsBc(fs, OP_JMP, 0, NO_JUMP); 59 return luaK_codeAsBx(fs, OP_JMP, 0, NO_JUMP);
60} 60}
61 61
62 62
63static void luaK_fixjump (FuncState *fs, int pc, int dest) { 63static void luaK_fixjump (FuncState *fs, int pc, int dest) {
64 Instruction *jmp = &fs->f->code[pc]; 64 Instruction *jmp = &fs->f->code[pc];
65 if (dest == NO_JUMP) 65 if (dest == NO_JUMP)
66 SETARG_sBc(*jmp, NO_JUMP); /* point to itself to represent end of list */ 66 SETARG_sBx(*jmp, NO_JUMP); /* point to itself to represent end of list */
67 else { /* jump is relative to position following jump instruction */ 67 else { /* jump is relative to position following jump instruction */
68 int offset = dest-(pc+1); 68 int offset = dest-(pc+1);
69 if (abs(offset) > MAXARG_sBc) 69 if (abs(offset) > MAXARG_sBx)
70 luaK_error(fs->ls, "control structure too long"); 70 luaK_error(fs->ls, "control structure too long");
71 SETARG_sBc(*jmp, offset); 71 SETARG_sBx(*jmp, offset);
72 } 72 }
73} 73}
74 74
@@ -90,7 +90,7 @@ int luaK_getlabel (FuncState *fs) {
90 90
91 91
92static int luaK_getjump (FuncState *fs, int pc) { 92static int luaK_getjump (FuncState *fs, int pc) {
93 int offset = GETARG_sBc(fs->f->code[pc]); 93 int offset = GETARG_sBx(fs->f->code[pc]);
94 if (offset == NO_JUMP) /* point to itself represents end of list */ 94 if (offset == NO_JUMP) /* point to itself represents end of list */
95 return NO_JUMP; /* end of list */ 95 return NO_JUMP; /* end of list */
96 else 96 else
@@ -213,7 +213,7 @@ static int addk (FuncState *fs, TObject *k, TObject *v) {
213 TObject o; 213 TObject o;
214 Proto *f = fs->f; 214 Proto *f = fs->f;
215 luaM_growvector(fs->L, f->k, fs->nk, f->sizek, TObject, 215 luaM_growvector(fs->L, f->k, fs->nk, f->sizek, TObject,
216 MAXARG_Bc, "constant table overflow"); 216 MAXARG_Bx, "constant table overflow");
217 setobj(&f->k[fs->nk], v); 217 setobj(&f->k[fs->nk], v);
218 setnvalue(&o, fs->nk); 218 setnvalue(&o, fs->nk);
219 luaH_set(fs->L, fs->h, k, &o); 219 luaH_set(fs->L, fs->h, k, &o);
@@ -267,7 +267,7 @@ void luaK_dischargevars (FuncState *fs, expdesc *e) {
267 break; 267 break;
268 } 268 }
269 case VGLOBAL: { 269 case VGLOBAL: {
270 e->info = luaK_codeABc(fs, OP_GETGLOBAL, 0, e->info); 270 e->info = luaK_codeABx(fs, OP_GETGLOBAL, 0, e->info);
271 e->k = VRELOCABLE; 271 e->k = VRELOCABLE;
272 break; 272 break;
273 } 273 }
@@ -305,7 +305,7 @@ static void discharge2reg (FuncState *fs, expdesc *e, int reg) {
305 break; 305 break;
306 } 306 }
307 case VK: { 307 case VK: {
308 luaK_codeABc(fs, OP_LOADK, reg, e->info); 308 luaK_codeABx(fs, OP_LOADK, reg, e->info);
309 break; 309 break;
310 } 310 }
311 case VRELOCABLE: { 311 case VRELOCABLE: {
@@ -347,7 +347,7 @@ static void luaK_exp2reg (FuncState *fs, expdesc *e, int reg) {
347 /* expression needs values */ 347 /* expression needs values */
348 if (e->k != VJMP) { 348 if (e->k != VJMP) {
349 luaK_getlabel(fs); /* these instruction may be jump target */ 349 luaK_getlabel(fs); /* these instruction may be jump target */
350 luaK_codeAsBc(fs, OP_JMP, 0, 2); /* to jump over both pushes */ 350 luaK_codeAsBx(fs, OP_JMP, 0, 2); /* to jump over both pushes */
351 } 351 }
352 else { /* last expression is a conditional (test + jump) */ 352 else { /* last expression is a conditional (test + jump) */
353 fs->pc--; /* remove its jump */ 353 fs->pc--; /* remove its jump */
@@ -433,7 +433,7 @@ void luaK_storevar (FuncState *fs, expdesc *var, expdesc *exp) {
433 } 433 }
434 case VGLOBAL: { 434 case VGLOBAL: {
435 int e = luaK_exp2anyreg(fs, exp); 435 int e = luaK_exp2anyreg(fs, exp);
436 luaK_codeABc(fs, OP_SETGLOBAL, e, var->info); 436 luaK_codeABx(fs, OP_SETGLOBAL, e, var->info);
437 break; 437 break;
438 } 438 }
439 case VINDEXED: { 439 case VINDEXED: {
@@ -509,7 +509,7 @@ void luaK_goiftrue (FuncState *fs, expdesc *e) {
509 break; 509 break;
510 } 510 }
511 case VFALSE: { 511 case VFALSE: {
512 pc = luaK_codeAsBc(fs, OP_JMP, 0, NO_JUMP); /* always jump */ 512 pc = luaK_codeAsBx(fs, OP_JMP, 0, NO_JUMP); /* always jump */
513 break; 513 break;
514 } 514 }
515 case VJMP: { 515 case VJMP: {
@@ -537,7 +537,7 @@ static void luaK_goiffalse (FuncState *fs, expdesc *e) {
537 break; 537 break;
538 } 538 }
539 case VTRUE: { 539 case VTRUE: {
540 pc = luaK_codeAsBc(fs, OP_JMP, 0, NO_JUMP); /* always jump */ 540 pc = luaK_codeAsBx(fs, OP_JMP, 0, NO_JUMP); /* always jump */
541 break; 541 break;
542 } 542 }
543 case VJMP: { 543 case VJMP: {
@@ -739,8 +739,8 @@ int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) {
739} 739}
740 740
741 741
742int luaK_codeABc (FuncState *fs, OpCode o, int a, unsigned int bc) { 742int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) {
743 lua_assert(getOpMode(o) == iABc || getOpMode(o) == iAsBc); 743 lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx);
744 return luaK_code(fs, CREATE_ABc(o, a, bc)); 744 return luaK_code(fs, CREATE_ABx(o, a, bc));
745} 745}
746 746
diff --git a/lcode.h b/lcode.h
index 57ceb662..66ee9a36 100644
--- a/lcode.h
+++ b/lcode.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.h,v 1.30 2002/04/02 20:34:53 roberto Exp roberto $ 2** $Id: lcode.h,v 1.31 2002/04/09 18:49:30 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*/
@@ -39,10 +39,10 @@ typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_NOUNOPR } UnOpr;
39 39
40#define getcode(fs,e) ((fs)->f->code[(e)->info]) 40#define getcode(fs,e) ((fs)->f->code[(e)->info])
41 41
42#define luaK_codeAsBc(fs,o,A,sBc) luaK_codeABc(fs,o,A,(sBc)+MAXARG_sBc) 42#define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx)
43 43
44void luaK_error (LexState *ls, const char *msg); 44void luaK_error (LexState *ls, const char *msg);
45int luaK_codeABc (FuncState *fs, OpCode o, int A, unsigned int Bc); 45int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx);
46int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); 46int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C);
47void luaK_nil (FuncState *fs, int from, int n); 47void luaK_nil (FuncState *fs, int from, int n);
48void luaK_reserveregs (FuncState *fs, int n); 48void luaK_reserveregs (FuncState *fs, int n);
diff --git a/ldebug.c b/ldebug.c
index 2fa719ee..4ee1b05f 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 1.108 2002/04/10 12:11:07 roberto Exp roberto $ 2** $Id: ldebug.c,v 1.109 2002/04/22 14:40:23 roberto Exp roberto $
3** Debug Interface 3** Debug Interface
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -290,13 +290,13 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int reg) {
290 (c >= MAXSTACK && c-MAXSTACK < pt->sizek)); 290 (c >= MAXSTACK && c-MAXSTACK < pt->sizek));
291 break; 291 break;
292 } 292 }
293 case iABc: { 293 case iABx: {
294 b = GETARG_Bc(i); 294 b = GETARG_Bx(i);
295 if (testOpMode(op, OpModeK)) check(b < pt->sizek); 295 if (testOpMode(op, OpModeK)) check(b < pt->sizek);
296 break; 296 break;
297 } 297 }
298 case iAsBc: { 298 case iAsBx: {
299 b = GETARG_sBc(i); 299 b = GETARG_sBx(i);
300 break; 300 break;
301 } 301 }
302 } 302 }
@@ -421,8 +421,8 @@ static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos,
421 lua_assert(pc != -1); 421 lua_assert(pc != -1);
422 switch (GET_OPCODE(i)) { 422 switch (GET_OPCODE(i)) {
423 case OP_GETGLOBAL: { 423 case OP_GETGLOBAL: {
424 lua_assert(ttype(&p->k[GETARG_Bc(i)]) == LUA_TSTRING); 424 lua_assert(ttype(&p->k[GETARG_Bx(i)]) == LUA_TSTRING);
425 *name = svalue(&p->k[GETARG_Bc(i)]); 425 *name = svalue(&p->k[GETARG_Bx(i)]);
426 return "global"; 426 return "global";
427 } 427 }
428 case OP_MOVE: { 428 case OP_MOVE: {
diff --git a/lopcodes.c b/lopcodes.c
index ac82dae2..5627ba01 100644
--- a/lopcodes.c
+++ b/lopcodes.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lopcodes.c,v 1.15 2002/04/09 19:47:44 roberto Exp roberto $ 2** $Id: lopcodes.c,v 1.16 2002/04/10 18:05:08 roberto Exp roberto $
3** extracted automatically from lopcodes.h by mkprint.lua 3** extracted automatically from lopcodes.h by mkprint.lua
4** DO NOT EDIT 4** DO NOT EDIT
5** See Copyright Notice in lua.h 5** See Copyright Notice in lua.h
@@ -66,13 +66,13 @@ const char *const luaP_opnames[] = {
66const lu_byte luaP_opmodes[NUM_OPCODES] = { 66const lu_byte luaP_opmodes[NUM_OPCODES] = {
67/* T _ B C sA K mode opcode */ 67/* T _ B C sA K mode opcode */
68 opmode(0,0,1,0, 1,0,iABC) /* OP_MOVE */ 68 opmode(0,0,1,0, 1,0,iABC) /* OP_MOVE */
69 ,opmode(0,0,0,0, 1,1,iABc) /* OP_LOADK */ 69 ,opmode(0,0,0,0, 1,1,iABx) /* OP_LOADK */
70 ,opmode(0,0,0,0, 1,0,iABC) /* OP_LOADBOOL */ 70 ,opmode(0,0,0,0, 1,0,iABC) /* OP_LOADBOOL */
71 ,opmode(0,0,1,0, 1,0,iABC) /* OP_LOADNIL */ 71 ,opmode(0,0,1,0, 1,0,iABC) /* OP_LOADNIL */
72 ,opmode(0,0,0,0, 1,0,iABC) /* OP_GETUPVAL */ 72 ,opmode(0,0,0,0, 1,0,iABC) /* OP_GETUPVAL */
73 ,opmode(0,0,0,0, 1,1,iABc) /* OP_GETGLOBAL */ 73 ,opmode(0,0,0,0, 1,1,iABx) /* OP_GETGLOBAL */
74 ,opmode(0,0,1,1, 1,0,iABC) /* OP_GETTABLE */ 74 ,opmode(0,0,1,1, 1,0,iABC) /* OP_GETTABLE */
75 ,opmode(0,0,0,0, 0,1,iABc) /* OP_SETGLOBAL */ 75 ,opmode(0,0,0,0, 0,1,iABx) /* OP_SETGLOBAL */
76 ,opmode(0,0,0,0, 0,0,iABC) /* OP_SETUPVAL */ 76 ,opmode(0,0,0,0, 0,0,iABC) /* OP_SETUPVAL */
77 ,opmode(0,0,1,1, 0,0,iABC) /* OP_SETTABLE */ 77 ,opmode(0,0,1,1, 0,0,iABC) /* OP_SETTABLE */
78 ,opmode(0,0,0,0, 1,0,iABC) /* OP_NEWTABLE */ 78 ,opmode(0,0,0,0, 1,0,iABC) /* OP_NEWTABLE */
@@ -85,7 +85,7 @@ const lu_byte luaP_opmodes[NUM_OPCODES] = {
85 ,opmode(0,0,1,0, 1,0,iABC) /* OP_UNM */ 85 ,opmode(0,0,1,0, 1,0,iABC) /* OP_UNM */
86 ,opmode(0,0,1,0, 1,0,iABC) /* OP_NOT */ 86 ,opmode(0,0,1,0, 1,0,iABC) /* OP_NOT */
87 ,opmode(0,0,1,1, 1,0,iABC) /* OP_CONCAT */ 87 ,opmode(0,0,1,1, 1,0,iABC) /* OP_CONCAT */
88 ,opmode(0,0,0,0, 0,0,iAsBc) /* OP_JMP */ 88 ,opmode(0,0,0,0, 0,0,iAsBx) /* OP_JMP */
89 ,opmode(1,0,0,1, 0,0,iABC) /* OP_TESTEQ */ 89 ,opmode(1,0,0,1, 0,0,iABC) /* OP_TESTEQ */
90 ,opmode(1,0,0,1, 0,0,iABC) /* OP_TESTNE */ 90 ,opmode(1,0,0,1, 0,0,iABC) /* OP_TESTNE */
91 ,opmode(1,0,0,1, 0,0,iABC) /* OP_TESTLT */ 91 ,opmode(1,0,0,1, 0,0,iABC) /* OP_TESTLT */
@@ -97,12 +97,12 @@ const lu_byte luaP_opmodes[NUM_OPCODES] = {
97 ,opmode(0,0,0,0, 0,0,iABC) /* OP_CALL */ 97 ,opmode(0,0,0,0, 0,0,iABC) /* OP_CALL */
98 ,opmode(0,0,0,0, 0,0,iABC) /* OP_TAILCALL */ 98 ,opmode(0,0,0,0, 0,0,iABC) /* OP_TAILCALL */
99 ,opmode(0,0,0,0, 0,0,iABC) /* OP_RETURN */ 99 ,opmode(0,0,0,0, 0,0,iABC) /* OP_RETURN */
100 ,opmode(0,0,0,0, 0,0,iAsBc) /* OP_FORLOOP */ 100 ,opmode(0,0,0,0, 0,0,iAsBx) /* OP_FORLOOP */
101 ,opmode(0,0,0,0, 0,0,iABC) /* OP_TFORLOOP */ 101 ,opmode(0,0,0,0, 0,0,iABC) /* OP_TFORLOOP */
102 ,opmode(0,0,0,0, 0,0,iABC) /* OP_TFORPREP */ 102 ,opmode(0,0,0,0, 0,0,iABC) /* OP_TFORPREP */
103 ,opmode(0,0,0,0, 0,0,iABc) /* OP_SETLIST */ 103 ,opmode(0,0,0,0, 0,0,iABx) /* OP_SETLIST */
104 ,opmode(0,0,0,0, 0,0,iABc) /* OP_SETLISTO */ 104 ,opmode(0,0,0,0, 0,0,iABx) /* OP_SETLISTO */
105 ,opmode(0,0,0,0, 0,0,iABC) /* OP_CLOSE */ 105 ,opmode(0,0,0,0, 0,0,iABC) /* OP_CLOSE */
106 ,opmode(0,0,0,0, 1,0,iABc) /* OP_CLOSURE */ 106 ,opmode(0,0,0,0, 1,0,iABx) /* OP_CLOSURE */
107}; 107};
108 108
diff --git a/lopcodes.h b/lopcodes.h
index 15e1f09d..627bf54e 100644
--- a/lopcodes.h
+++ b/lopcodes.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lopcodes.h,v 1.93 2002/03/25 17:47:14 roberto Exp roberto $ 2** $Id: lopcodes.h,v 1.94 2002/04/09 19:47:44 roberto Exp roberto $
3** Opcodes for Lua virtual machine 3** Opcodes for Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -17,8 +17,8 @@
17 `A' : 8 bits (25-32) 17 `A' : 8 bits (25-32)
18 `B' : 8 bits (17-24) 18 `B' : 8 bits (17-24)
19 `C' : 10 bits (7-16) 19 `C' : 10 bits (7-16)
20 `Bc' : 18 bits (`B' and `C' together) 20 `Bx' : 18 bits (`B' and `C' together)
21 `sBc' : signed Bc 21 `sBx' : signed Bx
22 22
23 A signed argument is represented in excess K; that is, the number 23 A signed argument is represented in excess K; that is, the number
24 value is the unsigned value minus K. K is exactly the maximum value 24 value is the unsigned value minus K. K is exactly the maximum value
@@ -28,7 +28,7 @@
28===========================================================================*/ 28===========================================================================*/
29 29
30 30
31enum OpMode {iABC, iABc, iAsBc}; /* basic instruction format */ 31enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */
32 32
33 33
34/* 34/*
@@ -36,14 +36,14 @@ enum OpMode {iABC, iABc, iAsBc}; /* basic instruction format */
36*/ 36*/
37#define SIZE_C 10 37#define SIZE_C 10
38#define SIZE_B 8 38#define SIZE_B 8
39#define SIZE_Bc (SIZE_C + SIZE_B) 39#define SIZE_Bx (SIZE_C + SIZE_B)
40#define SIZE_A 8 40#define SIZE_A 8
41 41
42#define SIZE_OP 6 42#define SIZE_OP 6
43 43
44#define POS_C SIZE_OP 44#define POS_C SIZE_OP
45#define POS_B (POS_C + SIZE_C) 45#define POS_B (POS_C + SIZE_C)
46#define POS_Bc POS_C 46#define POS_Bx POS_C
47#define POS_A (POS_B + SIZE_B) 47#define POS_A (POS_B + SIZE_B)
48 48
49 49
@@ -52,12 +52,12 @@ enum OpMode {iABC, iABc, iAsBc}; /* basic instruction format */
52** we use (signed) int to manipulate most arguments, 52** we use (signed) int to manipulate most arguments,
53** so they must fit in BITS_INT-1 bits (-1 for sign) 53** so they must fit in BITS_INT-1 bits (-1 for sign)
54*/ 54*/
55#if SIZE_Bc < BITS_INT-1 55#if SIZE_Bx < BITS_INT-1
56#define MAXARG_Bc ((1<<SIZE_Bc)-1) 56#define MAXARG_Bx ((1<<SIZE_Bx)-1)
57#define MAXARG_sBc (MAXARG_Bc>>1) /* `sBc' is signed */ 57#define MAXARG_sBx (MAXARG_Bx>>1) /* `sBx' is signed */
58#else 58#else
59#define MAXARG_Bc MAX_INT 59#define MAXARG_Bx MAX_INT
60#define MAXARG_sBc MAX_INT 60#define MAXARG_sBx MAX_INT
61#endif 61#endif
62 62
63 63
@@ -91,12 +91,12 @@ enum OpMode {iABC, iABc, iAsBc}; /* basic instruction format */
91#define SETARG_C(i,b) ((i) = (((i)&MASK0(SIZE_C,POS_C)) | \ 91#define SETARG_C(i,b) ((i) = (((i)&MASK0(SIZE_C,POS_C)) | \
92 (cast(Instruction, b)<<POS_C))) 92 (cast(Instruction, b)<<POS_C)))
93 93
94#define GETARG_Bc(i) (cast(int, ((i)>>POS_Bc) & MASK1(SIZE_Bc,0))) 94#define GETARG_Bx(i) (cast(int, ((i)>>POS_Bx) & MASK1(SIZE_Bx,0)))
95#define SETARG_Bc(i,b) ((i) = (((i)&MASK0(SIZE_Bc,POS_Bc)) | \ 95#define SETARG_Bx(i,b) ((i) = (((i)&MASK0(SIZE_Bx,POS_Bx)) | \
96 (cast(Instruction, b)<<POS_Bc))) 96 (cast(Instruction, b)<<POS_Bx)))
97 97
98#define GETARG_sBc(i) (GETARG_Bc(i)-MAXARG_sBc) 98#define GETARG_sBx(i) (GETARG_Bx(i)-MAXARG_sBx)
99#define SETARG_sBc(i,b) SETARG_Bc((i),cast(unsigned int, (b)+MAXARG_sBc)) 99#define SETARG_sBx(i,b) SETARG_Bx((i),cast(unsigned int, (b)+MAXARG_sBx))
100 100
101 101
102#define CREATE_ABC(o,a,b,c) (cast(Instruction, o) \ 102#define CREATE_ABC(o,a,b,c) (cast(Instruction, o) \
@@ -104,9 +104,9 @@ enum OpMode {iABC, iABc, iAsBc}; /* basic instruction format */
104 | (cast(Instruction, b)<<POS_B) \ 104 | (cast(Instruction, b)<<POS_B) \
105 | (cast(Instruction, c)<<POS_C)) 105 | (cast(Instruction, c)<<POS_C))
106 106
107#define CREATE_ABc(o,a,bc) (cast(Instruction, o) \ 107#define CREATE_ABx(o,a,bc) (cast(Instruction, o) \
108 | (cast(Instruction, a)<<POS_A) \ 108 | (cast(Instruction, a)<<POS_A) \
109 | (cast(Instruction, bc)<<POS_Bc)) 109 | (cast(Instruction, bc)<<POS_Bx))
110 110
111 111
112 112
@@ -129,15 +129,15 @@ typedef enum {
129name args description 129name args description
130------------------------------------------------------------------------*/ 130------------------------------------------------------------------------*/
131OP_MOVE,/* A B R(A) := R(B) */ 131OP_MOVE,/* A B R(A) := R(B) */
132OP_LOADK,/* A Bc R(A) := Kst(Bc) */ 132OP_LOADK,/* A Bx R(A) := Kst(Bx) */
133OP_LOADBOOL,/* A B C R(A) := (Bool)B; if (C) PC++ */ 133OP_LOADBOOL,/* A B C R(A) := (Bool)B; if (C) PC++ */
134OP_LOADNIL,/* A B R(A) := ... := R(B) := nil */ 134OP_LOADNIL,/* A B R(A) := ... := R(B) := nil */
135OP_GETUPVAL,/* A B R(A) := UpValue[B] */ 135OP_GETUPVAL,/* A B R(A) := UpValue[B] */
136 136
137OP_GETGLOBAL,/* A Bc R(A) := Gbl[Kst(Bc)] */ 137OP_GETGLOBAL,/* A Bx R(A) := Gbl[Kst(Bx)] */
138OP_GETTABLE,/* A B C R(A) := R(B)[R/K(C)] */ 138OP_GETTABLE,/* A B C R(A) := R(B)[R/K(C)] */
139 139
140OP_SETGLOBAL,/* A Bc Gbl[Kst(Bc)] := R(A) */ 140OP_SETGLOBAL,/* A Bx Gbl[Kst(Bx)] := R(A) */
141OP_SETUPVAL,/* A B UpValue[B] := R(A) */ 141OP_SETUPVAL,/* A B UpValue[B] := R(A) */
142OP_SETTABLE,/* A B C R(B)[R/K(C)] := R(A) */ 142OP_SETTABLE,/* A B C R(B)[R/K(C)] := R(A) */
143 143
@@ -155,7 +155,7 @@ OP_NOT,/* A B R(A) := not R(B) */
155 155
156OP_CONCAT,/* A B C R(A) := R(B).. ... ..R(C) */ 156OP_CONCAT,/* A B C R(A) := R(B).. ... ..R(C) */
157 157
158OP_JMP,/* sBc PC += sBc */ 158OP_JMP,/* sBx PC += sBx */
159 159
160OP_TESTEQ,/* A C if not (R(A) == R/K(C)) then pc++ */ 160OP_TESTEQ,/* A C if not (R(A) == R/K(C)) then pc++ */
161OP_TESTNE,/* A C if not (R(A) ~= R/K(C)) then pc++ */ 161OP_TESTNE,/* A C if not (R(A) ~= R/K(C)) then pc++ */
@@ -171,17 +171,17 @@ OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */
171OP_TAILCALL,/* A B return R(A)(R(A+1), ... ,R(A+B-1)) */ 171OP_TAILCALL,/* A B return R(A)(R(A+1), ... ,R(A+B-1)) */
172OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see (3)) */ 172OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see (3)) */
173 173
174OP_FORLOOP,/* A sBc R(A)+=R(A+2); if R(A) <?= R(A+1) then PC+= sBc */ 174OP_FORLOOP,/* A sBx R(A)+=R(A+2); if R(A) <?= R(A+1) then PC+= sBx */
175 175
176OP_TFORLOOP,/* A C R(A+2), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2)); 176OP_TFORLOOP,/* A C R(A+2), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2));
177 if R(A+2) ~= nil then pc++ */ 177 if R(A+2) ~= nil then pc++ */
178OP_TFORPREP,/* A if type(R(A)) == table then R(A+1):=R(A), R(A):=next */ 178OP_TFORPREP,/* A if type(R(A)) == table then R(A+1):=R(A), R(A):=next */
179 179
180OP_SETLIST,/* A Bc R(A)[Bc-Bc%FPF+i] := R(A+i), 1 <= i <= Bc%FPF+1 */ 180OP_SETLIST,/* A Bx R(A)[Bx-Bx%FPF+i] := R(A+i), 1 <= i <= Bx%FPF+1 */
181OP_SETLISTO,/* A Bc */ 181OP_SETLISTO,/* A Bx */
182 182
183OP_CLOSE,/* A close all variables in the stack up to (>=) R(A)*/ 183OP_CLOSE,/* A close all variables in the stack up to (>=) R(A)*/
184OP_CLOSURE/* A Bc R(A) := closure(KPROTO[Bc], R(A), ... ,R(A+n)) */ 184OP_CLOSURE/* A Bx R(A) := closure(KPROTO[Bx], R(A), ... ,R(A+n)) */
185} OpCode; 185} OpCode;
186 186
187 187
@@ -207,7 +207,7 @@ enum OpModeMask {
207 OpModeBreg = 2, /* B is a register */ 207 OpModeBreg = 2, /* B is a register */
208 OpModeCreg, /* C is a register/constant */ 208 OpModeCreg, /* C is a register/constant */
209 OpModesetA, /* instruction set register A */ 209 OpModesetA, /* instruction set register A */
210 OpModeK, /* Bc is a constant */ 210 OpModeK, /* Bx is a constant */
211 OpModeT /* operator is a test */ 211 OpModeT /* operator is a test */
212}; 212};
213 213
diff --git a/lparser.c b/lparser.c
index 688e39cd..9e6458e0 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.c,v 1.176 2002/04/10 19:14:45 roberto Exp roberto $ 2** $Id: lparser.c,v 1.177 2002/04/22 14:38:52 roberto Exp roberto $
3** Lua Parser 3** Lua Parser
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -354,9 +354,9 @@ static void pushclosure (LexState *ls, FuncState *func, expdesc *v) {
354 Proto *f = fs->f; 354 Proto *f = fs->f;
355 int i; 355 int i;
356 luaM_growvector(ls->L, f->p, fs->np, f->sizep, Proto *, 356 luaM_growvector(ls->L, f->p, fs->np, f->sizep, Proto *,
357 MAXARG_Bc, "constant table overflow"); 357 MAXARG_Bx, "constant table overflow");
358 f->p[fs->np++] = func->f; 358 f->p[fs->np++] = func->f;
359 init_exp(v, VRELOCABLE, luaK_codeABc(fs, OP_CLOSURE, 0, fs->np-1)); 359 init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np-1));
360 for (i=0; i<func->f->nupvalues; i++) { 360 for (i=0; i<func->f->nupvalues; i++) {
361 luaK_exp2nextreg(fs, &func->upvalues[i]); 361 luaK_exp2nextreg(fs, &func->upvalues[i]);
362 fs->freereg--; /* CLOSURE will use these values */ 362 fs->freereg--; /* CLOSURE will use these values */
@@ -563,7 +563,7 @@ static void closelistfield (FuncState *fs, struct ConsControl *cc) {
563 luaK_exp2nextreg(fs, &cc->v); 563 luaK_exp2nextreg(fs, &cc->v);
564 cc->v.k = VVOID; 564 cc->v.k = VVOID;
565 if (cc->tostore == LFIELDS_PER_FLUSH) { 565 if (cc->tostore == LFIELDS_PER_FLUSH) {
566 luaK_codeABc(fs, OP_SETLIST, cc->t->info, cc->na-1); /* flush */ 566 luaK_codeABx(fs, OP_SETLIST, cc->t->info, cc->na-1); /* flush */
567 cc->tostore = 0; /* no more items pending */ 567 cc->tostore = 0; /* no more items pending */
568 fs->freereg = cc->t->info + 1; /* free registers */ 568 fs->freereg = cc->t->info + 1; /* free registers */
569 } 569 }
@@ -574,12 +574,12 @@ static void lastlistfield (FuncState *fs, struct ConsControl *cc) {
574 if (cc->tostore == 0) return; 574 if (cc->tostore == 0) return;
575 if (cc->v.k == VCALL) { 575 if (cc->v.k == VCALL) {
576 luaK_setcallreturns(fs, &cc->v, LUA_MULTRET); 576 luaK_setcallreturns(fs, &cc->v, LUA_MULTRET);
577 luaK_codeABc(fs, OP_SETLISTO, cc->t->info, cc->na-1); 577 luaK_codeABx(fs, OP_SETLISTO, cc->t->info, cc->na-1);
578 } 578 }
579 else { 579 else {
580 if (cc->v.k != VVOID) 580 if (cc->v.k != VVOID)
581 luaK_exp2nextreg(fs, &cc->v); 581 luaK_exp2nextreg(fs, &cc->v);
582 luaK_codeABc(fs, OP_SETLIST, cc->t->info, cc->na-1); 582 luaK_codeABx(fs, OP_SETLIST, cc->t->info, cc->na-1);
583 } 583 }
584 fs->freereg = cc->t->info + 1; /* free registers */ 584 fs->freereg = cc->t->info + 1; /* free registers */
585} 585}
@@ -587,7 +587,7 @@ static void lastlistfield (FuncState *fs, struct ConsControl *cc) {
587 587
588static void listfield (LexState *ls, struct ConsControl *cc) { 588static void listfield (LexState *ls, struct ConsControl *cc) {
589 expr(ls, &cc->v); 589 expr(ls, &cc->v);
590 luaX_checklimit(ls, cc->na, MAXARG_Bc, "items in a constructor"); 590 luaX_checklimit(ls, cc->na, MAXARG_Bx, "items in a constructor");
591 cc->na++; 591 cc->na++;
592 cc->tostore++; 592 cc->tostore++;
593} 593}
@@ -1014,7 +1014,7 @@ static void fornum (LexState *ls, TString *varname, int line) {
1014 if (optional(ls, ',')) 1014 if (optional(ls, ','))
1015 exp1(ls); /* optional step */ 1015 exp1(ls); /* optional step */
1016 else { /* default step = 1 */ 1016 else { /* default step = 1 */
1017 luaK_codeABc(fs, OP_LOADK, fs->freereg, luaK_numberK(fs, 1)); 1017 luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_numberK(fs, 1));
1018 luaK_reserveregs(fs, 1); 1018 luaK_reserveregs(fs, 1);
1019 } 1019 }
1020 adjustlocalvars(ls, 3); /* scope for control variables */ 1020 adjustlocalvars(ls, 3); /* scope for control variables */
@@ -1024,7 +1024,7 @@ static void fornum (LexState *ls, TString *varname, int line) {
1024 check(ls, TK_DO); 1024 check(ls, TK_DO);
1025 block(ls); 1025 block(ls);
1026 luaK_patchtohere(fs, prep-1); 1026 luaK_patchtohere(fs, prep-1);
1027 endfor = luaK_codeAsBc(fs, OP_FORLOOP, base, NO_JUMP); 1027 endfor = luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP);
1028 luaK_patchlist(fs, endfor, prep); 1028 luaK_patchlist(fs, endfor, prep);
1029 fs->f->lineinfo[endfor] = line; /* pretend that `OP_FOR' starts the loop */ 1029 fs->f->lineinfo[endfor] = line; /* pretend that `OP_FOR' starts the loop */
1030} 1030}
diff --git a/ltests.c b/ltests.c
index 4893b312..bd8469f3 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.c,v 1.115 2002/04/02 20:43:08 roberto Exp roberto $ 2** $Id: ltests.c,v 1.116 2002/04/05 18:54:31 roberto Exp roberto $
3** Internal Module for Debugging of the Lua Implementation 3** Internal Module for Debugging of the Lua Implementation
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -151,11 +151,11 @@ static char *buildop (Proto *p, int pc, char *buff) {
151 sprintf(buff+strlen(buff), "%-12s%4d %4d %4d", name, 151 sprintf(buff+strlen(buff), "%-12s%4d %4d %4d", name,
152 GETARG_A(i), GETARG_B(i), GETARG_C(i)); 152 GETARG_A(i), GETARG_B(i), GETARG_C(i));
153 break; 153 break;
154 case iABc: 154 case iABx:
155 sprintf(buff+strlen(buff), "%-12s%4d %4d", name, GETARG_A(i), GETARG_Bc(i)); 155 sprintf(buff+strlen(buff), "%-12s%4d %4d", name, GETARG_A(i), GETARG_Bx(i));
156 break; 156 break;
157 case iAsBc: 157 case iAsBx:
158 sprintf(buff+strlen(buff), "%-12s%4d %4d", name, GETARG_A(i), GETARG_sBc(i)); 158 sprintf(buff+strlen(buff), "%-12s%4d %4d", name, GETARG_A(i), GETARG_sBx(i));
159 break; 159 break;
160 } 160 }
161 return buff; 161 return buff;
diff --git a/lvm.c b/lvm.c
index a8f8d983..49950df6 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 1.225 2002/04/10 12:11:07 roberto Exp roberto $ 2** $Id: lvm.c,v 1.226 2002/04/22 14:40:23 roberto Exp roberto $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -287,7 +287,7 @@ static void powOp (lua_State *L, StkId ra, StkId rb, StkId rc) {
287#define RKC(i) ((GETARG_C(i) < MAXSTACK) ? \ 287#define RKC(i) ((GETARG_C(i) < MAXSTACK) ? \
288 base+GETARG_C(i) : \ 288 base+GETARG_C(i) : \
289 k+GETARG_C(i)-MAXSTACK) 289 k+GETARG_C(i)-MAXSTACK)
290#define KBc(i) (k+GETARG_Bc(i)) 290#define KBx(i) (k+GETARG_Bx(i))
291 291
292#define Arith(op, optm) { \ 292#define Arith(op, optm) { \
293 const TObject *b = RB(i); const TObject *c = RKC(i); \ 293 const TObject *b = RB(i); const TObject *c = RKC(i); \
@@ -332,7 +332,7 @@ StkId luaV_execute (lua_State *L) {
332 break; 332 break;
333 } 333 }
334 case OP_LOADK: { 334 case OP_LOADK: {
335 setobj(ra, KBc(i)); 335 setobj(ra, KBx(i));
336 break; 336 break;
337 } 337 }
338 case OP_LOADBOOL: { 338 case OP_LOADBOOL: {
@@ -353,8 +353,8 @@ StkId luaV_execute (lua_State *L) {
353 break; 353 break;
354 } 354 }
355 case OP_GETGLOBAL: { 355 case OP_GETGLOBAL: {
356 lua_assert(ttype(KBc(i)) == LUA_TSTRING); 356 lua_assert(ttype(KBx(i)) == LUA_TSTRING);
357 luaV_gettable(L, gt(L), KBc(i), ra); 357 luaV_gettable(L, gt(L), KBx(i), ra);
358 break; 358 break;
359 } 359 }
360 case OP_GETTABLE: { 360 case OP_GETTABLE: {
@@ -362,8 +362,8 @@ StkId luaV_execute (lua_State *L) {
362 break; 362 break;
363 } 363 }
364 case OP_SETGLOBAL: { 364 case OP_SETGLOBAL: {
365 lua_assert(ttype(KBc(i)) == LUA_TSTRING); 365 lua_assert(ttype(KBx(i)) == LUA_TSTRING);
366 luaV_settable(L, gt(L), KBc(i), ra); 366 luaV_settable(L, gt(L), KBx(i), ra);
367 break; 367 break;
368 } 368 }
369 case OP_SETUPVAL: { 369 case OP_SETUPVAL: {
@@ -434,7 +434,7 @@ StkId luaV_execute (lua_State *L) {
434 break; 434 break;
435 } 435 }
436 case OP_JMP: { 436 case OP_JMP: {
437 dojump(pc, GETARG_sBc(i)); 437 dojump(pc, GETARG_sBx(i));
438 break; 438 break;
439 } 439 }
440 case OP_TESTEQ: { /* skip next instruction if test fails */ 440 case OP_TESTEQ: { /* skip next instruction if test fails */
@@ -531,7 +531,7 @@ StkId luaV_execute (lua_State *L) {
531 } 531 }
532 case OP_FORLOOP: { 532 case OP_FORLOOP: {
533 lua_Number step, index, limit; 533 lua_Number step, index, limit;
534 int j = GETARG_sBc(i); 534 int j = GETARG_sBx(i);
535 const TObject *plimit = ra+1; 535 const TObject *plimit = ra+1;
536 const TObject *pstep = ra+2; 536 const TObject *pstep = ra+2;
537 if (ttype(ra) != LUA_TNUMBER) 537 if (ttype(ra) != LUA_TNUMBER)
@@ -574,7 +574,7 @@ StkId luaV_execute (lua_State *L) {
574 Table *h; 574 Table *h;
575 runtime_check(L, ttype(ra) == LUA_TTABLE); 575 runtime_check(L, ttype(ra) == LUA_TTABLE);
576 h = hvalue(ra); 576 h = hvalue(ra);
577 bc = GETARG_Bc(i); 577 bc = GETARG_Bx(i);
578 if (GET_OPCODE(i) == OP_SETLIST) 578 if (GET_OPCODE(i) == OP_SETLIST)
579 n = (bc&(LFIELDS_PER_FLUSH-1)) + 1; 579 n = (bc&(LFIELDS_PER_FLUSH-1)) + 1;
580 else { 580 else {
@@ -594,7 +594,7 @@ StkId luaV_execute (lua_State *L) {
594 Proto *p; 594 Proto *p;
595 Closure *ncl; 595 Closure *ncl;
596 int nup, j; 596 int nup, j;
597 p = cl->p->p[GETARG_Bc(i)]; 597 p = cl->p->p[GETARG_Bx(i)];
598 nup = p->nupvalues; 598 nup = p->nupvalues;
599 ncl = luaF_newLclosure(L, nup); 599 ncl = luaF_newLclosure(L, nup);
600 ncl->l.p = p; 600 ncl->l.p = p;