From: Justin Seyster Date: Thu, 11 Feb 2010 21:18:12 +0000 (-0500) Subject: Added capture function for assignment left-hand side. X-Git-Tag: release-v1.0~123 X-Git-Url: https://git.fsl.cs.stonybrook.edu/?a=commitdiff_plain;h=a2249db78fb4576bc2e2173370c308136bc65b73;p=interaspect.git Added capture function for assignment left-hand side. --- diff --git a/src/aop-pc-assign.c b/src/aop-pc-assign.c index 7912732..6e9a25b 100644 --- a/src/aop-pc-assign.c +++ b/src/aop-pc-assign.c @@ -34,6 +34,35 @@ #include "aop-pointcut.h" #include "aop-type.h" +const char * +aop_capture_lhs_name (struct aop_joinpoint *jp) +{ + gimple stmt; + tree lhs; + + aop_assert (jp->pc->kind == ATP_ASSIGN); + + stmt = gsi_stmt (*jp->gsi); + aop_assert (gimple_has_lhs (stmt)); + lhs = gimple_get_lhs (stmt); + + if (TREE_CODE (lhs) == SSA_NAME) + lhs = SSA_NAME_VAR (lhs); + + if (lhs != NULL && DECL_P (lhs)) + { + tree name = DECL_NAME (lhs); + if (name != NULL) + return IDENTIFIER_POINTER (name); + else + return NULL; + } + else + { + return NULL; + } +} + static bool stmt_matches_pointcut (struct aop_pointcut *pc, gimple stmt) { diff --git a/src/aop.h b/src/aop.h index ccd67bf..b46ffdd 100644 --- a/src/aop.h +++ b/src/aop.h @@ -56,6 +56,8 @@ typedef void (*join_callback) (struct aop_joinpoint *); extern struct aop_pointcut *aop_match_assignment_by_type (struct aop_type *type); +extern const char *aop_capture_lhs_name (struct aop_joinpoint *jp); + 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 ();