Simplify code in StackValue$CollectionElement

This commit is contained in:
Alexander Udalov
2013-12-16 18:18:38 +04:00
parent ece549b4d4
commit 351aa30141
@@ -675,7 +675,7 @@ public abstract class StackValue {
v.dup2(); // collection and index v.dup2(); // collection and index
return; return;
} }
int size = 0; int size = 0;
// ugly hack: getting the last variable index // ugly hack: getting the last variable index
int lastIndex = frame.enterTemp(Type.INT_TYPE); int lastIndex = frame.enterTemp(Type.INT_TYPE);
@@ -693,17 +693,6 @@ public abstract class StackValue {
v.store((firstParamIndex = lastIndex) - sz, type); v.store((firstParamIndex = lastIndex) - sz, type);
} }
List<TypeParameterDescriptor> typeParameters = resolvedGetCall.getResultingDescriptor().getTypeParameters();
int firstTypeParamIndex = -1;
for (int i = typeParameters.size() - 1; i >= 0; --i) {
if (typeParameters.get(i).isReified()) {
frame.enterTemp(OBJECT_TYPE);
lastIndex++;
size++;
v.store(firstTypeParamIndex = lastIndex - 1, OBJECT_TYPE);
}
}
ReceiverValue receiverParameter = resolvedGetCall.getReceiverArgument(); ReceiverValue receiverParameter = resolvedGetCall.getReceiverArgument();
int receiverIndex = -1; int receiverIndex = -1;
if (receiverParameter.exists()) { if (receiverParameter.exists()) {
@@ -728,24 +717,16 @@ public abstract class StackValue {
int realReceiverIndex; int realReceiverIndex;
Type realReceiverType; Type realReceiverType;
if (thisIndex != -1) { if (receiverIndex != -1) {
if (receiverIndex != -1) { realReceiverType = codegen.typeMapper.mapType(receiverParameter.getType());
realReceiverIndex = receiverIndex; realReceiverIndex = receiverIndex;
realReceiverType = codegen.typeMapper.mapType(receiverParameter.getType()); }
} else if (thisIndex != -1) {
else { realReceiverType = OBJECT_TYPE;
realReceiverIndex = thisIndex; realReceiverIndex = thisIndex;
realReceiverType = OBJECT_TYPE;
}
} }
else { else {
if (receiverIndex != -1) { throw new UnsupportedOperationException();
realReceiverType = codegen.typeMapper.mapType(receiverParameter.getType());
realReceiverIndex = receiverIndex;
}
else {
throw new UnsupportedOperationException();
}
} }
if (resolvedSetCall.getThisObject().exists()) { if (resolvedSetCall.getThisObject().exists()) {
@@ -764,8 +745,8 @@ public abstract class StackValue {
} }
int index = firstParamIndex; int index = firstParamIndex;
for (int i = 0; i != valueParameters.size(); ++i) { for (ValueParameterDescriptor valueParameter : valueParameters) {
Type type = codegen.typeMapper.mapType(valueParameters.get(i).getType()); Type type = codegen.typeMapper.mapType(valueParameter.getType());
int sz = type.getSize(); int sz = type.getSize();
v.load(index - sz, type); v.load(index - sz, type);
index -= sz; index -= sz;
@@ -777,23 +758,12 @@ public abstract class StackValue {
} }
if (receiverIndex != -1) { if (receiverIndex != -1) {
Type type = codegen.typeMapper.mapType(receiverParameter.getType()); v.load(receiverIndex - realReceiverType.getSize(), realReceiverType);
v.load(receiverIndex - type.getSize(), type);
}
if (firstTypeParamIndex != -1) {
index = firstTypeParamIndex;
for (int i = 0; i != typeParameters.size(); ++i) {
if (typeParameters.get(i).isReified()) {
v.load(index - 1, OBJECT_TYPE);
index--;
}
}
} }
index = firstParamIndex; index = firstParamIndex;
for (int i = 0; i != valueParameters.size(); ++i) { for (ValueParameterDescriptor valueParameter : valueParameters) {
Type type = codegen.typeMapper.mapType(valueParameters.get(i).getType()); Type type = codegen.typeMapper.mapType(valueParameter.getType());
int sz = type.getSize(); int sz = type.getSize();
v.load(index - sz, type); v.load(index - sz, type);
index -= sz; index -= sz;
@@ -809,12 +779,6 @@ public abstract class StackValue {
return true; return true;
} }
for (TypeParameterDescriptor typeParameterDescriptor : call.getResultingDescriptor().getTypeParameters()) {
if (typeParameterDescriptor.isReified()) {
return false;
}
}
List<ValueParameterDescriptor> valueParameters = call.getResultingDescriptor().getValueParameters(); List<ValueParameterDescriptor> valueParameters = call.getResultingDescriptor().getValueParameters();
if (valueParameters.size() != valueParamsSize) { if (valueParameters.size() != valueParamsSize) {
return false; return false;