[aspectc-user] Matching an expression statement

Olaf Spinczyk os at aspectc.org
Fri Dec 30 11:54:22 CET 2011


Hi Ferosh!

A pointcut function that matches a statement in a particular line of a 
file does not exist in AspectC++. The reason is that this would 
automatically lead to "fragile" pointcut definitions. For example, you 
could easily break your aspect code by inserting a comment!

We are currently working on a prototypical implementation of statement 
annotations, such as this:
---
@atomic {
   a++;
}
---

Here "atomic" is just an example. Arbitrary annotations will be 
supported. The advice could affect all compound statements that are 
tagged with "atomic" like this: advice @atomic() : around() { ... }

This language feature might be available in a few months, but we will 
not add a function for matching particular lines. If you really want to 
do this, the ordinary "patch" command might be better suited.

Best regards,

Olaf


Am 28.12.2011 19:55, schrieb Ferosh Jacob:
>
>
> Consider the two files given below.
>
>  file1: main.cc
>   1 #include<stdio.h>
>    2 void hello();
>    3 void hello(){
>    4  printf("Replace me\n");
>    5 }
>    6 int main(){
>    7  int i=0;
>    8   i++;
>    9   hello();
>   10   return 0;
>   11 }
>
> file2: aspect file
>    1 aspect Test {
>    2   advice execution("void hello()") : around() {
>    3     printf(" New text\n");
>    4   }
>    5 };
>
>
> Here the function call is  replaced by another function call, Can you
> help with an aspect which can replace an expression statement like  
> "i++;"
> with function call. Say, for the same input file, file1, replace line 8
> with printf("New text\n");
>
> I couldn't find a setter, getter pointcut function to do this. Is there
> any other way?
>
> Thanks
> Ferosh
>
> _______________________________________________
> aspectc-user mailing list
> aspectc-user at aspectc.org
> http://www.aspectc.org/mailman/listinfo/aspectc-user
>




More information about the aspectc-user mailing list