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 31 import org.aspectj.compiler.base.bcg.CodeBuilder; 32 import org.aspectj.compiler.base.bcg.Label; 33 34 38 39 public class ThrowStmt extends Stmt { 40 41 public void unparse(CodeWriter writer) { 42 writer.writeKeyword("throw"); 43 writer.requiredSpace(); 44 writer.write(expr); 45 writer.closeStmt(); 46 } 47 48 public void checkSpec() { 49 getExpr().assertType(getTypeManager().getThrowableType()); 50 } 51 52 55 public void walkFlow(FlowCheckerPass w) { 56 w.process(getExpr()); 57 w.doReturn(); 58 w.setLive(false); 59 w.setExns(w.getExns().add((NameType) expr.getType())); 60 w.setVars(w.getAllVars()); 61 } 62 63 66 public void walkCleanup(ByteCodeCleanupPass w) { 67 w.setLive(false); 68 } 69 70 73 protected void cgStmt(CodeBuilder cb) { 74 expr.cgValue(cb); 75 cb.emitATHROW(); 76 } 77 78 protected Expr expr; 80 public Expr getExpr() { return expr; } 81 public void setExpr(Expr _expr) { 82 if (_expr != null) _expr.setParent(this); 83 expr = _expr; 84 } 85 86 public ThrowStmt(SourceLocation location, Expr _expr) { 87 super(location); 88 setExpr(_expr); 89 } 90 protected ThrowStmt(SourceLocation source) { 91 super(source); 92 } 93 94 public ASTObject copyWalk(CopyWalker walker) { 95 ThrowStmt ret = new ThrowStmt(getSourceLocation()); 96 ret.preCopy(walker, this); 97 if (expr != null) ret.setExpr( (Expr)walker.process(expr) ); 98 return ret; 99 } 100 101 public ASTObject getChildAt(int childIndex) { 102 switch(childIndex) { 103 case 0: return expr; 104 default: return super.getChildAt(childIndex); 105 } 106 } 107 public String getChildNameAt(int childIndex) { 108 switch(childIndex) { 109 case 0: return "expr"; 110 default: return super.getChildNameAt(childIndex); 111 } 112 } 113 public void setChildAt(int childIndex, ASTObject child) { 114 switch(childIndex) { 115 case 0: setExpr((Expr)child); return; 116 default: super.setChildAt(childIndex, child); return; 117 } 118 } 119 public int getChildCount() { 120 return 1; 121 } 122 123 public String getDefaultDisplayName() { 124 return "ThrowStmt()"; 125 } 126 127 } 129 130 131 | Popular Tags |