diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-11-30 16:50:47 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-11-30 16:50:47 -0200 |
commit | 01b00cc29261579600ce414b470c339510ac49d5 (patch) | |
tree | d485971f691e6914b92d52a4ba6976f6f3357a23 | |
parent | fc7b167ae0a0d65f0050299101e7d177550d7120 (diff) | |
download | lua-01b00cc29261579600ce414b470c339510ac49d5.tar.gz lua-01b00cc29261579600ce414b470c339510ac49d5.tar.bz2 lua-01b00cc29261579600ce414b470c339510ac49d5.zip |
better control over extensions of char/short to int
-rw-r--r-- | lcode.c | 6 | ||||
-rw-r--r-- | lcode.h | 8 | ||||
-rw-r--r-- | ldebug.c | 4 | ||||
-rw-r--r-- | lparser.c | 10 | ||||
-rw-r--r-- | lparser.h | 8 | ||||
-rw-r--r-- | ltm.c | 6 |
6 files changed, 22 insertions, 20 deletions
@@ -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 | ||
446 | int luaK_code2 (FuncState *fs, OpCode o, int arg1, int arg2) { | 446 | int 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 | ||
650 | const struct OpProperties luaK_opproperties[NUM_OPCODES] = { | 650 | const 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 */ |
@@ -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 | ||
41 | extern const struct OpProperties { | 41 | typedef 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 | |||
47 | extern const OpProperties luaK_opproperties[]; | ||
46 | 48 | ||
47 | 49 | ||
48 | void luaK_error (LexState *ls, const char *msg); | 50 | void luaK_error (LexState *ls, const char *msg); |
@@ -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 | } |
@@ -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 | ||
692 | static const struct { | 692 | static 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 | } |
@@ -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 */ |
@@ -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 */ |
54 | static const char luaT_validevents[NUM_TAGS][TM_N] = { | 54 | static 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 | ||
63 | int luaT_validevent (int t, int e) { /* ORDER LUA_T */ | 63 | int 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 | ||