Ejemplo n.º 1
0
int test_get_type()
{
	const char *test_name = "test_get_tree_type()";
	struct rooted_tree cladogram = tree_2();
	struct rooted_tree phylogram = tree_3();
	struct rooted_tree neither = tree_12();

	if (TREE_TYPE_UNKNOWN != cladogram.type) {
		printf ("%s: tree type should be unknown before get_tree_type() is called.\n",
				test_name);
		return 1;
	}

	if (TREE_TYPE_CLADOGRAM != get_tree_type(&cladogram)) {
		printf ("%s: tree should be a cladogram.\n", test_name);
		return 1;
	}

	if (TREE_TYPE_PHYLOGRAM != get_tree_type(&phylogram)) {
		printf ("%s: tree should be a phylogram.\n", test_name);
		return 1;
	}

	if (TREE_TYPE_NEITHER != get_tree_type(&neither)) {
		printf ("%s: tree should be of neither type.\n", test_name);
		return 1;
	}

	printf ("%s: ok.\n", test_name);
	return 0;
}
Ejemplo n.º 2
0
Archivo: xi_dom.cpp Proyecto: dhuth/xcc
ast_type* dom_qname_resolver::resolve_id_type(xi_id_type* t, xi_builder& b) {
    ptr<list<ast_decl>> dlist = b.find_all_declarations(t->name);
    if(dlist->size() == 0) {
        //TODO: throw an error or log an error or something
        std::cout << "unknown name " << first(t->name->names) << " at line " << t->source_location->first.line_number << "\n";

        assert(false);
        return nullptr;
    }
    else {
        auto decl = first(dlist);
        switch(decl->get_tree_type()) {
        case tree_type_id::xi_struct_decl:      return b.get_object_type(decl);
        default:
            __throw_unhandled_tree_type(__FILE__, __LINE__, decl, "dom_qname_resolver::resolve_id_type()");
        }
    }
}
Ejemplo n.º 3
0
Archivo: xi_dom.cpp Proyecto: dhuth/xcc
static void __merge_decls_in_namespace(
        xi_namespace_decl* ns,
        xi_builder& b,
        decl_swap_map_t& swapmap,
        const std::vector<tree_type_id>& treetypes) {
    ptr<list<ast_decl>>         decl_list   = ns->declarations;
    list<ast_decl>::iterator_t  decl_iter   = decl_list->begin();
    while(decl_iter < decl_list->end()) {
        auto decl = *decl_iter;
        if(__is_in(treetypes, decl->get_tree_type())) {
            merge_declarations_with(decl, decl_iter, decl_list, b, swapmap, treetypes);
        }
        else if(decl->is<xi_namespace_decl>()) {
            __merge_decls_in_namespace(decl->as<xi_namespace_decl>(), b, swapmap, treetypes);
        }

        decl_iter++;
    }
}