validate state in FrameMap.leave
fix variable leave order
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.codegen;
|
package org.jetbrains.jet.codegen;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import com.intellij.openapi.editor.Document;
|
import com.intellij.openapi.editor.Document;
|
||||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
@@ -875,7 +876,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
Label blockEnd = new Label();
|
Label blockEnd = new Label();
|
||||||
v.mark(blockEnd);
|
v.mark(blockEnd);
|
||||||
|
|
||||||
for (JetElement statement : statements) {
|
for (JetElement statement : Lists.reverse(statements)) {
|
||||||
if(statement instanceof JetNamedFunction) {
|
if(statement instanceof JetNamedFunction) {
|
||||||
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, statement);
|
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, statement);
|
||||||
myFrameMap.leave(descriptor);
|
myFrameMap.leave(descriptor);
|
||||||
|
|||||||
@@ -41,7 +41,11 @@ public class FrameMap {
|
|||||||
int size = myVarSizes.get(descriptor);
|
int size = myVarSizes.get(descriptor);
|
||||||
myMaxIndex -= size;
|
myMaxIndex -= size;
|
||||||
myVarSizes.remove(descriptor);
|
myVarSizes.remove(descriptor);
|
||||||
return myVarIndex.remove(descriptor);
|
int oldIndex = myVarIndex.remove(descriptor);
|
||||||
|
if (oldIndex != myMaxIndex) {
|
||||||
|
throw new IllegalStateException("descriptor can be left only if it is last");
|
||||||
|
}
|
||||||
|
return oldIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int enterTemp() {
|
public int enterTemp() {
|
||||||
|
|||||||
Reference in New Issue
Block a user