From 0c5960922a8fa0b1546b28c188155ba6b52da12e Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Mon, 26 Nov 2012 18:24:24 +0400 Subject: [PATCH] Refactor StackValue.coerce() --- .../org/jetbrains/jet/codegen/StackValue.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java b/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java index f8b0bf13800..c0a75898b76 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java @@ -235,10 +235,10 @@ public abstract class StackValue { public static void coerce(Type fromType, Type toType, InstructionAdapter v) { if (toType.equals(fromType)) return; - if (toType.getSort() == Type.VOID && fromType.getSort() != Type.VOID) { + if (toType.getSort() == Type.VOID) { pop(fromType, v); } - else if (toType.getSort() != Type.VOID && fromType.getSort() == Type.VOID) { + else if (fromType.getSort() == Type.VOID) { if (toType.getSort() == Type.OBJECT) { putTuple0Instance(v); } @@ -255,22 +255,24 @@ public abstract class StackValue { v.iconst(0); } } - else if (toType.equals(JET_TUPLE0_TYPE) && !fromType.equals(JET_TUPLE0_TYPE)) { + else if (toType.equals(JET_TUPLE0_TYPE)) { pop(fromType, v); putTuple0Instance(v); } - else if (toType.getSort() == Type.OBJECT && fromType.equals(OBJECT_TYPE) || toType.getSort() == Type.ARRAY) { + else if (toType.getSort() == Type.ARRAY) { v.checkcast(toType); } else if (toType.getSort() == Type.OBJECT) { - if (fromType.getSort() == Type.OBJECT && !toType.equals(OBJECT_TYPE)) { - v.checkcast(toType); + if (fromType.getSort() == Type.OBJECT || fromType.getSort() == Type.ARRAY) { + if (!toType.equals(OBJECT_TYPE)) { + v.checkcast(toType); + } } else { box(fromType, toType, v); } } - else if (fromType.getSort() == Type.OBJECT && toType.getSort() <= Type.DOUBLE) { + else if (fromType.getSort() == Type.OBJECT) { if (toType.getSort() == Type.BOOLEAN) { coerce(fromType, JvmPrimitiveType.BOOLEAN.getWrapper().getAsmType(), v); }