]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/ssa/statements/LetApply.java
(refs #7771) Fixed invalid inline
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / internal / codegen / ssa / statements / LetApply.java
index 210e3ded3243fc20755dd4553dd19bd309f0d0ba..2733868cf06d312ac82f0a687840b4ca4a2420ff 100644 (file)
@@ -15,6 +15,7 @@ import org.simantics.scl.compiler.internal.codegen.ssa.SSAExit;
 import org.simantics.scl.compiler.internal.codegen.ssa.SSAFunction;
 import org.simantics.scl.compiler.internal.codegen.ssa.SSAStatement;
 import org.simantics.scl.compiler.internal.codegen.ssa.binders.BoundVarBinder;
+import org.simantics.scl.compiler.internal.codegen.ssa.binders.ClosureBinder;
 import org.simantics.scl.compiler.internal.codegen.ssa.binders.ValRefBinder;
 import org.simantics.scl.compiler.internal.codegen.ssa.exits.Jump;
 import org.simantics.scl.compiler.internal.codegen.ssa.exits.Switch;
@@ -30,8 +31,12 @@ import org.simantics.scl.compiler.types.Type;
 import org.simantics.scl.compiler.types.Types;
 import org.simantics.scl.compiler.types.exceptions.MatchException;
 import org.simantics.scl.compiler.types.util.MultiFunction;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class LetApply extends LetStatement implements ValRefBinder {
+    private static final Logger LOGGER = LoggerFactory.getLogger(LetApply.class);
+    
     private ValRef function;
     private ValRef[] parameters;
     Type effect;
@@ -356,8 +361,17 @@ public class LetApply extends LetStatement implements ValRefBinder {
                
         SSABlock headBlock = getParent();
         SSAFunction thisFunction = headBlock.getParent();
-        if(thisFunction == function)
-            return;
+        {
+            SSAFunction curParent=thisFunction;
+            while(true) {
+                if(curParent == function)
+                    return;
+                ClosureBinder binder = curParent.getParent();
+                if(binder == null)
+                    break;
+                curParent = binder.getParentFunction();
+            }
+        }
                
         /*System.out.println("--- INLINING -------------------------------");
         System.out.println(thisFunction);