]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EIf.java
(refs #7375) Replaced collectVars method by a visitor
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / elaboration / expressions / EIf.java
index 418ba69c9cda9c2e3b1c352daedc02176e8b1570..fe6216fe153c3bb8fec3da0e83c86940aa8a9269 100644 (file)
@@ -17,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_;
@@ -39,29 +35,13 @@ public class EIf extends Expression {
         this.else_ = else_;
     }
 
-       public void collectRefs(TObjectIntHashMap<Object> 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<Variable> 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();
@@ -82,14 +62,6 @@ public class EIf extends Expression {
         return w.getParameters()[0];
     }
 
-    @Override
-    public void collectFreeVariables(THashSet<Variable> vars) {
-        condition.collectFreeVariables(vars);
-        then_.collectFreeVariables(vars);
-        if(else_ != null)
-            else_.collectFreeVariables(vars);
-    }
-
     @Override
     public Expression simplify(SimplificationContext context) {
         condition = condition.simplify(context);
@@ -139,14 +111,6 @@ public class EIf extends Expression {
     public boolean isEffectful() {
        return condition.isEffectful() || then_.isEffectful() || (else_ != null && else_.isEffectful());
     }
-
-    @Override
-    public void collectEffects(THashSet<Type> effects) {
-        condition.collectEffects(effects);
-        then_.collectEffects(effects);
-        if(else_ != null)
-            else_.collectEffects(effects);
-    }
     
     @Override
     public void setLocationDeep(long loc) {