From: Justin Seyster Date: Tue, 24 Aug 2010 20:03:22 +0000 (-0400) Subject: Correctly handle "all integer" types. X-Git-Tag: release-v1.0~65 X-Git-Url: https://git.fsl.cs.stonybrook.edu/?a=commitdiff_plain;h=9dbf0d3d9a09b9cec7f44af5425d3fbb2de80502;p=interaspect.git Correctly handle "all integer" types. Every integer value matched with aop_t_all_signed() or aop_t_all_unsigned() now gets cast to long long integer or long long unsigned (respectively). --- diff --git a/src/aop-weave.c b/src/aop-weave.c index 995251e..6235a41 100644 --- a/src/aop-weave.c +++ b/src/aop-weave.c @@ -42,6 +42,7 @@ #include "aop-duplicate.h" #include "aop-dynval.h" #include "aop-pointcut.h" +#include "aop-type.h" /* Throw a fatal error if a dynval is not allowed in a before-advice call. */ @@ -88,10 +89,48 @@ build_string_ptr (const char *string) return ret; } +/* Whenver InterAspect matches an "all signed" or "all unsigned" + value, it needs to cast it up to a long long before passing it. */ +static tree +cast_to_all_integer (tree val) +{ + tree gcc_type; + HOST_WIDE_INT size; + + gcc_type = TREE_TYPE (val); + aop_assert (TREE_CODE (gcc_type) == INTEGER_TYPE); + + size = int_size_in_bytes (gcc_type); + aop_assert (size > 0 && size <= 8); + + if (size < 8) + { + tree cast_type = TYPE_UNSIGNED (gcc_type) ? long_long_unsigned_type_node + : long_long_integer_type_node; + + val = build1 (CONVERT_EXPR, cast_type, val); + return val; + } + else + { + /* No cast necessary. */ + return val; + } +} + static tree build_dynval (struct aop_dynval *dv) { - return dv->get_dynval (dv); + const struct aop_type *type; + tree val; + + val = dv->get_dynval (dv); + type = dv->type; + + if (type->kind == ATK_ALL_SIGNED || type->kind == ATK_ALL_UNSIGNED) + val = cast_to_all_integer (val); + + return val; } /* Weaving functions all take varags parameters that represent the