Added generic constructor for pointcut
authorKetan Dixit <ketan.dixit@gmail.com>
Wed, 14 Jul 2010 21:02:00 +0000 (17:02 -0400)
committerJustin Seyster <jseyster@cs.sunysb.edu>
Thu, 15 Jul 2010 23:24:06 +0000 (19:24 -0400)
src/Makefile.am
src/aop-pc-assign.c
src/aop-pc-entry.c
src/aop-pc-exit.c
src/aop-pc-fun-call.c
src/aop-pointcut.c [new file with mode: 0644]
src/aop-pointcut.h

index e353f15c5570aed850b9b4c8edba05b7751bb43c..7102bdfb266a7f76fae56ba4f3e08bce98f81d88 100644 (file)
@@ -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)
index caba0b32df4d4b5f9824ea778e032ecd14beef77..de05e0f635deb0d072c9dd3a8bfdd0373712d931 100644 (file)
@@ -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;
 }
index e66d494b9116a8cdff805dbda85e0d9a82b5fa2b..cd776d4be2331998f69eaabeb9eee252d3b311e5 100644 (file)
@@ -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;
index 857ef4051dcb48d94b1f1e77da49e815466c3f5a..3c9149c7b9e3afb9b4e34fbe124a4b0638275c8c 100644 (file)
@@ -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;
index 0d5b9529253c95cc143baa1ff12642b99d1df362..9c8f7e9bb653d4bc262ed981fa026c19a2ab8731 100644 (file)
@@ -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 (file)
index 0000000..5dddc88
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+*/
+
+/* 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 <locale.h>
+
+#include <config.h>
+#include <system.h>
+#include <coretypes.h>
+#include <tm.h>
+#include <ggc.h>
+#include <gimple.h>
+
+#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;
+}
index 40bf26ef8b484b405a36aded090002d661acd78d..f48d9ded14f4fcb00b530ff5b2f8865e5251c4fd 100644 (file)
@@ -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);