From 6f75cd65e0ba87535a4b92003604f8f5fc94e9d5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Hannu=20Niemist=C3=B6?= Date: Thu, 13 Apr 2017 13:08:54 +0300 Subject: [PATCH] Declare effects for constants and variables Effectful constants and variables now correctly declare their effects. refs #7140 [PRIVATE-13312] Change-Id: Ie40c3985ac61acb707293161b8aefb361d691732 --- .../scl/compiler/elaboration/expressions/EConstant.java | 2 +- .../scl/compiler/elaboration/expressions/EVariable.java | 2 +- .../scl/compiler/elaboration/expressions/Expression.java | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) 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; } } -- 2.47.1