[aspectc-user] ‘srcthis’ was not declared in this scope

Panu Bloigu panu.bloigu at mbnet.fi
Fri Mar 2 12:05:39 CET 2007


Hi,

and many thanks for the answer! I've been pondering over this so much my 
head hurts.

Daniel Lohmann wrote:
> Hello Panu,
>
> this problem clearly indicates a bug in the ac++ implementation. As far
> as we can tell at the moment it is related to the use of 'that' in the
> following pointcut expression:
>
> pointcut on_test() = execution("% ...::_test_()") && that(target_class());
>
> If you replace 'that' by 'within', everything works fine. Of course,
> 'that' and 'within' don't have the same semantics, but in your test
> program the result should be identical.
>   

Hmm. I could swear I tried that already... I guess, I didn't then. 
Anyway, at least atm it seems, this could get me where I'm going. 
Although (as I've understood) that() discriminates the joinpoint shadows 
based on the dynamic context of the joinpoint, whereas within() does it 
based on the compile time context, this still could do what I'm looking 
for. If you have the time, could you please elaborate a little on what 
might be the most significant implications of replacing that() with 
within() in this case? For the background, here's the outline of what 
I'm doing:

- There's one more layer of inheritance between Base and aspects that 
actually define target_class() and advice on_test(). (This might not be 
relevant.)
- The method _test_() is actually introduced through a base class 
introduction, rather than directly introducing the method.

Now that I come to think of this, I can't see any reason why I would 
need to use that() instead of within(). However, I think I haven't yet 
really, really understood all the differences between the semantics of 
that() and within() -- at least not in this case. But this indeed seems 
solve my problem.

Thanks,

Panu.

> Best regards,
>
> Daniel
>
> Panu Bloigu wrote:
>   
>> Hello.
>>
>> I have the following problem. In an abstract base aspect I have virtual
>> pointcuts, which I then define in two separate inherited aspects. The
>> virtual pointcut is part of another pointcut in the abstract aspect and
>> that pointcut is used to instrument code in the inherited aspects. This
>> seems to be something that ac++ does not feel comfortable with. Or I
>> have made a mistake somewhere. To get the picture, please consider the
>> following file.
>> ======================================================================
>> #include <iostream>
>> // Base aspect
>> aspect Base
>> {
>>        pointcut virtual target_methods() = 0;
>>        pointcut virtual target_class() = 0;
>>
>>        pointcut on_test() = execution("% ...::_test_()") &&
>> that(target_class());
>>
>>        advice target_class() : slice class
>>        {
>>        private:
>>                void _test_(){}
>>        };
>>
>>
>>        advice execution(target_methods()) : around()
>>        {
>>                tjp->that()->_test_();
>>                tjp->proceed();
>>        }
>> };
>>
>> // Descendant A
>> aspect InherA : public Base
>> {
>>        pointcut target_methods() = "void A::a()";
>>        pointcut target_class() = "A";
>>
>>        advice on_test() : around()
>>        {
>>                std::cout<<"This is before void A::_test_()\n";
>>                tjp->proceed();
>>        }
>> };
>>
>> // Descendant B
>> aspect InherB : public Base
>> {
>>        pointcut target_methods() = "void B::b()";
>>        pointcut target_class() = "B";
>>
>>        advice on_test() : around()
>>        {
>>                std::cout<<"This is before void B::_test_()\n";
>>                tjp->proceed();
>>        }
>> };
>>
>> // The classes to be instrumented
>> class A
>> {
>> public:
>>        A(){}
>>        virtual ~A(){}
>>        void a(){}
>> };
>>
>> class B
>> {
>> public:
>>        B(){}
>>        virtual ~B(){}
>>        void b(){}
>> };
>>
>> // entry point
>> int main()
>> {
>>        A a;
>>        B b;
>>        a.a();
>>        b.b();
>>        return 0;
>> }
>> ======================================================================
>>
>> Now the compiler gives me the following error:
>> ======================================================================
>> [bloigu at athlonxp inher]$ ag++ -k --keep_acc inher.cpp -o inher
>> inher.acc: In member function ‘void A::TJP__ZN1A6_test_Ev_1::proceed()’:
>> inher.acc:409: error: ‘srcthis’ was not declared in this scope
>> error: Execution failed: "g++" -xc++ "inher.acc" -xnone -I"." -o "inher"
>> ======================================================================
>>
>> What is that 'srcthis' and how come it's not defined? I took a peek in
>> the generated .acc file and what struck me odd was that the structure
>> A::TJP__ZN1A6_test_Ev_1 referenced 'srcthis' while the corresponding
>> structure for the class B didn't reference 'srcthis' at all.I would also
>> like to know if this is a bug, missing feature or illegal AspectC++
>> code. Also, if someone would suggest a method to accomplish this
>> functionality, it would be greatly appreciated.
>>
>> Thanks in advance,
>>
>> Panu.
>>
>>
>>
>> _______________________________________________
>> aspectc-user mailing list
>> aspectc-user at aspectc.org
>> http://www.aspectc.org/mailman/listinfo/aspectc-user
>>     
>
>
>
> _______________________________________________
> 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