~ubuntu-branches/ubuntu/trusty/luajit/trusty

« back to all changes in this revision

Viewing changes to src/lib_bit.c

  • Committer: Bazaar Package Importer
  • Author(s): Enrico Tassi
  • Date: 2011-05-09 23:14:21 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20110509231421-zdcnqbqk5h6iryxr
Tags: 2.0.0~beta7+dfsg-1
New upstream release with arm support

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
LJLIB_ASM(bit_tobit)            LJLIB_REC(bit_unary IR_TOBIT)
23
23
{
24
 
  lj_lib_checknum(L, 1);
 
24
  lj_lib_checknumber(L, 1);
25
25
  return FFH_RETRY;
26
26
}
27
27
LJLIB_ASM_(bit_bnot)            LJLIB_REC(bit_unary IR_BNOT)
29
29
 
30
30
LJLIB_ASM(bit_lshift)           LJLIB_REC(bit_shift IR_BSHL)
31
31
{
32
 
  lj_lib_checknum(L, 1);
33
 
  lj_lib_checknum(L, 2);
 
32
  lj_lib_checknumber(L, 1);
 
33
  lj_lib_checkbit(L, 2);
34
34
  return FFH_RETRY;
35
35
}
36
36
LJLIB_ASM_(bit_rshift)          LJLIB_REC(bit_shift IR_BSHR)
41
41
LJLIB_ASM(bit_band)             LJLIB_REC(bit_nary IR_BAND)
42
42
{
43
43
  int i = 0;
44
 
  do { lj_lib_checknum(L, ++i); } while (L->base+i < L->top);
 
44
  do { lj_lib_checknumber(L, ++i); } while (L->base+i < L->top);
45
45
  return FFH_RETRY;
46
46
}
47
47
LJLIB_ASM_(bit_bor)             LJLIB_REC(bit_nary IR_BOR)
51
51
 
52
52
LJLIB_CF(bit_tohex)
53
53
{
54
 
  uint32_t b = (uint32_t)lj_num2bit(lj_lib_checknum(L, 1));
55
 
  int32_t i, n = L->base+1 >= L->top ? 8 : lj_num2bit(lj_lib_checknum(L, 2));
 
54
  uint32_t b = (uint32_t)lj_lib_checkbit(L, 1);
 
55
  int32_t i, n = L->base+1 >= L->top ? 8 : lj_lib_checkbit(L, 2);
56
56
  const char *hexdigits = "0123456789abcdef";
57
57
  char buf[8];
58
58
  if (n < 0) { n = -n; hexdigits = "0123456789ABCDEF"; }