1 package org.simantics.scl.compiler.elaboration.expressions;
3 import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext;
4 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
5 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
6 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
7 import org.simantics.scl.compiler.elaboration.equation.Equation;
8 import org.simantics.scl.compiler.errors.Locations;
9 import org.simantics.scl.compiler.types.Type;
10 import org.simantics.scl.compiler.types.Types;
11 import org.simantics.scl.compiler.types.exceptions.MatchException;
13 public class EEquations extends SimplifiableExpression {
15 public Equation[] equations;
16 public Type effect = Types.NO_EFFECTS;
18 public EEquations(Equation[] equations) {
19 this.equations = equations;
22 public EEquations(long location, Equation[] equations) {
24 this.location = location;
28 public Expression resolve(TranslationContext context) {
29 for(Equation equation : equations)
30 equation.resolve(context);
35 public void setLocationDeep(long loc) {
36 if(location == Locations.NO_LOCATION) {
38 for(Equation equation : equations)
39 equation.setLocationDeep(loc);
44 public Expression accept(ExpressionTransformer transformer) {
45 return transformer.transform(this);
49 protected void updateType() throws MatchException {
54 public void accept(ExpressionVisitor visitor) {
59 public Expression inferType(TypingContext context) {
60 context.declareEffect(this.location, effect);
61 for(Equation equation : equations)
62 equation.checkType(context);
67 public Expression checkIgnoredType(TypingContext context) {
68 return inferType(context);
72 public Expression simplify(SimplificationContext context) {
73 context.getErrorLog().log(location, "Equations should be transformed into other expressions before simplification phase.");
74 return Expressions.tuple();
78 public Expression replace(ReplaceContext context) {
79 Equation[] newEquations = new Equation[equations.length];
80 for(int i=0;i<equations.length;++i)
81 newEquations[i] = equations[i].replace(context);
82 return new EEquations(location, newEquations);