From fac333b05f9c2651dc8d164e51e1c3468c524415 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Hannu=20Niemist=C3=B6?= Date: Wed, 25 Oct 2017 11:18:35 +0300 Subject: [PATCH] (refs #7573) Provide typeable with functions with three effects Change-Id: Ieb45cab86a20080ac3c453c6e5cf37edb665cad4 --- .../scl/compiler/elaboration/java/Builtins.java | 7 ++++++- .../elaboration/constraints/ConstraintEnvironment.java | 9 +++++++++ .../src/org/simantics/scl/compiler/types/Types.java | 4 ++++ 3 files changed, 19 insertions(+), 1 deletion(-) 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) -- 2.43.2