Пример #1
0
static void print_node(Node* n, std::ostream& out) {
	std::string shape=(n->player==BLACK)?"box":"circle";
	out<<"\"" << n << "\"" <<"[label=\""<<n->val/n->visits <<"\"" <<" shape="<<shape <<"];"<<std::endl;
	for (child_map::const_iterator i = n->children.begin(); i != n->children.end(); ++i) {
		print_node(i->second, out);
	}
}
Пример #2
0
static void do_file(char *path, struct cramfs_inode *i)
{
	unsigned long offset = i->offset << 2;
	int fd = 0;

	if (offset == 0 && i->size != 0) {
		die(FSCK_UNCORRECTED, 0, "file inode has zero offset and non-zero size");
	}
	if (i->size == 0 && offset != 0) {
		die(FSCK_UNCORRECTED, 0, "file inode has zero size and non-zero offset");
	}
	if (offset != 0 && offset < start_data) {
		start_data = offset;
	}
	if (opt_verbose) {
		print_node('f', i, path);
	}
	if (opt_extract) {
		fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, i->mode);
		if (fd < 0) {
			die(FSCK_ERROR, 1, "open failed: %s", path);
		}
	}
	if (i->size) {
		do_uncompress(path, fd, offset, i->size);
	}
	if (opt_extract) {
		close(fd);
		change_file_status(path, i);
	}
}
Пример #3
0
	void print_node( const node &n, int indent = 0 ) {

		for( int i = 0; i < indent; ++i ) {
			std::cout << " ";
		}

		const std::string &a = n.get_annot();

		if( !a.empty() ) {
			std::cout << "[" << a << "]";
		}
		if( n.is_null() ) {
			std::cout << "null!!!\n";

		} else if( n.is_terminal() ) {
			std::cout << "term: " << n.get_terminal() << "\n";
		} else {
			std::cout << "inner:" << n.get_prod() << "\n";

			for( const node &cn : n.get_list() ) {
				print_node( cn, indent+1 );
			}

		}
	}
Пример #4
0
void
cxx_print_xnode (FILE *file, tree node, int indent)
{
  switch (TREE_CODE (node))
    {
    case BASELINK:
      print_node (file, "functions", BASELINK_FUNCTIONS (node), indent + 4);
      print_node (file, "binfo", BASELINK_BINFO (node), indent + 4);
      print_node (file, "access_binfo", BASELINK_ACCESS_BINFO (node),
		  indent + 4);
      break;
    case OVERLOAD:
      print_node (file, "function", OVL_FUNCTION (node), indent+4);
      print_node (file, "chain", TREE_CHAIN (node), indent+4);
      break;
    case TEMPLATE_PARM_INDEX:
      indent_to (file, indent + 3);
      fprintf (file, "index %d level %d orig_level %d",
	       TEMPLATE_PARM_IDX (node), TEMPLATE_PARM_LEVEL (node),
	       TEMPLATE_PARM_ORIG_LEVEL (node));
      break;
    case TEMPLATE_INFO:
      print_node (file, "template", TI_TEMPLATE (node), indent+4);
      print_node (file, "args", TI_ARGS (node), indent+4);
      if (TI_PENDING_TEMPLATE_FLAG (node))
	{
	  indent_to (file, indent + 3);
	  fprintf (file, "pending_template");
	}
      break;
    case ARGUMENT_PACK_SELECT:
      print_node (file, "pack", ARGUMENT_PACK_SELECT_FROM_PACK (node),
		  indent+4);
      indent_to (file, indent + 3);
      fprintf (file, "index %d", ARGUMENT_PACK_SELECT_INDEX (node));
      break;
    case DEFERRED_NOEXCEPT:
      print_node (file, "pattern", DEFERRED_NOEXCEPT_PATTERN (node), indent+4);
      print_node (file, "args", DEFERRED_NOEXCEPT_ARGS (node), indent+4);
      break;
    case LAMBDA_EXPR:
      cxx_print_lambda_node (file, node, indent);
      break;
    default:
      break;
    }
}
Пример #5
0
/* Prints all the Nodes in a list. */
void print_list(Node *node)
{
	if (node == NULL) 
		return;
	print_hashable(node->key);
	print_node(node);
	print_list(node->next);
}
static void free_image_node(image_node * current)
{
    print_node(current->item);
	SCI_FREE(current->item->mem);
	SCI_FREE(current->item->image_id);
	SCI_FREE(current->item);
	SCI_FREE(current);
}
Пример #7
0
void display_line_aux(t_sm_line l)
{
    if (IS_EMPTY_SM_LINE(l)) {
    } else {
	print_node(NODE_SM_LINE(l));
	display_line_aux(NEXT_SM_LINE(l));
    }
}
Пример #8
0
int cmd_parse_expr(FILE *file, const char *filename, const char *cmd)
{
    log_set_unit(basename(filename));

    lexer_init(file);
    parser_init();
    generator_init();

    struct node* node = NULL;
    symtable_t symtable = NULL;
    code_t code = NULL;

    if (strcmp(cmd, "parse_expr") == 0) {
        parser_flags_set(0);
        node = parser_parse_expr();
        print_node(node, 0, 0);
    } else if (strcmp(cmd, "parse_stmt") == 0) {
        parser_flags_set(0);
        node = parser_parse_statement();
        print_node(node, 0, 0);
    } else if (strcmp(cmd, "parse") == 0) {
        parser_flags_set(PF_RESOLVE_NAMES);
        symtable = parser_parse();
        print_symtable(symtable, 0);
    } else if (strcmp(cmd, "compile") == 0) {
        symtable = parser_parse();
        if (symtable != NULL) {
            code = generator_process(symtable);
            optimizer_optimize(code);
            generator_print_code(code);
        } else {
            print_symtable(symtable, 0);
        }
    }

    parser_free_node(node);
    symtable_destroy(symtable, 1);
    generator_free_code(code);

    generator_destroy();
    parser_destroy();
    lexer_destroy();

    log_close();
    return EXIT_SUCCESS;
}
void print_node(struct node *head)
{
	printf("%d\n", head->data);
	if (head->next != NULL)
		print_node(head->next);
	else
		return;
}
Пример #10
0
/* Print a leaf.
 */
static void *
print_leaf( JoinNode *node )
{
	if( node->type == JOIN_LEAF ) 
		print_node( node );

	return( NULL );
}
Пример #11
0
void print_finger(FILE *out, Finger *f, char *prefix, char *suffix)
{
	fprintf(out, "%sFinger:", prefix);
	print_node(out, &f->node);
	fprintf(out, " (status = %s, npings = %d, rtt = %ld/%ld) %s",
		   f->status ? "ACTIVE" : "PASSIVE", f->npings, f->rtt_avg, f->rtt_dev,
		   suffix);
}
Пример #12
0
void peg_print(struct peg_grammar *peg, FILE *out)
{
	int i;
	for ( i = 0; i < peg->max_nodes; ++i )
		if ( pn_is_type(peg, i, PEG_DEFINITION) )
			print_node(peg, i, 0, 0, out);
	fprintf(out, "\n");
}
Пример #13
0
static int print_db_tree(DB_NODE *root)
{
    if (!root)
        return 1;

    print_node(root);
    return 0;
}
Пример #14
0
Файл: main.c Проект: yumm007/C
int main(void)
{
	DARR *darr, *tmparr;
	struct scope tmp;
	int i;
	
	if ((darr = load_darr("db.db")) == NULL){
		printf("load db error.\n");
		if ((darr = create_darr(sizeof(struct scope))) == NULL) {
			printf("create date error.\n");
			return -1;
		}
	}
	
	for (i = 1; i <= 20; i++) {
		tmp.id = i;
		tmp.scope = 100 -i;
		snprintf(tmp.name, MAXNAME, "stu%d", i);
		if (append_darr(darr, &tmp) == -1)
			break;
	}

	i = 4;
	print_node(fetch(darr,&i,cmp_id));
#if 0
	for (i = 2; i < 13; i++)
	  delete_node(darr,&i,cmp_id);
	travel(darr,print_node);
	i = 15;
	print_node(fetch(darr,&i,cmp_id));
	travel(darr,print_node);
	travel(darr,print_node);
	i = 10;
	tmparr = fetch(darr, &i, cmp_id);
	printf("----------------------\n");
	print_node(tmparr);
	printf("----------------------\n");
	inserd_node(darr,tmparr,1);
	travel(darr,print_node);
	//save_darr(darr, "db.db");
	erase(darr);
	//printf("after travel\n");
	
#endif
	return 0;
}
Пример #15
0
/* Prints all the Nodes in a list. */
void print_list(Node *node)
{
    Node* current = node;
    while (current) {
        print_node(current);
        current = current->next;
    } 
}
Пример #16
0
// print the tree
void OBBTreeNavigator::print_tree() {
  // output file
  std::ofstream dotfile ("graph.dot");
  dotfile << "digraph graphname { " << std::endl;
  print_node(rootBox,dotfile);
  // navigate around the tree printing each node and its children
  dotfile << "} " << std::endl;
}
Пример #17
0
static int
pre_xr(DECL_ARGS)
{

	n = n->child;
	if (NULL == n)
		return 0;
	print_node(meta, n);
	n = n->next;
	if (NULL == n)
		return 0;
	outflags &= ~MMAN_spc;
	print_word("(");
	print_node(meta, n);
	print_word(")");
	return 0;
}
Пример #18
0
void branch(idxint curr_node_idx, ecos_bb_pwork* prob){
    idxint i, split_idx = prob->nodes[curr_node_idx].split_idx;

#if MI_PRINTLEVEL > 1
    if (prob->stgs->verbose) {
        PRINTTEXT("Branching->\t");
        print_node(prob, curr_node_idx);
    }
#endif

    /* Create right node*/
    prob->nodes[prob->iter].L = prob->nodes[curr_node_idx].L;
    prob->nodes[prob->iter].U = prob->nodes[curr_node_idx].U;
    prob->nodes[prob->iter].status = MI_NOT_SOLVED;

    /* Copy over the node id*/
    for(i=0; i < prob->num_bool_vars; ++i)
        get_bool_node_id(prob->iter, prob)[i] = get_bool_node_id(curr_node_idx, prob)[i];
    for(i=0; i < prob->num_int_vars*2; ++i)
        get_int_node_id(prob->iter, prob)[i] = get_int_node_id(curr_node_idx, prob)[i];

    if (split_idx < prob->num_bool_vars){
        get_bool_node_id(curr_node_idx, prob)[split_idx] = MI_ZERO;
        get_bool_node_id(prob->iter, prob)[split_idx] = MI_ONE;
    }else{
        split_idx -= prob->num_bool_vars;

        /* Left branch constrain UB */
        get_int_node_id(curr_node_idx, prob)[split_idx*2 + 1] =
            pfloat_floor( prob->nodes[curr_node_idx].split_val, prob->stgs->integer_tol );

        /* Right branch constrain LB */
        get_int_node_id(prob->iter, prob)[split_idx*2 ] =
            -pfloat_ceil( prob->nodes[curr_node_idx].split_val, prob->stgs->integer_tol  );
    }

    prob->nodes[curr_node_idx].status = MI_NOT_SOLVED;

#if MI_PRINTLEVEL > 1
    if (prob->stgs->verbose) {
        PRINTTEXT(" Left-> \t "); print_node(prob, curr_node_idx);
        PRINTTEXT(" Right->\t "); print_node(prob, prob->iter);
    }
#endif
}
Пример #19
0
        inline OutIt print_children(OutIt out, const xml_node<Ch>* node, int flags, int indent)
        {
            for (xml_node<Ch>* child = node->first_node(); child; child = child->next_sibling())
            {
                out = print_node(out, child, flags, indent);
            }

            return out;
        }
Пример #20
0
void print_tree(tnode *r) {
    if(r == NULL) return;
    static int pre = 0;
    int i = 0;
    print_node(pre, r);
    pre ++;
    for(; i < r->snum; i ++) print_tree(r->son[i]);
    pre --;
}
void mid_traverse_node(prbt_node root)
{
  if(root != nil)
    {
      mid_traverse_node(root->left);
      print_node(root);
      mid_traverse_node(root->right);
    }
}
Пример #22
0
/**
* l: left
* d: root
* r: right
*/
void ldr_print(const tree_node_t *tree)
{
    if (NULL != tree)
    {
        ldr_print(tree->left);
        print_node(tree);
        ldr_print(tree->right);
    }
}
Пример #23
0
Файл: main.cpp Проект: xRam0n/C
void traverse(struct node t)
{
  if(t != z)
  {
    print_node(t);
    traverse(t.l);
    traverse(t.r);
  }
}
// 中序遍历二叉查找树
void mid_traverse_node(bst_node* root)
{
    if(root)
    {
	mid_traverse_node(root->left);
	print_node(root);
	mid_traverse_node(root->right);
    }
}
Пример #25
0
/** Print a tree as text into a buffer.
 * @param[in,out] str Holds a pointer to the buffer; changed to point to the
 * null character.
 * @param[in,out] size Holds the size of the buffer; changed to hold the
 * remaining size.
 * @param type The format to use.
 * @param tree The root node of the tree to print.
 * @return EOK on success or an error code from errno.h. */
int bithenge_print_node_to_string(char **str, size_t *size,
    bithenge_print_type_t type, bithenge_node_t *tree)
{
	state_t state = {type, true, 0, *str, *size};
	int rc = print_node(&state, tree);
	*str = state.buffer;
	*size = state.buffer_size;
	return rc;
}
Пример #26
0
void print_branch(struct node *node, int level, int last)
{
    print_indent(level + 1);
    printf("\n");
    if (last) {
        show_indents[level + 1] = 0;
    }
    print_node(node, level + 1, 0);
}
Пример #27
0
void print_binary_operation_node(FILE *output, node *node) {
  static char *binary_operators[] = {
    "+",    /*  0 = ADDITION */
    "-",    /*  1 = SUBTRACTION */
    "="     /*  2 = ASSIGN */          
  };
  assert(NODE_BINARY_OPERATION == node->node_type);
  
  fputs("(", output);

  print_node(output, node->data.binary_operation->left_operand);
  fputs(" ", output);
  fputs(binary_operators[node->data.binary_operation->operation], output);
  fputs(" ", output);
  print_node(output, node->data.binary_operation->right_operand);

  fputs(")", output);
}
Пример #28
0
void generator::print_tree()
{
	INT i;
	
	cout << "generator::print_tree nb_oracle_nodes_used=" << nb_oracle_nodes_used << endl;
	for (i = 0; i < nb_oracle_nodes_used; i++) {
		print_node(i);
		}
}
Пример #29
0
int _list () {
	node* head = NULL;
//	node* head2 = NULL;
	int i = 0;// 'A';
	//int count = 0;
	while (i<10)
		append_node(&head,i++);
i--;
	while (i>=0)
		append_node(&head,i--);

#if 0
	insert_node(&head,11);
	insert_node(&head,0);
	insert_node(&head,100);
#endif
	print_node(head);
    //even_odd_merge(head);
	list_mirror (head);
    //reverse_sublist (&head, 5, 6);
	print_node(head);
	printf ("Total # of node is %d\n",count_node(head));
//	print_node(head2);
//	printf ("Total # of node is %d\n",count_node(head2));
//    node* result = merge_lists(head, head2);
//	print_node(result);
//	printf ("Total # of node is %d\n",count_node(result));
	// print_nth_node_from_last_rec(head,3,count);
	// prepend_node(&head,i++);
	// prepend_node(&head,i);
	// head = reverse_list(head);
	// reverse_list(&head);
	// print_node(head);
	// print_nth_node_from_last_rec(head,3,count);
	// printf ("Total # of node is %d\n",count_node(head));
	// printf ("loop %s detected\n",detect_loop (head)? "is":"is not");
	// delete_node(&head,i);
	// printf ("Total # of node is %d\n",count_node(head));
	// delete_node_by_addr(head);
	// printf ("5th node from last is %d\n",print_nth_node_from_last (head,5));
	// print_node(head);
	// printf ("Total # of node is %d\n",count_node(head));
	return 0;
}
Пример #30
0
void print_tree(struct node_t *tree)
{
    struct node_t *it;
    save_depth(tree);
    for (it = object_tree_l_most_node(tree->obj.parent); it;
         it = object_tree_iterator_increment(tree->obj.parent,
                                             OBJECT_POINTER(it))) {
        print_node(it);
    }
}