aboutsummaryrefslogtreecommitdiff
path: root/libobjc/encoding.c
diff options
context:
space:
mode:
Diffstat (limited to 'libobjc/encoding.c')
-rw-r--r--libobjc/encoding.c79
1 files changed, 77 insertions, 2 deletions
diff --git a/libobjc/encoding.c b/libobjc/encoding.c
index 35c9552..d417b87 100644
--- a/libobjc/encoding.c
+++ b/libobjc/encoding.c
@@ -148,6 +148,8 @@ objc_sizeof_type (const char *type)
/* Skip the variable name if any */
if (*type == '"')
{
+ /* FIXME: How do we know we won't read beyond the end of the
+ string. Here and in the rest of the file! */
for (type++; *type++ != '"';)
/* do nothing */;
}
@@ -217,6 +219,10 @@ objc_sizeof_type (const char *type)
return sizeof (double);
break;
+ case _C_LNG_DBL:
+ return sizeof (long double);
+ break;
+
case _C_VOID:
return sizeof (void);
break;
@@ -236,6 +242,19 @@ objc_sizeof_type (const char *type)
}
break;
+ case _C_VECTOR:
+ {
+ /* Skip the '!'. */
+ type++;
+ /* Skip the '['. */
+ type++;
+
+ /* The size in bytes is the following number. */
+ int size = atoi (type);
+ return size;
+ }
+ break;
+
case _C_BFLD:
{
/* The new encoding of bitfields is: b 'position' 'type' 'size' */
@@ -318,6 +337,10 @@ objc_sizeof_type (const char *type)
case _C_DBL:
return sizeof (_Complex double);
break;
+
+ case _C_LNG_DBL:
+ return sizeof (_Complex long double);
+ break;
default:
{
@@ -418,6 +441,10 @@ objc_alignof_type (const char *type)
return __alignof__ (double);
break;
+ case _C_LNG_DBL:
+ return __alignof__ (long double);
+ break;
+
case _C_PTR:
case _C_ATOM:
case _C_CHARPTR:
@@ -429,6 +456,23 @@ objc_alignof_type (const char *type)
/* do nothing */;
return objc_alignof_type (type);
+ case _C_VECTOR:
+ {
+ /* Skip the '!'. */
+ type++;
+ /* Skip the '['. */
+ type++;
+
+ /* Skip the size. */
+ while (isdigit ((unsigned char)*type))
+ type++;
+
+ /* Skip the ','. */
+ type++;
+
+ /* The alignment in bytes is the following number. */
+ return atoi (type);
+ }
case _C_STRUCT_B:
case _C_UNION_B:
{
@@ -496,6 +540,10 @@ objc_alignof_type (const char *type)
case _C_DBL:
return __alignof__ (_Complex double);
break;
+
+ case _C_LNG_DBL:
+ return __alignof__ (_Complex long double);
+ break;
default:
{
@@ -631,6 +679,7 @@ objc_skip_typespec (const char *type)
case _C_ULNG_LNG:
case _C_FLT:
case _C_DBL:
+ case _C_LNG_DBL:
case _C_VOID:
case _C_UNDEF:
return ++type;
@@ -642,7 +691,6 @@ objc_skip_typespec (const char *type)
case _C_ARY_B:
/* skip digits, typespec and closing ']' */
-
while (isdigit ((unsigned char)*++type))
;
type = objc_skip_typespec (type);
@@ -654,6 +702,30 @@ objc_skip_typespec (const char *type)
return 0;
}
+ case _C_VECTOR:
+ /* Skip '!' */
+ type++;
+ /* Skip '[' */
+ type++;
+ /* Skip digits (size) */
+ while (isdigit ((unsigned char)*type))
+ type++;
+ /* Skip ',' */
+ type++;
+ /* Skip digits (alignment) */
+ while (isdigit ((unsigned char)*type))
+ type++;
+ /* Skip typespec. */
+ type = objc_skip_typespec (type);
+ /* Skip closing ']'. */
+ if (*type == _C_ARY_E)
+ return ++type;
+ else
+ {
+ _objc_abort ("bad vector type %s\n", type);
+ return 0;
+ }
+
case _C_BFLD:
/* The new encoding of bitfields is: b 'position' 'type' 'size' */
while (isdigit ((unsigned char)*++type))
@@ -700,6 +772,8 @@ objc_skip_typespec (const char *type)
/*
Skip an offset as part of a method encoding. This is prepended by a
'+' if the argument is passed in registers.
+
+ FIXME: The compiler never generates '+'.
*/
const char *
objc_skip_offset (const char *type)
@@ -883,7 +957,7 @@ objc_get_type_qualifiers (const char *type)
the presence of bitfields inside the structure. */
void
objc_layout_structure (const char *type,
- struct objc_struct_layout *layout)
+ struct objc_struct_layout *layout)
{
const char *ntype;
@@ -979,6 +1053,7 @@ objc_layout_structure_next_member (struct objc_struct_layout *layout)
bfld_field_size = atoi (objc_skip_typespec (bfld_type));
}
+ /* The following won't work for vectors. */
#ifdef BIGGEST_FIELD_ALIGNMENT
desired_align = MIN (desired_align, BIGGEST_FIELD_ALIGNMENT);
#endif