Beispiel #1
0
dfsch_object_t* dfsch_make_class(dfsch_object_t* superclass,
                                 char* name,
                                 dfsch_object_t* slots){
  class_t* klass = (class_t*)dfsch_make_object(DFSCH_CLASS_TYPE);

  klass->standard_type.name = name;
  klass->standard_type.slots = make_slots(slots);
  klass->standard_type.flags = DFSCH_TYPEF_USER_EXTENSIBLE;
  if (superclass){
    class_t* super = DFSCH_ASSERT_INSTANCE(superclass,
                                           DFSCH_CLASS_TYPE);

    klass->standard_type.superclass = (dfsch_type_t*)super;

    klass->standard_type.size = 
      adjust_sizes(klass->standard_type.slots,
                   klass->standard_type.superclass->size);

    klass->initvalues = super->initvalues;
    klass->initargs = super->initargs;

  } else {
    klass->standard_type.superclass = NULL;
    klass->standard_type.size = adjust_sizes(klass->standard_type.slots,
                                             sizeof(dfsch_object_t));
  }

  klass->standard_type.write = instance_write;

  /* klass->standard_type.equal_p = class_equal_p;
  klass->standard_type.apply = class_apply;
  klass->standard_type.hash = class_hash;*/

  return (dfsch_object_t*)klass;
}
Beispiel #2
0
void merge_ranks(graph_t* subg)
{
	int		i,d,r,pos,ipos;
	node_t	*v;
	graph_t	*root;

	root = subg->root;
	if (subg->u.minrank > 0) 
		root->u.rank[subg->u.minrank-1].valid = FALSE;
	for (r = subg->u.minrank; r <= subg->u.maxrank; r++) {
		d = subg->u.rank[r].n;
		ipos = pos = subg->u.rankleader[r]->u.order;
		make_slots(root,r,pos,d);
		for (i = 0; i < subg->u.rank[r].n; i++) {
			v = root->u.rank[r].v[pos] = subg->u.rank[r].v[i];
			v->u.order = pos++;
			v->graph = subg->root;
			delete_fast_node(subg,v);
			fast_node(subg->root,v);
			subg->root->u.n_nodes++;
		}
		subg->u.rank[r].v = root->u.rank[r].v + ipos;
		root->u.rank[r].valid = FALSE;
	}
	if (r < root->u.maxrank) root->u.rank[r].valid = FALSE;
	subg->u.expanded = TRUE;
}
Beispiel #3
0
static void 
merge_ranks(graph_t * subg)
{
    int i, d, r, pos, ipos;
    node_t *v;
    graph_t *root;

    root = agroot(subg);
    if (GD_minrank(subg) > 0)
#ifndef WITH_CGRAPH
	ND_rank(root)[GD_minrank(subg) - 1].valid = FALSE;
#else /* WITH_CGRAPH */
	GD_rank(root)[GD_minrank(subg) - 1].valid = FALSE;
#endif /* WITH_CGRAPH */
    for (r = GD_minrank(subg); r <= GD_maxrank(subg); r++) {
	d = GD_rank(subg)[r].n;
#ifndef WITH_CGRAPH
	ipos = pos = GD_rankleader(subg)[r]->u.order;
#else /* WITH_CGRAPH */
	ipos = pos = ND_order(GD_rankleader(subg)[r]);
#endif /* WITH_CGRAPH */
	make_slots(root, r, pos, d);
	for (i = 0; i < GD_rank(subg)[r].n; i++) {
#ifndef WITH_CGRAPH
	    v = ND_rank(root)[r].v[pos] = GD_rank(subg)[r].v[i];
#else /* WITH_CGRAPH */
	    v = GD_rank(root)[r].v[pos] = GD_rank(subg)[r].v[i];
#endif /* WITH_CGRAPH */
	    ND_order(v) = pos++;
#ifndef WITH_CGRAPH
	    v->graph = subg->root;
#else /* WITH_CGRAPH */
	/* real nodes automatically have v->root = root graph */
	    if (ND_node_type(v) == VIRTUAL)
		v->root = root;
#endif /* WITH_CGRAPH */
	    delete_fast_node(subg, v);
	    fast_node(agroot(subg), v);
	    GD_n_nodes(agroot(subg))++;
	}
#ifndef WITH_CGRAPH
	GD_rank(subg)[r].v = ND_rank(root)[r].v + ipos;
	ND_rank(root)[r].valid = FALSE;
#else /* WITH_CGRAPH */
	GD_rank(subg)[r].v = GD_rank(root)[r].v + ipos;
	GD_rank(root)[r].valid = FALSE;
#endif /* WITH_CGRAPH */
    }
    if (r < GD_maxrank(root))
	GD_rank(root)[r].valid = FALSE;
    GD_expanded(subg) = TRUE;
}
Beispiel #4
0
node_t	*
clone_vn(graph_t* g, node_t* vn)
{
	node_t	*rv;
	int		r;

	r = vn->u.rank;
	make_slots(g,r,vn->u.order,2);
	rv = virtual_node(g);
	rv->u.lw = vn->u.lw;
	rv->u.rw = vn->u.rw;
	rv->u.rank = vn->u.rank;
	rv->u.order = vn->u.order + 1;
	g->u.rank[r].v[rv->u.order] = rv;
	return rv;
}
Beispiel #5
0
/* make d slots starting at position pos (where 1 already exists) */
static void 
make_slots(graph_t * root, int r, int pos, int d)
{
    int i;
    node_t *v, **vlist;
#ifndef WITH_CGRAPH
    vlist = ND_rank(root)[r].v;
#else /* WITH_CGRAPH */
    vlist = GD_rank(root)[r].v;
#endif /* WITH_CGRAPH */
    if (d <= 0) {
#ifndef WITH_CGRAPH
	for (i = pos - d + 1; i < ND_rank(root)[r].n; i++) {
#else /* WITH_CGRAPH */
	for (i = pos - d + 1; i < GD_rank(root)[r].n; i++) {
#endif /* WITH_CGRAPH */
	    v = vlist[i];
	    ND_order(v) = i + d - 1;
	    vlist[ND_order(v)] = v;
	}
#ifndef WITH_CGRAPH
	for (i = ND_rank(root)[r].n + d - 1; i < ND_rank(root)[r].n; i++)
#else /* WITH_CGRAPH */
	for (i = GD_rank(root)[r].n + d - 1; i < GD_rank(root)[r].n; i++)
#endif /* WITH_CGRAPH */
	    vlist[i] = NULL;
    } else {
/*assert(ND_rank(root)[r].n + d - 1 <= ND_rank(root)[r].an);*/
#ifndef WITH_CGRAPH
	for (i = ND_rank(root)[r].n - 1; i > pos; i--) {
#else /* WITH_CGRAPH */
	for (i = GD_rank(root)[r].n - 1; i > pos; i--) {
#endif /* WITH_CGRAPH */
	    v = vlist[i];
	    ND_order(v) = i + d - 1;
	    vlist[ND_order(v)] = v;
	}
	for (i = pos + 1; i < pos + d; i++)
	    vlist[i] = NULL;
    }
#ifndef WITH_CGRAPH
    ND_rank(root)[r].n += d - 1;
#else /* WITH_CGRAPH */
    GD_rank(root)[r].n += d - 1;
#endif /* WITH_CGRAPH */
}

static node_t* 
clone_vn(graph_t * g, node_t * vn)
{
    node_t *rv;
    int r;

    r = ND_rank(vn);
    make_slots(g, r, ND_order(vn), 2);
    rv = virtual_node(g);
    ND_lw(rv) = ND_lw(vn);
    ND_rw(rv) = ND_rw(vn);
    ND_rank(rv) = ND_rank(vn);
    ND_order(rv) = ND_order(vn) + 1;
    GD_rank(g)[r].v[ND_order(rv)] = rv;
    return rv;
}