public InstructionList reduce_postIncNameExpr(IASNode iNode, Binding unary, boolean need_result)
{
currentScope.getMethodBodySemanticChecker().checkIncDec(iNode, true, unary);
InstructionList result = createInstructionList(iNode);
if ( unary.isLocal() ) {
ICompilerProject project = currentScope.getProject();
IDefinition inType = SemanticUtils.resolveUnaryExprType(iNode, project);
IDefinition intType = project.getBuiltinType(BuiltinType.INT);
IDefinition numberType = project.getBuiltinType(BuiltinType.NUMBER);
if( inType == intType)
{
// Incrementing a local, typed as int
// we can use inclocal_i since we know the result will be stored in an int
if( need_result )
result.addInstruction(unary.getlocal());
result.addInstruction(unary.inclocal_i());
}
else if( inType == numberType)
{
// Incrementing a local, typed as Number
// we can use inclocal since we know the result will be stored in a Number
if( need_result )
result.addInstruction(unary.getlocal());
result.addInstruction(unary.inclocal());
}
else
{
result.addInstruction(unary.getlocal());
result.addInstruction(op_unplus());
if( need_result )
result.addInstruction(OP_dup);
result.addInstruction(OP_increment);
coerce(result, inType);
result.addInstruction(unary.setlocal());
}
}
else
{
Name n = unary.getName();
result.addAll(currentScope.findProperty(unary, true));
result.addInstruction(OP_getproperty,n);
result.addInstruction(op_unplus());
if( need_result )
result.addInstruction(OP_dup);
result.addInstruction(OP_increment);
result.addAll(currentScope.findProperty(unary, true));
result.addInstruction(OP_swap);
result.addInstruction(OP_setproperty,n);
}
return result;
}