mirror of https://github.com/rusefi/lua.git
better control over extensions of char/short to int
This commit is contained in:
parent
fc7b167ae0
commit
01b00cc292
6
lcode.c
6
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
|
** Code generator for Lua
|
||||||
** See Copyright Notice in lua.h
|
** 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) {
|
int luaK_code2 (FuncState *fs, OpCode o, int arg1, int arg2) {
|
||||||
Instruction i = previous_instruction(fs);
|
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 */
|
int optm = 0; /* 1 when there is an optimization */
|
||||||
switch (o) {
|
switch (o) {
|
||||||
case OP_CLOSURE: {
|
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 */
|
{iO, 0, 0}, /* OP_END */
|
||||||
{iU, 0, 0}, /* OP_RETURN */
|
{iU, 0, 0}, /* OP_RETURN */
|
||||||
{iAB, 0, 0}, /* OP_CALL */
|
{iAB, 0, 0}, /* OP_CALL */
|
||||||
|
|
8
lcode.h
8
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
|
** Code generator for Lua
|
||||||
** See Copyright Notice in lua.h
|
** 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 */
|
#define VD 100 /* flag for variable delta */
|
||||||
|
|
||||||
extern const struct OpProperties {
|
typedef struct OpProperties {
|
||||||
char mode;
|
char mode;
|
||||||
unsigned char push;
|
unsigned char push;
|
||||||
unsigned char pop;
|
unsigned char pop;
|
||||||
} luaK_opproperties[];
|
} OpProperties;
|
||||||
|
|
||||||
|
extern const OpProperties luaK_opproperties[];
|
||||||
|
|
||||||
|
|
||||||
void luaK_error (LexState *ls, const char *msg);
|
void luaK_error (LexState *ls, const char *msg);
|
||||||
|
|
4
ldebug.c
4
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
|
** Debug Interface
|
||||||
** See Copyright Notice in lua.h
|
** 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);
|
OpCode op = GET_OPCODE(i);
|
||||||
LUA_ASSERT(luaK_opproperties[op].push != VD,
|
LUA_ASSERT(luaK_opproperties[op].push != VD,
|
||||||
"invalid opcode for default");
|
"invalid opcode for default");
|
||||||
top -= luaK_opproperties[op].pop;
|
top -= (int)luaK_opproperties[op].pop;
|
||||||
LUA_ASSERT(top >= 0, "wrong stack");
|
LUA_ASSERT(top >= 0, "wrong stack");
|
||||||
top = pushpc(stack, pc, top, luaK_opproperties[op].push);
|
top = pushpc(stack, pc, top, luaK_opproperties[op].push);
|
||||||
}
|
}
|
||||||
|
|
10
lparser.c
10
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
|
** LL(1) Parser and code generator for Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -690,8 +690,8 @@ static BinOpr getbinopr (int op) {
|
||||||
|
|
||||||
|
|
||||||
static const struct {
|
static const struct {
|
||||||
char left; /* left priority for each binary operator */
|
unsigned char left; /* left priority for each binary operator */
|
||||||
char right; /* right priority */
|
unsigned char right; /* right priority */
|
||||||
} priority[] = { /* ORDER OPR */
|
} priority[] = { /* ORDER OPR */
|
||||||
{5, 5}, {5, 5}, {6, 6}, {6, 6}, /* arithmetic */
|
{5, 5}, {5, 5}, {6, 6}, {6, 6}, /* arithmetic */
|
||||||
{9, 8}, {4, 3}, /* power and concat (right associative) */
|
{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);
|
else simpleexp(ls, v);
|
||||||
/* expand while operators have priorities higher than `limit' */
|
/* expand while operators have priorities higher than `limit' */
|
||||||
op = getbinopr(ls->t.token);
|
op = getbinopr(ls->t.token);
|
||||||
while (op != OPR_NOBINOPR && priority[op].left > limit) {
|
while (op != OPR_NOBINOPR && (int)priority[op].left > limit) {
|
||||||
expdesc v2;
|
expdesc v2;
|
||||||
BinOpr nextop;
|
BinOpr nextop;
|
||||||
next(ls);
|
next(ls);
|
||||||
luaK_infix(ls, op, v);
|
luaK_infix(ls, op, v);
|
||||||
/* read sub-expression with higher priority */
|
/* 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);
|
luaK_posfix(ls, op, v, &v2);
|
||||||
op = nextop;
|
op = nextop;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
** LL(1) Parser and code generator for Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -44,9 +44,9 @@ typedef struct FuncState {
|
||||||
int pc; /* next position to code */
|
int pc; /* next position to code */
|
||||||
int lasttarget; /* `pc' of last `jump target' */
|
int lasttarget; /* `pc' of last `jump target' */
|
||||||
int jlt; /* list of jumps to `lasttarget' */
|
int jlt; /* list of jumps to `lasttarget' */
|
||||||
short stacklevel; /* number of values on activation register */
|
int stacklevel; /* number of values on activation register */
|
||||||
short nactloc; /* number of active local variables */
|
int nactloc; /* number of active local variables */
|
||||||
short nupvalues; /* number of upvalues */
|
int nupvalues; /* number of upvalues */
|
||||||
int lastline; /* line where last `lineinfo' was generated */
|
int lastline; /* line where last `lineinfo' was generated */
|
||||||
struct Breaklabel *bl; /* chain of breakable blocks */
|
struct Breaklabel *bl; /* chain of breakable blocks */
|
||||||
expdesc upvalues[MAXUPVALUES]; /* upvalues */
|
expdesc upvalues[MAXUPVALUES]; /* upvalues */
|
||||||
|
|
6
ltm.c
6
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
|
** Tag methods
|
||||||
** See Copyright Notice in lua.h
|
** 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
|
* 'placeholder' for "default" fallbacks
|
||||||
*/
|
*/
|
||||||
/* ORDER LUA_T, ORDER TM */
|
/* 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, 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, 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 */
|
{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 */
|
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];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue