VAL bigAShiftRight(VM* vm, VAL x, VAL y) { idris_requireAlloc(IDRIS_MAXGMP); mpz_t* bigint; VAL cl = allocate(sizeof(Closure) + sizeof(mpz_t), 0); idris_doneAlloc(); bigint = (mpz_t*)(((char*)cl) + sizeof(Closure)); mpz_fdiv_q_2exp(*bigint, GETMPZ(GETBIG(vm,x)), GETINT(y)); SETTY(cl, CT_BIGINT); cl -> info.ptr = (void*)bigint; return cl; }
VAL MKBIGSI(VM* vm, signed long val) { idris_requireAlloc(IDRIS_MAXGMP); mpz_t* bigint; VAL cl = allocate(sizeof(Closure) + sizeof(mpz_t), 0); bigint = (mpz_t*)(((char*)cl) + sizeof(Closure)); mpz_init_set_si(*bigint, val); SETTY(cl, BIGINT); cl -> info.ptr = (void*)bigint; return cl; }
VAL MKBIGM(VM* vm, void* big) { idris_requireAlloc(IDRIS_MAXGMP); mpz_t* bigint; VAL cl = allocate(sizeof(Closure) + sizeof(mpz_t), 0); bigint = (mpz_t*)(((char*)cl) + sizeof(Closure)); mpz_init(*bigint); mpz_set(*bigint, *((mpz_t*)big)); SETTY(cl, BIGINT); cl -> info.ptr = (void*)bigint; return cl; }
VAL idr_lock_texture(SDL_Texture* texture, VM* vm) { VAL m; void *pixels; int pitch; SDL_LockTexture(texture, NULL, &pixels, &pitch); idris_requireAlloc(128); // Conservative! idris_constructor(m, vm, 0, 0, 0); idris_setConArg(m, 0, MKPTR(vm, pixels)); idris_setConArg(m, 1, MKINT((intptr_t) pitch)); idris_doneAlloc(vm); return m; }
VAL MKBIGC(VM* vm, char* val) { if (*val == '\0') { return MKBIGI(0); } else { idris_requireAlloc(IDRIS_MAXGMP); mpz_t* bigint; VAL cl = allocate(sizeof(Closure) + sizeof(mpz_t), 0); idris_doneAlloc(); bigint = (mpz_t*)(((char*)cl) + sizeof(Closure)); mpz_init(*bigint); mpz_set_str(*bigint, val, 10); SETTY(cl, CT_BIGINT); cl -> info.ptr = (void*)bigint; return cl; } }
VAL GETBIG(VM * vm, VAL x) { idris_requireAlloc(IDRIS_MAXGMP); if (ISINT(x)) { mpz_t* bigint; VAL cl = allocate(sizeof(Closure) + sizeof(mpz_t), 0); bigint = (mpz_t*)(((char*)cl) + sizeof(Closure)); mpz_init(*bigint); mpz_set_si(*bigint, GETINT(x)); SETTY(cl, BIGINT); cl -> info.ptr = (void*)bigint; return cl; } else { switch(GETTY(x)) { case FWD: return GETBIG(vm, x->info.ptr); default: return x; } } }