]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Declare effects for constants and variables 10/410/2
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Thu, 13 Apr 2017 10:08:54 +0000 (13:08 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Thu, 13 Apr 2017 11:10:09 +0000 (14:10 +0300)
Effectful constants and variables now correctly declare their effects.

refs #7140
[PRIVATE-13312]

Change-Id: Ie40c3985ac61acb707293161b8aefb361d691732

bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EConstant.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EVariable.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/Expression.java

index f951de7374a09dfb0577e154cd1eb6312d202ca1..502c4f3695e466e8e44ffe0260e85b53f01077ee 100644 (file)
@@ -232,7 +232,7 @@ public class EConstant extends Expression {
             return this;
         }
         else
-            return applyPUnit(context.getCompilationContext());
+            return applyPUnit(context);
     }
 
     @Override
index 2e36b77db49a36f25814eed428527cfe2c2488cc..a4010303ca75ed20a23cb12f7780cf3e70f2fad6 100644 (file)
@@ -149,7 +149,7 @@ public class EVariable extends Expression {
             return this;
         }
         else
-            return applyPUnit(context.getCompilationContext());
+            return applyPUnit(context);
     }
     
     @Override
index 8adf33936524d266115b25a0b706052b30e6ea9c..a0f28d190bf7340234ae5a052675f572f6275c10 100644 (file)
@@ -5,7 +5,6 @@ import java.util.ArrayList;
 import org.simantics.scl.compiler.common.exceptions.InternalCompilerError;
 import org.simantics.scl.compiler.common.precedence.Precedence;
 import org.simantics.scl.compiler.constants.NoRepConstant;
-import org.simantics.scl.compiler.elaboration.contexts.EnvironmentalContext;
 import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext;
 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
@@ -84,13 +83,14 @@ public abstract class Expression extends Symbol implements Typed {
         return context.subsume(inferType(context), requiredType);
     }
     
-    protected Expression applyPUnit(EnvironmentalContext context) {
+    protected Expression applyPUnit(TypingContext context) {
         Type type = Types.canonical(getType());
         if(type instanceof TFun) {
             TFun fun = (TFun)type;
             if(fun.getCanonicalDomain() == Types.PUNIT) {
                 EApply result = new EApply(location, this, new ELiteral(NoRepConstant.PUNIT));
                 result.effect = fun.getCanonicalEffect();
+                context.declareEffect(this.location, result.effect);
                 return result;
             }
         }