1 16 package com.google.gwt.dev.jjs.ast; 17 18 import com.google.gwt.dev.jjs.SourceInfo; 19 20 23 public class JFieldRef extends JVariableRef implements HasEnclosingType { 24 25 28 private final JReferenceType enclosingType; 29 30 33 private JField field; 34 35 38 private JExpression instance; 39 40 public JFieldRef(JProgram program, SourceInfo info, JExpression instance, 41 JField field, JReferenceType enclosingType) { 42 super(program, info, field); 43 assert (instance != null || field.isStatic()); 44 this.instance = instance; 45 this.field = field; 46 this.enclosingType = enclosingType; 47 } 48 49 public JReferenceType getEnclosingType() { 50 return enclosingType; 51 } 52 53 public JField getField() { 54 return field; 55 } 56 57 public JExpression getInstance() { 58 return instance; 59 } 60 61 public boolean hasSideEffects() { 62 if (field.isStatic() 64 && (!field.isFinal() || field.constInitializer == null)) { 65 if (program.typeOracle.checkClinit(enclosingType, 66 field.getEnclosingType())) { 67 return true; 69 } 70 } 71 72 JExpression expr = instance; 73 if (expr == null) { 74 return false; 75 } 76 return expr.hasSideEffects(); 77 } 78 79 public void traverse(JVisitor visitor, Context ctx) { 80 if (visitor.visit(this, ctx)) { 81 if (instance != null) { 82 instance = visitor.accept(instance); 83 } 84 } 85 visitor.endVisit(this, ctx); 86 } 87 88 } 89 | Popular Tags |