// @Override
public void endVisit(JFieldRef x, Context ctx) {
JField field = x.getField();
JsName jsFieldName = getName(field);
JsNameRef nameRef = jsFieldName.makeRef();
JsExpression curExpr = nameRef;
/*
* Note: the comma expressions here would cause an illegal tree state if
* the result expression ended up on the lhs of an assignment. A hack in
* in endVisit(JBinaryOperation) rectifies the situation.
*/
// See if we need a clinit
JsInvocation jsInvocation = maybeCreateClinitCall(field);
if (jsInvocation != null) {
curExpr = createCommaExpression(jsInvocation, curExpr);
}
if (x.getInstance() != null) {
JsExpression qualifier = (JsExpression) pop();
if (field.isStatic()) {
// unnecessary qualifier, create a comma expression
curExpr = createCommaExpression(qualifier, curExpr);
} else {
// necessary qualifier, qualify the name ref