]> gerrit.simantics Code Review - simantics/platform.git/blob
b26598927b9a9a2409e9ae5522822afba1948917
[simantics/platform.git] /
1 package org.simantics.scl.compiler.elaboration.chr.plan;
2
3 import org.simantics.scl.compiler.compilation.CompilationContext;
4 import org.simantics.scl.compiler.elaboration.expressions.Expression;
5 import org.simantics.scl.compiler.elaboration.expressions.Variable;
6 import org.simantics.scl.compiler.elaboration.relations.SCLRelation;
7 import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
8
9 public class IterateRelationOp extends PlanOp {
10     
11     public SCLRelation relation;
12     public Variable[] variables;
13     public Expression[] expressions;
14     public int boundMask;
15     
16     public IterateRelationOp(long location, SCLRelation relation, Variable[] variables, Expression[] expressions,
17             int boundMask) {
18         super(location);
19         this.relation = relation;
20         this.variables = variables;
21         this.expressions = expressions;
22         this.boundMask = boundMask;
23         
24     }
25
26     @Override
27     public void toString(StringBuilder b) {
28         b.append("ITERATE ").append(relation);
29         for(int i=0;i<expressions.length;++i)
30             if((boundMask & (1 << i)) != 0) {
31                 b.append(" (").append(expressions[i]).append(")");
32             }
33             else {
34                 b.append(" ").append(variables[i]);
35             }
36     }
37
38     @Override
39     public void generateCode(CompilationContext context, PlanContext planContext, CodeWriter w) {
40         relation.generateIterate(planContext, w, location, boundMask, variables, expressions);
41     }   
42 }