From: Ketan Dixit Date: Wed, 14 Jul 2010 21:02:00 +0000 (-0400) Subject: Added generic constructor for pointcut X-Git-Tag: release-v1.0~82 X-Git-Url: https://git.fsl.cs.sunysb.edu/?a=commitdiff_plain;h=840b9c544f7872badb43d6488779d0b1986711c6;p=interaspect.git Added generic constructor for pointcut --- diff --git a/src/Makefile.am b/src/Makefile.am index e353f15..7102bdf 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,5 +1,5 @@ lib_LTLIBRARIES = libinteraspect.la -libinteraspect_la_SOURCES = aop-pc-assign.c aop-main.c aop-type.c aop-weave.c aop-pc-entry.c aop-pc-exit.c aop-pc-fun-call.c +libinteraspect_la_SOURCES = aop-pc-assign.c aop-main.c aop-type.c aop-weave.c aop-pc-entry.c aop-pc-exit.c aop-pc-fun-call.c aop-pointcut.c libinteraspect_la_CFLAGS = -Wall -Werror -fvisibility=hidden -prefer-pic libinteraspect_la_LDFLAGS = -static -prefer-pic -version-info 1:0:0 libinteraspect_la_CPPFLAGS = -DHAVE_CONFIG_H -DIN_GCC -I$(gcc_includes) diff --git a/src/aop-pc-assign.c b/src/aop-pc-assign.c index caba0b3..de05e0f 100644 --- a/src/aop-pc-assign.c +++ b/src/aop-pc-assign.c @@ -356,16 +356,13 @@ aop_match_assignment_by_type (const struct aop_type *type) { struct aop_pointcut *pc; - pc = ggc_alloc (sizeof (struct aop_pointcut)); - pc->kind = ATP_ASSIGN; + pc = create_pointcut (ATP_ASSIGN); + pc->join_on = op_join_on_assign; - pc->insert_before = op_default_insert_before; - pc->insert_after = op_default_insert_after; pc->prepare_for_weave = op_prepare_assign; pc->pc_assign.type = type; pc->pc_assign.include_temp_vars = false; - pc->need_regimplification = false; return pc; } diff --git a/src/aop-pc-entry.c b/src/aop-pc-entry.c index e66d494..cd776d4 100644 --- a/src/aop-pc-entry.c +++ b/src/aop-pc-entry.c @@ -116,13 +116,9 @@ struct aop_pointcut * aop_match_function_entry () { struct aop_pointcut *pc; - pc = ggc_alloc (sizeof (struct aop_pointcut)); - pc->kind = ATP_ENTRY; - pc->need_regimplification = false; + pc = create_pointcut (ATP_ENTRY); pc->join_on = op_join_on_function_entry; - pc->insert_before = op_default_insert_before; - pc->insert_after = op_default_insert_after; pc->prepare_for_weave = op_prepare_entry; pc->pc_entry.function_name = NULL; diff --git a/src/aop-pc-exit.c b/src/aop-pc-exit.c index 857ef40..3c9149c 100644 --- a/src/aop-pc-exit.c +++ b/src/aop-pc-exit.c @@ -103,13 +103,9 @@ struct aop_pointcut * aop_match_function_exit () { struct aop_pointcut *pc; - pc = ggc_alloc (sizeof (struct aop_pointcut)); - pc->kind = ATP_EXIT; - pc->need_regimplification = false; + pc = create_pointcut (ATP_EXIT); pc->join_on = op_join_on_function_exit; - pc->insert_before = op_default_insert_before; - pc->insert_after = op_default_insert_after; pc->prepare_for_weave = op_prepare_exit; return pc; diff --git a/src/aop-pc-fun-call.c b/src/aop-pc-fun-call.c index 0d5b952..9c8f7e9 100644 --- a/src/aop-pc-fun-call.c +++ b/src/aop-pc-fun-call.c @@ -178,14 +178,9 @@ aop_match_function_call () { struct aop_pointcut *pc; - pc = ggc_alloc (sizeof (struct aop_pointcut)); - pc->kind = ATP_CALL; - pc->need_regimplification = false; + pc = create_pointcut (ATP_CALL); pc->join_on = op_join_on_function_call; - pc->insert_after = op_default_insert_after; - pc->insert_before = op_default_insert_before; - pc->prepare_for_weave = op_default_prepare_for_weave; pc->pc_call.function_name = NULL; pc->pc_call.return_type = NULL; diff --git a/src/aop-pointcut.c b/src/aop-pointcut.c new file mode 100644 index 0000000..5dddc88 --- /dev/null +++ b/src/aop-pointcut.c @@ -0,0 +1,55 @@ +/* This program is free software: you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/* Whether we want them or not (we don't), Autoconf _insists_ on + defining these. Since GCC's config.h (which we must include) also + defines them, we have to undef them here. */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include + +#include +#include +#include +#include +#include +#include + +#include "aop.h" +#include "aop-pointcut.h" + +/* + * Creates a generic pointcut + * \return The default pointcut. + */ +struct aop_pointcut * +create_pointcut (enum aop_pckind kind) +{ + struct aop_pointcut *pc; + + pc = ggc_alloc (sizeof (struct aop_pointcut)); + + pc->need_regimplification = false; + pc->kind = kind; + + pc->insert_before = op_default_insert_before; + pc->insert_after = op_default_insert_after; + pc->prepare_for_weave = op_default_prepare_for_weave; + + return pc; +} diff --git a/src/aop-pointcut.h b/src/aop-pointcut.h index 40bf26e..f48d9de 100644 --- a/src/aop-pointcut.h +++ b/src/aop-pointcut.h @@ -106,6 +106,8 @@ struct aop_joinpoint { bool is_prepared; }; +struct aop_pointcut *create_pointcut (enum aop_pckind kind); + void op_default_prepare_for_weave (struct aop_joinpoint *jp); void op_default_insert_before (struct aop_joinpoint *jp, gimple stmt); void op_default_insert_after (struct aop_joinpoint *jp, gimple stmt);