1 package org.simantics.scl.compiler.internal.elaboration.constraints2;
3 import gnu.trove.map.hash.THashMap;
4 import gnu.trove.procedure.TObjectObjectProcedure;
6 import org.simantics.scl.compiler.environment.Environment;
7 import org.simantics.scl.compiler.types.TCon;
8 import org.simantics.scl.compiler.types.TPred;
9 import org.simantics.scl.compiler.types.util.TypeUnparsingContext;
11 public class ConstraintSolver {
12 final Environment environment;
13 private final THashMap<TCon, ConstraintStore> constraintStores =
14 new THashMap<TCon, ConstraintStore>();
16 public ConstraintSolver(Environment environment) {
17 this.environment = environment;
20 private ConstraintStore getConstraintStore(TCon typeClass) {
21 ConstraintStore store = constraintStores.get(typeClass);
23 store = new ConstraintStore(this, typeClass);
24 constraintStores.put(typeClass, store);
29 public ConstraintHandle addDemand(TPred pred, long location) {
30 return getConstraintStore(pred.typeClass).addConstraint(pred, location);
34 final TypeUnparsingContext tuc = new TypeUnparsingContext();
35 constraintStores.forEachEntry(new TObjectObjectProcedure<TCon, ConstraintStore>() {
37 public boolean execute(TCon pred, ConstraintStore store) {