aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-11-30 16:50:47 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-11-30 16:50:47 -0200
commit01b00cc29261579600ce414b470c339510ac49d5 (patch)
treed485971f691e6914b92d52a4ba6976f6f3357a23
parentfc7b167ae0a0d65f0050299101e7d177550d7120 (diff)
downloadlua-01b00cc29261579600ce414b470c339510ac49d5.tar.gz
lua-01b00cc29261579600ce414b470c339510ac49d5.tar.bz2
lua-01b00cc29261579600ce414b470c339510ac49d5.zip
better control over extensions of char/short to int
-rw-r--r--lcode.c6
-rw-r--r--lcode.h8
-rw-r--r--ldebug.c4
-rw-r--r--lparser.c10
-rw-r--r--lparser.h8
-rw-r--r--ltm.c6
6 files changed, 22 insertions, 20 deletions
diff --git a/lcode.c b/lcode.c
index 724fc2e4..3b228ff4 100644
--- a/lcode.c
+++ b/lcode.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.c,v 1.50 2000/08/31 14:08:27 roberto Exp roberto $ 2** $Id: lcode.c,v 1.51 2000/09/29 12:42:13 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*/
@@ -445,7 +445,7 @@ int luaK_code1 (FuncState *fs, OpCode o, int arg1) {
445 445
446int luaK_code2 (FuncState *fs, OpCode o, int arg1, int arg2) { 446int luaK_code2 (FuncState *fs, OpCode o, int arg1, int arg2) {
447 Instruction i = previous_instruction(fs); 447 Instruction i = previous_instruction(fs);
448 int delta = luaK_opproperties[o].push - luaK_opproperties[o].pop; 448 int delta = (int)luaK_opproperties[o].push - (int)luaK_opproperties[o].pop;
449 int optm = 0; /* 1 when there is an optimization */ 449 int optm = 0; /* 1 when there is an optimization */
450 switch (o) { 450 switch (o) {
451 case OP_CLOSURE: { 451 case OP_CLOSURE: {
@@ -647,7 +647,7 @@ int luaK_code2 (FuncState *fs, OpCode o, int arg1, int arg2) {
647} 647}
648 648
649 649
650const struct OpProperties luaK_opproperties[NUM_OPCODES] = { 650const OpProperties luaK_opproperties[NUM_OPCODES] = {
651 {iO, 0, 0}, /* OP_END */ 651 {iO, 0, 0}, /* OP_END */
652 {iU, 0, 0}, /* OP_RETURN */ 652 {iU, 0, 0}, /* OP_RETURN */
653 {iAB, 0, 0}, /* OP_CALL */ 653 {iAB, 0, 0}, /* OP_CALL */
diff --git a/lcode.h b/lcode.h
index c0f3392a..bb032267 100644
--- a/lcode.h
+++ b/lcode.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.h,v 1.15 2000/06/28 20:20:36 roberto Exp roberto $ 2** $Id: lcode.h,v 1.16 2000/08/09 14:49:13 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*/
@@ -38,11 +38,13 @@ enum Mode {iO, iU, iS, iAB}; /* instruction format */
38 38
39#define VD 100 /* flag for variable delta */ 39#define VD 100 /* flag for variable delta */
40 40
41extern const struct OpProperties { 41typedef struct OpProperties {
42 char mode; 42 char mode;
43 unsigned char push; 43 unsigned char push;
44 unsigned char pop; 44 unsigned char pop;
45} luaK_opproperties[]; 45} OpProperties;
46
47extern const OpProperties luaK_opproperties[];
46 48
47 49
48void luaK_error (LexState *ls, const char *msg); 50void luaK_error (LexState *ls, const char *msg);
diff --git a/ldebug.c b/ldebug.c
index b3d2dfac..72344181 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 1.49 2000/10/27 11:39:52 roberto Exp roberto $ 2** $Id: ldebug.c,v 1.50 2000/10/30 12:38:50 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*/
@@ -371,7 +371,7 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int stackpos) {
371 OpCode op = GET_OPCODE(i); 371 OpCode op = GET_OPCODE(i);
372 LUA_ASSERT(luaK_opproperties[op].push != VD, 372 LUA_ASSERT(luaK_opproperties[op].push != VD,
373 "invalid opcode for default"); 373 "invalid opcode for default");
374 top -= luaK_opproperties[op].pop; 374 top -= (int)luaK_opproperties[op].pop;
375 LUA_ASSERT(top >= 0, "wrong stack"); 375 LUA_ASSERT(top >= 0, "wrong stack");
376 top = pushpc(stack, pc, top, luaK_opproperties[op].push); 376 top = pushpc(stack, pc, top, luaK_opproperties[op].push);
377 } 377 }
diff --git a/lparser.c b/lparser.c
index b635a418..b07557b9 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.c,v 1.116 2000/10/27 11:39:52 roberto Exp roberto $ 2** $Id: lparser.c,v 1.117 2000/11/29 11:57:42 roberto Exp roberto $
3** LL(1) Parser and code generator for Lua 3** LL(1) Parser and code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -690,8 +690,8 @@ static BinOpr getbinopr (int op) {
690 690
691 691
692static const struct { 692static const struct {
693 char left; /* left priority for each binary operator */ 693 unsigned char left; /* left priority for each binary operator */
694 char right; /* right priority */ 694 unsigned char right; /* right priority */
695} priority[] = { /* ORDER OPR */ 695} priority[] = { /* ORDER OPR */
696 {5, 5}, {5, 5}, {6, 6}, {6, 6}, /* arithmetic */ 696 {5, 5}, {5, 5}, {6, 6}, {6, 6}, /* arithmetic */
697 {9, 8}, {4, 3}, /* power and concat (right associative) */ 697 {9, 8}, {4, 3}, /* power and concat (right associative) */
@@ -718,13 +718,13 @@ static BinOpr subexpr (LexState *ls, expdesc *v, int limit) {
718 else simpleexp(ls, v); 718 else simpleexp(ls, v);
719 /* expand while operators have priorities higher than `limit' */ 719 /* expand while operators have priorities higher than `limit' */
720 op = getbinopr(ls->t.token); 720 op = getbinopr(ls->t.token);
721 while (op != OPR_NOBINOPR && priority[op].left > limit) { 721 while (op != OPR_NOBINOPR && (int)priority[op].left > limit) {
722 expdesc v2; 722 expdesc v2;
723 BinOpr nextop; 723 BinOpr nextop;
724 next(ls); 724 next(ls);
725 luaK_infix(ls, op, v); 725 luaK_infix(ls, op, v);
726 /* read sub-expression with higher priority */ 726 /* read sub-expression with higher priority */
727 nextop = subexpr(ls, &v2, priority[op].right); 727 nextop = subexpr(ls, &v2, (int)priority[op].right);
728 luaK_posfix(ls, op, v, &v2); 728 luaK_posfix(ls, op, v, &v2);
729 op = nextop; 729 op = nextop;
730 } 730 }
diff --git a/lparser.h b/lparser.h
index 0445b5a0..7e8bd2d1 100644
--- a/lparser.h
+++ b/lparser.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.h,v 1.25 2000/09/29 12:42:13 roberto Exp roberto $ 2** $Id: lparser.h,v 1.26 2000/10/09 13:47:46 roberto Exp roberto $
3** LL(1) Parser and code generator for Lua 3** LL(1) Parser and code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -44,9 +44,9 @@ typedef struct FuncState {
44 int pc; /* next position to code */ 44 int pc; /* next position to code */
45 int lasttarget; /* `pc' of last `jump target' */ 45 int lasttarget; /* `pc' of last `jump target' */
46 int jlt; /* list of jumps to `lasttarget' */ 46 int jlt; /* list of jumps to `lasttarget' */
47 short stacklevel; /* number of values on activation register */ 47 int stacklevel; /* number of values on activation register */
48 short nactloc; /* number of active local variables */ 48 int nactloc; /* number of active local variables */
49 short nupvalues; /* number of upvalues */ 49 int nupvalues; /* number of upvalues */
50 int lastline; /* line where last `lineinfo' was generated */ 50 int lastline; /* line where last `lineinfo' was generated */
51 struct Breaklabel *bl; /* chain of breakable blocks */ 51 struct Breaklabel *bl; /* chain of breakable blocks */
52 expdesc upvalues[MAXUPVALUES]; /* upvalues */ 52 expdesc upvalues[MAXUPVALUES]; /* upvalues */
diff --git a/ltm.c b/ltm.c
index 14dbe772..ffe7a38b 100644
--- a/ltm.c
+++ b/ltm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltm.c,v 1.55 2000/10/20 16:39:03 roberto Exp roberto $ 2** $Id: ltm.c,v 1.56 2000/10/31 13:10:24 roberto Exp roberto $
3** Tag methods 3** Tag methods
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -51,7 +51,7 @@ static int luaI_checkevent (lua_State *L, const char *name, int t) {
51* 'placeholder' for "default" fallbacks 51* 'placeholder' for "default" fallbacks
52*/ 52*/
53/* ORDER LUA_T, ORDER TM */ 53/* ORDER LUA_T, ORDER TM */
54static const char luaT_validevents[NUM_TAGS][TM_N] = { 54static const unsigned char luaT_validevents[NUM_TAGS][TM_N] = {
55 {1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1}, /* LUA_TUSERDATA */ 55 {1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1}, /* LUA_TUSERDATA */
56 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* LUA_TNIL */ 56 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* LUA_TNIL */
57 {1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}, /* LUA_TNUMBER */ 57 {1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}, /* LUA_TNUMBER */
@@ -61,7 +61,7 @@ static const char luaT_validevents[NUM_TAGS][TM_N] = {
61}; 61};
62 62
63int luaT_validevent (int t, int e) { /* ORDER LUA_T */ 63int luaT_validevent (int t, int e) { /* ORDER LUA_T */
64 return (t >= NUM_TAGS) ? 1 : luaT_validevents[t][e]; 64 return (t >= NUM_TAGS) ? 1 : (int)luaT_validevents[t][e];
65} 65}
66 66
67 67