X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Felaboration%2Fexpressions%2FEIf.java;h=fe6216fe153c3bb8fec3da0e83c86940aa8a9269;hb=b77d6bc2e8713d4138a0af0afb64a97f92a21052;hp=661de4261e260c09b1cd543f3ac5e2dc97df7339;hpb=862c09c9608329f326404342d12da61792eece2c;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EIf.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EIf.java index 661de4261..fe6216fe1 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EIf.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EIf.java @@ -8,7 +8,6 @@ import org.simantics.scl.compiler.elaboration.contexts.TypingContext; import org.simantics.scl.compiler.errors.Locations; import org.simantics.scl.compiler.internal.codegen.references.IVal; import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter; -import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator; import org.simantics.scl.compiler.internal.interpreted.IConstant; import org.simantics.scl.compiler.internal.interpreted.IExpression; import org.simantics.scl.compiler.internal.interpreted.IIf; @@ -18,10 +17,6 @@ import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.exceptions.MatchException; import org.simantics.scl.runtime.tuple.Tuple0; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.THashSet; -import gnu.trove.set.hash.TIntHashSet; - public class EIf extends Expression { public Expression condition; public Expression then_; @@ -40,29 +35,13 @@ public class EIf extends Expression { this.else_ = else_; } - public void collectRefs(TObjectIntHashMap allRefs, TIntHashSet refs) { - condition.collectRefs(allRefs, refs); - then_.collectRefs(allRefs, refs); - if(else_ != null) - else_.collectRefs(allRefs, refs); + @Override + protected void updateType() throws MatchException { + setType(then_.getType()); } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - condition.collectVars(allVars, vars); - then_.collectVars(allVars, vars); - if(else_ != null) - else_.collectVars(allVars, vars); - } - - @Override - protected void updateType() throws MatchException { - setType(then_.getType()); - } - - @Override - public IVal toVal(CompilationContext context, CodeWriter w) { + @Override + public IVal toVal(CompilationContext context, CodeWriter w) { IVal conditionVal = condition.toVal(context, w); CodeWriter joinPoint = w.createBlock(getType()); CodeWriter thenBlock = w.createBlock(); @@ -83,14 +62,6 @@ public class EIf extends Expression { return w.getParameters()[0]; } - @Override - public void collectFreeVariables(THashSet vars) { - condition.collectFreeVariables(vars); - then_.collectFreeVariables(vars); - if(else_ != null) - else_.collectFreeVariables(vars); - } - @Override public Expression simplify(SimplificationContext context) { condition = condition.simplify(context); @@ -136,27 +107,10 @@ public class EIf extends Expression { return this; } - @Override - public Expression decorate(ExpressionDecorator decorator) { - condition = condition.decorate(decorator); - then_ = then_.decorate(decorator); - if(else_ != null) - else_ = else_.decorate(decorator); - return decorator.decorate(this); - } - @Override public boolean isEffectful() { return condition.isEffectful() || then_.isEffectful() || (else_ != null && else_.isEffectful()); } - - @Override - public void collectEffects(THashSet effects) { - condition.collectEffects(effects); - then_.collectEffects(effects); - if(else_ != null) - else_.collectEffects(effects); - } @Override public void setLocationDeep(long loc) { @@ -180,13 +134,6 @@ public class EIf extends Expression { 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);