1 46 package org.codehaus.groovy.ast.expr; 47 48 import org.codehaus.groovy.ast.FieldNode; 49 import org.codehaus.groovy.ast.GroovyCodeVisitor; 50 import org.codehaus.groovy.classgen.AsmClassGenerator2; 51 52 58 public class FieldExpression extends Expression { 59 60 private FieldNode field; 61 62 public FieldExpression(FieldNode field) { 63 this.field = field; 64 } 65 66 public void visit(GroovyCodeVisitor visitor) { 67 visitor.visitFieldExpression(this); 68 } 69 70 public Expression transformExpression(ExpressionTransformer transformer) { 71 return this; 72 } 73 74 public String getFieldName() { 75 return field.getName(); 76 } 77 78 public String getTypeName() { 79 return field.getType(); 80 } 81 82 public FieldNode getField() { 83 return field; 84 } 85 86 public String getText() { 87 return "this." + field.getName(); 88 } 89 90 public boolean isDynamic() { 91 return field.isDynamicType(); 92 } 93 94 public String getType() { 95 return getTypeName(); 96 } 97 98 public void setTypeClass(Class typeClass) { 99 super.setTypeClass(typeClass); 100 field.setType(typeClass.getName()); 101 } 102 103 public void setType(String type) { 104 super.setType(type); 105 field.setType(type); 106 } 107 108 protected void resolveType(AsmClassGenerator2 resolver) { 109 String fldType = field.getType(); 110 setType(fldType); 111 } 112 } 113 | Popular Tags |