/*---------------------------------------------------------------------------*/
void
disassemble_memory (oraddr_t from, oraddr_t to, int nl)
{
    const int INSTR_LEN = 4;
    oraddr_t i;			/* Row counter */

    for (i = from; i < to; i += INSTR_LEN)
    {
        struct label_entry *entry = get_label (i);

        PRINTF ("%" PRIxADDR, i);

        if (NULL != entry)
        {
            int padding = 11 - strlen (entry->name);

            PRINTF (" <%s>: ", entry->name);
            PRINTF ("%*s ", padding < 0 ? 0 : padding, " ");
        }
        else
        {
            PRINTF (":                ");
        }

        if (verify_memoryarea (i))
        {
            uint32_t insn = eval_direct32 (i, 0, 0);
            int index = or1ksim_insn_decode (insn);

            PRINTF ("%08" PRIx32 " ", insn);

            if (index >= 0)
            {
                or1ksim_disassemble_insn (insn);
                PRINTF (" %s", or1ksim_disassembled);
            }
            else
            {
                PRINTF ("<invalid>");
            }

        }
        else
        {
            /* Not a valid memory area. Print Xs as required */
            PRINTF ("XXXXXXXX");
        }

        if (nl)
        {
            PRINTF ("\n");
        }
    }
}	/* disassemble_memory() */
Esempio n. 2
0
/////////////
// TEXT-RELATED
/////////////
void Edit::set_text(const std::string& text)
{
	std::string string0 (text);
	if(string0.length() > get_character_limit()) 
	{
		string0 = string0.erase(string0.length() - string0.length() + get_character_limit());
	}	
	get_label()->set_string(string0);
	int char_width = 10; // estimated glyph width
	set_cursor_x(cursor_x + (get_width() / char_width)); // set cursor at end of string
}
Esempio n. 3
0
EditorNameDialog::EditorNameDialog() {
	makevb = memnew(VBoxContainer);
	add_child(makevb);
	name = memnew(LineEdit);
	makevb->add_child(name);
	makevb->move_child(name, get_label()->get_index() + 1);
	name->set_margin(MARGIN_TOP, 5);
	name->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 5);
	name->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 5);
	name->connect("gui_input", this, "_line_gui_input");
}
Esempio n. 4
0
void Edit::draw()
{
	if(is_visible())  // is it visible? 
	{
		if(is_active()) // is it disabled?
		{}
		double x = get_position().x;
		double y = get_position().y;
		double angle = get_angle();
		double scale_x = get_scale().x;
		double scale_y = get_scale().y;
		int width  = get_width();
		int height = get_height();
        int red    = get_color().x;
        int green  = get_color().y;
        int blue   = get_color().z;		
		int alpha  = get_color().w;
        void * font = (get_label() ? get_label()->get_font()->get_data() : nullptr);		
		Vector4 text_color = get_text_color();
		// Draw edit
		Renderer::draw_edit(get_text(), x, y, width, height, angle, scale_x, scale_y,
		    red, green, blue, alpha, multilined, cursor, cursor_x, cursor_y);
        // Draw text
		if(!label->get_string().empty())
		{
			label->draw();
			label->set_position(x, y + cursor_y);
			label->set_scale(0.5, 0.5);
			label->set_color(text_color);
		}
		// if mouse over edit, change mouse to I-beam	
		// edit is pressed, set cursor at position_pressed	
		on_hover();
		on_mousepress();
        on_keypress();
        on_backspace();
        on_enter();		
	}	
}
Esempio n. 5
0
int main(int argc, char * argv[]) {
    auto trees = get_trees(argc, argv);
    for (auto & tree : trees) {
        int leaf_count = 0;
        for (auto ndi = tree->leaf_begin(); ndi != tree->leaf_end(); ++ndi, ++leaf_count) {
            std::cout << leaf_count + 1 << "\t" << ndi->get_label() << std::endl;
            if (leaf_count > 40) {
                std::cerr << "terminating: too many nodes" << std::endl;
                exit(1);
            }
        }
    }
}
Esempio n. 6
0
static void
generate_for_statement(DVM_Executable *exe, Block *block,
                       Statement *statement, OpcodeBuf *ob)
{
    int loop_label;
    ForStatement *for_s = &statement->u.for_s;

    if (for_s->init) {
        generate_expression_statement(exe, block, for_s->init, ob);
    }
    loop_label = get_label(ob);
    set_label(ob, loop_label);

    if (for_s->condition) {
        generate_expression(exe, block, for_s->condition, ob);
    }

    for_s->block->parent.statement.break_label = get_label(ob);
    for_s->block->parent.statement.continue_label = get_label(ob);

    if (for_s->condition) {
        generate_code(ob, statement->line_number,
                      DVM_JUMP_IF_FALSE,
                      for_s->block->parent.statement.break_label);
    }

    generate_statement_list(exe, for_s->block,
                            for_s->block->statement_list, ob);
    set_label(ob, for_s->block->parent.statement.continue_label);

    if (for_s->post) {
        generate_expression_statement(exe, block, for_s->post, ob);
    }

    generate_code(ob, statement->line_number,
                  DVM_JUMP, loop_label);
    set_label(ob, for_s->block->parent.statement.break_label);
}
Esempio n. 7
0
int bx_param_bool_c::text_ask(FILE *fpin, FILE *fpout)
{
  fprintf(fpout, "\n");
  int status;
  const char *prompt = get_ask_format();
  const char *help = get_description();
  char buffer[512];
  if (prompt == NULL) {
    if (get_label() != NULL) {
      sprintf(buffer, "%s? [%%s] ", get_label());
      prompt = buffer;
    } else {
      // default prompt, if they didn't set an ask format or label string
      sprintf(buffer, "%s? [%%s] ", get_name());
      prompt = buffer;
    }
  }
  Bit32u n = get();
  status = ask_yn(prompt, help, n, &n);
  if (status < 0) return status;
  set(n);
  return 0;
}
Esempio n. 8
0
static void	set_champ_labels(t_labels **labels, char **file_content)
{
  int		cur_case;

  cur_case = -1;
  while (file_content[++cur_case])
    {
      if (is_instruction(file_content[cur_case]) != -1 &&
	  is_label(file_content[cur_case]) != -1 && !(*labels))
	add_label(labels, ".");
      if (is_label(file_content[cur_case]) != -1)
	add_label(labels, get_label(file_content[cur_case]));
    }
}
Esempio n. 9
0
File: lsm.c Progetto: balamark/criu
int collect_lsm_profile(pid_t pid, CredsEntry *ce)
{
	ce->lsm_profile = NULL;

	if (lsmtype == LSMTYPE__NO_LSM)
		return 0;

	if (get_label(pid, &ce->lsm_profile) < 0)
		return -1;

	if (ce->lsm_profile)
		pr_info("%d has lsm profile %s\n", pid, ce->lsm_profile);

	return 0;
}
Esempio n. 10
0
void
add_button(SWFMovie mo, int x, int y, const char* label, SWFAction ac)
{
	SWFMovieClip btnclip = newSWFMovieClip();
	SWFFont font = get_default_font(mediadir);
	SWFDisplayItem it;
	SWFTextField tf = get_label(label, font);

	SWFMovieClip_add(btnclip, (SWFBlock)tf);
	SWFMovieClip_nextFrame(btnclip);

	it = SWFMovie_add(mo, (SWFBlock)btnclip);
	SWFDisplayItem_moveTo(it, x, y);
	SWFDisplayItem_addAction(it, ac, SWFACTION_PRESS);
}
Esempio n. 11
0
static void
generate_if_statement(DVM_Executable *exe, Block *block,
                      Statement *statement, OpcodeBuf *ob)
{
    int if_false_label;
    int end_label;
    IfStatement *if_s = &statement->u.if_s;
    Elsif *elsif;

    generate_expression(exe, block, if_s->condition, ob);
    if_false_label = get_label(ob);
    generate_code(ob, statement->line_number,
                  DVM_JUMP_IF_FALSE, if_false_label);
    generate_statement_list(exe, if_s->then_block,
                            if_s->then_block->statement_list, ob);
    end_label = get_label(ob);
    generate_code(ob, statement->line_number, DVM_JUMP, end_label);
    set_label(ob, if_false_label);

    for (elsif = if_s->elsif_list; elsif; elsif = elsif->next) {
        generate_expression(exe, block, elsif->condition, ob);
        if_false_label = get_label(ob);
        generate_code(ob, statement->line_number, DVM_JUMP_IF_FALSE,
                      if_false_label);
        generate_statement_list(exe, elsif->block,
                                elsif->block->statement_list, ob);
        generate_code(ob, statement->line_number, DVM_JUMP, end_label);
        set_label(ob, if_false_label);
    }
    if (if_s->else_block) {
        generate_statement_list(exe, if_s->else_block,
                                if_s->else_block->statement_list,
                                ob);
    }
    set_label(ob, end_label);
}
Esempio n. 12
0
static void
generate_logical_or_expression(DVM_Executable *exe, Block *block,
                               Expression *expr,
                               OpcodeBuf *ob)
{
    int true_label;

    true_label = get_label(ob);
    generate_expression(exe, block, expr->u.binary_expression.left, ob);
    generate_code(ob, expr->line_number, DVM_DUPLICATE);
    generate_code(ob, expr->line_number, DVM_JUMP_IF_TRUE, true_label);
    generate_expression(exe, block, expr->u.binary_expression.right, ob);
    generate_code(ob, expr->line_number, DVM_LOGICAL_OR);
    set_label(ob, true_label);
}
Esempio n. 13
0
void grid_segment::remove_skinny_part(grid_cell::ptr cell)
{
    if(!cell)
        return;

    if(cell->is_checked_for_skinny())
        return;

    cell->set_checked_for_skinny(true);

    for(int i=0; i<4; i+=1)
    {
        auto nb = grid_.get_neighbour_cell_4(cell, i);
        if(nb && nb->get_label() == cell->get_label()
                && nb->get_approx_label()==nb->get_label())
        {
            if(get_approximate_neighbours_count(nb) <= 1)
            {
                nb->set_approx_label(0);
                remove_skinny_part(nb);
            }
        }
    }
}
Esempio n. 14
0
static void
generate_logical_and_expression(DVM_Executable *exe, Block *block,
                                Expression *expr,
                                OpcodeBuf *ob)
{
    int false_label;

    false_label = get_label(ob);
    generate_expression(exe, block, expr->u.binary_expression.left, ob);
    generate_code(ob, expr->line_number, DVM_DUPLICATE);
    generate_code(ob, expr->line_number, DVM_JUMP_IF_FALSE, false_label);
    generate_expression(exe, block, expr->u.binary_expression.right, ob);
    generate_code(ob, expr->line_number, DVM_LOGICAL_AND);
    set_label(ob, false_label);
}
Esempio n. 15
0
/*
 * set the location of a label 
 */
Label* register_label(Assembly* assembly, char* name, int segment, int location) {
	Label* label;
	
	/* find/create the label */
	label = get_label(assembly, name);
	if (label->segment != UNKNOWN) {
		/* location allready set => multiple labels with the same name */
		printf("Label '%s' points to multiple locations\n", name);
		error(linenr, "Duplicate label found");
	} else {
		/* set location and segment */
		label->segment = segment;
		label->location = location;
		return label;
	}
}
Esempio n. 16
0
static gchar*
print_info (AtspiAccessible *accessible)
{
  gchar *name = "NULL";
  gchar *role_name = "NULL";

  if (accessible != NULL) {
    name = atspi_accessible_get_name (accessible, NULL);
    if ((name == NULL) || (g_strcmp0 (name, "") == 0))
        name = get_label (accessible);

    role_name = atspi_accessible_get_role_name (accessible, NULL);
  }

  return g_strdup_printf ("(%s, %s)", name, role_name);
}
Esempio n. 17
0
vgg_process::vgg_process()
{
		get_label("/home/aicrobo/deeplearning/data/synset_words.txt", label);

#ifdef USE_CUDA
		// mode setting - CPU/GPU
		Caffe::set_mode(Caffe::GPU);
#else
		Caffe::set_mode(Caffe::CPU);
#endif

		// gpu device number
		int device_id = 0;
		Caffe::SetDevice(device_id);

		caffe_test_net.CopyTrainedLayersFrom("/home/aicrobo/deeplearning/VGG_ILSVRC_19_layers.caffemodel");
}
Esempio n. 18
0
/*
 * Print label of tk truncated then print ellipsis
 */
static void print_label_truncated(printer_t *p, pp_open_token_t *tk) {
  char *s;
  uint32_t space;

  assert(p->col + 3 <= p->margin);
  space = p->margin - p->col;
  if (space > 3) {
    if (tk_has_par(tk)) {
      pp_open_par(p);
      space --;
    }
    s = get_label(p, tk);
    pp_prefix(p, s, space - 3);
  }
  pp_ellipsis(p);
  free_open_token(p, tk);
}
Esempio n. 19
0
static void	set_labels_instruction(t_labels **labels, char **file_content)
{
  int		cur_case;
  t_labels	*labls;

  cur_case = -1;
  labls = *labels;
  while (file_content[++cur_case])
    {
      if (is_label(file_content[cur_case]) != -1)
	labls = search_in_labels(labls, get_label(file_content[cur_case]));
      if (is_instruction(file_content[cur_case]) != -1)
	add_instruction(&(labls->lst_cmd),
			get_name_instruction(file_content[cur_case]),
			get_params(get_instruction(file_content[cur_case])));
    }
}
Esempio n. 20
0
/* Disassemble a line */
static void disassemble(TilemDisasmView *dv, TilemCalc *calc, dword pos,
                        dword *nextpos, char **mnemonic, char **args)
{
	dword addr = POS_TO_ADDR(pos);
	const char *lbl;
	char buf[500], *p;

	g_return_if_fail(calc != NULL);
	g_return_if_fail(dv->dbg->dasm != NULL);

	if (!(pos & 1) && (lbl = get_label(dv, calc, addr))) {
		if (mnemonic) {
			*mnemonic = NULL;
			*args = g_strdup_printf(_("%s:"), lbl);
		}

		if (nextpos)
			*nextpos = pos + 1;
	}
	else if (mnemonic) {
		tilem_disasm_disassemble(dv->dbg->dasm, calc,
		                         !dv->use_logical, addr,
		                         &addr, buf, sizeof(buf));

		p = strchr(buf, '\t');
		if (p) {
			*mnemonic = g_strndup(buf, p - buf);
			*args = g_strdup(p + 1);
		}
		else {
			*mnemonic = g_strdup(buf);
			*args = NULL;
		}

		if (nextpos)
			*nextpos = ADDR_TO_POS(addr);
	}
	else {
		tilem_disasm_disassemble(dv->dbg->dasm, calc,
		                         !dv->use_logical, addr,
		                         &addr, NULL, 0);
		if (nextpos)
			*nextpos = ADDR_TO_POS(addr);
	}
}
Esempio n. 21
0
static struct smack_label *label_add(struct smack_accesses *handle, const char *label)
{
    struct smack_hash_entry *hash_entry;
    unsigned int hash_value = 0;
    struct smack_label *new_label;
    int len;

    len = get_label(NULL, label, &hash_value);
    if (len == -1)
        return NULL;

    new_label = is_label_known(handle, label, hash_value);
    if (new_label == NULL) {/*no entry added yet*/
        if (handle->labels_cnt == handle->labels_alloc)
            if (accesses_resize(handle))
                return NULL;

        new_label = malloc(sizeof(struct smack_label));
        if (new_label == NULL)
            return NULL;
        new_label->label = malloc(len + 1);
        if (new_label->label == NULL) {
            free(new_label);
            return NULL;
        }

        memcpy(new_label->label, label, len + 1);
        new_label->id = handle->labels_cnt;
        new_label->len = len;
        new_label->first_rule = NULL;
        new_label->last_rule = NULL;
        new_label->next_label = NULL;
        hash_entry = &(handle->label_hash[hash_value]);
        if (hash_entry->first == NULL) {
            hash_entry->first = new_label;
            hash_entry->last = new_label;
        } else {
            hash_entry->last->next_label = new_label;
            hash_entry->last = new_label;
        }
        handle->labels[handle->labels_cnt++] = new_label;
    }

    return new_label;
}
 static std::size_t one_time_init_major_version()
 {
   std::size_t version{0};
   char const * cpu_info_path{"/proc/cpuinfo"};
   char const board_version_label[]{"Revision"};
   char const * eof_label{"###"};
   std::size_t const board_version_size{sizeof(board_version_label)};
   bool not_done{true};
   char buffer[board_version_size];
   std::size_t const board_version_length{board_version_size-1};
   char const * label{nullptr};
   FILE * info_file{fopen(cpu_info_path, "r")};
   do
     {
       label = get_label(info_file, buffer, board_version_length, eof_label);
       not_done = std::strcmp(label, eof_label)!=0;
       if (not_done)
         {
           not_done = std::strcmp(label, board_version_label)!=0;
           if (not_done)
             {
               skip_to_next_line( info_file );
             }
           else
             {
               version = extract_version( info_file );
             }
         }
     }
   while (not_done);
   if ( info_file )
     {
       fclose( info_file );
     }
   if (version>0&&version<=3) return 1;
   else if (version>3&&version<=0xf) return 2;
   else if (version==0x10 || version==0x12) return 3; // 0x10:B+, 0x12:A+
   else if (version==0x11) return 4; // Compute module
   else
     {
       throw std::runtime_error( "rpi_init::init_major_version: Unable to "
                                 "deduce board version from /proc/cpuinfo."
                               );
     }
 }
Esempio n. 23
0
static int prop_label(enum prop_object_type type,
		      const char *object,
		      const char *name,
		      const char *value)
{
	int ret;

	if (value) {
		ret = set_label((char *) object, (char *) value);
	} else {
		char label[BTRFS_LABEL_SIZE];

		ret = get_label((char *) object, label);
		if (!ret)
			fprintf(stdout, "label=%s\n", label);
	}

	return ret;
}
Esempio n. 24
0
int get_category(FILE * fd, char *type, struct Categories *labels)
{
    long cat;
    char *lbl;

    R_stabilize();		/* force out all graphics */
    do {
	fprintf(stdout, "\n");
	cat = get_cat(type);
	lbl = get_label(cat, labels);
	fprintf(stdout, "%ld [%s]\n", cat,
		*lbl ? lbl : G_get_cat((CELL) cat, labels));
    } while (!G_yes(_("Look ok? "), 1));
    if (*lbl)
	G_set_cat((CELL) cat, lbl, labels);

    fprintf(fd, "= %ld %s\n", cat, lbl);
    return (0);
}
Esempio n. 25
0
/* Get "previous" position */
static dword get_prev_pos(TilemDisasmView *dv, TilemCalc *calc, dword pos)
{
	dword addr = POS_TO_ADDR(pos), a2;

	g_return_val_if_fail(calc != NULL, 0);

	if (pos & 1) {
		return pos - 1;
	}
	else {
		a2 = tilem_disasm_guess_prev_address(dv->dbg->dasm, calc,
		                                     !dv->use_logical, addr);

		if (a2 != addr && get_label(dv, calc, a2))
			return ADDR_TO_POS(a2) + 1;
		else
			return ADDR_TO_POS(a2);
	}
}
Esempio n. 26
0
int smack_set_label_for_self(const char *label)
{
    int len;
    int fd;
    int ret;

    len = get_label(NULL, label, NULL);
    if (len < 0)
        return -1;

    fd = open(SELF_LABEL_FILE, O_WRONLY);
    if (fd < 0)
        return -1;

    ret = write(fd, label, len);
    close(fd);

    return (ret < 0) ? -1 : 0;
}
/*---------------------------------------------------------------------------*/
void
dump_memory (oraddr_t from, oraddr_t to)
{
    const int ROW_LEN = 16;
    oraddr_t i;			/* Row counter */

    for (i = from; i < to; i += ROW_LEN)
    {
        struct label_entry *entry = get_label (i);
        oraddr_t j;		/* Index in row */

        PRINTF ("%" PRIxADDR, i);

        if (NULL != entry)
        {
            int padding = 11 - strlen (entry->name);

            PRINTF (" <%s>: ", entry->name);
            PRINTF ("%*s ", padding < 0 ? 0 : padding, " ");
        }
        else
        {
            PRINTF (":                ");
        }


        for (j = 0; j < ROW_LEN; j++)
        {
            if (verify_memoryarea (i + j))
            {
                PRINTF ("%02" PRIx8 " ", eval_direct8 (i + j, 0, 0));
            }
            else
            {
                /* Not a valid memory area. Print Xs as required */
                PRINTF ("XX ");
            }
        }

        PRINTF ("\n");
    }
}				/* dump_memory() */
static void
print_info (AtspiAccessible *accessible,
            gchar *app_name)
{
  gchar *name = "NULL";
  gchar *role_name = "NULL";
  gchar *state_set = NULL;

  if (accessible != NULL) {
    name = atspi_accessible_get_name (accessible, NULL);
    if ((name == NULL) || (g_strcmp0 (name, "") == 0))
        name = get_label (accessible);

    role_name = atspi_accessible_get_role_name (accessible, NULL);
  }

  state_set = get_state_set (accessible);
  g_print ("(%s, %s, %s, %s)\n", app_name, name, role_name, state_set);
  g_free (state_set);
}
Esempio n. 29
0
/**
 * show_partition_information - print information about a partition
 * @ptab:	part_entry describing the partition
 * @i:		Partition number (UI purposes only)
 * @ptab_root:	part_entry describing the root partition (extended only)
 * @drive_info:	driveinfo struct describing the drive on which the partition
 *		is
 *
 * Note on offsets (from hpa, see chain.c32):
 *
 *  To make things extra confusing: data partition offsets are relative to where
 *  the data partition record is stored, whereas extended partition offsets
 *  are relative to the beginning of the extended partition all the way back
 *  at the MBR... but still not absolute!
 **/
static void show_partition_information(struct driveinfo *drive_info,
				       struct part_entry *ptab,
				       int partition_offset,
				       int nb_partitions_seen)
{
    char size[11];
    char bootloader_name[9];
    char *parttype;
    unsigned int start, end;

    int i = nb_partitions_seen;

    reset_more_printf();

    start = partition_offset;
    end = start + ptab->length - 1;

    if (ptab->length > 0)
	sectors_to_size(ptab->length, size);
    else
	memset(size, 0, sizeof size);

    if (i == 1)
	more_printf(" #  B       Start         End    Size Id Type\n");

    get_label(ptab->ostype, &parttype);
    more_printf("%2d  %s %11d %11d %s %02X %s",
		i, (ptab->active_flag == 0x80) ? "x" : " ",
		start, end, size, ptab->ostype, parttype);

    /* Extra info */
    if (ptab->ostype == 0x82 && swsusp_check(drive_info, ptab))
	more_printf("%s", " (Swsusp sig. detected)");

    if (get_bootloader_string(drive_info, ptab, bootloader_name, 9) == 0)
	more_printf("%-46s %s %s", " ", "Bootloader:", bootloader_name);

    more_printf("\n");

    free(parttype);
}
Esempio n. 30
0
static int
do_value_labels (struct lexer *lexer, const struct dictionary *dict, bool erase)
{
  struct variable **vars; /* Variable list. */
  size_t var_cnt;         /* Number of variables. */
  int parse_err=0;        /* true if error parsing variables */

  lex_match (lexer, T_SLASH);

  while (lex_token (lexer) != T_ENDCMD)
    {
      parse_err = !parse_variables (lexer, dict, &vars, &var_cnt,
				    PV_SAME_WIDTH);
      if (var_cnt < 1)
	{
	  free(vars);
	  return CMD_FAILURE;
	}
      if (erase)
        erase_labels (vars, var_cnt);
      while (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD)
	if (!get_label (lexer, vars, var_cnt, dict_get_encoding (dict)))
          goto lossage;

      if (lex_token (lexer) != T_SLASH)
	{
          free (vars);
          break;
	}

      lex_get (lexer);

      free (vars);
    }

  return parse_err ? CMD_FAILURE : CMD_SUCCESS;

 lossage:
  free (vars);
  return CMD_FAILURE;
}