diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1998-12-28 11:44:54 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1998-12-28 11:44:54 -0200 |
commit | 766e67ef3b2af42f800b281e0fa0f57c7e3d2e3f (patch) | |
tree | 96fbaa15baec33d4f14b27df79778e766ef46f57 /lparser.c | |
parent | 4c94d8cc2cbeac74ae3618b1322c3f3d3ec166ea (diff) | |
download | lua-766e67ef3b2af42f800b281e0fa0f57c7e3d2e3f.tar.gz lua-766e67ef3b2af42f800b281e0fa0f57c7e3d2e3f.tar.bz2 lua-766e67ef3b2af42f800b281e0fa0f57c7e3d2e3f.zip |
to avoid warnings about "typecast" (Visual C++)
Diffstat (limited to 'lparser.c')
-rw-r--r-- | lparser.c | 30 |
1 files changed, 15 insertions, 15 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.c,v 1.5 1998/08/11 13:28:05 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 1.6 1998/12/23 14:06:57 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 | */ |
@@ -158,18 +158,18 @@ static int code_oparg_at (LexState *ls, int pc, OpCode op, int builtin, | |||
158 | Byte *code = ls->fs->f->code; | 158 | Byte *code = ls->fs->f->code; |
159 | deltastack(ls, delta); | 159 | deltastack(ls, delta); |
160 | if (arg < builtin) { | 160 | if (arg < builtin) { |
161 | code[pc] = op+1+arg; | 161 | code[pc] = (Byte)(op+1+arg); |
162 | return 1; | 162 | return 1; |
163 | } | 163 | } |
164 | else if (arg <= 255) { | 164 | else if (arg <= 255) { |
165 | code[pc] = op; | 165 | code[pc] = (Byte)op; |
166 | code[pc+1] = arg; | 166 | code[pc+1] = (Byte)arg; |
167 | return 2; | 167 | return 2; |
168 | } | 168 | } |
169 | else if (arg <= MAX_WORD) { | 169 | else if (arg <= MAX_WORD) { |
170 | code[pc] = op+1+builtin; | 170 | code[pc] = (Byte)(op+1+builtin); |
171 | code[pc+1] = arg>>8; | 171 | code[pc+1] = (Byte)(arg>>8); |
172 | code[pc+2] = arg&0xFF; | 172 | code[pc+2] = (Byte)(arg&0xFF); |
173 | return 3; | 173 | return 3; |
174 | } | 174 | } |
175 | else luaX_error(ls, "code too long " MES_LIM("64K") | 175 | else luaX_error(ls, "code too long " MES_LIM("64K") |
@@ -202,7 +202,7 @@ static void code_oparg (LexState *ls, OpCode op, int builtin, int arg, | |||
202 | 202 | ||
203 | static void code_opcode (LexState *ls, OpCode op, int delta) { | 203 | static void code_opcode (LexState *ls, OpCode op, int delta) { |
204 | deltastack(ls, delta); | 204 | deltastack(ls, delta); |
205 | code_byte(ls->fs, op); | 205 | code_byte(ls->fs, (Byte)op); |
206 | } | 206 | } |
207 | 207 | ||
208 | 208 | ||
@@ -277,7 +277,7 @@ static void flush_record (LexState *ls, int n) { | |||
277 | static void flush_list (LexState *ls, int m, int n) { | 277 | static void flush_list (LexState *ls, int m, int n) { |
278 | if (n == 0) return; | 278 | if (n == 0) return; |
279 | code_oparg(ls, SETLIST, 1, m, -n); | 279 | code_oparg(ls, SETLIST, 1, m, -n); |
280 | code_byte(ls->fs, n); | 280 | code_byte(ls->fs, (Byte)n); |
281 | } | 281 | } |
282 | 282 | ||
283 | 283 | ||
@@ -391,7 +391,7 @@ static void adjuststack (LexState *ls, int n) { | |||
391 | static void close_exp (LexState *ls, int pc, int nresults) { | 391 | static void close_exp (LexState *ls, int pc, int nresults) { |
392 | if (pc > 0) { /* expression is an open function call */ | 392 | if (pc > 0) { /* expression is an open function call */ |
393 | Byte *code = ls->fs->f->code; | 393 | Byte *code = ls->fs->f->code; |
394 | int nparams = code[pc]; /* save nparams */ | 394 | Byte nparams = code[pc]; /* save nparams */ |
395 | pc += fix_opcode(ls, pc-2, CALLFUNC, 2, nresults); | 395 | pc += fix_opcode(ls, pc-2, CALLFUNC, 2, nresults); |
396 | code[pc] = nparams; /* restore nparams */ | 396 | code[pc] = nparams; /* restore nparams */ |
397 | if (nresults != MULT_RET) | 397 | if (nresults != MULT_RET) |
@@ -426,11 +426,11 @@ static void code_args (LexState *ls, int nparams, int dots) { | |||
426 | fs->nlocalvar += nparams; /* "self" may already be there */ | 426 | fs->nlocalvar += nparams; /* "self" may already be there */ |
427 | nparams = fs->nlocalvar; | 427 | nparams = fs->nlocalvar; |
428 | if (!dots) { | 428 | if (!dots) { |
429 | fs->f->code[1] = nparams; /* fill-in arg information */ | 429 | fs->f->code[1] = (Byte)nparams; /* fill-in arg information */ |
430 | deltastack(ls, nparams); | 430 | deltastack(ls, nparams); |
431 | } | 431 | } |
432 | else { | 432 | else { |
433 | fs->f->code[1] = nparams+ZEROVARARG; | 433 | fs->f->code[1] = (Byte)(nparams+ZEROVARARG); |
434 | deltastack(ls, nparams+1); | 434 | deltastack(ls, nparams+1); |
435 | add_localvar(ls, luaS_new("arg")); | 435 | add_localvar(ls, luaS_new("arg")); |
436 | } | 436 | } |
@@ -515,7 +515,7 @@ static void func_onstack (LexState *ls, FuncState *func) { | |||
515 | for (i=0; i<func->nupvalues; i++) | 515 | for (i=0; i<func->nupvalues; i++) |
516 | lua_pushvar(ls, &func->upvalues[i]); | 516 | lua_pushvar(ls, &func->upvalues[i]); |
517 | code_oparg(ls, CLOSURE, 0, c, -func->nupvalues+1); | 517 | code_oparg(ls, CLOSURE, 0, c, -func->nupvalues+1); |
518 | code_byte(fs, func->nupvalues); | 518 | code_byte(fs, (Byte)func->nupvalues); |
519 | } | 519 | } |
520 | } | 520 | } |
521 | 521 | ||
@@ -548,7 +548,7 @@ static void close_func (LexState *ls) { | |||
548 | FuncState *fs = ls->fs; | 548 | FuncState *fs = ls->fs; |
549 | TProtoFunc *f = fs->f; | 549 | TProtoFunc *f = fs->f; |
550 | code_opcode(ls, ENDCODE, 0); | 550 | code_opcode(ls, ENDCODE, 0); |
551 | f->code[0] = fs->maxstacksize; | 551 | f->code[0] = (Byte)fs->maxstacksize; |
552 | f->code = luaM_reallocvector(f->code, fs->pc, Byte); | 552 | f->code = luaM_reallocvector(f->code, fs->pc, Byte); |
553 | f->consts = luaM_reallocvector(f->consts, f->nconsts, TObject); | 553 | f->consts = luaM_reallocvector(f->consts, f->nconsts, TObject); |
554 | if (fs->maxvars != -1) { /* debug information? */ | 554 | if (fs->maxvars != -1) { /* debug information? */ |
@@ -1092,7 +1092,7 @@ static int funcparams (LexState *ls, int slf) { | |||
1092 | } | 1092 | } |
1093 | code_byte(fs, 0); /* save space for opcode */ | 1093 | code_byte(fs, 0); /* save space for opcode */ |
1094 | code_byte(fs, 0); /* and nresult */ | 1094 | code_byte(fs, 0); /* and nresult */ |
1095 | code_byte(fs, nparams+slf); | 1095 | code_byte(fs, (Byte)(nparams+slf)); |
1096 | return fs->pc-1; | 1096 | return fs->pc-1; |
1097 | } | 1097 | } |
1098 | 1098 | ||