]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/pre/QPreBinds.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / elaboration / query / pre / QPreBinds.java
diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/pre/QPreBinds.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/pre/QPreBinds.java
new file mode 100644 (file)
index 0000000..3f9af04
--- /dev/null
@@ -0,0 +1,46 @@
+package org.simantics.scl.compiler.elaboration.query.pre;
+
+import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
+import org.simantics.scl.compiler.elaboration.expressions.Expression;
+import org.simantics.scl.compiler.elaboration.expressions.QueryTransformer;
+import org.simantics.scl.compiler.elaboration.java.MemberRelation;
+import org.simantics.scl.compiler.elaboration.query.QAtom;
+import org.simantics.scl.compiler.elaboration.query.Query;
+import org.simantics.scl.compiler.errors.Locations;
+
+public class QPreBinds extends PreQuery {
+    public Expression left;
+    public Expression right;
+    
+    public QPreBinds(Expression left, Expression right) {
+        this.left = left;
+        this.right = right;
+    }
+
+    @Override
+    public Query resolve(TranslationContext context) {
+        PreQuery oldPreQuery = context.currentPreQuery;
+        context.currentPreQuery = this;
+        QAtom atom = new QAtom(MemberRelation.INSTANCE, 
+                new Expression[] {
+                left.resolve(context), 
+                right.resolve(context)});
+        context.currentPreQuery = oldPreQuery;
+        atom.location = location;
+        return withSideQueries(atom);
+    }
+    
+    @Override
+    public void setLocationDeep(long loc) {
+        if(location == Locations.NO_LOCATION) {
+            location = loc;
+            left.setLocationDeep(loc);
+            right.setLocationDeep(loc);
+        }
+    }
+    
+    @Override
+    public Query accept(QueryTransformer transformer) {
+        return transformer.transform(this);
+    }
+}