Shared var initialization moved to variable declaration generation
This commit is contained in:
@@ -935,7 +935,14 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
|
||||
final Type sharedVarType = typeMapper.getSharedVarType(variableDescriptor);
|
||||
final Type type = sharedVarType != null ? sharedVarType : asmType(variableDescriptor.getType());
|
||||
myFrameMap.enter(variableDescriptor, type.getSize());
|
||||
int index = myFrameMap.enter(variableDescriptor, type.getSize());
|
||||
|
||||
if (sharedVarType != null) {
|
||||
v.anew(sharedVarType);
|
||||
v.dup();
|
||||
v.invokespecial(sharedVarType.getInternalName(), "<init>", "()V");
|
||||
v.store(index, TYPE_OBJECT);
|
||||
}
|
||||
|
||||
leaveTasks.add(new Function<StackValue, Void>() {
|
||||
@Override
|
||||
@@ -2578,12 +2585,6 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
assert variableDescriptor != null;
|
||||
|
||||
Type varType = asmType(variableDescriptor.getType());
|
||||
if (sharedVarType != null) {
|
||||
v.anew(sharedVarType);
|
||||
v.dup();
|
||||
v.invokespecial(sharedVarType.getInternalName(), "<init>", "()V");
|
||||
v.store(index, TYPE_OBJECT);
|
||||
}
|
||||
|
||||
JetExpression initializer = property.getInitializer();
|
||||
if (initializer != null) {
|
||||
|
||||
@@ -34,10 +34,12 @@ public class FrameMap {
|
||||
private final TObjectIntHashMap<DeclarationDescriptor> myVarSizes = new TObjectIntHashMap<DeclarationDescriptor>();
|
||||
private int myMaxIndex = 0;
|
||||
|
||||
public void enter(DeclarationDescriptor descriptor, int size) {
|
||||
myVarIndex.put(descriptor, myMaxIndex);
|
||||
public int enter(DeclarationDescriptor descriptor, int size) {
|
||||
int index = myMaxIndex;
|
||||
myVarIndex.put(descriptor, index);
|
||||
myMaxIndex += size;
|
||||
myVarSizes.put(descriptor, size);
|
||||
return index;
|
||||
}
|
||||
|
||||
public int leave(DeclarationDescriptor descriptor) {
|
||||
|
||||
Reference in New Issue
Block a user