1 package org.simantics.scl.compiler.elaboration.query.compilation;
3 import gnu.trove.impl.Constants;
4 import gnu.trove.map.hash.TObjectIntHashMap;
6 import java.util.ArrayList;
8 import org.simantics.scl.compiler.elaboration.expressions.Variable;
10 public class ConstraintCollectionContext {
11 QueryCompilationContext context;
12 ArrayList<Variable> variables = new ArrayList<Variable>();
13 TObjectIntHashMap<Variable> variableMap = new TObjectIntHashMap<Variable>(
14 Constants.DEFAULT_CAPACITY, Constants.DEFAULT_LOAD_FACTOR, -1);
15 ArrayList<QueryConstraint> constraints = new ArrayList<QueryConstraint>();
17 public ConstraintCollectionContext(QueryCompilationContext context) {
18 this.context = context;
21 public int addVariable(Variable variable) {
22 int id = variables.size();
23 variables.add(variable);
24 variableMap.put(variable, id);
28 public TObjectIntHashMap<Variable> getVariableMap() {
32 public void addConstraint(QueryConstraint constraint) {
33 constraints.add(constraint);
36 public QueryConstraint[] getConstraints() {
37 return constraints.toArray(new QueryConstraint[constraints.size()]);
40 public QueryCompilationContext getQueryCompilationContext() {
44 public Variable getVariable(int id) {
45 return variables.get(id);