@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); }
@Override public boolean equals(Object o) { if (o == this) return true; if (!(o instanceof MethodDescriptor)) return false; MethodDescriptor md = (MethodDescriptor)o; return ret.equals(md.ret) && Arrays.equals(params, md.params); }
public void adjustConstType(VarType expectedType) { // BYTECHAR and SHORTCHAR => CHAR in the CHAR context if ((expectedType.equals(VarType.VARTYPE_CHAR) || expectedType.equals(VarType.VARTYPE_CHARACTER)) && (constType.equals(VarType.VARTYPE_BYTECHAR) || constType.equals(VarType.VARTYPE_SHORTCHAR))) { int intValue = getIntValue(); if (isPrintableAscii(intValue) || CHAR_ESCAPES.containsKey(intValue)) { setConstType(VarType.VARTYPE_CHAR); } } // BYTE, BYTECHAR, SHORTCHAR, SHORT, CHAR => INT in the INT context else if ((expectedType.equals(VarType.VARTYPE_INT) || expectedType.equals(VarType.VARTYPE_INTEGER)) && constType.typeFamily == CodeConstants.TYPE_FAMILY_INTEGER) { setConstType(VarType.VARTYPE_INT); } }
public boolean isSuperset(VarType val) { return this.equals(val) || this.isStrictSuperset(val); }
private static boolean isAppendConcat(InvocationExprent expr, VarType cltype) { if ("append".equals(expr.getName())) { MethodDescriptor md = expr.getDescriptor(); if (md.ret.equals(cltype) && md.params.length == 1) { VarType param = md.params[0]; switch (param.type) { case CodeConstants.TYPE_OBJECT: if (!param.equals(VarType.VARTYPE_STRING) && !param.equals(VarType.VARTYPE_OBJECT)) { break; } case CodeConstants.TYPE_BOOLEAN: case CodeConstants.TYPE_CHAR: case CodeConstants.TYPE_DOUBLE: case CodeConstants.TYPE_FLOAT: case CodeConstants.TYPE_INT: case CodeConstants.TYPE_LONG: return true; default: } } } return false; }
@Override public VarType getExprType() { VarType exprType = array.getExprType(); if (exprType.equals(VarType.VARTYPE_NULL)) { return hardType.copy(); } else { return exprType.decreaseArrayDim(); } }
private static Exprent removeStringValueOf(Exprent exprent) { if (exprent.type == Exprent.EXPRENT_INVOCATION) { InvocationExprent iex = (InvocationExprent)exprent; if ("valueOf".equals(iex.getName()) && stringClass.equals(iex.getClassname())) { MethodDescriptor md = iex.getDescriptor(); if (md.params.length == 1) { VarType param = md.params[0]; switch (param.type) { case CodeConstants.TYPE_OBJECT: if (!param.equals(VarType.VARTYPE_OBJECT)) { break; } case CodeConstants.TYPE_BOOLEAN: case CodeConstants.TYPE_CHAR: case CodeConstants.TYPE_DOUBLE: case CodeConstants.TYPE_FLOAT: case CodeConstants.TYPE_INT: case CodeConstants.TYPE_LONG: return iex.getLstParameters().get(0); } } } } return exprent; } }
case Exprent.EXPRENT_CONST: ConstExprent constExpr = (ConstExprent)expr; res = (VarType.VARTYPE_CLASS.equals(constExpr.getConstType()) && classname.equals(constExpr.getValue()) || classType.equals(constExpr.getConstType())); break; case Exprent.EXPRENT_FIELD: if (varExpr.isDefinition()) { VarType varType = varExpr.getVarType(); if (classType.equals(varType) || (varType.arrayDim > 0 && classType.value.equals(varType.value))) { res = true;
private static InvocationExprent isAssertionError(Statement stat) { if (stat == null || stat.getExprents() == null || stat.getExprents().size() != 1) { return null; } Exprent expr = stat.getExprents().get(0); if (expr.type == Exprent.EXPRENT_EXIT) { ExitExprent exexpr = (ExitExprent)expr; if (exexpr.getExitType() == ExitExprent.EXIT_THROW && exexpr.getValue().type == Exprent.EXPRENT_NEW) { NewExprent nexpr = (NewExprent)exexpr.getValue(); if (CLASS_ASSERTION_ERROR.equals(nexpr.getNewType()) && nexpr.getConstructor() != null) { return nexpr.getConstructor(); } } } return null; }
if (headexpr.getLstOperands().get(0).type == Exprent.EXPRENT_FIELD && headexpr.getLstOperands().get(1).type == Exprent.EXPRENT_CONST && ((ConstExprent)headexpr.getLstOperands().get(1)).getConstType().equals(VarType.VARTYPE_NULL)) {
@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; }
(!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;
if (cst.getStats().size() == 2 && cst.getFirst().type == Statement.TYPE_BASICBLOCK && cst.getStats().get(1).type == Statement.TYPE_BASICBLOCK && cst.getVars().get(0).getVarType().equals(new VarType(CodeConstants.TYPE_OBJECT, 0, "java/lang/ClassNotFoundException"))) {
if (left.equals(econd) && (midlayer == null || midlayer.equals(condtype))) { FunctionExprent ret = new FunctionExprent( func.getFuncType() == FunctionExprent.FUNCTION_ADD ? FunctionExprent.FUNCTION_PPI : FunctionExprent.FUNCTION_MMI,
(rightType.equals(VarType.VARTYPE_OBJECT) || leftType.type != CodeConstants.TYPE_OBJECT)) { if (right.getPrecedence() >= FunctionExprent.getPrecedence(FunctionExprent.FUNCTION_CAST)) { res.enclose("(", ")");