Cleanup (formatting)

This commit is contained in:
Roman Shevchenko 2014-10-24 21:46:41 +02:00
parent 99404ea6cf
commit c64b0aaa10
2 changed files with 19 additions and 18 deletions

View File

@ -855,8 +855,12 @@ public class ExprProcessor implements CodeConstants {
return defaultval;
}
public static boolean getCastedExprent(Exprent exprent, VarType leftType, TextBuffer buffer, int indent,
boolean castNull, BytecodeMappingTracer tracer) {
public static boolean getCastedExprent(Exprent exprent,
VarType leftType,
TextBuffer buffer,
int indent,
boolean castNull,
BytecodeMappingTracer tracer) {
return getCastedExprent(exprent, leftType, buffer, indent, castNull, false, tracer);
}
@ -865,7 +869,8 @@ public class ExprProcessor implements CodeConstants {
TextBuffer buffer,
int indent,
boolean castNull,
boolean castAlways, BytecodeMappingTracer tracer) {
boolean castAlways,
BytecodeMappingTracer tracer) {
boolean ret = false;
VarType rightType = exprent.getExprType();
@ -873,16 +878,10 @@ public class ExprProcessor implements CodeConstants {
TextBuffer res = exprent.toJava(indent, tracer);
boolean cast =
!leftType.isSuperset(rightType) && (rightType.equals(VarType.VARTYPE_OBJECT) || leftType.type != CodeConstants.TYPE_OBJECT);
cast |= castAlways;
if (!cast && castNull && rightType.type == CodeConstants.TYPE_NULL) {
// check for a nameless anonymous class
cast = !UNDEFINED_TYPE_STRING.equals(getTypeName(leftType));
}
if (!cast) {
cast = isIntConstant(exprent) && VarType.VARTYPE_INT.isStrictSuperset(leftType);
}
castAlways ||
(!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))) ||
(isIntConstant(exprent) && VarType.VARTYPE_INT.isStrictSuperset(leftType));
if (cast) {
if (exprent.getPrecedence() >= FunctionExprent.getPrecedence(FunctionExprent.FUNCTION_CAST)) {

View File

@ -357,21 +357,23 @@ public class InvocationExprent extends Exprent {
Set<Integer> setAmbiguousParameters = getAmbiguousParameters();
boolean firstpar = true;
boolean firstParameter = true;
int start = isEnum ? 2 : 0;
for (int i = start; i < lstParameters.size(); i++) {
if (sigFields == null || sigFields.get(i) == null) {
if (!firstpar) {
if (!firstParameter) {
buf.append(", ");
}
TextBuffer buff = new TextBuffer();
ExprProcessor.getCastedExprent(lstParameters.get(i), descriptor.params[i], buff, indent, true, setAmbiguousParameters.contains(i), tracer);
boolean ambiguous = setAmbiguousParameters.contains(i);
ExprProcessor.getCastedExprent(lstParameters.get(i), descriptor.params[i], buff, indent, true, ambiguous, tracer);
buf.append(buff);
firstpar = false;
firstParameter = false;
}
}
buf.append(")");
return buf;