Remove useless StackValue.upcast()

This commit is contained in:
Alexander Udalov
2012-11-01 19:01:01 +04:00
parent e89ccf5f1b
commit a9aef66b15
3 changed files with 3 additions and 17 deletions
@@ -176,16 +176,13 @@ public class ClosureCodegen extends GenerationStateAware {
final ReceiverParameterDescriptor receiver = funDescriptor.getReceiverParameter();
int count = 1;
if (receiver != null) {
StackValue.local(count, OBJECT_TYPE).put(OBJECT_TYPE, iv);
StackValue.onStack(OBJECT_TYPE)
.upcast(typeMapper.mapType(receiver.getType()), iv);
StackValue.local(count, OBJECT_TYPE).put(typeMapper.mapType(receiver.getType()), iv);
count++;
}
final List<ValueParameterDescriptor> params = funDescriptor.getValueParameters();
for (ValueParameterDescriptor param : params) {
StackValue.local(count, OBJECT_TYPE).put(OBJECT_TYPE, iv);
StackValue.onStack(OBJECT_TYPE).upcast(typeMapper.mapType(param.getType()), iv);
StackValue.local(count, OBJECT_TYPE).put(typeMapper.mapType(param.getType()), iv);
count++;
}
@@ -1806,7 +1806,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
JetType type = fd.getReturnType();
assert type != null;
final Type retType = typeMapper.mapReturnType(type);
StackValue.onStack(callReturnType).upcast(retType, v);
StackValue.coerce(callReturnType, retType, v);
return StackValue.onStack(retType);
}
return StackValue.none();
@@ -228,17 +228,6 @@ public abstract class StackValue {
}
}
public void upcast(Type type, InstructionAdapter v) {
if (type.equals(this.type)) return;
if (type.getSort() == Type.OBJECT && this.type.getSort() == Type.OBJECT) {
v.checkcast(type);
}
else {
coerceTo(type, v);
}
}
private static void pop(Type type, InstructionAdapter v) {
if (type.getSize() == 1) {
v.pop();