}
bool
-check_in_param (struct aop_param_desc *param_desc)
+check_in_param (int param_index, const struct aop_type *type)
{
- tree param_type;
- tree param_decl;
- int index = 0;
- bool index_found = false;
- for (param_decl = DECL_ARGUMENTS (current_function_decl);
- param_decl; param_decl = TREE_CHAIN (param_decl))
- {
- if (index == param_desc->param_index)
- {
- /* Index found check the type */
- if ((param_type = TREE_TYPE (param_decl)) == NULL
- || !does_type_match (param_type, param_desc->type))
- index_found = false;
- else
- index_found = true;
-
- break;
- }
- index++;
- }
- return index_found;
+ tree param_decl;
+ tree param_type;
+ int index = 0;
+ bool index_found = false;
+ for (param_decl = DECL_ARGUMENTS (current_function_decl);
+ param_decl; param_decl = TREE_CHAIN (param_decl))
+ {
+ if (index == param_index)
+ {
+ /* Index found check the type */
+ if ((param_type = TREE_TYPE (param_decl)) == NULL
+ || !does_type_match (param_type, type))
+ index_found = false;
+ else
+ index_found = true;
+
+ break;
+ }
+ index++;
+ }
+ return index_found;
}
bool
for (param_desc = pc->in_param_list_head ; param_desc != NULL ;
param_desc = param_desc->next)
{
- if(!check_in_param (param_desc))
+ if(!check_in_param (param_desc->param_index, param_desc->type))
return false;
}
param->type = type;
}
+/**
+ * Get a dynval representing the nth parameter passed to the current
+ * function if there is a parameter n and it matches the specified
+ * type. This function makes it possible to capture a parameter even
+ * if you have not filtered on its type with
+ * aop_filter_call_pc_by_param(). However, it returns NULL if there
+ * is no parameter n or if parameter n does not match the specified
+ * type.
+ * \param jp A function call join point. Function call join points
+ * are obtained by joining on an aop_match_function_call() pointcut.
+ * \param n The index of the parameter to capture. Parameters are
+ * indexed from zero.
+ * \param type This function verifies that the captured parameter
+ * matches the specified type.
+ * \return dynval with its type determined by the specified type or
+ * NULL if there is no matching parameter n.
+ */
+struct aop_dynval *
+aop_capture_in_param_by_type (struct aop_joinpoint *jp, int n,
+ const struct aop_type *type)
+{
+ struct aop_pointcut *pc;
+ struct aop_dynval *dv;
+
+ pc = jp->pc;
+
+ /* Check that there is a nth parameter and that it matches the
+ type. */
+
+ if (!check_in_param (n, type))
+ return NULL;
+
+ dv = ggc_alloc (sizeof (struct aop_dynval));
+ dv->kind = ADV_FUN_PARAM;
+ dv->type = type;
+ dv->jp = jp;
+ dv->get_dynval = op_get_in_param;
+ dv->dynval_call.param_index = n;
+ return dv;
+}