if (isOptimizableCompileTimeConstant(binding)) {
return getConstant(info, x.constant);
}
JExpression result = null;
if (binding instanceof LocalVariableBinding) {
LocalVariableBinding b = (LocalVariableBinding) binding;
if ((x.bits & ASTNode.DepthMASK) != 0) {
VariableBinding[] path = scope.getEmulationPath(b);
if (path == null) {
/*
* Don't like this, but in rare cases (e.g. the variable is only
* ever used as an unnecessary qualifier) JDT provides no emulation
* to the desired variable.
*/
// throw new InternalCompilerException("No emulation path.");
return null;
}
assert path.length == 1;
if (curMethod.scope.isInsideInitializer() && path[0] instanceof SyntheticArgumentBinding) {
SyntheticArgumentBinding sb = (SyntheticArgumentBinding) path[0];
JField field = curClass.syntheticFields.get(sb);
assert field != null;
result = makeInstanceFieldRef(info, field);
} else if (path[0] instanceof LocalVariableBinding) {
result = makeLocalRef(info, (LocalVariableBinding) path[0]);
} else if (path[0] instanceof FieldBinding) {
FieldBinding fb = (FieldBinding) path[0];
assert curClass.typeDecl.binding.isCompatibleWith(x.actualReceiverType.erasure());
JField field = typeMap.get(fb);
assert field != null;
result = makeInstanceFieldRef(info, field);
} else {
throw new InternalCompilerException("Unknown emulation path.");
}
} else {
result = makeLocalRef(info, b);
}
} else if (binding instanceof FieldBinding) {
FieldBinding b = ((FieldBinding) x.binding).original();
JField field = typeMap.get(b);
assert field != null;
JExpression thisRef = null;
if (!b.isStatic()) {
thisRef = makeThisReference(info, (ReferenceBinding) x.actualReceiverType, false, scope);
}
result = new JFieldRef(info, thisRef, field, curClass.type);
} else {
return null;