import org.simantics.scl.compiler.elaboration.expressions.ERecord;
import org.simantics.scl.compiler.elaboration.expressions.Expression;
import org.simantics.scl.compiler.elaboration.expressions.Variable;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.elaboration.expressions.printing.ExpressionToStringVisitor;
import org.simantics.scl.compiler.elaboration.expressions.records.FieldAssignment;
import org.simantics.scl.compiler.elaboration.relations.SCLRelation;
parameter.collectVars(allVars, vars);
}
- public void forVariables(VariableProcedure procedure) {
- for(Expression parameter : parameters)
- parameter.forVariables(procedure);
- if(typeConstraintEvidenceParameters != null)
- for(Expression parameter : typeConstraintEvidenceParameters)
- parameter.forVariables(procedure);
- }
-
public void collectFreeVariables(THashSet<Variable> vars) {
if(relation == SpecialCHRRelation.ASSIGN) {
parameters[1].collectFreeVariables(vars);
import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
import org.simantics.scl.compiler.elaboration.expressions.Expression;
import org.simantics.scl.compiler.elaboration.expressions.Variable;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.elaboration.expressions.printing.ExpressionToStringVisitor;
import org.simantics.scl.compiler.errors.Locations;
import org.simantics.scl.compiler.internal.parsing.Symbol;
literal.collectVars(allVars, vars);
}
- public void forVariables(VariableProcedure procedure) {
- for(CHRLiteral literal : literals)
- literal.forVariables(procedure);
- }
-
public void collectFreeVariables(THashSet<Variable> vars) {
for(CHRLiteral literal : literals)
literal.collectFreeVariables(vars);
import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
import org.simantics.scl.compiler.elaboration.expressions.EVariable;
import org.simantics.scl.compiler.elaboration.expressions.Variable;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.elaboration.expressions.printing.ExpressionToStringVisitor;
import org.simantics.scl.compiler.errors.Locations;
import org.simantics.scl.compiler.internal.parsing.Symbol;
body.collectVars(allVars, vars);
}
- public void forVariables(VariableProcedure procedure) {
- head.forVariables(procedure);
- body.forVariables(procedure);
- }
-
public void collectFreeVariables(THashSet<Variable> vars) {
head.collectFreeVariables(vars);
body.collectFreeVariables(vars);
import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
import org.simantics.scl.compiler.elaboration.expressions.Variable;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.elaboration.expressions.block.IncludeStatement;
import org.simantics.scl.compiler.environment.AmbiguousNameException;
import org.simantics.scl.compiler.errors.Locations;
rule.collectVars(allVars, vars);
}
- public void forVariables(VariableProcedure procedure) {
- for(IncludeStatement include : includes)
- include.value.forVariables(procedure);
- for(CHRRule rule : rules)
- rule.forVariables(procedure);
- }
-
public void collectFreeVariables(THashSet<Variable> vars) {
for(IncludeStatement include : includes)
include.value.collectFreeVariables(vars);
variable.setVal(expression.toVal(context, w));
planContext.nextOp(w);
}
-
-
}
import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
import org.simantics.scl.compiler.elaboration.expressions.Expression;
import org.simantics.scl.compiler.elaboration.expressions.Variable;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.errors.Locations;
import org.simantics.scl.compiler.types.Type;
}
}
- @Override
- public void forVariables(VariableProcedure procedure) {
- left.forVariables(procedure);
- right.forVariables(procedure);
- }
-
@Override
public void collectFreeVariables(THashSet<Variable> vars) {
left.collectFreeVariables(vars);
}
}
- @Override
- public void forVariables(VariableProcedure procedure) {
- guard.forVariables(procedure);
- }
-
@Override
public void collectFreeVariables(THashSet<Variable> vars) {
guard.collectFreeVariables(vars);
public abstract void setLocationDeep(long loc);
- public abstract void forVariables(VariableProcedure procedure);
public abstract void collectFreeVariables(THashSet<Variable> vars);
public abstract void collectEffects(THashSet<Type> effects);
public abstract void checkType(TypingContext context);
getClass().getSimpleName() + " does not implement method inferType.");
}
- @Override
- public void forVariables(VariableProcedure procedure) {
- throw new InternalCompilerError("Class " +
- getClass().getSimpleName() + " does not implement method forVariables.");
- }
-
@Override
public void setLocationDeep(long loc) {
if(location == Locations.NO_LOCATION)
pattern.setLocationDeep(loc);
value.setLocationDeep(loc);
}
-
- public void forVariables(VariableProcedure procedure) {
- value.forVariables(procedure);
- }
}
patterns[i] = patterns[i].checkTypeAsPattern(context, parameterTypes[i]);
value = value.checkIgnoredType(context);
}
-
- public void forVariables(VariableProcedure procedure) {
- value.forVariables(procedure);
- }
}
}
}
- @Override
- public void forVariables(VariableProcedure procedure) {
- expression.forVariables(procedure);
- }
-
@Override
public IVal toVal(CompilationContext context, CodeWriter w) {
throw new InternalCompilerError("Cannot generate code for " + getClass().getSimpleName() + ".");
TIntHashSet vars) {
}
- @Override
- public void forVariables(VariableProcedure procedure) {
- }
-
@Override
protected void updateType() throws MatchException {
throw new InternalCompilerError();
return false;
}
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- function.forVariables(procedure);
- for(Expression parameter : parameters)
- parameter.forVariables(procedure);
- }
@Override
public boolean isPattern(int arity) {
public void accept(ExpressionVisitor visitor) {
visitor.visit(this);
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- expression.forVariables(procedure);
- }
@Override
public Expression accept(ExpressionTransformer transformer) {
public class EAsPattern extends Expression {
- Variable var;
- EVar eVar;
- Expression pattern;
+ public Variable var;
+ public EVar eVar;
+ public Expression pattern;
public EAsPattern(EVar eVar, Expression pattern) {
this.eVar = eVar;
public void accept(ExpressionVisitor visitor) {
visitor.visit(this);
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- procedure.execute(eVar.location, var);
- pattern.forVariables(procedure);
- }
@Override
public Expression accept(ExpressionTransformer transformer) {
public Expression pattern;
public Expression value;
public Expression in;
- private EVariable monadEvidence;
+ EVariable monadEvidence;
SCLValue bindFunction;
Type monadType;
Type valueContentType;
public void accept(ExpressionVisitor visitor) {
visitor.visit(this);
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- pattern.forVariables(procedure);
- value.forVariables(procedure);
- if(monadEvidence != null)
- monadEvidence.forVariables(procedure);
- }
@Override
public Expression accept(ExpressionTransformer transformer) {
in.collectVars(allVars, vars);
}
@Override
- public void forVariables(VariableProcedure procedure) {
- ruleset.forVariables(procedure);
- in.forVariables(procedure);
- }
- @Override
protected void updateType() throws MatchException {
setType(in.getType());
}
ruleset.collectVars(allVars, vars);
}
@Override
- public void forVariables(VariableProcedure procedure) {
- ruleset.forVariables(procedure);
- }
- @Override
protected void updateType() throws MatchException {
throw new InternalCompilerError("Type of ECHRRulesetConstructor should be already given.");
}
expression.collectVars(allVars, vars);
}
- @Override
- public void forVariables(VariableProcedure procedure) {
- query.forVariables(procedure);
- expression.forVariables(procedure);
- }
-
@Override
protected void updateType() throws MatchException {
setType(Types.list(expression.getType()));
public Precedence getPrecedence() {
return value.getPrecedence();
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- }
@Override
public boolean isPattern(int arity) {
public void accept(ExpressionVisitor visitor) {
visitor.visit(this);
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- query.forVariables(procedure);
- }
@Override
public Expression replace(ReplaceContext context) {
equation.collectVars(allVars, vars);
}
- @Override
- public void forVariables(VariableProcedure procedure) {
- for(Equation equation : equations)
- equation.forVariables(procedure);
- }
-
@Override
protected void updateType() throws MatchException {
setType(Types.UNIT);
public Expression replace(ReplaceContext context) {
return this;
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- }
@Override
public Expression accept(ExpressionTransformer transformer) {
public IExpression toIExpression(ExpressionInterpretationContext context) {
return new IConstant(value);
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- }
@Override
public Expression accept(ExpressionTransformer transformer) {
public void accept(ExpressionVisitor visitor) {
visitor.visit(this);
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- parent.forVariables(procedure);
- accessor.forVariables(procedure);
- }
@Override
public Expression accept(ExpressionTransformer transformer) {
public void accept(ExpressionVisitor visitor) {
visitor.visit(this);
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- evidence.forVariables(procedure);
- }
@Override
public Expression accept(ExpressionTransformer transformer) {
else_ != null ? else_.toIExpression(target) : new IConstant(Tuple0.INSTANCE));
}
- @Override
- public void forVariables(VariableProcedure procedure) {
- condition.forVariables(procedure);
- then_.forVariables(procedure);
- if(else_ != null)
- else_.forVariables(procedure);
- }
@Override
public Expression accept(ExpressionTransformer transformer) {
return transformer.transform(this);
public void accept(ExpressionVisitor visitor) {
visitor.visit(this);
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- if(constraint != null)
- constraint.forVariables(procedure);
- }
@Override
public boolean isPattern(int arity) {
public void accept(ExpressionVisitor visitor) {
visitor.visit(this);
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- for(Case case_ : cases)
- case_.forVariables(procedure);
- }
@Override
public Expression accept(ExpressionTransformer transformer) {
public void accept(ExpressionVisitor visitor) {
visitor.visit(this);
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- value.forVariables(procedure);
- }
@Override
public Expression accept(ExpressionTransformer transformer) {
public void accept(ExpressionVisitor visitor) {
visitor.visit(this);
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- for(Assignment assignment : assignments)
- assignment.forVariables(procedure);
- in.forVariables(procedure);
- }
@Override
public Expression accept(ExpressionTransformer transformer) {
public void accept(ExpressionVisitor visitor) {
visitor.visit(this);
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- head.forVariables(procedure);
- qualifier.forVariables(procedure);
- }
@Override
public Expression accept(ExpressionTransformer transformer) {
componentExpressions[i] = components[i].toIExpression(target);
return new IListLiteral(componentExpressions);
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- for(Expression component : components)
- component.forVariables(procedure);
- }
@Override
public Expression replace(ReplaceContext context) {
public void accept(ExpressionVisitor visitor) {
visitor.visit(this);
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- }
@Override
public boolean isPattern(int arity) {
public Case[] getCases() {
return cases;
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- for(Expression s : scrutinee)
- s.forVariables(procedure);
- for(Case case_ : cases)
- case_.forVariables(procedure);
- }
@Override
public Expression accept(ExpressionTransformer transformer) {
public String getValue() {
return value;
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- if(constraint != null)
- constraint.forVariables(procedure);
- }
@Override
public Expression accept(ExpressionTransformer transformer) {
visitor.visit(this);
return b.toString();
}
-
- public void forVariables(VariableProcedure procedure) {
- for(Expression headParameter : headParameters)
- headParameter.forVariables(procedure);
- body.forVariables(procedure);
- }
}
private void checkRuleTypes(TypingContext context) {
public Expression getIn() {
return in;
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- for(DatalogRule rule : rules)
- rule.forVariables(procedure);
- in.forVariables(procedure);
- }
@Override
public Expression accept(ExpressionTransformer transformer) {
public void accept(ExpressionVisitor visitor) {
visitor.visit(this);
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- expression.forVariables(procedure);
- query.forVariables(procedure);
- }
@Override
public Expression simplify(SimplificationContext context) {
public Variable getParameter() {
return parameter;
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- value.forVariables(procedure);
- }
@Override
public Expression accept(ExpressionTransformer transformer) {
return in;
}
- @Override
- public void forVariables(VariableProcedure procedure) {
- value.forVariables(procedure);
- in.forVariables(procedure);
- }
-
@Override
public Expression accept(ExpressionTransformer transformer) {
return transformer.transform(this);
public void accept(ExpressionVisitor visitor) {
visitor.visit(this);
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- seed.forVariables(procedure);
- }
@Override
public Expression accept(ExpressionTransformer transformer) {
public Expression getValue() {
return value;
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- value.forVariables(procedure);
- }
@Override
public Expression accept(ExpressionTransformer transformer) {
public class EVariable extends Expression {
public static final EVariable[] EMPTY_ARRAY = new EVariable[0];
- Variable variable;
+ public Variable variable;
public EVariable(Variable variable) {
this.variable = variable;
public void accept(ExpressionVisitor visitor) {
visitor.visit(this);
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- if(variable != null)
- procedure.execute(location, variable);
- }
@Override
public boolean isPattern(int arity) {
expression.collectVars(allVars, vars);
pattern.collectVars(allVars, vars);
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- expression.forVariables(procedure);
- pattern.forVariables(procedure);
- }
@Override
public Expression inferType(TypingContext context) {
public Expression getAction() {
return action;
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- query.forVariables(procedure);
- action.forVariables(procedure);
- }
@Override
public Expression simplify(SimplificationContext context) {
import org.simantics.scl.compiler.elaboration.expressions.lhstype.LhsType;
import org.simantics.scl.compiler.elaboration.expressions.lhstype.PatternMatchingLhs;
import org.simantics.scl.compiler.elaboration.expressions.printing.ExpressionToStringVisitor;
+import org.simantics.scl.compiler.elaboration.expressions.visitors.ForVariablesUsesVisitor;
import org.simantics.scl.compiler.elaboration.query.QAtom;
import org.simantics.scl.compiler.elaboration.relations.SCLRelation;
import org.simantics.scl.compiler.internal.codegen.references.IVal;
public abstract void collectRefs(TObjectIntHashMap<Object> allRefs, TIntHashSet refs);
public abstract void collectVars(TObjectIntHashMap<Variable> allVars, TIntHashSet vars);
- public abstract void forVariables(VariableProcedure procedure);
-
- public Expression decomposeMatching() {
+
+ public void forVariableUses(VariableProcedure procedure) {
+ accept(new ForVariablesUsesVisitor(procedure));
+ }
+
+ public Expression decomposeMatching() {
return this;
}
value.setLocationDeep(loc);
}
}
-
- public void forVariables(VariableProcedure procedure) {
- for(Expression guard : guards)
- guard.forVariables(procedure);
- value.forVariables(procedure);
- }
}
visitor.visit(this);
}
- @Override
- public void forVariables(VariableProcedure procedure) {
- for(GuardedExpression expression : expressions)
- expression.forVariables(procedure);
- }
-
@Override
public Expression accept(ExpressionTransformer transformer) {
return transformer.transform(this);
expression.pattern.accept(this);
expression.value.accept(this);
expression.in.accept(this);
+ if(expression.monadEvidence != null)
+ visit(expression.monadEvidence);
}
@Override
public void visit(ELet expression) {
for(Assignment assignment : expression.assignments)
visit(assignment);
+ expression.in.accept(this);
}
public void visit(Assignment assignment) {
visit(rule.head);
visit(rule.body);
}
+ for(IncludeStatement include : ruleset.includes)
+ include.value.accept(this);
}
@Override
import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
import org.simantics.scl.compiler.elaboration.expressions.Expression;
import org.simantics.scl.compiler.elaboration.expressions.Variable;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.errors.Locations;
import org.simantics.scl.compiler.types.Types;
public void accept(FieldAccessorVisitor visitor) {
visitor.visit(this);
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- fieldName.forVariables(procedure);
- }
}
import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
import org.simantics.scl.compiler.elaboration.expressions.Expression;
import org.simantics.scl.compiler.elaboration.expressions.Variable;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.internal.parsing.Symbol;
import gnu.trove.map.hash.TObjectIntHashMap;
public abstract void setLocationDeep(long loc);
public abstract void accept(FieldAccessorVisitor visitor);
-
- public abstract void forVariables(VariableProcedure procedure);
}
import org.simantics.scl.compiler.constants.StringConstant;
import org.simantics.scl.compiler.elaboration.expressions.ELiteral;
import org.simantics.scl.compiler.elaboration.expressions.Expression;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.errors.Locations;
public class IdAccessor extends FieldAccessor {
public void accept(FieldAccessorVisitor visitor) {
visitor.visit(this);
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- }
}
import org.simantics.scl.compiler.constants.StringConstant;
import org.simantics.scl.compiler.elaboration.expressions.ELiteral;
import org.simantics.scl.compiler.elaboration.expressions.Expression;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.errors.Locations;
public class StringAccessor extends FieldAccessor {
public void accept(FieldAccessorVisitor visitor) {
visitor.visit(this);
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- }
}
import org.simantics.scl.compiler.elaboration.expressions.EVariable;
import org.simantics.scl.compiler.elaboration.expressions.Expression;
import org.simantics.scl.compiler.elaboration.expressions.Variable;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.errors.Locations;
import org.simantics.scl.compiler.types.Type;
visitor.visit(this);
}
- @Override
- public void forVariables(VariableProcedure procedure) {
- value.forVariables(procedure);
- }
-
@Override
public ListQualifier accept(ListQualifierTransformer transformer) {
return transformer.transform(this);
import org.simantics.scl.compiler.elaboration.expressions.EVariable;
import org.simantics.scl.compiler.elaboration.expressions.Expression;
import org.simantics.scl.compiler.elaboration.expressions.Variable;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.errors.Locations;
import org.simantics.scl.compiler.types.TMetaVar;
import org.simantics.scl.compiler.types.Type;
visitor.visit(this);
}
- @Override
- public void forVariables(VariableProcedure procedure) {
- value.forVariables(procedure);
- }
-
@Override
public ListQualifier accept(ListQualifierTransformer transformer) {
return transformer.transform(this);
import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
import org.simantics.scl.compiler.elaboration.expressions.Expression;
import org.simantics.scl.compiler.elaboration.expressions.Variable;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.errors.Locations;
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
visitor.visit(this);
}
- @Override
- public void forVariables(VariableProcedure procedure) {
- condition.forVariables(procedure);
- }
-
@Override
public ListQualifier accept(ListQualifierTransformer transformer) {
return transformer.transform(this);
import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
import org.simantics.scl.compiler.elaboration.expressions.Variable;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.internal.parsing.Symbol;
import org.simantics.scl.compiler.types.Type;
public abstract void setLocationDeep(long loc);
public abstract void accept(ListQualifierVisitor visitor);
public abstract ListQualifier accept(ListQualifierTransformer transformer);
- public abstract void forVariables(VariableProcedure procedure);
}
import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
import org.simantics.scl.compiler.elaboration.expressions.Expression;
import org.simantics.scl.compiler.elaboration.expressions.Variable;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.errors.Locations;
import org.simantics.scl.compiler.types.Type;
visitor.visit(this);
}
- @Override
- public void forVariables(VariableProcedure procedure) {
- a.forVariables(procedure);
- b.forVariables(procedure);
- }
-
@Override
public ListQualifier accept(ListQualifierTransformer transformer) {
return transformer.transform(this);
import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
import org.simantics.scl.compiler.elaboration.expressions.Expression;
import org.simantics.scl.compiler.elaboration.expressions.Variable;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.errors.Locations;
import org.simantics.scl.compiler.types.TMetaVar;
import org.simantics.scl.compiler.types.Type;
public void accept(ListQualifierVisitor visitor) {
visitor.visit(this);
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- left.forVariables(procedure);
- transformer.forVariables(procedure);
- if(by != null)
- by.forVariables(procedure);
- }
@Override
public ListQualifier accept(ListQualifierTransformer transformer) {
--- /dev/null
+package org.simantics.scl.compiler.elaboration.expressions.visitors;
+
+import org.simantics.scl.compiler.elaboration.expressions.EAsPattern;
+import org.simantics.scl.compiler.elaboration.expressions.EVariable;
+import org.simantics.scl.compiler.elaboration.expressions.StandardExpressionVisitor;
+import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
+
+public class ForVariablesUsesVisitor extends StandardExpressionVisitor {
+ VariableProcedure procedure;
+
+ public ForVariablesUsesVisitor(VariableProcedure procedure) {
+ this.procedure = procedure;
+ }
+
+ @Override
+ public void visit(EVariable expression) {
+ if(expression.variable != null)
+ procedure.execute(expression.location, expression.variable);
+ }
+ @Override
+ public void visit(EAsPattern expression) {
+ expression.pattern.accept(this);
+ procedure.execute(expression.eVar.location, expression.var);
+ }
+}
import org.simantics.scl.compiler.elaboration.expressions.EVar;
import org.simantics.scl.compiler.elaboration.expressions.Expression;
import org.simantics.scl.compiler.elaboration.expressions.Variable;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.elaboration.query.pre.QPreExists;
import org.simantics.scl.compiler.elaboration.query.pre.QPreGuard;
import org.simantics.scl.compiler.errors.Locations;
query.setLocationDeep(loc);
}
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- for(Query query : queries)
- query.forVariables(procedure);
- }
}
import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
import org.simantics.scl.compiler.elaboration.expressions.Variable;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.errors.Locations;
import gnu.trove.map.hash.TObjectIntHashMap;
query.setLocationDeep(loc);
}
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- query.forVariables(procedure);
- }
}
}
else {
optionalVariableByParameter[i] = -1;
- parameter.forVariables(procedure);
+ parameter.forVariableUses(procedure);
}
}
}
visitor.visit(this);
}
- @Override
- public void forVariables(VariableProcedure procedure) {
- for(Expression parameter : parameters)
- parameter.forVariables(procedure);
- }
-
@Override
public void splitToPhases(TIntObjectHashMap<ArrayList<Query>> result) {
int phase = relation.getPhase();
import org.simantics.scl.compiler.elaboration.expressions.EVariable;
import org.simantics.scl.compiler.elaboration.expressions.QueryTransformer;
import org.simantics.scl.compiler.elaboration.expressions.Variable;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.elaboration.query.compilation.ConstraintCollectionContext;
import org.simantics.scl.compiler.elaboration.query.compilation.DerivateException;
import org.simantics.scl.compiler.elaboration.query.compilation.UnsolvableQueryException;
visitor.visit(this);
}
- @Override
- public void forVariables(VariableProcedure procedure) {
- for(Variable variable : variables)
- procedure.execute(location, variable);
- super.forVariables(procedure);
- }
-
@Override
public Query accept(QueryTransformer transformer) {
return transformer.transform(this);
import org.simantics.scl.compiler.elaboration.expressions.Expression;
import org.simantics.scl.compiler.elaboration.expressions.QueryTransformer;
import org.simantics.scl.compiler.elaboration.expressions.Variable;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.elaboration.query.compilation.ConstraintCollectionContext;
import org.simantics.scl.compiler.elaboration.query.compilation.UnsolvableQueryException;
import org.simantics.scl.compiler.errors.Locations;
public void accept(QueryVisitor visitor) {
visitor.visit(this);
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- condition.forVariables(procedure);
- elseQuery.forVariables(procedure);
- thenQuery.forVariables(procedure);
- }
@Override
public Query accept(QueryTransformer transformer) {
import org.simantics.scl.compiler.elaboration.expressions.Expression;
import org.simantics.scl.compiler.elaboration.expressions.QueryTransformer;
import org.simantics.scl.compiler.elaboration.expressions.Variable;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.elaboration.query.compilation.ConstraintCollectionContext;
import org.simantics.scl.compiler.elaboration.query.compilation.UnsolvableQueryException;
import org.simantics.scl.compiler.elaboration.rules.MappingRelation;
public void accept(QueryVisitor visitor) {
visitor.visit(this);
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- for(Expression parameter : parameters)
- parameter.forVariables(procedure);
- }
@Override
public Query accept(QueryTransformer transformer) {
import org.simantics.scl.compiler.elaboration.expressions.Variable;
import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.elaboration.expressions.printing.ExpressionToStringVisitor;
+import org.simantics.scl.compiler.elaboration.expressions.visitors.ForVariablesUsesVisitor;
import org.simantics.scl.compiler.elaboration.query.compilation.ConstraintCollectionContext;
import org.simantics.scl.compiler.elaboration.query.compilation.DerivateException;
import org.simantics.scl.compiler.elaboration.query.compilation.DynamicProgrammingOrdering;
});
}
- public abstract void forVariables(VariableProcedure procedure);
-
public TIntObjectHashMap<ArrayList<Query>> splitToPhases() {
TIntObjectHashMap<ArrayList<Query>> result = new TIntObjectHashMap<ArrayList<Query>>(2);
splitToPhases(result);
}
public abstract Query accept(QueryTransformer transformer);
+
+ public void forVariables(VariableProcedure procedure) {
+ accept(new ForVariablesUsesVisitor(procedure));
+ }
}
query = new QExists(extraVariables.toArray(new Variable[extraVariables.size()]), query);
return query;
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- throw new InternalCompilerError(location, getClass().getSimpleName() + " does not support forVariables.");
- }
}
import static org.simantics.scl.compiler.elaboration.expressions.Expressions.tuple;
import static org.simantics.scl.compiler.elaboration.expressions.Expressions.var;
-import org.simantics.scl.compiler.common.names.Name;
import org.simantics.scl.compiler.common.names.Names;
import org.simantics.scl.compiler.elaboration.expressions.EApply;
import org.simantics.scl.compiler.elaboration.expressions.EVariable;
}
};
for(QMapping mapping : decomposed.targetMappings)
- mapping.parameters[0].forVariables(check);
+ mapping.parameters[0].forVariableUses(check);
sourceVariables = sourceVariableList.toArray(new Variable[sourceVariableList.size()]);
}
}
else {
PatternAnalyzer analyzer = new PatternAnalyzer(variableSet, mappedVariableUseCount);
- expression.forVariables(analyzer);
+ expression.forVariableUses(analyzer);
if(analyzer.containsVariables)
semiopenMappings.add(mapping);
// Default action
final THashSet<Variable> dependences = new THashSet<Variable>();
- expression.forVariables(new VariableProcedure() {
+ expression.forVariableUses(new VariableProcedure() {
@Override
public void execute(long location, Variable variable) {