Ejemplo n.º 1
0
/* machine printing, (write) */
void sexp_pprint(secd_t* secd, cell_t *port, const cell_t *cell) {
    switch (cell_type(cell)) {
      case CELL_UNDEF:  secd_pprintf(secd, port, "#?"); break;
      case CELL_INT:    secd_pprintf(secd, port, "%d", cell->as.num); break;
      case CELL_CHAR:
        if (isprint(cell->as.num))
            secd_pprintf(secd, port, "#\\%c", (char)cell->as.num);
        else
            secd_pprintf(secd, port, "#\\x%x", numval(cell));
        break;
      case CELL_OP:     sexp_print_opcode(secd, port, cell->as.op); break;
      case CELL_FUNC:   secd_pprintf(secd, port, "##func*%p", cell->as.ptr); break;
      case CELL_FRAME:  secd_pprintf(secd, port,
                                "##frame@%ld ", cell_index(secd, cell)); break;
      case CELL_KONT:   secd_pprintf(secd, port,
                                "##kont@%ld ", cell_index(secd, cell)); break;
      case CELL_CONS:   sexp_print_list(secd, port, cell); break;
      case CELL_ARRAY:  sexp_print_array(secd, port, cell); break;
      case CELL_STR:    secd_pprintf(secd, port, "\"%s\"", strval(cell) + cell->as.str.offset); break;
      case CELL_SYM:    secd_pprintf(secd, port, "%s", symname(cell)); break;
      case CELL_BYTES:  sexp_print_bytes(secd, port, strval(cell), mem_size(cell)); break;
      case CELL_ERROR:  secd_pprintf(secd, port, "#!\"%s\"", errmsg(cell)); break;
      case CELL_PORT:   sexp_pprint_port(secd, port, cell); break;
      case CELL_REF:    sexp_pprint(secd, port, cell->as.ref);  break;
      default: errorf("sexp_print: unknown cell type %d", (int)cell_type(cell));
    }
}
Ejemplo n.º 2
0
Archivo: memory.c Proyecto: 8l/SECD
cell_t *pop_free(secd_t *secd) {
    cell_t *cell;
    if (not_nil(secd->free)) {
        /* take a cell from the list */
        cell = secd->free;
        secd->free = get_cdr(secd->free);
        if (secd->free)
            secd->free->as.cons.car = SECD_NIL;
        memdebugf("NEW [%ld]\n", cell_index(secd, cell));
        -- secd->free_cells;
    } else {
        assert(secd->free_cells == 0,
               "pop_free: free=NIL when nfree=%zd\n", secd->free_cells);
        /* move fixedptr */
        if (secd->fixedptr >= secd->arrayptr)
            return &secd_out_of_memory;

        cell = secd->fixedptr;
        ++ secd->fixedptr;
        memdebugf("NEW [%ld] ++\n", cell_index(secd, cell));
    }

    cell->type = CELL_UNDEF;
    cell->nref = 0;
    return cell;
}
Ejemplo n.º 3
0
void show_labyrinth(const LABYRINTH labyrinth)
{
    for (int y = 0; y < LABYRINTH_SIZE; y++) {
        // Dessine les bordures supérieures de la ligne.
        for (int x = 0; x < LABYRINTH_SIZE; x++) {
            if (is_wall(*cell_index(labyrinth, x, y), WALL_TOP))
                printf("·――");
            else
                printf("·  ");
        }
        printf("·\n");

        // Dessine les bordures latérales des cellules de la ligne
        for (int x = 0; x < LABYRINTH_SIZE; x++) {
            if (is_wall(*cell_index(labyrinth, x, y), WALL_LEFT))
                printf("|  ");
            else
                printf("   ");
        }
        if (is_wall(*cell_index(labyrinth, LABYRINTH_SIZE - 1, y), WALL_RIGHT))
            putchar('|');

        putchar('\n');
    }

    // Dessine la bordure inférieure de la dernière ligne
    for (int x = 0; x < LABYRINTH_SIZE; x++) {
        if (is_wall(*cell_index(labyrinth, x, LABYRINTH_SIZE - 1), WALL_BOTTOM))
            printf("·――");
        else
            printf("·  ");
    }
    printf("·\n");
}
Ejemplo n.º 4
0
Archivo: memory.c Proyecto: 8l/SECD
void print_array_layout(secd_t *secd) {
    errorf(";; Array heap layout:\n");
    errorf(";;  arrayptr = %ld\n", cell_index(secd, secd->arrayptr));
    errorf(";;  arrlist  = %ld\n", cell_index(secd, secd->arrlist));
    errorf(";; Array list is:\n");
    cell_t *cur = secd->arrlist;
    while (not_nil(mcons_next(cur))) {
        cur = mcons_next(cur);
        errorf(";;  %ld\t%ld (size=%zd,\t%s)\n", cell_index(secd, cur),
                cell_index(secd, mcons_prev(cur)), arrmeta_size(secd, cur),
                (is_array_free(secd, cur)? "free" : "used"));
    }
}
Ejemplo n.º 5
0
void dbg_print_list(secd_t *secd, cell_t *list) {
    printf("  -= ");
    while (not_nil(list)) {
        assertv(is_cons(list),
                "Not a cons at [%ld]\n", cell_index(secd, list));
        printf("[%ld]:%ld\t",
                cell_index(secd, list),
                cell_index(secd, get_car(list)));
        dbg_print_cell(secd, get_car(list));
        printf("  -> ");
        list = list_next(secd, list);
    }
    printf("NIL\n");
}
Ejemplo n.º 6
0
Archivo: memory.c Proyecto: 8l/SECD
void push_free(secd_t *secd, cell_t *c) {
    assertv(c, "push_free(NULL)");
    assertv(c->nref == 0,
            "push_free: [%ld]->nref is %ld\n", cell_index(secd, c), (long)c->nref);
    assertv(c < secd->fixedptr, "push_free: Trying to free array cell");

    if (c + 1 < secd->fixedptr) {
        /* just add the cell to the list secd->free */
        c->type = CELL_FREE;
        c->as.cons.car = SECD_NIL;
        c->as.cons.cdr = secd->free;

        if (not_nil(secd->free))
            secd->free->as.cons.car = c;
        secd->free = c;

        ++secd->free_cells;
        memdebugf("FREE[%ld], %zd free\n",
                cell_index(secd, c), secd->free_cells);
    } else {
        memdebugf("FREE[%ld] --\n", cell_index(secd, c));
        --c;

        while (c->type == CELL_FREE) {
            /* it is a cell adjacent to the free space */
            if (c != secd->free) {
                cell_t *prev = c->as.cons.car;
                cell_t *next = c->as.cons.cdr;
                if (not_nil(prev)) {
                    prev->as.cons.cdr = next;
                }
                if (not_nil(next)) {
                    next->as.cons.car = prev;
                }
            } else {
                cell_t *next = c->as.cons.cdr;
                if (not_nil(next))
                    next->as.cons.car = SECD_NIL;

                secd->free = next;
            }
            memdebugf("FREE[%ld] --\n", cell_index(secd, c));
            --c;
            --secd->free_cells;
        }

        secd->fixedptr = c + 1;
    }
}
Ejemplo n.º 7
0
/* 
 * Make an alias to a page in a source spd @ a source address to a
 * destination spd/addr
 */
vaddr_t mman_alias_page(spdid_t s_spd, vaddr_t s_addr, spdid_t d_spd, vaddr_t d_addr)
{
	int alias = -1, i;
	struct mem_cell *c;
	struct mapping_info *base;
	
	c = find_cell(s_spd, s_addr, &alias);
	if (-1 == alias) {printc("WTF\n");goto err;}
	assert(alias >= 0 && alias < MAX_ALIASES);
	base = c->map;
	for (i = 0 ; i < MAX_ALIASES ; i++) {
		if (alias == i || base[i].owner_spd != 0 || base[i].addr != 0) {
			continue;
		}

		if (cos_mmap_cntl(COS_MMAP_GRANT, 0, d_spd, d_addr, cell_index(c))) {
			printc("mm: could not alias page @ %x to spd %d from %x(%d)\n", 
			       (unsigned int)d_addr, (unsigned int)d_spd, (unsigned int)s_addr, (unsigned int)s_spd);
			goto err;
		}
		base[i].owner_spd = d_spd;
		base[i].addr = d_addr;
		base[i].parent = alias;
		c->naliases++;

		return d_addr;
	}
	/* no available alias slots! */
err:
	return 0;
}
Ejemplo n.º 8
0
/* 
 * Call to get a page of memory at a location.
 */
vaddr_t mman_get_page(spdid_t spd, vaddr_t addr, int flags)
{
	struct mem_cell *c;
	struct mapping_info *m;

	c = find_unused();
	if (!c) {
		printc("mm: no more available pages!\n");
		goto err;
	}

	c->naliases++;
	m = c->map;
	m->owner_spd = spd;
	m->addr = addr;
	m->parent = -1;

	/* Here we check for overwriting an already established mapping. */
	if (cos_mmap_cntl(COS_MMAP_GRANT, 0, spd, addr, cell_index(c))) {
		printc("mm: could not grant page @ %x to spd %d\n", 
		       (unsigned int)addr, (unsigned int)spd);
		m->owner_spd = m->addr = 0;
		goto err;
	}

	return addr;
err:
	return 0;
}
int GridSampleHolder::Add(const Sample & sample)
{
    if(sample.coordinate.Dimension() != Dimension()) return 0;

    vector<int> cell_index(Dimension());
    
    if(! LocateCell(sample, cell_index))
    {
        return 0;
    }
            
    Cell cell;
    if(!_cells.Get(cell_index, cell))
    {
        return 0;
    }
    
#ifndef _ALLOW_MULTIPLE_SAMPLES_PER_CELL
    if(cell.samples.size() > 0)
    {
        return 0;
    }
    else
#endif
    {
        cell.samples.push_back(&sample);
        if(!_cells.Put(cell_index, cell)) return 0;
        return 1;
    }
}
Ejemplo n.º 10
0
int CellList::add(int pid, const clam::Vec3d& pos){
    int cidx       = cell_index(pos);
    p_cell_ids_[pid] = cidx;

    linked_list_[pid] = cell_[cidx];
    cell_[cidx] = pid;

    return cidx;
}
Ejemplo n.º 11
0
int secd_dump_state(secd_t *secd, cell_t *fname) {
    cell_t *p = secd_newport(secd, "w", "file", fname);
    secd_pprintf(secd, p,
                 ";; secd->fixedptr = %ld\n", cell_index(secd, secd->fixedptr));
    secd_pprintf(secd, p,
                 ";; secd->arrayptr = %ld\n", cell_index(secd, secd->arrayptr));
    secd_pprintf(secd, p,
                 ";; secd->end      = %ld\n", cell_index(secd, secd->end));
    secd_pprintf(secd, p, ";; secd->input_port = %ld, secd->output_port = %ld\n",
                 cell_index(secd, secd->input_port), cell_index(secd, secd->output_port));
    secd_pprintf(secd, p, ";; SECD = (%ld, %ld, %ld, %ld)\n",
                 cell_index(secd, secd->stack), cell_index(secd, secd->env),
                 cell_index(secd, secd->control), cell_index(secd, secd->dump));
    secd_pprintf(secd, p, ";; secd->free = %ld (%ld free)\n",
                 cell_index(secd, secd->free), secd->stat.free_cells);
    /* dump fixed heap */
    long i;
    long n_fixed = secd->fixedptr - secd->begin;
    secd_pprintf(secd, p, "\n;; SECD persistent heap:\n");
    for (i = 0; i < n_fixed; ++i) {
        cell_t *cell_info = serialize_cell(secd, secd->begin + i);
        sexp_pprint(secd, p, cell_info);
        secd_pprintf(secd, p, "\n");
        free_cell(secd, cell_info);
    }

    secd_pprintf(secd, p, "\n;; SECD array heap:\n");
    cell_t *mcons = secd->arrlist;
    while (mcons_next(mcons)) {
        cell_t *cell_info = serialize_cell(secd, mcons);
        sexp_pprint(secd, p, cell_info);
        if (!mcons->as.mcons.free)
            secd_pdump_array(secd, p, mcons);
        secd_pprintf(secd, p, "\n");
        free_cell(secd, cell_info);

        mcons = mcons_next(mcons);
    }

    secd_pclose(secd, p);
    free_cell(secd, p);
    return 0;
}
int GridSampleHolder::GetNeighbors(const Sample & query, const float radius, vector<const Sample *> & neighbors) const
{
    neighbors.clear();

    const int dimension = Dimension();

    vector<int> cell_index(dimension);
    if(! LocateCell(query, cell_index))
    {
        // outside the grid
        return 0;
    }

    const float radius_in_cells = (radius/_domain_spec.cell_size + 1);

    NBallSliceCounter counter(dimension, radius_in_cells*radius_in_cells);

    vector<int> offset_index(dimension);
    vector<int> current_index(dimension);
    vector<int> corrected_index(dimension);
    
    counter.Reset();
    do
    {
        counter.Get(offset_index);

        for(unsigned int i = 0; i < current_index.size(); i++)
        {
            current_index[i] = cell_index[i] + offset_index[i];

            if(_domain.Boundary() == Domain::BOUNDARY_TOROIDAL)
            {
                corrected_index[i] = (((current_index[i]%_cells.Size(i))+_cells.Size(i))%_cells.Size(i));
            }
            else
            {
                corrected_index[i] = current_index[i];
            }
        }

        Cell current_cell;
        if(_cells.Get(corrected_index, current_cell))
        {
            for(unsigned int j = 0; j < current_cell.samples.size(); j++)
            {
                neighbors.push_back(current_cell.samples[j]);
            }
        }
    }
    while(counter.Next());

    // done
    return 1;
}
Ejemplo n.º 13
0
void init_labyrinth(LABYRINTH labyrinth)
{
    assert (
           LABYRINTH_SIZE % 2 == 0
        && LABYRINTH_SIZE * LABYRINTH_SIZE - 1 <= GROUP_MASK
    );

    // Chaque cellule se voit attribuer son propre groupe au début de la
    // génération du labyrinthe.
    for (int i = 0; i < LABYRINTH_SIZE * LABYRINTH_SIZE; i++)
        labyrinth[i] = WALLS_MASK | (CELL) i;

    // Spécifie que les cases limitrophes aux bordures des générateurs sont
    // partagées entre plusieurs processus.
    int max_index = LABYRINTH_SIZE - 1;
    int middle = max_index / 2;
    for (int i = 0; i < LABYRINTH_SIZE; i++) {
        for (int j = middle; j < middle + 2; j++) {
            set_shared(cell_index(labyrinth, i, j)); // Horizontale
            set_shared(cell_index(labyrinth, j, i)); // Verticale
        }
    }
}
Ejemplo n.º 14
0
Archivo: env.c Proyecto: EarlGray/SECD
cell_t *lookup_env(secd_t *secd, const char *symbol, cell_t **symc) {
    cell_t *env = secd->env;
    assert(cell_type(env) == CELL_CONS,
            "lookup_env: environment is not a list");

    cell_t *res = lookup_fake_variables(secd, symbol);
    if (not_nil(res))
        return res;

    hash_t symh = secd_strhash(symbol);

    while (not_nil(env)) {       // walk through frames
        cell_t *frame = get_car(env);
        if (is_nil(frame)) {
            /* skip omega-frame */
            env = list_next(secd, env);
            continue;
        }

        cell_t *symlist = get_car(frame);
        cell_t *vallist = get_cdr(frame);

        while (not_nil(symlist)) {   // walk through symbols
            if (is_symbol(symlist)) {
                if (symh == symhash(symlist) && str_eq(symbol, symname(symlist))) {
                    if (symc != NULL) *symc = symlist;
                    return vallist;
                }
                break;
            }

            cell_t *curc = get_car(symlist);
            assert(is_symbol(curc),
                   "lookup_env: variable at [%ld] is not a symbol\n",
                   cell_index(secd, curc));

            if (symh == symhash(curc) && str_eq(symbol, symname(curc))) {
                if (symc != NULL) *symc = curc;
                return get_car(vallist);
            }

            symlist = list_next(secd, symlist);
            vallist = list_next(secd, vallist);
        }

        env = list_next(secd, env);
    }
    //errorf(";; error in lookup_env(): %s not found\n", symbol);
    return new_error(secd, SECD_NIL, "Lookup failed for: '%s'", symbol);
}
Ejemplo n.º 15
0
Archivo: memory.c Proyecto: 8l/SECD
cell_t *alloc_array(secd_t *secd, size_t size) {
    /* look through the list of arrays */
    cell_t *cur = secd->arrlist;
    while (not_nil(mcons_next(cur))) {
        if (is_array_free(secd, cur)) {
            size_t cursize = arrmeta_size(secd, cur);
            if (cursize >= size) {
                /* allocate this gap */
                if (cursize > size + 1) {
                    /* make a free gap after */
                    cell_t *newmeta = cur + size + 1;
                    cell_t *prevmeta = mcons_prev(cur);
                    init_meta(secd, newmeta, prevmeta, cur);

                    cur->as.mcons.prev = newmeta;
                    prevmeta->as.mcons.next = newmeta;

                    mark_free(newmeta, true);
                }
                mark_free(cur, false);
                return meta_mem(cur);
            }
        }
        cur = mcons_next(cur);
    }

    /* no chunks of sufficient size found, move secd->arrayptr */
    if (secd->arrayptr - secd->fixedptr <= (int)size)
        return &secd_out_of_memory;

    /* create new metadata cons at arrayptr - size - 1 */
    cell_t *oldmeta = secd->arrayptr;

    cell_t *meta = oldmeta - size - 1;
    init_meta(secd, meta, oldmeta, SECD_NIL);

    oldmeta->as.mcons.next = meta;

    secd->arrayptr = meta;

    memdebugf("NEW ARR[%ld], size %zd\n", cell_index(secd, meta), size);
    mark_free(meta, false);
    return meta_mem(meta);
}
Ejemplo n.º 16
0
EXPORT boolean rect_in_which(
	const double     *coords,
	int	        *icoords,
	const RECT_GRID	*grid)
{
	boolean	    status = FUNCTION_SUCCEEDED;
	const double *h = grid->h;
	const double *VL = grid->VL, *VU = grid->VU;
	const int   *gmax = grid->gmax;
	const int   *lbuf = grid->lbuf, *ubuf = grid->ubuf;
	int	    i, dim = grid->dim;
	static const double SHIFT = 0.2; /* TOLERANCE */

		/* Find Grid Block and points outside and moved in */

	for(i = 0; i < dim; ++i)
	{
	    if (grid->h[i] == 0.0)
	    {
	    	icoords[i] = 0;
	    }
	    else
	    {
	        icoords[i] = cell_index(coords[i],i,grid);

	        if (icoords[i] < -lbuf[i])
	        {
	    	    if (VL[i] - coords[i] <= SHIFT*h[i])
	    	        icoords[i] = -lbuf[i];
	    	    else
	    	        status = FUNCTION_FAILED;
	        }
	        if (icoords[i] >= gmax[i]+ubuf[i])
	        {
	    	    if (coords[i] - VU[i] <= SHIFT*h[i])
	    	        icoords[i] = gmax[i] + ubuf[i] - 1;
	    	    else
	    	        status = FUNCTION_FAILED;
	        }
	    }
	}
	return status;
}		/*end rect_in_which*/
Ejemplo n.º 17
0
int CellList::update(int pid, const clam::Vec3d& pos){
    int cidx = cell_index(pos);
    if(cidx == p_cell_ids_[pid]) return cidx;

    int cidx_old = p_cell_ids_[pid];
    if(cell_[cidx_old] == pid) cell_[cidx_old] = linked_list_[pid];
    else{
        for(int ci = cell_[cidx_old]; ci != CLL_EMPTY; ci = linked_list_[ci]){
            if(linked_list_[ci] == pid){
                linked_list_[ci] = linked_list_[pid];
                break;
            }
        }
    }

    linked_list_[pid] = cell_[cidx];
    cell_[cidx] = pid;
    p_cell_ids_[pid] = cidx;

    return cidx;
}
Ejemplo n.º 18
0
Archivo: memory.c Proyecto: 8l/SECD
void free_array(secd_t *secd, cell_t *mem) {
    assertv(mem <= secd->arrlist, "free_array: tried to free arrlist");
    assertv(secd->arrayptr < mem, "free_array: not an array");

    cell_t *meta = arr_meta(mem);
    cell_t *prev = mcons_prev(meta);

    assertv(meta->nref == 0, "free_array: someone seems to still use the array");
    mark_free(meta, true);

    if (meta != secd->arrayptr) {
        if (is_array_free(secd, prev)) {
            /* merge with the previous array */
            cell_t *pprev = prev->as.mcons.prev;
            pprev->as.mcons.next = meta;
            meta->as.mcons.prev = pprev;
        }

        cell_t *next = mcons_next(meta);
        if (is_array_free(secd, next)) {
            /* merge with the next array */
            cell_t *newprev = meta->as.mcons.prev;
            next->as.mcons.prev = newprev;
            newprev->as.mcons.next = next;
        }
        mark_free(meta, true);
    } else {
        /* move arrayptr into the array area */
        prev->as.mcons.next = SECD_NIL;
        secd->arrayptr = prev;

        if (is_array_free(secd, prev)) {
            /* at most one array after 'arr' may be free */
            cell_t *pprev = prev->as.mcons.prev;
            pprev->as.mcons.next = SECD_NIL;
            secd->arrayptr = pprev;
        }
    }
    memdebugf("FREE ARR[%ld]", cell_index(secd, meta));
}
Ejemplo n.º 19
0
cell_t * run_secd(secd_t *secd, cell_t *ctrl) {
    cell_t *op, *ret;
    TIMING_DECLARATIONS(ts_then, ts_now);

    share_cell(secd, ctrl);
    set_control(secd, &ctrl);

    while (true)  {
        TIMING_START_OPERATION(ts_then);

        op = pop_control(secd);
        assert_cell(op, "run: no command");
        if (cell_type(op) != CELL_OP) {
            errorf("run: not an opcode at [%ld]\n", cell_index(secd, op));
            dbg_printc(secd, op);
            continue;
        }

        int opind = op->as.op;
        if (about_to_halt(secd, opind, &ret))
            return ret;

        secd_opfunc_t callee = (secd_opfunc_t) opcode_table[ opind ].fun;

        ret = callee(secd);
        if (is_error(ret))
            if (!handle_exception(secd, ret))
                return fatal_exception(secd, ret, opind);

        drop_cell(secd, op);

        TIMING_END_OPERATION(ts_then, ts_now)

        run_postop(secd);

        ++secd->tick;
    }
}
int GridSampleHolder::Remove(const Sample & sample)
{
    vector<int> cell_index(Dimension());
    
    if(! LocateCell(sample, cell_index))
    {
        return 0;
    }
            
    Cell cell;
    if(!_cells.Get(cell_index, cell))
    {
        return 0;
    }
    
    int found = 0;
    for(unsigned int i = 0; i < cell.samples.size(); i++)
    {
        if(cell.samples[i] == &sample)
        {
            found = 1;
            cell.samples[i] = cell.samples[cell.samples.size()-1];
            cell.samples.pop_back();
            break;
        }
    }

    if(! found)
    {
        return 0;
    }
    else
    {
        if(!_cells.Put(cell_index, cell)) return 0;
        return 1;
    }
}
Ejemplo n.º 21
0
void dbg_print_cell(secd_t *secd, const cell_t *c) {
    if (is_nil(c)) {
         secd_printf(secd, "NIL\n");
         return;
    }
    char buf[128];
    if (c->nref > DONT_FREE_THIS - 100000) strncpy(buf, "-", 64);
    else snprintf(buf, 128, "%ld", (long)c->nref);
    printf("[%ld]^%s: ", cell_index(secd, c), buf);

    switch (cell_type(c)) {
      case CELL_CONS:
        printf("CONS([%ld], [%ld])\n",
               cell_index(secd, get_car(c)), cell_index(secd, get_cdr(c)));
        break;
      case CELL_FRAME:
        printf("FRAME(syms: [%ld], vals: [%ld])\n",
               cell_index(secd, get_car(c)), cell_index(secd, get_cdr(c)));
        break;
      case CELL_INT:  printf("%d\n", c->as.num); break;
      case CELL_CHAR:
        if (isprint(c->as.num)) printf("#\\%c\n", (char)c->as.num);
        else printf("#x%x\n", c->as.num);
        break;
      case CELL_OP:
        sexp_print_opcode(secd, secd->output_port, c->as.op);
        printf("\n");
        break;
      case CELL_FUNC: printf("*%p()\n", c->as.ptr); break;
      case CELL_KONT: printf("KONT[%ld, %ld, %ld]\n",
                             cell_index(secd, c->as.kont.stack),
                             cell_index(secd, c->as.kont.env),
                             cell_index(secd, c->as.kont.ctrl)); break;
      case CELL_ARRAY: printf("ARR[%ld]\n",
                               cell_index(secd, arr_val(c, 0))); break;
      case CELL_STR: printf("STR[%ld\n",
                             cell_index(secd, (cell_t*)strval(c))); break;
      case CELL_SYM: printf("SYM[%08x]='%s'\n",
                             symhash(c), symname(c)); break;
      case CELL_BYTES: printf("BVECT[%ld]\n",
                               cell_index(secd, (cell_t*)strval(c))); break;
      case CELL_REF: printf("REF[%ld]\n",
                             cell_index(secd, c->as.ref)); break;
      case CELL_ERROR: printf("ERR[%s]\n", errmsg(c)); break;
      case CELL_ARRMETA: printf("META[%ld, %ld]\n",
                                 cell_index(secd, mcons_prev((cell_t*)c)),
                                 cell_index(secd, mcons_next((cell_t*)c))); break;
      case CELL_UNDEF: printf("#?\n"); break;
      case CELL_FREE: printf("FREE\n"); break;
      default: printf("unknown type: %d\n", cell_type(c));
    }
}
Ejemplo n.º 22
0
CellList::CellNeighbourIterator CellList::particle_cell_nbs(const clam::Vec3d& pos)const{
    return CellNeighbourIterator(cell_neighbours_ + 27 * cell_index(pos));
}
Ejemplo n.º 23
0
sanguis::model::object
sanguis::tools::libmergeimage::to_model(
	sanguis::model::cell_size const _cell_size,
	sanguis::tools::libmergeimage::saved_image_vector const &_images
)
{
	sanguis::model::object result(
		_cell_size,
		sanguis::model::optional_animation_delay(),
		sanguis::model::part_map(),
		sanguis::model::optional_image_name()
	);

	for(
		sanguis::tools::libmergeimage::saved_image const &image
		:
		_images
	)
	{
		sanguis::model::animation_index cell_index(
			0u
		);

		for(
			sanguis::tools::libmergeimage::path_count_pair const &element
			:
			image.paths()
		)
		{
			sanguis::tools::libmergeimage::path const &path(
				element.path()
			);

			FCPPT_ASSERT_ERROR(
				path.size()
				==
				sanguis::tools::libmergeimage::impl::tree_depth::value
			);

			sanguis::model::animation_index const range(
				fcppt::cast::size<
					sanguis::model::animation_index
				>(
					element.count()
				)
			);

			result[
				sanguis::model::part_name(
					path[
						0
					]
				)
			][
				sanguis::model::weapon_category_name(
					path[
						1
					]
				)
			].insert(
				sanguis::model::animation_name(
					path[
						2
					]
				),
				sanguis::model::animation(
					sanguis::model::animation_range(
						cell_index,
						cell_index
						+
						range
					),
					sanguis::model::optional_animation_delay(),
					sanguis::model::optional_animation_sound(),
					sanguis::model::optional_image_name(
						image.image_name()
					)
				)
			);

			cell_index +=
				range;
		}
	}

	return
		result;
}
Ejemplo n.º 24
0
static cell_t *chain_index(secd_t *secd, const cell_t *cell, cell_t *prev) {
    return new_cons(secd, new_number(secd, cell_index(secd, cell)), prev);
}