public VarType decreaseArrayDim() { if (arrayDim > 0) { return new VarType(type, arrayDim - 1, value); } else { //throw new RuntimeException("array dimension equals 0!"); FIXME: investigate this case return this; } }
@Override public VarType getExprType() { VarType exprType = array.getExprType(); if (exprType.equals(VarType.VARTYPE_NULL)) { return hardType.copy(); } else { return exprType.decreaseArrayDim(); } }
public VarType(int type, int arrayDim) { this(type, arrayDim, getChar(type)); }
private static boolean isNarrowedIntType(VarType type) { return VarType.VARTYPE_INT.isStrictSuperset(type) || type.equals(VarType.VARTYPE_BYTE_OBJ) || type.equals(VarType.VARTYPE_SHORT_OBJ); } }
public VarType(int type, int arrayDim, String value) { this(type, arrayDim, value, getFamily(type, arrayDim), getStackSize(type, arrayDim), false); }
@Override public boolean equals(Object o) { if (o == this) return true; if (!(o instanceof FieldDescriptor)) return false; FieldDescriptor fd = (FieldDescriptor)o; return type.equals(fd.type); }
type = getType(value.charAt(0)); this.arrayDim = arrayDim; this.value = value; this.typeFamily = getFamily(type, arrayDim); this.stackSize = getStackSize(type, arrayDim); this.falseBoolean = false;
if (minInteger.isStrictSuperset(newType)) { newType = minInteger; newMinType = VarType.getCommonSupertype(currentMinType, newType); if (currentMinType != null && (newMinType.typeFamily > currentMinType.typeFamily || newMinType.isStrictSuperset(currentMinType))) { return false; newMaxType = VarType.getCommonMinType(currentMaxType, newType);
VarType supertype = getExprType(); result.addMinTypeExprent(param1, VarType.VARTYPE_BOOLEAN); result.addMinTypeExprent(param2, VarType.getMinTypeInFamily(supertype.typeFamily)); result.addMinTypeExprent(lstOperands.get(2), VarType.getMinTypeInFamily(supertype.typeFamily)); break; case FUNCTION_I2L: case FUNCTION_NE: { if (type1.type == CodeConstants.TYPE_BOOLEAN) { if (type2.isStrictSuperset(type1)) { result.addMinTypeExprent(param1, VarType.VARTYPE_BYTECHAR); type1.isFalseBoolean() || (param1.type == Exprent.EXPRENT_CONST && !((ConstExprent)param1).hasBooleanValue()); boolean param2_false_boolean = type1.isFalseBoolean() || (param2.type == Exprent.EXPRENT_CONST && !((ConstExprent)param2).hasBooleanValue()); if (type1.isStrictSuperset(type2)) { result.addMinTypeExprent(param2, VarType.VARTYPE_BYTECHAR);
stack.push(new VarType(CodeConstants.TYPE_NULL, 0, null)); break; case CodeConstants.opc_ldc: switch (constant.type) { case CodeConstants.CONSTANT_Integer: stack.push(new VarType(CodeConstants.TYPE_INT)); break; case CodeConstants.CONSTANT_Float: stack.push(new VarType(CodeConstants.TYPE_FLOAT)); break; case CodeConstants.CONSTANT_Long: stack.push(new VarType(CodeConstants.TYPE_LONG)); stack.push(new VarType(CodeConstants.TYPE_GROUP2EMPTY)); break; case CodeConstants.CONSTANT_Double: stack.push(new VarType(CodeConstants.TYPE_DOUBLE)); stack.push(new VarType(CodeConstants.TYPE_GROUP2EMPTY)); break; case CodeConstants.CONSTANT_String: stack.push(new VarType(CodeConstants.TYPE_OBJECT, 0, "java/lang/String")); break; case CodeConstants.CONSTANT_Class: stack.push(new VarType(CodeConstants.TYPE_OBJECT, 0, "java/lang/Class")); break; case CodeConstants.CONSTANT_MethodHandle: stack.push(new VarType(((LinkConstant)constant).descriptor)); break;
int paramType = invocationExprent.getDescriptor().params[0].type; if (exprent.type == Exprent.EXPRENT_CONST && ((ConstExprent)exprent).getConstType().type != paramType) { leftType = new VarType(paramType); (!leftType.isSuperset(rightType) && (rightType.equals(VarType.VARTYPE_OBJECT) || leftType.type != CodeConstants.TYPE_OBJECT)) || (castNull && rightType.type == CodeConstants.TYPE_NULL && !UNDEFINED_TYPE_STRING.equals(getTypeName(leftType))) || (castNarrowing && isIntConstant(exprent) && isNarrowedIntType(leftType)); if (leftType.equals(VarType.VARTYPE_BYTE_OBJ)) { leftType = VarType.VARTYPE_BYTE; else if (leftType.equals(VarType.VARTYPE_SHORT_OBJ)) { leftType = VarType.VARTYPE_SHORT;
@Override public CheckTypesResult checkExprTypeBounds() { CheckTypesResult result = new CheckTypesResult(); VarType typeLeft = left.getExprType(); VarType typeRight = right.getExprType(); if (typeLeft.typeFamily > typeRight.typeFamily) { result.addMinTypeExprent(right, VarType.getMinTypeInFamily(typeLeft.typeFamily)); } else if (typeLeft.typeFamily < typeRight.typeFamily) { result.addMinTypeExprent(left, typeRight); } else { result.addMinTypeExprent(left, VarType.getCommonSupertype(typeLeft, typeRight)); } return result; }
@Override public CheckTypesResult checkExprTypeBounds() { CheckTypesResult result = new CheckTypesResult(); result.addMinTypeExprent(value, VarType.VARTYPE_BYTECHAR); result.addMaxTypeExprent(value, VarType.VARTYPE_INT); VarType valType = value.getExprType(); for (List<Exprent> lst : caseValues) { for (Exprent expr : lst) { if (expr != null) { VarType caseType = expr.getExprType(); if (!caseType.equals(valType)) { valType = VarType.getCommonSupertype(caseType, valType); result.addMinTypeExprent(value, valType); } } } } return result; }
@Override public CheckTypesResult checkExprTypeBounds() { CheckTypesResult result = new CheckTypesResult(); if (newType.arrayDim != 0) { for (Exprent dim : lstDims) { result.addMinTypeExprent(dim, VarType.VARTYPE_BYTECHAR); result.addMaxTypeExprent(dim, VarType.VARTYPE_INT); } if (newType.arrayDim == 1) { VarType leftType = newType.decreaseArrayDim(); for (Exprent element : lstArrayElements) { result.addMinTypeExprent(element, VarType.getMinTypeInFamily(leftType.typeFamily)); result.addMaxTypeExprent(element, leftType); } } } else if (constructor != null) { return constructor.checkExprTypeBounds(); } return result; }
VarType secondType = mapExprentMinTypes.get(secondPair); if (firstType.equals(secondType) || (firstType.equals(VarType.VARTYPE_NULL) && secondType.type == CodeConstants.TYPE_OBJECT) || (secondType.equals(VarType.VARTYPE_NULL) && firstType.type == CodeConstants.TYPE_OBJECT)) { VarType type = firstMaxType == null ? secondMaxType : secondMaxType == null ? firstMaxType : VarType.getCommonMinType(firstMaxType, secondMaxType); mapExprentMinTypes.remove(secondPair); if (firstType.equals(VarType.VARTYPE_NULL)) { mapExprentMinTypes.put(firstPair, secondType); firstType = secondType;
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.type != CodeConstants.TYPE_BOOLEAN && VarType.VARTYPE_INT.isSuperset(supertype)) { exprType = VarType.VARTYPE_INT;
isVarArg &= parameterType.arrayDim > 0; if (isVarArg) { parameterType = parameterType.decreaseArrayDim(); VarType type = new VarType(attr.getExcClassname(i, cl.getPool()), true); buffer.append(ExprProcessor.getCastTypeName(type));
public VarType copy() { return copy(false); }