1 24 25 package org.aspectj.compiler.base.ast; 26 27 import org.aspectj.compiler.base.*; 28 import org.aspectj.compiler.base.JavaCompiler; 29 import org.aspectj.compiler.base.CodeWriter; 30 import java.io.IOException ; 31 32 import org.aspectj.compiler.base.bcg.CodeBuilder; 33 import org.aspectj.compiler.base.bcg.Label; 34 35 39 public class BreakStmt extends Stmt { 40 41 public void unparse(CodeWriter writer) throws IOException { 42 writer.writeKeyword("break"); 43 if (label != null) { 44 writer.requiredSpace(); 45 writer.write(label); 46 } 47 writer.closeStmt(); 48 } 49 50 53 public void walkFlow(FlowCheckerPass w) { 54 try { 55 w.doBreak(getLabel()); 56 } catch (java.util.NoSuchElementException e) { 57 if (getLabel() == null) 58 showError("break outside of switch or loop"); 59 else 60 showError("undefined label: " + getLabel()); 61 } 62 w.setLive(false); 63 w.setVars(w.getAllVars()); 64 } 65 66 69 public void walkCleanup(ByteCodeCleanupPass w) { 70 w.doBreak(getLabel()); 71 w.setLive(false); 72 } 73 74 77 protected void cgStmt(CodeBuilder cb) { 78 cb.doBreak(label); 79 } 80 protected void registerLocation(CodeBuilder cb) { } 82 83 protected String label; 85 public String getLabel() { return label; } 86 public void setLabel(String _label) { label = _label; } 87 88 public BreakStmt(SourceLocation location, String _label) { 89 super(location); 90 setLabel(_label); 91 } 92 protected BreakStmt(SourceLocation source) { 93 super(source); 94 } 95 96 public ASTObject copyWalk(CopyWalker walker) { 97 BreakStmt ret = new BreakStmt(getSourceLocation()); 98 ret.preCopy(walker, this); 99 ret.label = label; 100 return ret; 101 } 102 103 104 public String getDefaultDisplayName() { 105 return "BreakStmt(label: "+label+")"; 106 } 107 108 } 110 111 112 | Popular Tags |