From: Hannu Niemistö Date: Wed, 25 Oct 2017 08:18:35 +0000 (+0300) Subject: (refs #7573) Provide typeable with functions with three effects X-Git-Tag: v1.31.0~96^2 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=fac333b05f9c2651dc8d164e51e1c3468c524415;p=simantics%2Fplatform.git (refs #7573) Provide typeable with functions with three effects Change-Id: Ieb45cab86a20080ac3c453c6e5cf37edb665cad4 --- diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/java/Builtins.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/java/Builtins.java index 631ef2ddc..4061b8652 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/java/Builtins.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/java/Builtins.java @@ -286,7 +286,12 @@ public class Builtins extends ConcreteModule { "union", Types.NO_EFFECTS, Type, Type, Type)); - + addValue("TUnion3", new JavaStaticMethod( + "org/simantics/scl/compiler/types/Types", + "union", + Types.NO_EFFECTS, + Type, Type, Type, Type)); + StandardTypeConstructor TypeC = new StandardTypeConstructor(Type, Kinds.STAR, TypeDesc.forClass("org/simantics/scl/compiler/types/Type")); TypeC.setType(Type); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/elaboration/constraints/ConstraintEnvironment.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/elaboration/constraints/ConstraintEnvironment.java index 72aa1ea9e..5479371a6 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/elaboration/constraints/ConstraintEnvironment.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/elaboration/constraints/ConstraintEnvironment.java @@ -107,6 +107,15 @@ public class ConstraintEnvironment { Types.pred(Types.TYPEABLE, union.effects[1]) }); } + else if(union.effects.length == 3) { + return new Reduction( + new EConstant(Builtins.INSTANCE.getValue("TUnion3")), + Type.EMPTY_ARRAY, new TPred[] { + Types.pred(Types.TYPEABLE, union.effects[0]), + Types.pred(Types.TYPEABLE, union.effects[1]), + Types.pred(Types.TYPEABLE, union.effects[2]) + }); + } } } diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/Types.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/Types.java index 1a6bdc257..50eec32fe 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/Types.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/Types.java @@ -1050,6 +1050,10 @@ public class Types { public static Type union(Type effect1, Type effect2) { return new TUnion(effect1, effect2); } + + public static Type union(Type effect1, Type effect2, Type effect3) { + return new TUnion(effect1, effect2, effect3); + } public static Type union(List effects) { if(effects.size() == 0)