@Override
public final void writeTo(final ITextOutput output) {
final AstCode code = _code;
final Object operand = _operand;
final TypeReference inferredType = _inferredType;
final TypeReference expectedType = _expectedType;
if (operand instanceof Variable /*&&
((Variable) operand).isGenerated()*/) {
if (AstCodeHelpers.isLocalStore(code)) {
output.write(((Variable) operand).getName());
output.write(" = ");
getArguments().get(0).writeTo(output);
return;
}
if (AstCodeHelpers.isLocalLoad(code)) {
output.write(((Variable) operand).getName());
if (inferredType != null) {
output.write(':');
writeType(output, inferredType, NameSyntax.SHORT_TYPE_NAME);
if (expectedType != null &&
!Comparer.equals(expectedType.getInternalName(), inferredType.getInternalName())) {
output.write("[expected:");
writeType(output, expectedType, NameSyntax.SHORT_TYPE_NAME);
output.write(']');
}
}
return;
}
}
output.writeReference(code.name().toLowerCase(), code);
if (inferredType != null) {
output.write(':');
writeType(output, inferredType, NameSyntax.SHORT_TYPE_NAME);
if (expectedType != null &&
!Comparer.equals(expectedType.getInternalName(), inferredType.getInternalName())) {
output.write("[expected:");
writeType(output, expectedType, NameSyntax.SHORT_TYPE_NAME);
output.write(']');
}
}
else if (expectedType != null) {
output.write("[expected:");
writeType(output, expectedType, NameSyntax.SHORT_TYPE_NAME);
output.write(']');
}
output.write('(');
boolean first = true;
if (operand != null) {
if (operand instanceof Label) {
output.writeReference(((Label) operand).getName(), operand);
}
else if (operand instanceof Label[]) {
final Label[] labels = (Label[]) operand;
for (int i = 0; i < (labels).length; i++) {
if (i != 0) {
output.write(", ");
}
output.writeReference(labels[i].getName(), labels[i]);
}
}
else if (operand instanceof MethodReference ||
operand instanceof FieldReference) {
final MemberReference member = (MemberReference) operand;
final TypeReference declaringType = member.getDeclaringType();
if (declaringType != null) {
writeType(output, declaringType, NameSyntax.SHORT_TYPE_NAME);
output.write("::");
}