Get rid of the remaining silly cast macros from Lua.

This commit is contained in:
Mike Pall
2011-03-10 02:13:43 +01:00
parent bfce3c1127
commit 889368e921
17 changed files with 58 additions and 65 deletions

View File

@@ -31,30 +31,29 @@
#define NO_JMP (~(BCPos)0)
/* Macros to get instruction fields. */
#define bc_op(i) (cast(BCOp, (i)&0xff))
#define bc_a(i) (cast(BCReg, ((i)>>8)&0xff))
#define bc_b(i) (cast(BCReg, (i)>>24))
#define bc_c(i) (cast(BCReg, ((i)>>16)&0xff))
#define bc_d(i) (cast(BCReg, (i)>>16))
#define bc_op(i) ((BCOp)((i)&0xff))
#define bc_a(i) ((BCReg)(((i)>>8)&0xff))
#define bc_b(i) ((BCReg)((i)>>24))
#define bc_c(i) ((BCReg)(((i)>>16)&0xff))
#define bc_d(i) ((BCReg)((i)>>16))
#define bc_j(i) ((ptrdiff_t)bc_d(i)-BCBIAS_J)
/* Macros to set instruction fields. */
#define setbc_byte(p, x, ofs) \
((uint8_t *)(p))[LJ_ENDIAN_SELECT(ofs, 3-ofs)] = cast_byte(x)
((uint8_t *)(p))[LJ_ENDIAN_SELECT(ofs, 3-ofs)] = (uint8_t)(x)
#define setbc_op(p, x) setbc_byte(p, (x), 0)
#define setbc_a(p, x) setbc_byte(p, (x), 1)
#define setbc_b(p, x) setbc_byte(p, (x), 3)
#define setbc_c(p, x) setbc_byte(p, (x), 2)
#define setbc_d(p, x) \
((uint16_t *)(p))[LJ_ENDIAN_SELECT(1, 0)] = cast(uint16_t, (x))
((uint16_t *)(p))[LJ_ENDIAN_SELECT(1, 0)] = (uint16_t)(x)
#define setbc_j(p, x) setbc_d(p, (BCPos)((int32_t)(x)+BCBIAS_J))
/* Macros to compose instructions. */
#define BCINS_ABC(o, a, b, c) \
(cast(BCIns, o)|(cast(BCIns, a)<<8)|\
(cast(BCIns, b)<<24)|(cast(BCIns, c)<<16))
(((BCIns)(o))|((BCIns)(a)<<8)|((BCIns)(b)<<24)|((BCIns)(c)<<16))
#define BCINS_AD(o, a, d) \
(cast(BCIns, o)|(cast(BCIns, a)<<8)|(cast(BCIns, d)<<16))
(((BCIns)(o))|((BCIns)(a)<<8)|((BCIns)(d)<<16))
#define BCINS_AJ(o, a, j) BCINS_AD(o, a, (BCPos)((int32_t)(j)+BCBIAS_J))
/* Bytecode instruction definition. Order matters, see below.
@@ -240,12 +239,12 @@ typedef enum {
} BCMode;
#define BCM___ BCMnone
#define bcmode_a(op) (cast(BCMode, lj_bc_mode[op] & 7))
#define bcmode_b(op) (cast(BCMode, (lj_bc_mode[op]>>3) & 15))
#define bcmode_c(op) (cast(BCMode, (lj_bc_mode[op]>>7) & 15))
#define bcmode_a(op) ((BCMode)(lj_bc_mode[op] & 7))
#define bcmode_b(op) ((BCMode)((lj_bc_mode[op]>>3) & 15))
#define bcmode_c(op) ((BCMode)((lj_bc_mode[op]>>7) & 15))
#define bcmode_d(op) bcmode_c(op)
#define bcmode_hasd(op) ((lj_bc_mode[op] & (15<<3)) == (BCMnone<<3))
#define bcmode_mm(op) (cast(MMS, lj_bc_mode[op]>>11))
#define bcmode_mm(op) ((MMS)(lj_bc_mode[op]>>11))
#define BCMODE(name, ma, mb, mc, mm) \
(BCM##ma|(BCM##mb<<3)|(BCM##mc<<7)|(MM_##mm<<11)),