abc.main
Class AbcExtension

java.lang.Object
  extended by abc.main.AbcExtension
Direct Known Subclasses:
AbcExtension

public class AbcExtension
extends java.lang.Object

This class should be sub-classed to extend the behaviour of abc

A sub-class, with overriden methods to effect some new behaviour, can be loaded at runtime by using the "-ext" switch to abc.

Author:
Julian Tibble, Eric Bodden

Constructor Summary
AbcExtension()
           
 
Method Summary
 void addBasicClassesToSoot()
          Call Scene.v().addBasicClass for each runtime class that the backend might generate code for.
 void addJimplePacks()
          This method adds optimisation passes specificially required for abc.
protected  void collectVersions(java.lang.StringBuffer versions)
          Override this method to add the version information for this extension, calling the same method in the super-class to ensure that all extensions are reported.
protected  CompileSequence createCompileSequence()
          Creates the unique compile sequence for this extension.
protected  GlobalAspectInfo createGlobalAspectInfo()
          Override this to create a custom global aspect info.
protected  void createReweavingPasses(java.util.List passes)
          Adds a new reweaving passes to the pass list.
 SJPInfo createSJPInfo(java.lang.String kind, java.lang.String signatureTypeClass, java.lang.String signatureType, java.lang.String signature, Host host)
          Create a (compile-time) static join point information object that generates code to initialize static join point fields with reflective information about a join point.
protected  Weaver createWeaver()
          Override this to create a custom weaver.
 void doMethodRestructuring()
          This method is called right after "declare parents" has been processed and all Jimple bodies have been loaded.
 void findMethodShadows(GlobalAspectInfo info, MethodAdviceList mal, SootClass cls, SootMethod method)
          This method is responsible for taking a method and calling AdviceApplication.doShadows for each "position" in the method that might have a join point associated with it.
 void forceReportError(int level, java.lang.String message, Position position)
          Reports an error, even if error reporting is suspended.
 CompileSequence getCompileSequence()
           
 ErrorQueue getErrorQueue()
           
 GlobalAspectInfo getGlobalAspectInfo()
          Returns the GlobalAspectInfo structure, which stores all the AspectJ-specific information from the frontend for use in the backend.
 int getPrecedence(AbstractAdviceDecl a, AbstractAdviceDecl b)
          Get the precedence relationship between two aspects.
protected  int getPrecNum(AbstractAdviceDecl d)
           
 java.util.List getReweavingPasses()
          Returns the reweaving passes for this extension.
 Weaver getWeaver()
          Returns the Weaver object, which co-ordinates everything that happens in the backend.
 void initLexerKeywords(AbcLexer lexer)
          Initialise the HashMaps that define how keywords are handled in the different lexer states.
protected  java.util.List listShadowTypes()
          Override this method to add new joinpoints to the abc.
 AdviceInliner makeAdviceInliner()
          Make a new AdviceInliner, which is responsible for inlining advice bodies, as well as pointcuts which are implemented by methods, such as if.
 ExtensionInfo makeExtensionInfo(java.util.Collection jar_classes, java.util.Collection aspect_sources)
          Creates an instance of the ExtensionInfo structure used for extending the Polyglot-based frontend.
 void reportError(ErrorInfo ei)
          Reports an error, if error reporting is not suspended.
 void reportError(int level, java.lang.String s, Position pos)
          Reports an error, if error reporting is not suspended.
 java.util.List residueConjuncts(AbstractAdviceDecl ad, Pointcut pc, ShadowMatch sm, SootMethod method, SootClass cls, WeavingEnv we)
          return the list of residue conjuncts.
 void resumeErrorReporting()
          Resumes error reporting after suspendErrorReporting() was called.
 java.lang.String runtimeSJPFactoryClass()
          Specify the class that will be used at runtime to generate StaticJoinPoint objects.
 void setErrorQueue(ErrorQueue eq)
           
 java.util.Iterator shadowTypes()
          Get all the shadow joinpoints that are matched in this extension of AspectJ
 void suspendErrorReporting()
          Suspends error reporting until resumeErrorReporting() is called.
 java.lang.String versions()
          Constructs a version string for all loaded extensions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbcExtension

public AbcExtension()
Method Detail

versions

public final java.lang.String versions()
Constructs a version string for all loaded extensions


collectVersions

protected void collectVersions(java.lang.StringBuffer versions)
Override this method to add the version information for this extension, calling the same method in the super-class to ensure that all extensions are reported.


getCompileSequence

public final CompileSequence getCompileSequence()

createCompileSequence

protected CompileSequence createCompileSequence()
Creates the unique compile sequence for this extension. This method is called exactly once.


reportError

public void reportError(ErrorInfo ei)
Reports an error, if error reporting is not suspended.

See Also:
suspendErrorReporting(), resumeErrorReporting()

reportError

public void reportError(int level,
                        java.lang.String s,
                        Position pos)
Reports an error, if error reporting is not suspended.

See Also:
suspendErrorReporting(), resumeErrorReporting()

forceReportError

public void forceReportError(int level,
                             java.lang.String message,
                             Position position)
Reports an error, even if error reporting is suspended.

See Also:
suspendErrorReporting(), resumeErrorReporting()

makeExtensionInfo

public ExtensionInfo makeExtensionInfo(java.util.Collection jar_classes,
                                       java.util.Collection aspect_sources)
Creates an instance of the ExtensionInfo structure used for extending the Polyglot-based frontend.


getGlobalAspectInfo

public final GlobalAspectInfo getGlobalAspectInfo()
Returns the GlobalAspectInfo structure, which stores all the AspectJ-specific information from the frontend for use in the backend.


createGlobalAspectInfo

protected GlobalAspectInfo createGlobalAspectInfo()
Override this to create a custom global aspect info.


getWeaver

public final Weaver getWeaver()
Returns the Weaver object, which co-ordinates everything that happens in the backend.


createWeaver

protected Weaver createWeaver()
Override this to create a custom weaver.


makeAdviceInliner

public AdviceInliner makeAdviceInliner()
Make a new AdviceInliner, which is responsible for inlining advice bodies, as well as pointcuts which are implemented by methods, such as if. The instance is cached in abc.weaving.weaver.AdviceInliner, so we don't do so here like we do with the Weaver.


shadowTypes

public final java.util.Iterator shadowTypes()
Get all the shadow joinpoints that are matched in this extension of AspectJ


listShadowTypes

protected java.util.List listShadowTypes()
Override this method to add new joinpoints to the abc. Call the same method in the super-class to ensure the standard joinpoints needed are loaded too.


addJimplePacks

public void addJimplePacks()
This method adds optimisation passes specificially required for abc.


addBasicClassesToSoot

public void addBasicClassesToSoot()
Call Scene.v().addBasicClass for each runtime class that the backend might generate code for. Derived implementations should normally make sure to call the superclass implementation.


runtimeSJPFactoryClass

public java.lang.String runtimeSJPFactoryClass()
Specify the class that will be used at runtime to generate StaticJoinPoint objects.


createSJPInfo

public SJPInfo createSJPInfo(java.lang.String kind,
                             java.lang.String signatureTypeClass,
                             java.lang.String signatureType,
                             java.lang.String signature,
                             Host host)
Create a (compile-time) static join point information object that generates code to initialize static join point fields with reflective information about a join point.


initLexerKeywords

public void initLexerKeywords(AbcLexer lexer)
Initialise the HashMaps that define how keywords are handled in the different lexer states. Keywords are added by calling the methods addJavaKeyword(), addAspectJKeyword(), lexer.addPointcutKeyword() and addPointcutIfExprKeyword(), which are defined in the Lexer_c class. There are the utility methods lexer.addGlobalKeyword() (which adds its parameters to all four states) and lexer.addAspectJContextKeyword() (which adds its parameters to the AspectJ and PointcutIfExpr states). Each of these methods takes two arguments - a String (the keyword to be added) and a class implementing abc.aspectj.parse.LexerAction defining what to do when this keyword is encountered.


findMethodShadows

public void findMethodShadows(GlobalAspectInfo info,
                              MethodAdviceList mal,
                              SootClass cls,
                              SootMethod method)
                       throws polyglot.types.SemanticException
This method is responsible for taking a method and calling AdviceApplication.doShadows for each "position" in the method that might have a join point associated with it. The base list of positions consists of WholeMethodPosition, StmtMethodPosition, NewStmtMethodPosition and TrapMethodPosition; if a new join point requires something else then it will be necessary to override this method and add a new kind of method position.

Throws:
polyglot.types.SemanticException

getPrecedence

public int getPrecedence(AbstractAdviceDecl a,
                         AbstractAdviceDecl b)
Get the precedence relationship between two aspects.

Parameters:
a - the first advice decl.
b - the second advice decl.
Returns:
GlobalAspectInfo.PRECEDENCE_NONE if none of the advice decls have precedence, GlobalAspectInfo.PRECEDENCE_FIRST if the first advice decl has precedence, GlobalAspectInfo.PRECEDENCE_SECOND if the second advice decl has precedence, or GlobalAspectInfo.PRECEDENCE_CONFLICT if there is a precedence conflict between the two advice decls.

getPrecNum

protected int getPrecNum(AbstractAdviceDecl d)

residueConjuncts

public java.util.List residueConjuncts(AbstractAdviceDecl ad,
                                       Pointcut pc,
                                       ShadowMatch sm,
                                       SootMethod method,
                                       SootClass cls,
                                       WeavingEnv we)
return the list of residue conjuncts. This should return a list all of whose elements are of type abc.weaving.matching.AdviceApplication.ResidueConjunct.


createReweavingPasses

protected void createReweavingPasses(java.util.List passes)
Adds a new reweaving passes to the pass list.

Parameters:
passes - the current list of reweaving passes; add your analysis passes here as needed; do not forget to call super

getReweavingPasses

public final java.util.List getReweavingPasses()
Returns the reweaving passes for this extension.

Returns:
the reweaving passes

getErrorQueue

public ErrorQueue getErrorQueue()

setErrorQueue

public void setErrorQueue(ErrorQueue eq)

suspendErrorReporting

public void suspendErrorReporting()
Suspends error reporting until resumeErrorReporting() is called.


resumeErrorReporting

public void resumeErrorReporting()
Resumes error reporting after suspendErrorReporting() was called.


doMethodRestructuring

public void doMethodRestructuring()
This method is called right after "declare parents" has been processed and all Jimple bodies have been loaded. Subclasses can implement this method to do restrucuring of bodies prior to weaving. This default implementation does nothing.