1 46 package org.codehaus.groovy.ast.expr; 47 48 import org.codehaus.groovy.ast.GroovyCodeVisitor; 49 import org.codehaus.groovy.classgen.AsmClassGenerator2; 50 import org.codehaus.groovy.syntax.Token; 51 52 58 public class PrefixExpression extends Expression { 59 60 private Token operation; 61 private Expression expression; 62 63 public PrefixExpression(Token operation, Expression expression) { 64 this.operation = operation; 65 this.expression = expression; 66 } 67 68 public String toString() { 69 return super.toString() + "[" + operation + expression + "]"; 70 } 71 72 public void visit(GroovyCodeVisitor visitor) { 73 visitor.visitPrefixExpression(this); 74 } 75 76 public Expression transformExpression(ExpressionTransformer transformer) { 77 return new PrefixExpression(operation, transformer.transform(expression)); 78 } 79 80 protected void resolveType(AsmClassGenerator2 resolver) { 81 expression.resolve(resolver); 82 setTypeClass(expression.getTypeClass()); 83 } 84 85 public void setExpression(Expression expression) { 86 this.expression = expression; 87 } 88 89 public Token getOperation() { 90 return operation; 91 } 92 93 public Expression getExpression() { 94 return expression; 95 } 96 97 public String getText() { 98 return "(" + operation.getText() + expression.getText() + ")"; 99 } 100 public Class getTypeClass() { 101 return expression.getTypeClass(); 102 } 103 104 public String getType() { 105 return expression.getType(); 106 } 107 108 } 109 | Popular Tags |