Exemple #1
0
EC_API ec_list_iterator ec_list_iterator_create( ec_list list )
{
	ec_list_iterator iter;

	check_list(list);
	iter = (ec_list_iterator) ec_malloc( sizeof(struct ec_list_iterator_struct) );
	if (! iter) return NULL;

	make_magic_iter(iter);
	ITLIST(iter) = list;
	ITPOS(iter)  = HEAD(ITLIST(iter));
	check_iter(iter);
	return iter;
}
Exemple #2
0
EC_API ec_list_node ec_list_iterator_next( ec_list_iterator iterator )
{
	ec_list_node node;

	check_iter(iterator);
	node = NULL;
	if (ITPOS(iterator))
	{
		node = ITPOS(iterator);
		check_node(node);
		ITPOS(iterator) = NEXT(node);
	}

	return node;
}
Exemple #3
0
  bool FileHeader::checkType(const std::string& check_type) const
  {
    std::istringstream check_sstr(check_type);
    std::istream_iterator<std::string> check_iter(check_sstr), check_iter_end;
    std::istringstream type_sstr(file_type);
    std::istream_iterator<std::string> type_iter(type_sstr), type_iter_end;

    while (check_iter != check_iter_end)
    {
      if (type_iter == type_iter_end
          || check_iter->compare(*type_iter) != 0)
        return false;
      ++check_iter;
      ++type_iter;
    }
    return true;
  }
Exemple #4
0
EC_API void ec_list_iterator_rewind( ec_list_iterator iterator )
{
	check_iter(iterator);
	ITPOS(iterator) = HEAD(ITLIST(iterator));
}
Exemple #5
0
EC_API void ec_list_iterator_destroy( ec_list_iterator iterator )
{
	check_iter(iterator);
	del_magic_iter(iterator);
	ec_free( iterator );
}
/*
#define NO_IMMED_DOM ((size_t)-1)
array_tos<SGraphNode> *build_immediate_dominators(
			    const SGraph *reachable,
			    const SGraph *domination,
			    tos<SGraphNode> *rev_postord_list,
			    SGraphNode root,
			    bool do_forward) {
			    */
void build_immediate_dominators(SGraph *immed_doms,
                                const SGraph *reachable,
                                const SGraph *domination,
                                SGraphNodeList *rev_postord_list,
                                SGraphNode root,
                                bool do_forward) {
    //unsigned num = reachable->max_num_nodes();
    //  unsigned root = (forward ? entry_node()->number() : exit_node()->number());
    //  Bit_set *d = (forward ? doms : pdoms);
    /*
    array_tos<SGraphNode> *immed_doms =
      new array_tos<SGraphNode>;
    for (unsigned i = 0; i < num; i++) {
      //  cfgraph_node **im = new cfgraph_node*[num];
      immed_doms->set_elem(i, NO_IMMED_DOM);

      //  im[root] = NULL;
    }
    */
    // Iterate over all of the nodes
    for (SNodeIter iter(domination->get_node_iterator());
            !iter.done(); iter.increment()) {

        //  for (unsigned n = 0; n < num; n++) {
        SGraphNode current_node = iter.get();

        /* the root node has no dominators */
        if (current_node == root) continue;

        /* remove self for comparison */
        //    domination->remove_edge(n, n);
        //    d[n].remove(n);

        /* check nodes in dominator set */
        bool found = false;

        // iterate over all of the possible predecessors
        for (SNodeIter iter2(domination->get_node_iterator());
                !iter2.done(); iter2.increment()) {

            //    bit_set_iter diter(&d[n]);
            //    while (!diter.is_empty()) {
            SGraphNode check_node = iter2.get();
            if (check_node == current_node) continue;

            // Now iterate over the successors of current_node and check_node
            // at the same time.  Ignore self.
            SNodeIter current_iter(domination->get_node_successor_iterator(current_node, do_forward));
            SNodeIter check_iter(domination->get_node_successor_iterator(check_node, do_forward));

            bool not_found = false;
            // The easier way:
            // get the first, remove it
            // then compare.
            for (; !current_iter.done() && !check_iter.done();
                    current_iter.increment(), check_iter.increment()) {

                //      while (!current_iter.done() &&
                //	     !check_iter.done()) {
                //	SGraphNode current_edge = current_iter.get();
                if (current_node == current_iter.get()) {
                    current_iter.increment();
                    if (current_iter.done()) break;
                }
                //	SGraphNode check_edge = check_iter.get();
                if (current_iter.get() != check_iter.get()) {
                    not_found = true;
                    break;
                }
            }
            if (!not_found &&
                    !current_iter.done() &&
                    check_iter.done()) {
                if (current_iter.get() == current_node) {
                    current_iter.increment();
                }
            }

            if (!not_found &&
                    current_iter.done() &&
                    check_iter.done()) {
                found = true;
                immed_doms->add_edge(SGraphEdge(current_node,check_node));
                break;
            }
        }

        if (!found) {
            suif_warning("can't find idom of node %u", current_node);
        }

    }
}