Added aop_pointcut and aop_type types. Added a match function and the
authorJustin Seyster <jseyster@cs.sunysb.edu>
Sat, 6 Feb 2010 02:49:17 +0000 (21:49 -0500)
committerJustin Seyster <jseyster@cs.sunysb.edu>
Sat, 6 Feb 2010 02:49:17 +0000 (21:49 -0500)
join_on () function.

src/Makefile.am
src/aop-main.c
src/aop-pc-assign.c [new file with mode: 0644]
src/aop-pointcut.h [new file with mode: 0644]
src/aop-type.c [new file with mode: 0644]
src/aop-type.h [new file with mode: 0644]
src/aop.h

index 57fb87493b8964494dcb9d2d7d18d71dca73e9d0..cb075f2f2a76489f015c71409a8ed41fb2a2b2dc 100644 (file)
@@ -1,5 +1,5 @@
 lib_LTLIBRARIES = libinteraspect.la
-libinteraspect_la_SOURCES = aop-main.c
+libinteraspect_la_SOURCES = aop-pc-assign.c aop-main.c aop-type.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 c7d3bd73a1c500bd9d68005aa2b75852dc2bb1d6..eb79f191de0250433823a9ae3ac20664adb29ef2 100644 (file)
 #include <c-common.h>
 
 #include "aop.h"
+#include "aop-pointcut.h"
 
 static const char *aop_plugin_name;
 
+void
+aop_join_on (struct aop_pointcut *pc, join_callback callback)
+{
+  aop_assert (pc != NULL && pc->join_on != NULL);
+
+  pc->join_on (pc, callback);
+}
+
 /* Store a list of all struct opt_pass objects we create so that we
    can free them at cleanup time. */
 typedef struct opt_pass *aop_pass;
@@ -150,3 +159,10 @@ plugin_init (struct plugin_name_args *plugin_info,
 
   return 0;
 }
+
+void
+aop_abort (const char *filename, int lineno, const char *function)
+{
+  fprintf (stderr, "Assertion failure within InterAspect plug-in:\n");
+  fancy_abort(filename, lineno, function);
+}
diff --git a/src/aop-pc-assign.c b/src/aop-pc-assign.c
new file mode 100644 (file)
index 0000000..048599c
--- /dev/null
@@ -0,0 +1,47 @@
+/* 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 <config.h>
+#include <system.h>
+#include <ggc.h>
+
+#include "aop.h"
+#include "aop-pointcut.h"
+
+static void
+op_join_on_assign (struct aop_pointcut *pc, join_callback cb)
+{
+  aop_assert(pc->kind == ATP_ASSIGN);
+}
+
+struct aop_pointcut *
+aop_match_assignment_by_type (struct aop_type *type)
+{
+  struct aop_pointcut *pc;
+
+  pc = ggc_alloc (sizeof (struct aop_pointcut *));
+  pc->kind = ATP_ASSIGN;
+  pc->join_on = op_join_on_assign;
+
+  return pc;
+}
diff --git a/src/aop-pointcut.h b/src/aop-pointcut.h
new file mode 100644 (file)
index 0000000..82beda8
--- /dev/null
@@ -0,0 +1,41 @@
+#ifndef __AOP_POINTCUT_H__
+#define __AOP_POINTCUT_H__
+
+/* 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/>.
+*/
+
+/* This is a private header.  Do not include it in source file for
+   client plug-ins. */
+
+struct aop_type;
+
+enum aop_pckind {
+  ATP_ASSIGN,
+};
+
+struct aop_pc_assign {
+  struct aop_type *type;
+};
+
+struct aop_pointcut {
+  enum aop_pckind kind;
+
+  void (*join_on) (struct aop_pointcut *, join_callback);
+
+  union {
+    struct aop_pc_assign pc_assign;
+  };
+};
+
+#endif
diff --git a/src/aop-type.c b/src/aop-type.c
new file mode 100644 (file)
index 0000000..a7e6587
--- /dev/null
@@ -0,0 +1,65 @@
+/* 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/>.
+*/
+
+#include <stddef.h>
+
+#include "aop-type.h"
+
+static struct aop_type _aop_t_all_signed = {
+  .kind = ATK_ALL_SIGNED,
+  .pointer_levels = 0,
+  .tag = NULL,
+};
+
+static struct aop_type _aop_t_all_unsigned = {
+  .kind = ATK_ALL_UNSIGNED,
+  .pointer_levels = 0,
+  .tag = NULL,
+};
+
+static struct aop_type _aop_t_all_fp = {
+  .kind = ATK_ALL_FP,
+  .pointer_levels = 0,
+  .tag = NULL,
+};
+
+static struct aop_type _aop_t_all_pointer = {
+  .kind = ATK_ALL_POINTER,
+  .pointer_levels = 0,
+  .tag = NULL,
+};
+
+const struct aop_type *
+aop_t_all_signed ()
+{
+  return &_aop_t_all_signed;
+}
+
+const struct aop_type *
+aop_t_all_unsigned ()
+{
+  return &_aop_t_all_unsigned;
+}
+
+const struct aop_type *
+aop_t_all_fp ()
+{
+  return &_aop_t_all_fp;
+}
+
+const struct aop_type *
+aop_t_all_pointer ()
+{
+  return &_aop_t_all_pointer;
+}
diff --git a/src/aop-type.h b/src/aop-type.h
new file mode 100644 (file)
index 0000000..d4c6c86
--- /dev/null
@@ -0,0 +1,38 @@
+#ifndef __AOP_TYPE_H__
+#define __AOP_TYPE_H__
+
+/* 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/>.
+*/
+
+/* This is a private header.  Do not include it in source file for
+   client plug-ins. */
+
+enum aop_tykind {
+  ATK_ALL_SIGNED,
+  ATK_ALL_UNSIGNED,
+  ATK_ALL_FP,
+  ATK_ALL_POINTER,
+
+  ATK_STRUCT,
+  ATK_UNION,
+};
+
+struct aop_type {
+  enum aop_tykind kind;
+
+  int pointer_levels;
+  const char *tag;
+};
+
+#endif
index bc7857b77d9ae69c2fd5257efdfec8b914d8cbf9..134c4f805676fa1e593ae17e0e81c4fd2627f89d 100644 (file)
--- a/src/aop.h
+++ b/src/aop.h
@@ -1,5 +1,5 @@
-#ifndef __AOP_H_
-#define __AOP_H_
+#ifndef __AOP_H__
+#define __AOP_H__
 
 /* This program is free software: you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
    just declare it as a void function! */
 #define AOP_MAIN_PROTO __attribute__((visibility("hidden"))) void
 
-typedef unsigned int (*pass_callback)();
+/* This assertion routine is mostly copied from gcc/system.h */
+#ifndef AOP_NO_ASSERT_CHECK
+#define aop_assert(EXPR)                                               \
+  ((void)(!(EXPR) ? aop_abort (__FILE__, __LINE__, __FUNCTION__), 0 : 0))
+#else /* AOP_NO_ASSERT_CHECK */
+/* Include EXPR, so that unused variable warnings do not occur.  */
+#define aop_assert(EXPR) ((void)(0 && (EXPR)))
+#endif
+
+struct aop_pointcut;
+struct aop_type;
+
+typedef unsigned int (*pass_callback) ();
+typedef void (*join_callback) ();
+
+extern struct aop_pointcut *aop_match_assignment_by_type (struct aop_type *type);
+
+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 ();
 
-void aop_register_pass(const char *pass_name, pass_callback callback);
-void aop_main();
+extern void aop_abort (const char *filename, int lineno, const char *function)
+  __attribute__((noreturn));
 
 #endif