]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
(refs #7573) Provide typeable with functions with three effects 41/1141/2
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Wed, 25 Oct 2017 08:18:35 +0000 (11:18 +0300)
committerHannu Niemistö <hannu.niemisto@semantum.fi>
Wed, 25 Oct 2017 08:20:26 +0000 (11:20 +0300)
Change-Id: Ieb45cab86a20080ac3c453c6e5cf37edb665cad4

bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/java/Builtins.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/elaboration/constraints/ConstraintEnvironment.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/Types.java

index 631ef2ddc6d7ac874ca073c6b5c6b4363579a488..4061b86525afe895c40e35eec063cb19a864e2e2 100644 (file)
@@ -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);
index 72aa1ea9e09e627c441125cfb16048c91d0d7993..5479371a64098dacd6da68aafb83f2a180431995 100644 (file)
@@ -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])
+                            });
+                }
             }
         }
         
index 1a6bdc257a5ce6d2f995eaa0e0a42609c56d04fe..50eec32fe29e9f8c37209f91eba6e2709f88aa59 100644 (file)
@@ -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<Type> effects) {
         if(effects.size() == 0)