]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/elaboration/constraints2/ConstraintHandle.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / internal / elaboration / constraints2 / ConstraintHandle.java
diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/elaboration/constraints2/ConstraintHandle.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/elaboration/constraints2/ConstraintHandle.java
new file mode 100644 (file)
index 0000000..4699505
--- /dev/null
@@ -0,0 +1,28 @@
+package org.simantics.scl.compiler.internal.elaboration.constraints2;
+
+import org.simantics.scl.compiler.types.TPred;
+import org.simantics.scl.compiler.types.util.TypeUnparsingContext;
+
+public class ConstraintHandle {
+    public final TPred constraint;
+    public final long demandLocation;
+    private ConstraintResolution resolution;
+    
+    public ConstraintHandle(TPred constraint, long demandLocation) {
+        this.constraint = constraint;
+        this.demandLocation = demandLocation;
+    }
+    
+    public ConstraintResolution getResolution() {
+        return resolution;
+    }
+
+    public void setResolution(ConstraintResolution newResolution) {
+        if(resolution == null || newResolution.priority > resolution.priority)
+            resolution = newResolution;
+    }
+
+    public String toString(TypeUnparsingContext tuc) {
+        return constraint.toString(tuc) +  (resolution != null ? " <= " + resolution.toString(tuc) : "");
+    }
+}