join_on () function.
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)
#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;
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);
+}
--- /dev/null
+/* 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;
+}
--- /dev/null
+#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
--- /dev/null
+/* 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;
+}
--- /dev/null
+#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
-#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