|
|
@ -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(')'); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (quote) buffer.append('('); |
|
|
|
|
|
|
|
|
|
|
|
buffer.append(res); |
|
|
|
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: |
|
|
|