Re: [abc-dev] Extension

From: Pavel Avgustinov <pavel.avgustinov@magdalen.oxford.ac.uk>
Date: Thu Mar 23 2006 - 10:07:09 GMT

Hi,

> My first question is where should I generate the code that creates the
> List field inside the aspect? (Every associable aspect needs a static
> List that keeps track of associated instances.) Should it go in a
> ContextVisitor that visits all nodes until it finds an aspect that has
> been marked as associable and then generate the code in enter()?

Essentially, you're trying to introduce new static members onto the
aspect class. A very similar case arises in pure AspectJ -- think of the
static aspectOf() method that is added onto aspect classes.

Since your Aspect.associate() and Aspect.disassociate() methods need to
be visible to the base code, you need to introduce them (or at least
stub methods that you fill in later) before method calls are resolved.
The natural place for this is the AspectDecl_c class. Take a look at how
it handles the aspectOf() method -- you'll need to do something very
similar. Override AspectDecl_c in your extension, and override the
factory that instantiates it so that it creates your updated class.

The bodies of those methods can be generated whenever convenient; it
might make sense to stick to the aspectOf() pattern. The body of that
method is filled in in src/abc/weaving/weaver/AspectCodeGen.java, and
happens on Jimple using Soot.

> My second question is about the association Residue: I started writing
> an IsAssociated residue that can be used for both 'this' and 'target'
> association but I'm not sure how to refer back to the aspect from the
> codeGen method. I would need to generate code that checks whether the
> instance is in the List of that aspect before proceeding with the adivce.

How you actually implement the isAssociated stuff is of course your
choice, but note that if you introduce a method on the aspect class
called "isAssociated(Object)", you can reduce the checks to if()
pointcuts. Thus, you can rewrite your custom pointcuts to if() in the
frontend.

Note that if you want to do this globally, there is a mechanism for
adding a new conjunct to every single pointcut. Thus, you could make all
pointcuts respect aspect association. Take a look at
src/abc/om/AbcExtension.java and its use of residueConjuncts.

We gave a tutorial on extending abc at AOSD yesterday. The slides should
appear on http://aspectbench.org sometime soon, in the meantime you can
access a copy at http://musketeer.comlab.ox.ac.uk/~pavel/slides.pdf --
there are some further explanations about residueConjuncts there, if
nothing else.

Apologies for the delay in this reply. Most of us are currently visiting
the AOSD conference, so our access to email is somewhat sporadic. Hope
this helps, feel free to ask for more information if you need it.

Best wishes,
Pavel
Received on Thu Mar 23 10:07:49 2006

This archive was generated by hypermail 2.1.8 : Fri Mar 24 2006 - 00:30:05 GMT