Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
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;
}
Exemplo n.º 4
0
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;
}
Exemplo n.º 5
0
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;
    }
}
Exemplo n.º 6
0
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;
        }
    }
}