aboutsummaryrefslogtreecommitdiff
path: root/lcode.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-08-31 16:46:07 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-08-31 16:46:07 -0300
commite1d072571ec6f9d830e575a2ecdc95fd43428e53 (patch)
tree830fab7f2acb9adaee2d63073d339cc9557a5437 /lcode.c
parent7651a5c6b2ee6ec59cadec6199319d482071f176 (diff)
downloadlua-e1d072571ec6f9d830e575a2ecdc95fd43428e53.tar.gz
lua-e1d072571ec6f9d830e575a2ecdc95fd43428e53.tar.bz2
lua-e1d072571ec6f9d830e575a2ecdc95fd43428e53.zip
better syntax for type casts
Diffstat (limited to 'lcode.c')
-rw-r--r--lcode.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/lcode.c b/lcode.c
index 694a715d..d1b5355a 100644
--- a/lcode.c
+++ b/lcode.c
@@ -41,7 +41,7 @@ static Instruction previous_instruction (FuncState *fs) {
41 if (fs->pc > fs->lasttarget) /* no jumps to current position? */ 41 if (fs->pc > fs->lasttarget) /* no jumps to current position? */
42 return fs->f->code[fs->pc-1]; /* returns previous instruction */ 42 return fs->f->code[fs->pc-1]; /* returns previous instruction */
43 else 43 else
44 return (Instruction)(-1);/* no optimizations after an invalid instruction */ 44 return cast(Instruction, -1);/* invalid instruction avoids optimizations */
45} 45}
46 46
47 47
@@ -203,7 +203,7 @@ void luaK_reserveregs (FuncState *fs, int n) {
203 if (fs->freereg > fs->f->maxstacksize) { 203 if (fs->freereg > fs->f->maxstacksize) {
204 if (fs->freereg >= MAXSTACK) 204 if (fs->freereg >= MAXSTACK)
205 luaK_error(fs->ls, l_s("function or expression too complex")); 205 luaK_error(fs->ls, l_s("function or expression too complex"));
206 fs->f->maxstacksize = (short)fs->freereg; 206 fs->f->maxstacksize = cast(short, fs->freereg);
207 } 207 }
208} 208}
209 209
@@ -225,8 +225,8 @@ static void freeexp (FuncState *fs, expdesc *e) {
225static int addk (FuncState *fs, TObject *k) { 225static int addk (FuncState *fs, TObject *k) {
226 const TObject *index = luaH_get(fs->h, k); 226 const TObject *index = luaH_get(fs->h, k);
227 if (ttype(index) == LUA_TNUMBER) { 227 if (ttype(index) == LUA_TNUMBER) {
228 lua_assert(luaO_equalObj(&fs->f->k[(int)nvalue(index)], k)); 228 lua_assert(luaO_equalObj(&fs->f->k[cast(int, nvalue(index))], k));
229 return (int)nvalue(index); 229 return cast(int, nvalue(index));
230 } 230 }
231 else { /* constant not found; create a new entry */ 231 else { /* constant not found; create a new entry */
232 TObject o; 232 TObject o;
@@ -329,7 +329,7 @@ static void discharge2reg (FuncState *fs, expdesc *e, int reg) {
329 } 329 }
330 case VNUMBER: { 330 case VNUMBER: {
331 lua_Number f = e->u.n; 331 lua_Number f = e->u.n;
332 int i = (int)f; 332 int i = cast(int, f);
333 if ((lua_Number)i == f && -MAXARG_sBc <= i && i <= MAXARG_sBc) 333 if ((lua_Number)i == f && -MAXARG_sBc <= i && i <= MAXARG_sBc)
334 luaK_codeAsBc(fs, OP_LOADINT, reg, i); /* f has a small int value */ 334 luaK_codeAsBc(fs, OP_LOADINT, reg, i); /* f has a small int value */
335 else 335 else