From: Justin Seyster Date: Fri, 12 Mar 2010 01:53:14 +0000 (-0500) Subject: Partial implementation of does_type_match(). Other fixups. X-Git-Tag: release-v1.0~121 X-Git-Url: https://git.fsl.cs.sunysb.edu/?a=commitdiff_plain;h=4be591b983d62665bb7aef7c17045526d6fcf092;p=interaspect.git Partial implementation of does_type_match(). Other fixups. Added const qualifier to some aop_type variables. Added locale.h include, which is necessary to compile on Ubuntu. --- diff --git a/src/aop-main.c b/src/aop-main.c index eb79f19..e47de52 100644 --- a/src/aop-main.c +++ b/src/aop-main.c @@ -23,6 +23,8 @@ #undef PACKAGE_TARNAME #undef PACKAGE_VERSION +#include + #include #include #include diff --git a/src/aop-pc-assign.c b/src/aop-pc-assign.c index 6e9a25b..9768c76 100644 --- a/src/aop-pc-assign.c +++ b/src/aop-pc-assign.c @@ -21,6 +21,8 @@ #undef PACKAGE_TARNAME #undef PACKAGE_VERSION +#include + #include #include #include @@ -105,7 +107,7 @@ op_join_on_assign (struct aop_pointcut *pc, join_callback cb) } struct aop_pointcut * -aop_match_assignment_by_type (struct aop_type *type) +aop_match_assignment_by_type (const struct aop_type *type) { struct aop_pointcut *pc; @@ -113,5 +115,7 @@ aop_match_assignment_by_type (struct aop_type *type) pc->kind = ATP_ASSIGN; pc->join_on = op_join_on_assign; + pc->pc_assign.type = type; + return pc; } diff --git a/src/aop-pointcut.h b/src/aop-pointcut.h index fae1b39..f096485 100644 --- a/src/aop-pointcut.h +++ b/src/aop-pointcut.h @@ -25,7 +25,7 @@ enum aop_pckind { }; struct aop_pc_assign { - struct aop_type *type; + const struct aop_type *type; }; /* An AOP pointcut represents the a set of joinponts: locations in the diff --git a/src/aop-type.c b/src/aop-type.c index 3c31ae7..f0b4aef 100644 --- a/src/aop-type.c +++ b/src/aop-type.c @@ -21,12 +21,16 @@ #undef PACKAGE_TARNAME #undef PACKAGE_VERSION +#include #include #include #include #include +#include +#include +#include "aop.h" #include "aop-type.h" static struct aop_type _aop_t_all_signed = { @@ -79,7 +83,30 @@ aop_t_all_pointer () /* Match an actual GCC type with an AOP type specification. */ bool -does_type_match (tree gcc_type, struct aop_type *aop_type) +does_type_match (tree gcc_type, const struct aop_type *aop_type) { - return true; + aop_assert (gcc_type != NULL && aop_type != NULL); + + if (aop_type->kind == ATK_ALL_POINTER) + { + return (TREE_CODE (gcc_type) == POINTER_TYPE); + } + else if (aop_type->pointer_levels == 0) + { + switch (aop_type->kind) + { + case ATK_ALL_SIGNED: + return (TREE_CODE (gcc_type) == INTEGER_TYPE + && !TYPE_UNSIGNED (gcc_type)); + case ATK_ALL_UNSIGNED: + return (TREE_CODE (gcc_type) == INTEGER_TYPE + && TYPE_UNSIGNED (gcc_type)); + case ATK_ALL_FP: + return (TREE_CODE (gcc_type) == REAL_TYPE); + default: + break; + } + } + + aop_assert (0); } diff --git a/src/aop-type.h b/src/aop-type.h index 66607fb..7b88c8b 100644 --- a/src/aop-type.h +++ b/src/aop-type.h @@ -35,6 +35,6 @@ struct aop_type { const char *tag; }; -bool does_type_match (tree gcc_type, struct aop_type *aop_type); +bool does_type_match (tree gcc_type, const struct aop_type *aop_type); #endif diff --git a/src/aop-weave.c b/src/aop-weave.c index 770d4c3..fa1db88 100644 --- a/src/aop-weave.c +++ b/src/aop-weave.c @@ -22,6 +22,7 @@ #undef PACKAGE_TARNAME #undef PACKAGE_VERSION +#include #include #include diff --git a/src/aop.h b/src/aop.h index 33a2f56..17050e9 100644 --- a/src/aop.h +++ b/src/aop.h @@ -54,12 +54,18 @@ struct aop_type; typedef unsigned int (*pass_callback) (); typedef void (*join_callback) (struct aop_joinpoint *); -extern struct aop_pointcut *aop_match_assignment_by_type (struct aop_type *type); +extern struct aop_pointcut *aop_match_assignment_by_type ( + const struct aop_type *type); extern const char *aop_capture_lhs_name (struct aop_joinpoint *jp); extern void aop_do_weave (struct aop_joinpoint *jp, const char *name, ...); +extern const struct aop_type *aop_t_all_signed (); +extern const struct aop_type *aop_t_all_unsigned (); +extern const struct aop_type *aop_t_all_fp (); +extern const struct aop_type *aop_t_all_pointer (); + extern void aop_register_pass (const char *pass_name, pass_callback callback); extern void aop_join_on (struct aop_pointcut *pc, join_callback callback); extern void aop_main ();