[aspectc-user] ‘srcthis’ was not declared in this scope
Daniel Lohmann
daniel.lohmann at informatik.uni-erlangen.de
Fri Mar 2 11:30:33 CET 2007
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.
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
More information about the aspectc-user
mailing list