LJLIB_ASM(bit_band) LJLIB_REC(bit_nary IR_BAND) { #if LJ_HASFFI CTypeID id = 0; TValue *o = L->base, *top = L->top; int i = 0; do { lj_carith_check64(L, ++i, &id); } while (++o < top); if (id) { CTState *cts = ctype_cts(L); CType *ct = ctype_get(cts, id); int op = curr_func(L)->c.ffid - (int)FF_bit_bor; uint64_t x, y = op >= 0 ? 0 : ~(uint64_t)0; o = L->base; do { lj_cconv_ct_tv(cts, ct, (uint8_t *)&x, o, 0); if (op < 0) y &= x; else if (op == 0) y |= x; else y ^= x; } while (++o < top); return bit_result64(L, id, y); } return FFH_RETRY; #else int i = 0; do { lj_lib_checknumber(L, ++i); } while (L->base+i < L->top); return FFH_RETRY; #endif }
/* Convert argument to C pointer. */ static void *ffi_checkptr(lua_State *L, int narg, CTypeID id) { CTState *cts = ctype_cts(L); TValue *o = L->base + narg-1; void *p; if (o >= L->top) lj_err_arg(L, narg, LJ_ERR_NOVAL); lj_cconv_ct_tv(cts, ctype_get(cts, id), (uint8_t *)&p, o, CCF_ARG(narg)); return p; }
/* Convert argument to int32_t. */ static int32_t ffi_checkint(lua_State *L, int narg) { CTState *cts = ctype_cts(L); TValue *o = L->base + narg-1; int32_t i; if (o >= L->top) lj_err_arg(L, narg, LJ_ERR_NOVAL); lj_cconv_ct_tv(cts, ctype_get(cts, CTID_INT32), (uint8_t *)&i, o, CCF_ARG(narg)); return i; }
/* Pass a small struct argument. */ static int ccall_struct_arg(CCallState *cc, CTState *cts, CType *d, int *rcl, TValue *o, int narg) { GPRArg dp[2]; dp[0] = dp[1] = 0; /* Convert to temp. struct. */ lj_cconv_ct_tv(cts, d, (uint8_t *)dp, o, CCF_ARG(narg)); if (ccall_struct_reg(cc, dp, rcl)) { /* Register overflow? Pass on stack. */ MSize nsp = cc->nsp, n = rcl[1] ? 2 : 1; if (nsp + n > CCALL_MAXSTACK) return 1; /* Too many arguments. */ cc->nsp = nsp + n; memcpy(&cc->stack[nsp], dp, n*CTSIZE_PTR); } return 0; /* Ok. */ }