]> gerrit.simantics Code Review - simantics/platform.git/blob - 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
1 package org.simantics.scl.compiler.internal.elaboration.constraints2;
2
3 import org.simantics.scl.compiler.types.TPred;
4 import org.simantics.scl.compiler.types.util.TypeUnparsingContext;
5
6 public class ConstraintHandle {
7     public final TPred constraint;
8     public final long demandLocation;
9     private ConstraintResolution resolution;
10     
11     public ConstraintHandle(TPred constraint, long demandLocation) {
12         this.constraint = constraint;
13         this.demandLocation = demandLocation;
14     }
15     
16     public ConstraintResolution getResolution() {
17         return resolution;
18     }
19
20     public void setResolution(ConstraintResolution newResolution) {
21         if(resolution == null || newResolution.priority > resolution.priority)
22             resolution = newResolution;
23     }
24
25     public String toString(TypeUnparsingContext tuc) {
26         return constraint.toString(tuc) +  (resolution != null ? " <= " + resolution.toString(tuc) : "");
27     }
28 }