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 ExprStmt extends Stmt { 40 41 public void unparse(CodeWriter writer) throws IOException { 42 writer.write(expr); 43 writer.closeStmt(); 44 } 45 46 public void checkSpec() { 47 if (!expr.isLegalStmt()) { 48 showError("not a statement"); 49 } 50 } 51 52 55 public void walkFlow(FlowCheckerPass w) { 56 w.process(getExpr()); 57 } 58 59 62 protected void cgStmt(CodeBuilder cb) { 63 expr.cgEffect(cb); 64 } 65 66 protected Expr expr; 68 public Expr getExpr() { return expr; } 69 public void setExpr(Expr _expr) { 70 if (_expr != null) _expr.setParent(this); 71 expr = _expr; 72 } 73 74 public ExprStmt(SourceLocation location, Expr _expr) { 75 super(location); 76 setExpr(_expr); 77 } 78 protected ExprStmt(SourceLocation source) { 79 super(source); 80 } 81 82 public ASTObject copyWalk(CopyWalker walker) { 83 ExprStmt ret = new ExprStmt(getSourceLocation()); 84 ret.preCopy(walker, this); 85 if (expr != null) ret.setExpr( (Expr)walker.process(expr) ); 86 return ret; 87 } 88 89 public ASTObject getChildAt(int childIndex) { 90 switch(childIndex) { 91 case 0: return expr; 92 default: return super.getChildAt(childIndex); 93 } 94 } 95 public String getChildNameAt(int childIndex) { 96 switch(childIndex) { 97 case 0: return "expr"; 98 default: return super.getChildNameAt(childIndex); 99 } 100 } 101 public void setChildAt(int childIndex, ASTObject child) { 102 switch(childIndex) { 103 case 0: setExpr((Expr)child); return; 104 default: super.setChildAt(childIndex, child); return; 105 } 106 } 107 public int getChildCount() { 108 return 1; 109 } 110 111 public String getDefaultDisplayName() { 112 return "ExprStmt()"; 113 } 114 115 } 117 118 119 | Popular Tags |