From: Hannu Niemistö Date: Thu, 13 Apr 2017 10:08:54 +0000 (+0300) Subject: Declare effects for constants and variables X-Git-Tag: v1.29.0~111^2 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F10%2F410%2F2;p=simantics%2Fplatform.git Declare effects for constants and variables Effectful constants and variables now correctly declare their effects. refs #7140 [PRIVATE-13312] Change-Id: Ie40c3985ac61acb707293161b8aefb361d691732 --- diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EConstant.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EConstant.java index f951de737..502c4f369 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EConstant.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EConstant.java @@ -232,7 +232,7 @@ public class EConstant extends Expression { return this; } else - return applyPUnit(context.getCompilationContext()); + return applyPUnit(context); } @Override diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EVariable.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EVariable.java index 2e36b77db..a4010303c 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EVariable.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EVariable.java @@ -149,7 +149,7 @@ public class EVariable extends Expression { return this; } else - return applyPUnit(context.getCompilationContext()); + return applyPUnit(context); } @Override diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/Expression.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/Expression.java index 8adf33936..a0f28d190 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/Expression.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/Expression.java @@ -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; } }