The design is such that the caller of the generate method does the conversion if it notices that the requested type is not the one that it got but casting is possible, but its better if the generate method does it since it works in more situations
@Override
public MethodVisitor generate(Class<?> resultType, MethodVisitor mv)
{
generatedType = type();
if (π.equals(fieldName))
{
getStaticField(mv, π);
}
else if (half.equals(fieldName))
{
getStaticField(mv, "half");
}
else
{
// todo: https://github.com/crowlogic/arb4j/issues/222: use the primitive int ,
// the signature of the method being invoked will also have to know this has
// been done and change correspondingly
expression.loadFieldOntoStack(loadThisOntoStack(mv),
fieldName,
generatedType.descriptorString());
}
if (isResult)
{
expression.generateSetResultInvocation(mv, generatedType);
}
// expression.addToTypeStack(thisType, toString() );
return mv;
}
The design is such that the caller of the generate method does the conversion if it notices that the requested type is not the one that it got but casting is possible, but its better if the generate method does it since it works in more situations