Esempio n. 1
0
    void check_block(const Block *b) {
      for (auto input : b->inputs()) {
        check_value(input);
        JIT_ASSERT(input->node()->kind_ == kParam);
      }

      for (auto n : b->nodes()) {
        JIT_ASSERT(n->kind_ != kParam);
        JIT_ASSERT(n->kind_ != kReturn);
        check_node(n);
      }

      JIT_ASSERT(b->output_->kind() == kReturn);
      check_node(b->output_);

      // all_nodes
      // - inputs_, output_ and nodes_ are all included in all_nodes
      // - all_nodes does not contain dead nodes??? (likely to be temporarily
      // suspended).  Weaker: all_nodes contains all inputs and returns
      // - only one return node???

      node_set nodes_set(ALL_OF(b->nodes()));
      node_set inputs_set {b->input_};
      node_set output_set {b->output_};
      // TODO: Make a more type safe std::includes wrapper which disallows use on
      // non-ordered containers
      JIT_ASSERT(std::includes(ALL_OF(all_nodes_set), ALL_OF(nodes_set)));
      JIT_ASSERT(std::includes(ALL_OF(all_nodes_set), ALL_OF(inputs_set)));
      JIT_ASSERT(std::includes(ALL_OF(all_nodes_set), ALL_OF(output_set)));

      sum_set.insert(ALL_OF(nodes_set));
      sum_set.insert(ALL_OF(inputs_set));
      sum_set.insert(ALL_OF(output_set));
    }
Esempio n. 2
0
/*=====================================
 * check_node -- check node for bad pointers
 *  and bad levels, and continue traverse
 * 2001/02/18, Perry Rapp
 *===================================*/
static void
check_node (CNSTRING n0key, NODE node, INT level)
{
    BOOLEAN lineage=FALSE;
    /* ignore lineage links - they are checked elsewhere */
    if (level==1) {
        INT i;
        for (i=0; i<ARRSIZE(lineage_tags); i++) {
            if (eqstr(ntag(node), lineage_tags[i])) {
                lineage=TRUE;
                break;
            }
        }
    }
    /*
    TO DO: How do we tell non-pointers that *ought* to
    be pointers, eg "1 SOUR <FamilyHistory>" ?
    */
    if (!lineage) {
        STRING skey = rmvat(nval(node));
        if (skey) {
            NODE xnode = qkey_to_type(skey);
            if (!xnode) {
                report_error(ERR_BADPOINTER
                             , _("Bad pointer (in %s): %s")
                             , n0key, nval(node));
            }
        }
    }
    if (nchild(node))
        check_node(n0key, nchild(node), level+1);
    if (nsibling(node))
        check_node(n0key, nsibling(node), level);
}
Esempio n. 3
0
void check_node(avl_tree_node_t *atn, multigrid_t *mg, multigrid_graph_t *mg_g) {
    struct T *t = atn->data;

    avl_tree_node_t *atn_from, *atn_to;
    graph_vertex_idx_t from, to;

    atn_from = avl_tree_get(
                   &mg_g->grid_to_graph_vertex,
                   (avl_tree_key_t)multigrid_get_grid(mg, t->from)
               );

    atn_to = avl_tree_get(
                 &mg_g->grid_to_graph_vertex,
                 (avl_tree_key_t)multigrid_get_grid(mg, t->to)
             );

    from = *(graph_vertex_idx_t *)atn_from->data;
    to = *(graph_vertex_idx_t *)atn_to->data;

    graph_edge_found_t gef = graph_remove_edge(&mg_g->graph, from, to);

    ck_assert_int_eq(gef.found, true);

    free(gef.data);

    if (atn->left)
        check_node(atn->left, mg, mg_g);

    if (atn->right)
        check_node(atn->right, mg, mg_g);
}
Esempio n. 4
0
struct node *check_node(struct bintree *root,struct node *node,short depth)
	{
	short cmp;

	cmp=bin_compare(root->node->square,node->square);

	if(cmp<0)
		{
		if(!root->lson)
			{
			root->lson=set_node(root,node,depth);
			return NULL;
			}
		else return check_node(root->lson,node,depth+1);
		}
	else if(cmp>0)
		{
		if(!root->rson)
			{
			root->rson=set_node(root,node,depth);
			return NULL;
			}
		else return check_node(root->rson,node,depth+1);
		}

	return root->node;
	}
Esempio n. 5
0
// FIXME - deal with whitespace!
static void got_inventory_items_resp(SoupSession *session, SoupMessage *msg, gpointer user_data) {
  //USER_PRIV_DEF(user_data);
  //GRID_PRIV_DEF(sim);
  inv_items_req *req = (inv_items_req*)user_data;
  user_grid_glue* user_glue = req->user_glue;
  xmlDocPtr doc;
  xmlNodePtr node;
  struct inventory_contents* inv;
  user_grid_glue_deref(user_glue);
  if(msg->status_code != 200) {
    printf("ERROR: Inventory request failed: got %i %s\n",(int)msg->status_code,msg->reason_phrase);
    goto fail;
  }

  printf("DEBUG: inventory folder content resp {{%s}}\n",
	 msg->response_body->data);

  doc = xmlReadMemory(msg->response_body->data,
		      msg->response_body->length,
		      "inventory.xml", NULL, 0);
  if(doc == NULL) {
    printf("ERROR: inventory XML parse failed\n");
    goto fail;    
  }
  node = xmlDocGetRootElement(doc);
  if(strcmp((char*)node->name, "InventoryCollection") != 0) {
    printf("ERROR: unexpected root node %s\n",(char*)node->name);
    goto free_fail;
  }

  node = node->children;
  if(!check_node(node,"Folders")) goto free_fail;

  inv = caj_inv_new_contents_desc(req->folder_id);
  parse_inv_folders(doc, node->children, inv);

  node = node->next;
  if(!check_node(node,"Items")) goto free_inv_fail;
  parse_inv_items(doc, node->children, inv);

  // there's a UserID node next, but it's just the null UUID anyway.

  req->cb(inv, req->cb_priv);
  caj_inv_free_contents_desc(inv);
  xmlFreeDoc(doc);
  delete req;

  return;

 free_inv_fail:
  caj_inv_free_contents_desc(inv);
 free_fail:
  xmlFreeDoc(doc);
 fail:
  req->cb(NULL, req->cb_priv);
  delete req;
  printf("ERROR: inventory response parse failure\n");
  return;
}
Esempio n. 6
0
END_TEST


START_TEST(check_node_test)
  {
  struct pbsnode pnode;
  login_node ln(&pnode);

  pnode.nd_slots.add_execution_slot();
  fail_unless(check_node(&ln, NULL) != NULL);
  pnode.nd_slots.mark_as_used(0);
  fail_unless(check_node(&ln, NULL) == NULL);

  }
Esempio n. 7
0
//-------------------------------------------------------------------------------------------------
void rotate_left(
    Node *n
) {
    check_node(n, "Rotate left: n == NIL");
    check_node(n->right, "Rotate left: n->right == NIL");	
	
	Node *r = n->right;
	if (n->parent == NULL) {
        root = r;
    } else {
        if (n == n->parent->left)
            n->parent->left = r;
        else
            n->parent->right = r;
    }
    if (r != NULL) {
       r->parent = n->parent;
    }
    n->right = r->left;
    if (r->left != NULL) {
        r->left->parent = n;
    }
    r->left = n;
    n->parent = r;
    
	/*
	Node *p = n->parent;
    Node *r = n->right->left;

    n->parent = n->right;
    n->right->parent = p;
    if(p) {
        if(n == p->right) {
            p->right = n->right;
        } else {
            p->left = n->right;
        }
    } else {
        root = n->right;
    }
    n->right->left = n;
    n->right = r;
	
	*/
    
error:
    return;	
}
Esempio n. 8
0
static void check_nodelist(test_nodes* pnodes, UINT32 num, const char* str) {
	static char str_tmp[128];
	for (UINT32 i = 0; i < num; ++i) {
		sprintf(str_tmp, "%s<%d>", str, i);
		check_node(pnodes + i, str_tmp);
	}
}
Esempio n. 9
0
 /***
  * Iterate through all nodes of waterways in pass 3 if way is coastline
  * or riverbank. Otherwise iterate just through the nodes between
  * firstnode and lastnode.
  */
 void way(const osmium::Way& way) {
     if (is_valid(way)) {
         if (check_all_nodes(way)) {
             for (auto node : way.nodes()) {
                 check_node(node);
             }
         } else {
             if (way.nodes().size() > 2) {
                 for (auto node = way.nodes().begin() + 1;
                         node != way.nodes().end() - 1; ++node) {
                     check_node(*node);
                 }
             }
         }
     }
 }
Esempio n. 10
0
graph_t * new_graph (unsigned int n, char **lbl){

graph_t *grafo;
unsigned int i;

if( (n <= ZERO) || !lbl || !check_node(lbl,n)) {
					errno = EINVAL; 
		   			return NULL; }

MALLOC_IF(grafo, sizeof(graph_t), UNO) 


if( !( MALLOC(grafo->node, sizeof(node_t), n)) ) {
					free(grafo);						
					return NULL; }

grafo->size = n;				 

for(i = ZERO; i<n; i++){
	((grafo-> node)+i) -> adj = NULL;
	if( !( MALLOC( ((grafo-> node)+i)->label, sizeof(char), LLABEL+UNO ) ) ){
									free_graph(&grafo);	
									return NULL; }						 
	
	strcpy( (((grafo-> node)+i) -> label) , lbl[i]); 
		}

return grafo;	
}
Esempio n. 11
0
EC_API ec_list ec_list_copy( ec_list list )
{
	ec_list          newlist;
	ec_list_iterator iter;
	ec_list_node     node, newnode, last;

	check_list(list);

	newlist = ec_list_create();
	if (! newlist) return NULL;

	last = NULL;
	iter = ec_list_iterator_create( list );
	while ((node = ec_list_iterator_next( iter )))
	{
		check_node(node);
		newnode = alloc_node( KEY(node), DATA(node) );
		ASSERT( newnode );
		if (! newnode) return NULL;								/* argh ! */
		if (last)
			NEXT(last) = newnode;
		else
		{
			HEAD(newlist) = newnode;
			last          = newnode;
		}
	}
	ec_list_iterator_destroy( iter );

	check_list(newlist);
	return newlist;
}
Esempio n. 12
0
EC_API ec_list ec_list_remove( ec_list list, ec_list_node node )
{
	ec_list_node prev, cur;

	check_list(list);
	check_node(node);
	if (! node) return list;

	prev = NULL;
	cur  = HEAD(list);
	while (cur && (cur != node))
	{
		prev = cur;
		cur  = NEXT(cur);
	}

	if (cur != node) return list;

	ASSERT( cur && (cur == node) );

	if (prev)
		NEXT(prev) = NEXT(node);
	else
		HEAD(list) = NEXT(node);
	NEXT(node) = NULL;

	check_list(list);
	return list;
}
Esempio n. 13
0
//-------------------------------------------------------------------------------------------------
void rotate_right(
    Node *n
) {
    check_node(n, "Rotate right: n == NIL");
    check_node(n->left, "Rotate right: n->left == NIL");	

	Node *l = n->left;
	if (n->parent == NULL) {
        root = l;
    } else {
        if (n == n->parent->left)
            n->parent->left = l;
        else
            n->parent->right = l;
    }
    if (l != NULL) {
		l->parent = n->parent;
    }
    n->left = l->right;
    if (l->right != NULL) {
        l->right->parent = n;
    }
    l->right = n;
    n->parent = l;
    
	/*
	Node *p = n->parent;
    Node *l = n->left->right;

    n->parent = n->left;
    n->left->parent = p;
    if(p) {
        if(n == p->left) {
            p->left = n->left;
        } else {
            p->right = n->left;
        }
    } else {
        root = n->left;
    }
    n->left->right = n;
    n->left = l;
    
	*/
error:
    return;	
}
void test() {
	NodePtr hello = new Leaf("hello");
	NodePtr world = new Leaf("world");
	//check_node(hello);
	NodePtr hw = hello->concat_with(world);
	//hw->debug_print();
	check_node(hw);

	//concatenation
	for (int i = 0; i<100; i++) {
		if (i%20 == 0)
			std::cout<<i<<std::endl;
		hw = hw->concat_with(hello);
		//hw->debug_print();
		assert(check_node(hw));
	}
	assert(check_node(hw));
	hw->debug_print();

	//random access
	for (int i = 0; i<100; i++) {
		Iterator iter = Iterator(hw);
		int pos = 0;
		std::string s = hw->as_string();
		while (pos < hw->length()) {
			//std::cout<<pos<<" ";
			assert(s[pos] == iter.current());
			int d = rand()%100;
			pos += d;
			iter.advance(d);
		}
		assert(!iter.valid);
		//std::cout<<std::endl;
	}

	//slices
	for (int i = 0; i<100; i++) {
		int begin = rand()%(hw->length()+1);
		int end = begin+rand()%(hw->length()-begin+1);
		NodePtr slice = hw->slice(begin, end);
		assert(check_node(slice));
		std::cout<<begin<<" "<<end<<std::endl;
	}
	std::cout<<"hw depth "<<hw->depth()<<std::endl;
}
Esempio n. 15
0
struct pbsnode *find_fitting_node(

  struct prop *needed)

  {
  struct pbsnode  *pnode = NULL;
  login_node      *ln;
  login_node      *ordered_ln;
  int              iter = -1;
  int              ordered_iter;
  int              index;
  resizable_array *ordered = initialize_resizable_array(logins.ra->num + 1);

  /* create a sorted list of the logins */
  while ((ln = (login_node *)next_thing(logins.ra, &iter)) != NULL)
    {
    /* if ordered is empty just insert without attempting to sort */
    if (ordered->num == 0)
      insert_thing(ordered, ln);
    else
      {
      ordered_iter = -1;
      index = ordered->slots[ALWAYS_EMPTY_INDEX].next;

      while ((ordered_ln = (login_node *)next_thing(ordered, &ordered_iter)) != NULL)
        {
        if (ln->times_used <= ordered_ln->times_used)
          {
          insert_thing_before(ordered, ln, index);
          break;
          }

        index = ordered_iter;
        }

      /* insert if it hasn't been inserted yet */
      if (ordered_ln == NULL)
        insert_thing(ordered, ln);
      }
    }

  iter = -1;

  while ((ln = (login_node *)next_thing(ordered, &iter)) != NULL)
    {
    if ((pnode = check_node(ln, needed)) != NULL)
      {
      ln->times_used++;
      free_resizable_array(ordered);
      return(pnode);
      }
    }

  free_resizable_array(ordered);

  return(NULL);
  } /* END find_fitting_node() */
int rb_tree_check(rb_tree *t)
{
     int nblack;
     if (nil.c != BLACK) return 0;
     if (nil.p != NIL || nil.r != NIL || nil.l != NIL) return 0;
     if (t->root == NIL) return 1;
     if (t->root->c != BLACK) return 0;
     return check_node(t->root, &nblack, t);
}
Esempio n. 17
0
static bool check_node(WTiling *ws, WSplit *split)
{
    if(split->parent)
        return check_node(ws, (WSplit*)split->parent);
    
    if((split->ws_if_root!=(void*)ws)){
        warn(TR("Split not on workspace."));
        return FALSE;
    }
    return TRUE;
}
Esempio n. 18
0
EC_API ec_list_node ec_list_append( ec_list list, EcAny key, EcAny data )
{
	ec_list_node last, newnode;

	check_list(list);
	last = ec_list_tail( list );

	newnode = alloc_node( key, data );
	ASSERT( newnode );
	if (! newnode) return NULL;									/* argh ! */
	if (last)
	{
		check_node(last);
		NEXT(last) = newnode;
	}
	else
		HEAD(list) = newnode;
	check_node(newnode);
	return newnode;
}
Esempio n. 19
0
    int program(ast::Program* program) {
        assert(program != nullptr);
        for (auto it = program->body.begin(); it != program->body.end(); ++it) {
            declare_node(it->get());
        }

        for (auto it = program->body.begin(); it != program->body.end(); ++it) {
            check_node(it->get());
        }
        return EXIT_SUCCESS;
    }
Esempio n. 20
0
static void deassembleTree(HQTreeNode* pnodes, const char* str) {
	char str_temp[64];
	for (UINT32 i = 0; i < 6; ++i) {
		pnodes[i].Detach();
	}
	for (UINT32 i = 0; i < 6; ++i) {
		test_nodes temp = {pnodes + i, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
		sprintf(str_temp, "%s[%d]", str, i);
		check_node(&temp, str);
	}
}
Esempio n. 21
0
/* return next block to free; search backwards, first not in collection,
   then in collection, return NULL at the end */
static MemBlock *next_to_free(void)
{
    MemBlock *block;
    int count;

    /* not in collection */
    DL_FOREACH(g_mem_blocks, block) {
        check_node(block);
        if (!block->flags.in_collection)
            return block;
    }
Esempio n. 22
0
/*==============================================
 * check_node_recursively -- Check node and all descendant nodes
 *============================================*/
static void
check_node_recursively (NODE node, NODE parent, INT level, CNSTRING key, CNSTRING scope)
{
	NODE child=0;

	check_node(node, parent, level, key, scope);

	for (child = nchild(node); child; child = nsibling(child)) {
		check_node_recursively(child, node, level+1, key, scope);
	}
}
Esempio n. 23
0
EC_API EcBool ec_list_finddata( ec_list list, EcAny key, EcAny *data )
{
	ec_list_node node;

	check_list(list);
	node = ec_list_find( list, key );
	if (! node) return FALSE;
	check_node(node);
	if (data)
		*data = DATA(node);
	return TRUE;
}
Esempio n. 24
0
EC_API ec_list_node ec_list_tail( ec_list list )
{
	ec_list_node node;

	check_list(list);
	/* find the last node */
	for (node = HEAD(list); node && NEXT(node); node = NEXT(node))
		check_node(node)
		;

	return node;
}
Esempio n. 25
0
static void check_node_and_range(int inode, enum e_route_type route_type) {

	/* Checks that inode is within the legal range, then calls check_node to    *
	 * check that everything else about the node is OK.                         */

	if (inode < 0 || inode >= num_rr_nodes) { 
		vpr_printf(TIO_MESSAGE_ERROR, "in check_node_and_range: rr_node #%d is out of legal, range (0 to %d).\n", 
				inode, num_rr_nodes - 1);
		exit(1);
	}
	check_node(inode, route_type);
}
static int check_node(rb_node *n, int *nblack, rb_tree *t)
{
     int nbl, nbr;
     rb_compare compare = t->compare;
     if (n == NIL) { *nblack = 0; return 1; }
     if (n->r != NIL && n->r->p != n) return 0;
     if (n->r != NIL && compare(n->r->k, n->k) < 0)
	  return 0;
     if (n->l != NIL && n->l->p != n) return 0;
     if (n->l != NIL && compare(n->l->k, n->k) > 0)
	  return 0;
     if (n->c == RED) {
	  if (n->r != NIL && n->r->c == RED) return 0;
	  if (n->l != NIL && n->l->c == RED) return 0;
     }
     if (!(check_node(n->r, &nbl, t) && check_node(n->l, &nbr, t))) 
	  return 0;
     if (nbl != nbr) return 0;
     *nblack = nbl + (n->c == BLACK);
     return 1;
}
std::vector< Ellipsoid_rasterizer::EuclideanVector >&
Ellipsoid_rasterizer::rasterize() {
  GsTLInt center_id = 
    cursor_.node_id( center_[0], center_[1], center_[2] );
  appli_assert( center_id >= 0 && center_id < int(already_visited_.size()) );

  already_visited_[ center_id ] = true;
  s_.push( center_id );

  EuclideanVector west(-1,0,0);
  EuclideanVector east(1,0,0);
  EuclideanVector south(0,-1,0);
  EuclideanVector north(0,1,0);
  EuclideanVector down(0,0,-1);
  EuclideanVector up(0,0,1);


  // move away from center, until we reach the border of the ellipsoid
  while( ! s_.empty() ) {
    GsTLInt id = s_.top();
    s_.pop();
    GsTLGridNode loc;
    cursor_.coords( id, loc[0], loc[1], loc[2] );
    
    check_node( loc+west );
    check_node( loc+east );
    check_node( loc+north );
    check_node( loc+south );
    check_node( loc+up );
    check_node( loc+down );
        
  }

  return ellipsoid_nodes_;
}
Esempio n. 28
0
EC_API ec_list_node ec_list_prepend( ec_list list, EcAny key, EcAny data )
{
	ec_list_node newnode;

	check_list(list);
	newnode = alloc_node( key, data );
	ASSERT( newnode );
	if (! newnode) return NULL;									/* argh ! */
	NEXT(newnode) = HEAD(list);
	HEAD(list)    = newnode;
	check_node(newnode);
	return newnode;
}
Esempio n. 29
0
static isc_result_t
check_hints(dns_db_t *db) {
	isc_result_t result;
	dns_rdataset_t rootns;
	dns_dbiterator_t *dbiter = NULL;
	dns_dbnode_t *node = NULL;
	isc_stdtime_t now;
	dns_fixedname_t fixname;
	dns_name_t *name;
	dns_rdatasetiter_t *rdsiter = NULL;

	isc_stdtime_get(&now);

	dns_fixedname_init(&fixname);
	name = dns_fixedname_name(&fixname);

	dns_rdataset_init(&rootns);
	(void)dns_db_find(db, dns_rootname, NULL, dns_rdatatype_ns, 0,
			  now, NULL, name, &rootns, NULL);
	result = dns_db_createiterator(db, 0, &dbiter);
	if (result != ISC_R_SUCCESS)
		goto cleanup;
	result = dns_dbiterator_first(dbiter);
	while (result == ISC_R_SUCCESS) {
		result = dns_dbiterator_current(dbiter, &node, name);
		if (result != ISC_R_SUCCESS)
			goto cleanup;
		result = dns_db_allrdatasets(db, node, NULL, now, &rdsiter);
		if (result != ISC_R_SUCCESS)
			goto cleanup;
		result = check_node(&rootns, name, rdsiter);
		if (result != ISC_R_SUCCESS)
			goto cleanup;
		dns_rdatasetiter_destroy(&rdsiter);
		dns_db_detachnode(db, &node);
		result = dns_dbiterator_next(dbiter);
	}
	if (result == ISC_R_NOMORE)
		result = ISC_R_SUCCESS;

 cleanup:
	if (dns_rdataset_isassociated(&rootns))
		dns_rdataset_disassociate(&rootns);
	if (rdsiter != NULL)
		dns_rdatasetiter_destroy(&rdsiter);
	if (node != NULL)
		dns_db_detachnode(db, &node);
	if (dbiter != NULL)
		dns_dbiterator_destroy(&dbiter);
	return (result);
}
Esempio n. 30
0
int scribble_check_defined_roles(st_tree *tree)
{
  assert(tree != NULL);
  assert(tree->root != NULL);

  if (tree->info->type != ST_TYPE_GLOBAL) {
    fprintf(stderr, "%s:%d %s Given protocol is not global protocol\n", __FILE__, __LINE__, __FUNCTION__);
    return 1; // Cannot check so always return error
  }

  t = tree;

  return check_node(tree->root, tree->info->roles, tree->info->nrole);
}