1 package org.simantics.scl.compiler.elaboration.expressions.list;
3 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
4 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
5 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
6 import org.simantics.scl.compiler.elaboration.expressions.Expression;
7 import org.simantics.scl.compiler.elaboration.expressions.Variable;
8 import org.simantics.scl.compiler.errors.Locations;
10 import gnu.trove.map.hash.TObjectIntHashMap;
11 import gnu.trove.set.hash.TIntHashSet;
13 public class ListSeq extends ListQualifier {
14 public ListQualifier a;
15 public ListQualifier b;
17 public ListSeq(ListQualifier a, ListQualifier b) {
23 public void checkType(TypingContext context) {
29 public void collectVars(TObjectIntHashMap<Variable> allVars,
31 a.collectVars(allVars, vars);
32 b.collectVars(allVars, vars);
36 public CompiledQualifier compile(SimplificationContext context) {
37 CompiledQualifier cA = a.compile(context);
38 CompiledQualifier cB = b.compile(context);
40 Variable x = new Variable("xTemp", cA.pattern.getType());
41 Variable y = new Variable("yTemp", cB.pattern.getType());
43 Expression value = context.concatMap(
44 context.lambda(context.var(x), context.mapList(
45 context.lambda(context.var(y), context.tuple(context.var(x), context.var(y))),
46 context.match(context.var(x), cA.pattern, cB.value))),
49 value.validateType(context.getEnvironment());
50 } catch (TypeValidationException e) {
53 return new CompiledQualifier(value, context.tuple(cA.pattern, cB.pattern));
57 public void resolve(TranslationContext context) {
63 public void setLocationDeep(long loc) {
64 if(location == Locations.NO_LOCATION) {
66 a.setLocationDeep(loc);
67 b.setLocationDeep(loc);
72 public void accept(ListQualifierVisitor visitor) {
77 public ListQualifier accept(ListQualifierTransformer transformer) {
78 return transformer.transform(this);