本文整理汇总了C++中TYPE_FIELD_NAME函数的典型用法代码示例。如果您正苦于以下问题:C++ TYPE_FIELD_NAME函数的具体用法?C++ TYPE_FIELD_NAME怎么用?C++ TYPE_FIELD_NAME使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TYPE_FIELD_NAME函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: m2_is_long_set
int
m2_is_long_set (struct type *type)
{
LONGEST previous_high = 0; /* Unnecessary initialization
keeps gcc -Wall happy. */
int len, i;
struct type *range;
if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
{
/* check if all fields of the RECORD are consecutive sets. */
len = TYPE_NFIELDS (type);
for (i = TYPE_N_BASECLASSES (type); i < len; i++)
{
if (TYPE_FIELD_TYPE (type, i) == NULL)
return 0;
if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) != TYPE_CODE_SET)
return 0;
if (TYPE_FIELD_NAME (type, i) != NULL
&& (strcmp (TYPE_FIELD_NAME (type, i), "") != 0))
return 0;
range = TYPE_INDEX_TYPE (TYPE_FIELD_TYPE (type, i));
if ((i > TYPE_N_BASECLASSES (type))
&& previous_high + 1 != TYPE_LOW_BOUND (range))
return 0;
previous_high = TYPE_HIGH_BOUND (range);
}
return len>0;
}
return 0;
}
示例2: gccgo_string_p
static int
gccgo_string_p (struct type *type)
{
/* gccgo strings don't necessarily have a name we can use. */
if (TYPE_NFIELDS (type) == 2)
{
struct type *type0 = TYPE_FIELD_TYPE (type, 0);
struct type *type1 = TYPE_FIELD_TYPE (type, 1);
type0 = check_typedef (type0);
type1 = check_typedef (type1);
if (TYPE_CODE (type0) == TYPE_CODE_PTR
&& strcmp (TYPE_FIELD_NAME (type, 0), "__data") == 0
&& TYPE_CODE (type1) == TYPE_CODE_INT
&& strcmp (TYPE_FIELD_NAME (type, 1), "__length") == 0)
{
struct type *target_type = TYPE_TARGET_TYPE (type0);
target_type = check_typedef (target_type);
if (TYPE_CODE (target_type) == TYPE_CODE_INT
&& TYPE_LENGTH (target_type) == 1
&& strcmp (TYPE_NAME (target_type), "uint8") == 0)
return 1;
}
}
return 0;
}
示例3: is_pascal_string_type
/* Determines if type TYPE is a pascal string type.
Returns a positive value if the type is a known pascal string type.
This function is used by p-valprint.c code to allow better string display.
If it is a pascal string type, then it also sets info needed
to get the length and the data of the string
length_pos, length_size and string_pos are given in bytes.
char_size gives the element size in bytes.
FIXME: if the position or the size of these fields
are not multiple of TARGET_CHAR_BIT then the results are wrong
but this does not happen for Free Pascal nor for GPC. */
int
is_pascal_string_type (struct type *type,int *length_pos,
int *length_size, int *string_pos,
struct type **char_type,
const char **arrayname)
{
if (type != NULL && TYPE_CODE (type) == TYPE_CODE_STRUCT)
{
/* Old Borland type pascal strings from Free Pascal Compiler. */
/* Two fields: length and st. */
if (TYPE_NFIELDS (type) == 2
&& TYPE_FIELD_NAME (type, 0)
&& strcmp (TYPE_FIELD_NAME (type, 0), "length") == 0
&& TYPE_FIELD_NAME (type, 1)
&& strcmp (TYPE_FIELD_NAME (type, 1), "st") == 0)
{
if (length_pos)
*length_pos = TYPE_FIELD_BITPOS (type, 0) / TARGET_CHAR_BIT;
if (length_size)
*length_size = TYPE_LENGTH (TYPE_FIELD_TYPE (type, 0));
if (string_pos)
*string_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
if (char_type)
*char_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 1));
if (arrayname)
*arrayname = TYPE_FIELD_NAME (type, 1);
return 2;
};
/* GNU pascal strings. */
/* Three fields: Capacity, length and schema$ or _p_schema. */
if (TYPE_NFIELDS (type) == 3
&& TYPE_FIELD_NAME (type, 0)
&& strcmp (TYPE_FIELD_NAME (type, 0), "Capacity") == 0
&& TYPE_FIELD_NAME (type, 1)
&& strcmp (TYPE_FIELD_NAME (type, 1), "length") == 0)
{
if (length_pos)
*length_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
if (length_size)
*length_size = TYPE_LENGTH (TYPE_FIELD_TYPE (type, 1));
if (string_pos)
*string_pos = TYPE_FIELD_BITPOS (type, 2) / TARGET_CHAR_BIT;
/* FIXME: how can I detect wide chars in GPC ?? */
if (char_type)
{
*char_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 2));
if (TYPE_CODE (*char_type) == TYPE_CODE_ARRAY)
*char_type = TYPE_TARGET_TYPE (*char_type);
}
if (arrayname)
*arrayname = TYPE_FIELD_NAME (type, 2);
return 3;
};
}
return 0;
}
示例4: field_name
static PyObject *
field_name (struct type *type, int field)
{
PyObject *result;
if (TYPE_FIELD_NAME (type, field))
result = PyString_FromString (TYPE_FIELD_NAME (type, field));
else
{
result = Py_None;
Py_INCREF (result);
}
return result;
}
示例5: recursion
/* Print the unchecked union type TYPE in something resembling Ada
format on STREAM. LEVEL is the recursion (indentation) level
in case the element type itself has nested structure, and SHOW is the
number of levels of internal structure to show (see ada_print_type). */
static void
print_unchecked_union_type (struct type *type, struct ui_file *stream,
int show, int level,
const struct type_print_options *flags)
{
if (show < 0)
fprintf_filtered (stream, "record (?) is ... end record");
else if (TYPE_NFIELDS (type) == 0)
fprintf_filtered (stream, "record (?) is null; end record");
else
{
int i;
fprintf_filtered (stream, "record (?) is\n%*scase ? is", level + 4, "");
for (i = 0; i < TYPE_NFIELDS (type); i += 1)
{
fprintf_filtered (stream, "\n%*swhen ? =>\n%*s", level + 8, "",
level + 12, "");
ada_print_type (TYPE_FIELD_TYPE (type, i),
TYPE_FIELD_NAME (type, i),
stream, show - 1, level + 12, flags);
fprintf_filtered (stream, ";");
}
fprintf_filtered (stream, "\n%*send case;\n%*send record",
level + 4, "", level, "");
}
}
示例6: print_enum_type
static void
print_enum_type (struct type *type, struct ui_file *stream)
{
int len = TYPE_NFIELDS (type);
int i;
LONGEST lastval;
fprintf_filtered (stream, "(");
wrap_here (" ");
lastval = 0;
for (i = 0; i < len; i++)
{
QUIT;
if (i)
fprintf_filtered (stream, ", ");
wrap_here (" ");
fputs_filtered (ada_enum_name (TYPE_FIELD_NAME (type, i)), stream);
if (lastval != TYPE_FIELD_ENUMVAL (type, i))
{
fprintf_filtered (stream, " => %s",
plongest (TYPE_FIELD_ENUMVAL (type, i)));
lastval = TYPE_FIELD_ENUMVAL (type, i);
}
lastval += 1;
}
fprintf_filtered (stream, ")");
}
示例7: m2_record_fields
void
m2_record_fields (struct type *type, struct ui_file *stream, int show,
int level)
{
/* Print the tag if it exists.
*/
if (TYPE_TAG_NAME (type) != NULL)
{
if (strncmp (TYPE_TAG_NAME (type), "$$", 2) != 0)
{
fputs_filtered (TYPE_TAG_NAME (type), stream);
if (show > 0)
fprintf_filtered (stream, " = ");
}
}
wrap_here (" ");
if (show < 0)
{
if (TYPE_CODE (type) == DECLARED_TYPE_STRUCT)
fprintf_filtered (stream, "RECORD ... END ");
else if (TYPE_DECLARED_TYPE (type) == DECLARED_TYPE_UNION)
fprintf_filtered (stream, "CASE ... END ");
}
else if (show > 0)
{
int i;
int len = TYPE_NFIELDS (type);
if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
fprintf_filtered (stream, "RECORD\n");
else if (TYPE_CODE (type) == TYPE_CODE_UNION)
/* i18n: Do not translate "CASE" and "OF" */
fprintf_filtered (stream, _("CASE <variant> OF\n"));
for (i = TYPE_N_BASECLASSES (type); i < len; i++)
{
QUIT;
print_spaces_filtered (level + 4, stream);
fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
fputs_filtered (" : ", stream);
m2_print_type (TYPE_FIELD_TYPE (type, i),
"",
stream, 0, level + 4);
if (TYPE_FIELD_PACKED (type, i))
{
/* It is a bitfield. This code does not attempt
to look at the bitpos and reconstruct filler,
unnamed fields. This would lead to misleading
results if the compiler does not put out fields
for such things (I don't know what it does). */
fprintf_filtered (stream, " : %d",
TYPE_FIELD_BITSIZE (type, i));
}
fprintf_filtered (stream, ";\n");
}
fprintfi_filtered (level, stream, "END ");
}
}
示例8: m2_enum
void
m2_enum (struct type *type, struct ui_file *stream, int show, int level)
{
int lastval, i, len;
if (show < 0)
{
/* If we just printed a tag name, no need to print anything else. */
if (TYPE_TAG_NAME (type) == NULL)
fprintf_filtered (stream, "(...)");
}
else if (show > 0 || TYPE_TAG_NAME (type) == NULL)
{
fprintf_filtered (stream, "(");
len = TYPE_NFIELDS (type);
lastval = 0;
for (i = 0; i < len; i++)
{
QUIT;
if (i > 0)
fprintf_filtered (stream, ", ");
wrap_here (" ");
fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
if (lastval != TYPE_FIELD_BITPOS (type, i))
{
fprintf_filtered (stream, " = %d", TYPE_FIELD_BITPOS (type, i));
lastval = TYPE_FIELD_BITPOS (type, i);
}
lastval++;
}
fprintf_filtered (stream, ")");
}
}
示例9: dynamic_array_type
static int
dynamic_array_type (struct type *type, const gdb_byte *valaddr,
int embedded_offset, CORE_ADDR address,
struct ui_file *stream, int recurse,
const struct value *val,
const struct value_print_options *options)
{
if (TYPE_NFIELDS (type) == 2
&& TYPE_CODE (TYPE_FIELD_TYPE (type, 0)) == TYPE_CODE_INT
&& strcmp (TYPE_FIELD_NAME (type, 0), "length") == 0
&& strcmp (TYPE_FIELD_NAME (type, 1), "ptr") == 0
&& !value_bits_any_optimized_out (val,
TARGET_CHAR_BIT * embedded_offset,
TARGET_CHAR_BIT * TYPE_LENGTH (type)))
{
CORE_ADDR addr;
struct type *elttype;
struct type *true_type;
struct type *ptr_type;
struct value *ival;
int length;
length = unpack_field_as_long (type, valaddr + embedded_offset, 0);
ptr_type = TYPE_FIELD_TYPE (type, 1);
elttype = check_typedef (TYPE_TARGET_TYPE (ptr_type));
addr = unpack_pointer (ptr_type,
valaddr + TYPE_FIELD_BITPOS (type, 1) / 8
+ embedded_offset);
true_type = check_typedef (elttype);
true_type = lookup_array_range_type (true_type, 0, length - 1);
ival = value_at (true_type, addr);
true_type = value_type (ival);
d_val_print (true_type,
value_contents_for_printing (ival),
value_embedded_offset (ival), addr,
stream, recurse + 1, ival, options);
return 0;
}
return 1;
}
示例10: add_struct_fields
/* Helper for expression_completer which recursively adds field and
method names from TYPE, a struct or union type, to the array
OUTPUT. This function assumes that OUTPUT is correctly-sized. */
static void
add_struct_fields (struct type *type, int *nextp, char **output,
char *fieldname, int namelen)
{
int i;
int computed_type_name = 0;
char *type_name = NULL;
CHECK_TYPEDEF (type);
for (i = 0; i < TYPE_NFIELDS (type); ++i)
{
if (i < TYPE_N_BASECLASSES (type))
add_struct_fields (TYPE_BASECLASS (type, i), nextp, output,
fieldname, namelen);
else if (TYPE_FIELD_NAME (type, i)
&& ! strncmp (TYPE_FIELD_NAME (type, i), fieldname, namelen))
{
output[*nextp] = xstrdup (TYPE_FIELD_NAME (type, i));
++*nextp;
}
}
for (i = TYPE_NFN_FIELDS (type) - 1; i >= 0; --i)
{
char *name = TYPE_FN_FIELDLIST_NAME (type, i);
if (name && ! strncmp (name, fieldname, namelen))
{
if (!computed_type_name)
{
type_name = type_name_no_tag (type);
computed_type_name = 1;
}
/* Omit constructors from the completion list. */
if (type_name && strcmp (type_name, name))
{
output[*nextp] = xstrdup (name);
++*nextp;
}
}
}
}
示例11: m2_is_unbounded_array
int
m2_is_unbounded_array (struct type *type)
{
if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
{
/*
* check if we have a structure with exactly two fields named
* _m2_contents and _m2_high. It also checks to see if the
* type of _m2_contents is a pointer. The TYPE_TARGET_TYPE
* of the pointer determines the unbounded ARRAY OF type.
*/
if (TYPE_NFIELDS (type) != 2)
return 0;
if (strcmp (TYPE_FIELD_NAME (type, 0), "_m2_contents") != 0)
return 0;
if (strcmp (TYPE_FIELD_NAME (type, 1), "_m2_high") != 0)
return 0;
if (TYPE_CODE (TYPE_FIELD_TYPE (type, 0)) != TYPE_CODE_PTR)
return 0;
return 1;
}
return 0;
}
示例12: store_regs
static void
store_regs (struct type *regs_type, CORE_ADDR regs_base)
{
struct gdbarch *gdbarch = target_gdbarch ();
struct regcache *regcache = get_thread_regcache (inferior_ptid);
int fieldno;
for (fieldno = 0; fieldno < TYPE_NFIELDS (regs_type); fieldno++)
{
const char *reg_name = TYPE_FIELD_NAME (regs_type, fieldno);
ULONGEST reg_bitpos = TYPE_FIELD_BITPOS (regs_type, fieldno);
ULONGEST reg_bitsize = TYPE_FIELD_BITSIZE (regs_type, fieldno);
ULONGEST reg_offset;
struct type *reg_type = check_typedef (TYPE_FIELD_TYPE (regs_type,
fieldno));
ULONGEST reg_size = TYPE_LENGTH (reg_type);
int regnum;
struct value *regval;
CORE_ADDR inferior_addr;
if (strcmp (reg_name, COMPILE_I_SIMPLE_REGISTER_DUMMY) == 0)
continue;
if ((reg_bitpos % 8) != 0 || reg_bitsize != 0)
error (_("Invalid register \"%s\" position %s bits or size %s bits"),
reg_name, pulongest (reg_bitpos), pulongest (reg_bitsize));
reg_offset = reg_bitpos / 8;
if (TYPE_CODE (reg_type) != TYPE_CODE_INT
&& TYPE_CODE (reg_type) != TYPE_CODE_PTR)
error (_("Invalid register \"%s\" type code %d"), reg_name,
TYPE_CODE (reg_type));
regnum = compile_register_name_demangle (gdbarch, reg_name);
regval = value_from_register (reg_type, regnum, get_current_frame ());
if (value_optimized_out (regval))
error (_("Register \"%s\" is optimized out."), reg_name);
if (!value_entirely_available (regval))
error (_("Register \"%s\" is not available."), reg_name);
inferior_addr = regs_base + reg_offset;
if (0 != target_write_memory (inferior_addr, value_contents (regval),
reg_size))
error (_("Cannot write register \"%s\" to inferior memory at %s."),
reg_name, paddress (gdbarch, inferior_addr));
}
}
示例13: vb_match
static int
vb_match (struct type *type, int index, struct type *basetype)
{
struct type *fieldtype;
char *name = TYPE_FIELD_NAME (type, index);
char *field_class_name = NULL;
if (*name != '_')
return 0;
/* gcc 2.4 uses _vb$. */
if (name[1] == 'v' && name[2] == 'b' && is_cplus_marker (name[3]))
field_class_name = name + 4;
/* gcc 2.5 will use __vb_. */
if (name[1] == '_' && name[2] == 'v' && name[3] == 'b' && name[4] == '_')
field_class_name = name + 5;
if (field_class_name == NULL)
/* This field is not a virtual base class pointer. */
return 0;
/* It's a virtual baseclass pointer, now we just need to find out whether
it is for this baseclass. */
fieldtype = TYPE_FIELD_TYPE (type, index);
if (fieldtype == NULL
|| TYPE_CODE (fieldtype) != TYPE_CODE_PTR)
/* "Can't happen". */
return 0;
/* What we check for is that either the types are equal (needed for
nameless types) or have the same name. This is ugly, and a more
elegant solution should be devised (which would probably just push
the ugliness into symbol reading unless we change the stabs format). */
if (TYPE_TARGET_TYPE (fieldtype) == basetype)
return 1;
if (TYPE_NAME (basetype) != NULL
&& TYPE_NAME (TYPE_TARGET_TYPE (fieldtype)) != NULL
&& strcmp (TYPE_NAME (basetype),
TYPE_NAME (TYPE_TARGET_TYPE (fieldtype))) == 0)
return 1;
return 0;
}
示例14: ada_val_print_enum
static void
ada_val_print_enum (struct type *type, const gdb_byte *valaddr,
int offset, int offset_aligned, CORE_ADDR address,
struct ui_file *stream, int recurse,
struct value *original_value,
const struct value_print_options *options,
const struct language_defn *language)
{
int i;
unsigned int len;
LONGEST val;
if (options->format)
{
val_print_scalar_formatted (type, offset_aligned,
original_value, options, 0, stream);
return;
}
len = TYPE_NFIELDS (type);
val = unpack_long (type, valaddr + offset_aligned);
for (i = 0; i < len; i++)
{
QUIT;
if (val == TYPE_FIELD_ENUMVAL (type, i))
break;
}
if (i < len)
{
const char *name = ada_enum_name (TYPE_FIELD_NAME (type, i));
if (name[0] == '\'')
fprintf_filtered (stream, "%ld %s", (long) val, name);
else
fputs_filtered (name, stream);
}
else
print_longest (stream, 'd', 0, val);
}
示例15: print_selected_record_field_types
static int
print_selected_record_field_types (struct type *type, struct type *outer_type,
int fld0, int fld1,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags)
{
int i, flds;
flds = 0;
if (fld0 > fld1 && TYPE_STUB (type))
return -1;
for (i = fld0; i <= fld1; i += 1)
{
QUIT;
if (ada_is_parent_field (type, i) || ada_is_ignored_field (type, i))
;
else if (ada_is_wrapper_field (type, i))
flds += print_record_field_types (TYPE_FIELD_TYPE (type, i), type,
stream, show, level, flags);
else if (ada_is_variant_part (type, i))
{
print_variant_part (type, i, outer_type, stream, show, level, flags);
flds = 1;
}
else
{
flds += 1;
fprintf_filtered (stream, "\n%*s", level + 4, "");
ada_print_type (TYPE_FIELD_TYPE (type, i),
TYPE_FIELD_NAME (type, i),
stream, show - 1, level + 4, flags);
fprintf_filtered (stream, ";");
}
}
return flds;
}