1 24 25 package org.aspectj.compiler.base.ast; 26 27 import org.aspectj.compiler.base.FlowCheckerPass; 28 import org.aspectj.compiler.base.AssignmentCheckerPass; 29 import org.aspectj.compiler.base.JavaCompiler; 30 import org.aspectj.compiler.base.CodeWriter; 31 32 import java.util.*; 33 34 import org.aspectj.compiler.base.bcg.CodeBuilder; 35 import org.aspectj.compiler.base.bcg.Label; 36 37 42 public class ParenExpr extends Expr { 43 44 protected void bindNamesSelf() { 45 } 47 48 protected Type discoverType() { 49 return expr.getType(); 50 } 51 52 public Expr makeReference() { 53 Expr ret = expr.makeReference(); 54 if (!(ret instanceof ParenExpr)) return ret; 55 return super.makeReference(); 56 } 57 58 public boolean canBeCopied() { 59 return expr.canBeCopied(); 60 } 61 62 public boolean isUltimatelyLiteral() { 63 return expr.isUltimatelyLiteral(); 64 } 65 66 public void unparse(CodeWriter writer) { 67 writer.write('('); 68 writer.write(expr); 69 writer.write(')'); 70 } 71 72 75 public ASTObject postAssignmentCheck(AssignmentCheckerPass walker) { 76 if (expr instanceof LiteralExpr) { 77 return (LiteralExpr)expr.copy().setSource(this); 78 } else { 79 return this; 80 } 81 } 82 83 protected void cgValue(CodeBuilder cb) { 86 expr.cgValue(cb); 87 } 88 protected void cgValue(CodeBuilder cb, Type castTo) { 89 expr.cgValue(cb, castTo); 90 } 91 protected void cgEffect(CodeBuilder cb) { 92 expr.cgEffect(cb); 93 } 94 protected void cgBuffer(CodeBuilder cb) { 95 expr.cgBuffer(cb); 96 } 97 protected void cgTest(CodeBuilder cb, Label tdest, Label fdest) { 98 expr.cgTest(cb, tdest, fdest); 99 } 100 101 protected Expr expr; 103 public Expr getExpr() { return expr; } 104 public void setExpr(Expr _expr) { 105 if (_expr != null) _expr.setParent(this); 106 expr = _expr; 107 } 108 109 public ParenExpr(SourceLocation location, Expr _expr) { 110 super(location); 111 setExpr(_expr); 112 } 113 protected ParenExpr(SourceLocation source) { 114 super(source); 115 } 116 117 public ASTObject copyWalk(CopyWalker walker) { 118 ParenExpr ret = new ParenExpr(getSourceLocation()); 119 ret.preCopy(walker, this); 120 if (expr != null) ret.setExpr( (Expr)walker.process(expr) ); 121 return ret; 122 } 123 124 public ASTObject getChildAt(int childIndex) { 125 switch(childIndex) { 126 case 0: return expr; 127 default: return super.getChildAt(childIndex); 128 } 129 } 130 public String getChildNameAt(int childIndex) { 131 switch(childIndex) { 132 case 0: return "expr"; 133 default: return super.getChildNameAt(childIndex); 134 } 135 } 136 public void setChildAt(int childIndex, ASTObject child) { 137 switch(childIndex) { 138 case 0: setExpr((Expr)child); return; 139 default: super.setChildAt(childIndex, child); return; 140 } 141 } 142 public int getChildCount() { 143 return 1; 144 } 145 146 public String getDefaultDisplayName() { 147 return "ParenExpr()"; 148 } 149 150 } 152 | Popular Tags |