Extract method

This commit is contained in:
Natalia.Ukhorskaya
2012-12-24 14:35:53 +04:00
parent 538aa869b4
commit f4a44155d9
3 changed files with 26 additions and 25 deletions
@@ -532,6 +532,30 @@ public class AsmUtil {
}
}
public static void pushDefaultValueOnStack(@NotNull Type type, @NotNull InstructionAdapter v) {
if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) {
v.aconst(null);
}
else {
pushDefaultPrimitiveValueOnStack(type, v);
}
}
public static void pushDefaultPrimitiveValueOnStack(@NotNull Type type, @NotNull InstructionAdapter v) {
if (type.getSort() == Type.FLOAT) {
v.fconst(0);
}
else if (type.getSort() == Type.DOUBLE) {
v.dconst(0);
}
else if (type.getSort() == Type.LONG) {
v.lconst(0);
}
else {
v.iconst(0);
}
}
public static Type comparisonOperandType(Type left, Type right) {
if (left == Type.DOUBLE_TYPE || right == Type.DOUBLE_TYPE) return Type.DOUBLE_TYPE;
if (left == Type.FLOAT_TYPE || right == Type.FLOAT_TYPE) return Type.FLOAT_TYPE;
@@ -2131,21 +2131,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
else if (resolvedValueArgument instanceof DefaultValueArgument) {
Type type = valueParameterTypes.get(index);
if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) {
v.aconst(null);
}
else if (type.getSort() == Type.FLOAT) {
v.aconst(0f);
}
else if (type.getSort() == Type.DOUBLE) {
v.aconst(0d);
}
else if (type.getSort() == Type.LONG) {
v.aconst(0l);
}
else {
v.iconst(0);
}
pushDefaultValueOnStack(type, v);
mask |= (1 << index);
}
else if (resolvedValueArgument instanceof VarargValueArgument) {
@@ -242,17 +242,8 @@ public abstract class StackValue {
if (toType.getSort() == Type.OBJECT) {
putTuple0Instance(v);
}
else if (toType == Type.LONG_TYPE) {
v.lconst(0);
}
else if (toType == Type.FLOAT_TYPE) {
v.fconst(0);
}
else if (toType == Type.DOUBLE_TYPE) {
v.dconst(0);
}
else {
v.iconst(0);
pushDefaultPrimitiveValueOnStack(toType, v);
}
}
else if (toType.equals(JET_TUPLE0_TYPE)) {