1 package org.simantics.scl.compiler.elaboration.chr.ast;
3 import java.util.ArrayList;
6 import org.simantics.scl.compiler.elaboration.chr.CHRLiteral;
7 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
9 public class CHRAstConjunction extends CHRAstQuery {
10 public List<CHRAstQuery> conjuncts;
12 public CHRAstConjunction(List<CHRAstQuery> conjuncts) {
13 this.conjuncts = conjuncts;
17 public void accept(CHRAstQueryVisitor visitor) {
21 public static CHRAstQuery conjunction(CHRAstQuery[] conjuncts) {
22 ArrayList<CHRAstQuery> result = new ArrayList<CHRAstQuery>(conjuncts.length);
23 for(CHRAstQuery conjunct : conjuncts) {
24 if(conjunct instanceof CHRAstConjunction)
25 result.addAll(((CHRAstConjunction)conjunct).conjuncts);
29 if(result.size() == 1)
32 return new CHRAstConjunction(result);
36 protected void translate(TranslationContext context, boolean isHead, ArrayList<CHRLiteral> literals) {
37 for(CHRAstQuery conjunct : conjuncts)
38 conjunct.translate(context, isHead, literals);