]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/pre/QPreEquals.java
Databoard and SCL enchancements.
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / elaboration / query / pre / QPreEquals.java
1 package org.simantics.scl.compiler.elaboration.query.pre;
2
3 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
4 import org.simantics.scl.compiler.elaboration.expressions.Expression;
5 import org.simantics.scl.compiler.elaboration.expressions.QueryTransformer;
6 import org.simantics.scl.compiler.elaboration.java.EqRelation;
7 import org.simantics.scl.compiler.elaboration.query.QAtom;
8 import org.simantics.scl.compiler.elaboration.query.Query;
9 import org.simantics.scl.compiler.errors.Locations;
10
11 public class QPreEquals extends PreQuery {
12     public Expression left;
13     public Expression right;
14     
15     public QPreEquals(Expression left, Expression right) {
16         this.left = left;
17         this.right = right;
18     }
19
20     @Override
21     public Query resolve(TranslationContext context) {
22         PreQuery oldPreQuery = context.currentPreQuery;
23         context.currentPreQuery = this;
24         QAtom atom = new QAtom(EqRelation.INSTANCE, 
25                 new Expression[] {
26                 left.resolve(context), 
27                 right.resolve(context)});
28         context.currentPreQuery = oldPreQuery;
29         atom.location = location;
30         return withSideQueries(atom);
31     }
32     
33     @Override
34     public void setLocationDeep(long loc) {
35         if(location == Locations.NO_LOCATION) {
36             location = loc;
37             left.setLocationDeep(loc);
38             right.setLocationDeep(loc);
39         }
40     }
41     
42     @Override
43     public Query accept(QueryTransformer transformer) {
44         return transformer.transform(this);
45     }
46 }