From: Justin Seyster Date: Fri, 27 Aug 2010 00:08:35 +0000 (-0400) Subject: Ability to create and match enum types. X-Git-Tag: release-v1.0~52 X-Git-Url: https://git.fsl.cs.stonybrook.edu/?a=commitdiff_plain;h=c8032aa2abaaf6b297e490e925022f6c9a095a0a;p=interaspect.git Ability to create and match enum types. --- diff --git a/src/aop-type.c b/src/aop-type.c index 0c5caff..9066c88 100644 --- a/src/aop-type.c +++ b/src/aop-type.c @@ -533,6 +533,16 @@ aop_t_union (const char *tag) return init_aop_type (ATK_UNION, 0, tag, -1); } +const struct aop_type * +aop_t_enum (const char *tag) +{ + if (tag == NULL) + fatal_error ("(InterAspect) Must supply a non-NULL tag when specifying an" + " enum type."); + + return init_aop_type (ATK_ENUM, 0, tag, -1); +} + /** * Return a type that will match pointers to the specified type. * @@ -660,10 +670,11 @@ does_fp_type_match (tree gcc_type, int aop_size) static bool does_custom_type_match (tree gcc_type, enum aop_tykind kind, const char *tag) { - aop_assert (kind == ATK_STRUCT || kind == ATK_UNION); + aop_assert (kind == ATK_STRUCT || kind == ATK_UNION || kind == ATK_ENUM); if ((kind == ATK_STRUCT && TREE_CODE (gcc_type) == RECORD_TYPE) - || (kind == ATK_UNION && TREE_CODE (gcc_type) == UNION_TYPE)) + || (kind == ATK_UNION && TREE_CODE (gcc_type) == UNION_TYPE) + || (kind == ATK_ENUM && TREE_CODE (gcc_type) == ENUMERAL_TYPE)) { aop_assert (tag != NULL); return safe_str_equal (tag, get_type_name (gcc_type)); @@ -704,6 +715,7 @@ does_type_match (tree gcc_type, const struct aop_type *aop_type) return does_fp_type_match (gcc_type, aop_type->size); case ATK_STRUCT: case ATK_UNION: + case ATK_ENUM: return does_custom_type_match (gcc_type, aop_type->kind, aop_type->tag); default: aop_assert (0); diff --git a/src/aop-type.h b/src/aop-type.h index ce37c9e..5bb167e 100644 --- a/src/aop-type.h +++ b/src/aop-type.h @@ -26,6 +26,7 @@ enum aop_tykind { ATK_STRUCT, ATK_UNION, + ATK_ENUM, }; /* NB: Do not update this struct without updating the correspodning diff --git a/src/aop.h b/src/aop.h index 7536c1e..1569504 100644 --- a/src/aop.h +++ b/src/aop.h @@ -182,6 +182,7 @@ extern const struct aop_type *aop_t_float64 (); extern const struct aop_type *aop_t_float128 (); extern const struct aop_type *aop_t_struct (const char *tag); extern const struct aop_type *aop_t_union (const char *tag); +extern const struct aop_type *aop_t_enum (const char *tag); extern const struct aop_type *aop_t_pointer_to (const struct aop_type *type); extern void aop_register_pass (const char *pass_name, pass_callback callback);