From 01b00cc29261579600ce414b470c339510ac49d5 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 30 Nov 2000 16:50:47 -0200 Subject: better control over extensions of char/short to int --- lcode.c | 6 +++--- lcode.h | 8 +++++--- ldebug.c | 4 ++-- lparser.c | 10 +++++----- lparser.h | 8 ++++---- ltm.c | 6 +++--- 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 @@ /* -** $Id: lcode.c,v 1.50 2000/08/31 14:08:27 roberto Exp roberto $ +** $Id: lcode.c,v 1.51 2000/09/29 12:42:13 roberto Exp roberto $ ** Code generator for Lua ** See Copyright Notice in lua.h */ @@ -445,7 +445,7 @@ int luaK_code1 (FuncState *fs, OpCode o, int arg1) { int luaK_code2 (FuncState *fs, OpCode o, int arg1, int arg2) { Instruction i = previous_instruction(fs); - int delta = luaK_opproperties[o].push - luaK_opproperties[o].pop; + int delta = (int)luaK_opproperties[o].push - (int)luaK_opproperties[o].pop; int optm = 0; /* 1 when there is an optimization */ switch (o) { case OP_CLOSURE: { @@ -647,7 +647,7 @@ int luaK_code2 (FuncState *fs, OpCode o, int arg1, int arg2) { } -const struct OpProperties luaK_opproperties[NUM_OPCODES] = { +const OpProperties luaK_opproperties[NUM_OPCODES] = { {iO, 0, 0}, /* OP_END */ {iU, 0, 0}, /* OP_RETURN */ {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 @@ /* -** $Id: lcode.h,v 1.15 2000/06/28 20:20:36 roberto Exp roberto $ +** $Id: lcode.h,v 1.16 2000/08/09 14:49:13 roberto Exp roberto $ ** Code generator for Lua ** See Copyright Notice in lua.h */ @@ -38,11 +38,13 @@ enum Mode {iO, iU, iS, iAB}; /* instruction format */ #define VD 100 /* flag for variable delta */ -extern const struct OpProperties { +typedef struct OpProperties { char mode; unsigned char push; unsigned char pop; -} luaK_opproperties[]; +} OpProperties; + +extern const OpProperties luaK_opproperties[]; void 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 @@ /* -** $Id: ldebug.c,v 1.49 2000/10/27 11:39:52 roberto Exp roberto $ +** $Id: ldebug.c,v 1.50 2000/10/30 12:38:50 roberto Exp roberto $ ** Debug Interface ** See Copyright Notice in lua.h */ @@ -371,7 +371,7 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int stackpos) { OpCode op = GET_OPCODE(i); LUA_ASSERT(luaK_opproperties[op].push != VD, "invalid opcode for default"); - top -= luaK_opproperties[op].pop; + top -= (int)luaK_opproperties[op].pop; LUA_ASSERT(top >= 0, "wrong stack"); top = pushpc(stack, pc, top, luaK_opproperties[op].push); } diff --git a/lparser.c b/lparser.c index b635a418..b07557b9 100644 --- a/lparser.c +++ b/lparser.c @@ -1,5 +1,5 @@ /* -** $Id: lparser.c,v 1.116 2000/10/27 11:39:52 roberto Exp roberto $ +** $Id: lparser.c,v 1.117 2000/11/29 11:57:42 roberto Exp roberto $ ** LL(1) Parser and code generator for Lua ** See Copyright Notice in lua.h */ @@ -690,8 +690,8 @@ static BinOpr getbinopr (int op) { static const struct { - char left; /* left priority for each binary operator */ - char right; /* right priority */ + unsigned char left; /* left priority for each binary operator */ + unsigned char right; /* right priority */ } priority[] = { /* ORDER OPR */ {5, 5}, {5, 5}, {6, 6}, {6, 6}, /* arithmetic */ {9, 8}, {4, 3}, /* power and concat (right associative) */ @@ -718,13 +718,13 @@ static BinOpr subexpr (LexState *ls, expdesc *v, int limit) { else simpleexp(ls, v); /* expand while operators have priorities higher than `limit' */ op = getbinopr(ls->t.token); - while (op != OPR_NOBINOPR && priority[op].left > limit) { + while (op != OPR_NOBINOPR && (int)priority[op].left > limit) { expdesc v2; BinOpr nextop; next(ls); luaK_infix(ls, op, v); /* read sub-expression with higher priority */ - nextop = subexpr(ls, &v2, priority[op].right); + nextop = subexpr(ls, &v2, (int)priority[op].right); luaK_posfix(ls, op, v, &v2); op = nextop; } diff --git a/lparser.h b/lparser.h index 0445b5a0..7e8bd2d1 100644 --- a/lparser.h +++ b/lparser.h @@ -1,5 +1,5 @@ /* -** $Id: lparser.h,v 1.25 2000/09/29 12:42:13 roberto Exp roberto $ +** $Id: lparser.h,v 1.26 2000/10/09 13:47:46 roberto Exp roberto $ ** LL(1) Parser and code generator for Lua ** See Copyright Notice in lua.h */ @@ -44,9 +44,9 @@ typedef struct FuncState { int pc; /* next position to code */ int lasttarget; /* `pc' of last `jump target' */ int jlt; /* list of jumps to `lasttarget' */ - short stacklevel; /* number of values on activation register */ - short nactloc; /* number of active local variables */ - short nupvalues; /* number of upvalues */ + int stacklevel; /* number of values on activation register */ + int nactloc; /* number of active local variables */ + int nupvalues; /* number of upvalues */ int lastline; /* line where last `lineinfo' was generated */ struct Breaklabel *bl; /* chain of breakable blocks */ 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 @@ /* -** $Id: ltm.c,v 1.55 2000/10/20 16:39:03 roberto Exp roberto $ +** $Id: ltm.c,v 1.56 2000/10/31 13:10:24 roberto Exp roberto $ ** Tag methods ** See Copyright Notice in lua.h */ @@ -51,7 +51,7 @@ static int luaI_checkevent (lua_State *L, const char *name, int t) { * 'placeholder' for "default" fallbacks */ /* ORDER LUA_T, ORDER TM */ -static const char luaT_validevents[NUM_TAGS][TM_N] = { +static const unsigned char luaT_validevents[NUM_TAGS][TM_N] = { {1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1}, /* LUA_TUSERDATA */ {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* LUA_TNIL */ {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] = { }; int luaT_validevent (int t, int e) { /* ORDER LUA_T */ - return (t >= NUM_TAGS) ? 1 : luaT_validevents[t][e]; + return (t >= NUM_TAGS) ? 1 : (int)luaT_validevents[t][e]; } -- cgit v1.2.3-55-g6feb