VarType () { VarType exprType = null; if (funcType <= FUNCTION_NEG || funcType == FUNCTION_IPP || funcType == FUNCTION_PPI || funcType == FUNCTION_IMM || funcType == FUNCTION_MMI) { VarType type1 = lstOperands.get(0).getExprType(); VarType type2 = null; if (lstOperands.size() > 1) { type2 = lstOperands.get(1).getExprType(); } switch (funcType) { case FUNCTION_IMM, FUNCTION_MMI, FUNCTION_IPP, FUNCTION_PPI -> exprType = implicitType; case FUNCTION_BOOL_NOT -> exprType = VarType.VARTYPE_BOOLEAN; case FUNCTION_SHL, FUNCTION_SHR, FUNCTION_USHR, FUNCTION_BIT_NOT, FUNCTION_NEG -> exprType = getMaxVarType(new VarType[]{type1}); case FUNCTION_ADD, FUNCTION_SUB, FUNCTION_MUL, FUNCTION_DIV, FUNCTION_REM -> exprType = getMaxVarType(new VarType[]{type1, type2}); case FUNCTION_AND, FUNCTION_OR, FUNCTION_XOR -> { if (type1.getType() == CodeConstants.TYPE_BOOLEAN & type2.getType() == CodeConstants.TYPE_BOOLEAN) { exprType = VarType.VARTYPE_BOOLEAN; } else { exprType = getMaxVarType(new VarType[]{type1, type2}); } } } } else if (funcType == FUNCTION_CAST) { exprType = lstOperands.get(1).getExprType(); } else if (funcType == FUNCTION_IIF) { Exprent param1 = lstOperands.get(1); Exprent param2 = lstOperands.get(2); VarType supertype = VarType.getCommonSupertype(param1.getExprType(), param2.getExprType()); if (param1.type == Exprent.EXPRENT_CONST && param2.type == Exprent.EXPRENT_CONST && supertype.getType() != CodeConstants.TYPE_BOOLEAN && VarType.VARTYPE_INT.isSuperset(supertype)) { exprType = VarType.VARTYPE_INT; } else { exprType = supertype; } } else if (funcType == FUNCTION_STR_CONCAT) { exprType = VarType.VARTYPE_STRING; } else if (funcType >= FUNCTION_EQ || funcType == FUNCTION_INSTANCEOF) { exprType = VarType.VARTYPE_BOOLEAN; } else if (funcType >= FUNCTION_ARRAY_LENGTH) { exprType = VarType.VARTYPE_INT; } else { exprType = TYPES[funcType - FUNCTION_I2L]; } return exprType; }