Cleanup (formatting)
This commit is contained in:
@@ -849,26 +849,24 @@ public class ExprProcessor implements CodeConstants {
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConstExprent getDefaultArrayValue(VarType arrtype) {
|
public static ConstExprent getDefaultArrayValue(VarType arrType) {
|
||||||
|
ConstExprent defaultVal;
|
||||||
ConstExprent defaultval;
|
if (arrType.type == CodeConstants.TYPE_OBJECT || arrType.arrayDim > 0) {
|
||||||
if (arrtype.type == CodeConstants.TYPE_OBJECT || arrtype.arrayDim > 0) {
|
defaultVal = new ConstExprent(VarType.VARTYPE_NULL, null, null);
|
||||||
defaultval = new ConstExprent(VarType.VARTYPE_NULL, null, null);
|
|
||||||
}
|
}
|
||||||
else if (arrtype.type == CodeConstants.TYPE_FLOAT) {
|
else if (arrType.type == CodeConstants.TYPE_FLOAT) {
|
||||||
defaultval = new ConstExprent(VarType.VARTYPE_FLOAT, new Float(0), null);
|
defaultVal = new ConstExprent(VarType.VARTYPE_FLOAT, new Float(0), null);
|
||||||
}
|
}
|
||||||
else if (arrtype.type == CodeConstants.TYPE_LONG) {
|
else if (arrType.type == CodeConstants.TYPE_LONG) {
|
||||||
defaultval = new ConstExprent(VarType.VARTYPE_LONG, new Long(0), null);
|
defaultVal = new ConstExprent(VarType.VARTYPE_LONG, new Long(0), null);
|
||||||
}
|
}
|
||||||
else if (arrtype.type == CodeConstants.TYPE_DOUBLE) {
|
else if (arrType.type == CodeConstants.TYPE_DOUBLE) {
|
||||||
defaultval = new ConstExprent(VarType.VARTYPE_DOUBLE, new Double(0), null);
|
defaultVal = new ConstExprent(VarType.VARTYPE_DOUBLE, new Double(0), null);
|
||||||
}
|
}
|
||||||
else { // integer types
|
else { // integer types
|
||||||
defaultval = new ConstExprent(0, true, null);
|
defaultVal = new ConstExprent(0, true, null);
|
||||||
}
|
}
|
||||||
|
return defaultVal;
|
||||||
return defaultval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getCastedExprent(Exprent exprent,
|
public static boolean getCastedExprent(Exprent exprent,
|
||||||
@@ -887,35 +885,30 @@ public class ExprProcessor implements CodeConstants {
|
|||||||
boolean castNull,
|
boolean castNull,
|
||||||
boolean castAlways,
|
boolean castAlways,
|
||||||
BytecodeMappingTracer tracer) {
|
BytecodeMappingTracer tracer) {
|
||||||
|
|
||||||
VarType rightType = exprent.getExprType();
|
VarType rightType = exprent.getExprType();
|
||||||
|
|
||||||
TextBuffer res = exprent.toJava(indent, tracer);
|
|
||||||
|
|
||||||
boolean cast =
|
boolean cast =
|
||||||
castAlways ||
|
castAlways ||
|
||||||
(!leftType.isSuperset(rightType) && (rightType.equals(VarType.VARTYPE_OBJECT) || leftType.type != CodeConstants.TYPE_OBJECT)) ||
|
(!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))) ||
|
(castNull && rightType.type == CodeConstants.TYPE_NULL && !UNDEFINED_TYPE_STRING.equals(getTypeName(leftType))) ||
|
||||||
(isIntConstant(exprent) && VarType.VARTYPE_INT.isStrictSuperset(leftType));
|
(isIntConstant(exprent) && VarType.VARTYPE_INT.isStrictSuperset(leftType));
|
||||||
|
|
||||||
if (cast) {
|
boolean quote = cast && exprent.getPrecedence() >= FunctionExprent.getPrecedence(FunctionExprent.FUNCTION_CAST);
|
||||||
if (exprent.getPrecedence() >= FunctionExprent.getPrecedence(FunctionExprent.FUNCTION_CAST)) {
|
|
||||||
res.enclose("(", ")");
|
|
||||||
}
|
|
||||||
|
|
||||||
res.prepend("(" + getCastTypeName(leftType) + ")");
|
if (cast) buffer.append('(').append(getCastTypeName(leftType)).append(')');
|
||||||
}
|
|
||||||
|
|
||||||
buffer.append(res);
|
if (quote) buffer.append('(');
|
||||||
|
|
||||||
|
buffer.append(exprent.toJava(indent, tracer));
|
||||||
|
|
||||||
|
if (quote) buffer.append(')');
|
||||||
|
|
||||||
return cast;
|
return cast;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isIntConstant(Exprent exprent) {
|
private static boolean isIntConstant(Exprent exprent) {
|
||||||
|
|
||||||
if (exprent.type == Exprent.EXPRENT_CONST) {
|
if (exprent.type == Exprent.EXPRENT_CONST) {
|
||||||
ConstExprent cexpr = (ConstExprent)exprent;
|
switch (((ConstExprent)exprent).getConstType().type) {
|
||||||
switch (cexpr.getConstType().type) {
|
|
||||||
case CodeConstants.TYPE_BYTE:
|
case CodeConstants.TYPE_BYTE:
|
||||||
case CodeConstants.TYPE_BYTECHAR:
|
case CodeConstants.TYPE_BYTECHAR:
|
||||||
case CodeConstants.TYPE_SHORT:
|
case CodeConstants.TYPE_SHORT:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2000-2014 JetBrains s.r.o.
|
* Copyright 2000-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -27,7 +27,6 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class ArrayExprent extends Exprent {
|
public class ArrayExprent extends Exprent {
|
||||||
|
|
||||||
private Exprent array;
|
private Exprent array;
|
||||||
private Exprent index;
|
private Exprent index;
|
||||||
private final VarType hardType;
|
private final VarType hardType;
|
||||||
@@ -91,7 +90,7 @@ public class ArrayExprent extends Exprent {
|
|||||||
|
|
||||||
tracer.addMapping(bytecode);
|
tracer.addMapping(bytecode);
|
||||||
|
|
||||||
return res.append("[").append(index.toJava(indent, tracer)).append("]");
|
return res.append('[').append(index.toJava(indent, tracer)).append(']');
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -121,4 +120,4 @@ public class ArrayExprent extends Exprent {
|
|||||||
public Exprent getIndex() {
|
public Exprent getIndex() {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user