aspect CodeGenCJP { //TODO still must add appropriate args(..) pointcuts for forwarding arguments //do not jimplify joinpointtype declarations public void JoinpointTypeDecl.jimplify2() { //do not jimplify } //do not emit inner-class attributes for JoinpointTypeDecls syn lazy boolean TypeDecl.isJoinpointTypeDecl() = false; eq JoinpointTypeDecl.isJoinpointTypeDecl() = true; refine EmitJimple eq TypeDecl.innerClassesAttributeEntries() { Collection res = EmitJimple.TypeDecl.innerClassesAttributeEntries(); for(Iterator iter = res.iterator();iter.hasNext();) { TypeDecl t = (TypeDecl)iter.next(); if(t.isJoinpointTypeDecl()) iter.remove(); } return res; } //flag extracted methods with a tag refine EmitJimple public void MethodDecl.jimplify1phase2() { EmitJimple.MethodDecl.jimplify1phase2(); if(wasExtractedFromCJP()) { SootMethod m = sootMethod(); m.addTag(new abc.ja.cjp.weaving.ExtractedTag(cjpTypeName())); } } syn lazy Pointcut CJPPointcutExpr.pointcut() { Pointcut cjpCall = new abc.ja.cjp.weaving.CJPCall(joinpointTypeDeclReferencedByAdvice().fullName(),pos()); java.util.List args = new LinkedList(); for(ParameterDeclaration p: paramDecls()) { if(!p.getID().equals("thisJoinPoint") && !p.getID().equals("thisJoinPointStaticPart")) args.add(new ArgVar(new Var(p.getID(), pos()), pos())); } if(args.isEmpty()) return cjpCall; else return AndPointcut.construct(cjpCall, new Args(args,pos()), pos()); } inh JoinpointTypeDecl CJPPointcutExpr.joinpointTypeDeclReferencedByAdvice(); eq CJPAdviceDecl.getPointcutExpr().joinpointTypeDeclReferencedByAdvice() = cjpTypeDecl(); eq Program.getChild().joinpointTypeDeclReferencedByAdvice() { throw new InternalError("attribute not supported here"); } inh List CJPPointcutExpr.paramDecls(); eq CJPAdviceDecl.getPointcutExpr().paramDecls() = getAdviceSpec().getParameters(); eq Program.getChild().paramDecls() { throw new InternalError("attribute not supported here"); } syn lazy int CJPPointcutExpr.binds(String var) { int i = 0; for(ParameterDeclaration p: paramDecls()) { if(var.equals(p.getID())) i++; } return i; } }