1 24 25 package org.aspectj.compiler.base; 26 27 import org.aspectj.compiler.base.ast.*; 28 import org.aspectj.compiler.base.*; 29 30 import java.util.*; 31 32 37 38 public class ByteCodeCleanupPass extends WalkerPass { 39 public ByteCodeCleanupPass(JavaCompiler compiler) { 40 super(compiler); 41 } 42 43 public String getDisplayName() { 44 return "clean up ast"; 45 } 46 47 public ASTObject process(ASTObject object) { 48 object.walkCleanup(this); 49 ASTObject ret = object.postCleanup(this); 50 if (ret instanceof Stmt) { 51 ((Stmt)ret).setCompletesNormally(isLive()); 52 } 53 return ret; 54 } 55 56 private boolean liveFlag = true; 57 public void setLive(boolean b) { liveFlag = b; } 58 public boolean isLive() { return liveFlag; } 59 60 private ControlContext context = new ControlContext(); 62 63 public void enterContext(Stmt s) { context.enter(s); } 64 public void leaveContext() { context.exit(); } 65 66 public void doBreak(String label) { 67 breaks.add(context.getBreakTarget(label)); 68 } 69 70 public void doContinue(String label) { 71 continues.add(context.getContinueTarget(label)); 72 } 73 74 private Set breaks = new HashSet(); 75 private Set continues = new HashSet(); 76 77 public boolean isBroken(Stmt s) { return breaks.contains(s); } 78 public boolean isContinued(Stmt s) { return continues.contains(s); } 79 } 80 | Popular Tags |