]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApply.java
(refs #7375) Replaced collectVars method by a visitor
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / elaboration / expressions / EApply.java
index c7bce466759d62eaf154c4a0a415b634249903cf..02c7dff4585c95e0d55d7bf485266f90327b31e6 100644 (file)
@@ -19,7 +19,6 @@ import org.simantics.scl.compiler.elaboration.modules.SCLValue;
 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.IApply;
 import org.simantics.scl.compiler.internal.interpreted.IExpression;
 import org.simantics.scl.compiler.internal.interpreted.IListLiteral;
@@ -33,14 +32,10 @@ import org.simantics.scl.compiler.types.exceptions.UnificationException;
 import org.simantics.scl.compiler.types.kinds.Kinds;
 import org.simantics.scl.compiler.types.util.MultiFunction;
 
-import gnu.trove.map.hash.TObjectIntHashMap;
-import gnu.trove.set.hash.THashSet;
-import gnu.trove.set.hash.TIntHashSet;
-
 public class EApply extends Expression {
     public Expression function;
     public Expression[] parameters;
-    Type effect = Types.NO_EFFECTS;
+    public Type effect = Types.NO_EFFECTS;
     
     public EApply(Expression function, Expression ... parameters) {
         this.function = function;
@@ -76,22 +71,9 @@ public class EApply extends Expression {
     public Expression[] getParameters() {
         return parameters;
     }
-    
 
-    public void collectRefs(TObjectIntHashMap<Object> allRefs, TIntHashSet refs) {
-        function.collectRefs(allRefs, refs);
-        for(Expression parameter : parameters)
-            parameter.collectRefs(allRefs, refs);
-    }
-    
-    public void collectVars(TObjectIntHashMap<Variable> allVars, TIntHashSet vars) {
-        function.collectVars(allVars, vars);
-        for(Expression parameter : parameters)
-            parameter.collectVars(allVars, vars);
-    }
-       
-       @Override
-       protected void updateType() throws MatchException {
+    @Override
+    protected void updateType() throws MatchException {
         MultiFunction mfun = Types.matchFunction(function.getType(), parameters.length);
         /*for(int i=0;i<parameters.length;++i)
             if(!Types.equals(parameters[i].getType(), mfun.parameterTypes[i]))
@@ -110,13 +92,6 @@ public class EApply extends Expression {
         effect = Types.simplifyFinalEffect(effect);
         return w.applyWithEffect(location, effect, type, functionVal, parameterVals);
     }
-
-    @Override
-    public void collectFreeVariables(THashSet<Variable> vars) {
-        function.collectFreeVariables(vars);
-        for(Expression parameter : parameters)
-            parameter.collectFreeVariables(vars);
-    }
     
     private void combineApplications() {
         if(function instanceof EApply) {
@@ -194,13 +169,6 @@ public class EApply extends Expression {
         for(Expression parameter : this.parameters)
             parameters.add(parameter);
     }
-    
-    @Override
-    public void removeFreeVariables(THashSet<Variable> vars) {
-        function.removeFreeVariables(vars);
-        for(Expression parameter : parameters)
-            parameter.removeFreeVariables(vars);
-    }
 
     @Override
     public Expression replace(ReplaceContext context) {
@@ -303,16 +271,6 @@ public class EApply extends Expression {
             return new ESimpleLet(location, null, this, new ELiteral(NoRepConstant.PUNIT));
         return this;
     }
-
-    @Override
-    public Expression decorate(ExpressionDecorator decorator) {
-        if(decorator.decorateSubstructure(this)) {
-            function = function.decorate(decorator);
-            for(int i=0;i<parameters.length;++i)
-                parameters[i] = parameters[i].decorate(decorator);
-        }
-        return decorator.decorate(this);
-    }
     
     public Type getLocalEffect() {
         return effect;
@@ -358,14 +316,6 @@ public class EApply extends Expression {
         return function.isConstructorApplication();
     }
 
-    @Override
-    public void collectEffects(THashSet<Type> effects) {
-        effects.add(effect);
-        function.collectEffects(effects);
-        for(Expression parameter : parameters)
-            parameter.collectEffects(effects);
-    }
-
     @Override
     public void accept(ExpressionVisitor visitor) {
         visitor.visit(this);
@@ -380,13 +330,6 @@ public class EApply extends Expression {
             return false;
         }
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        function.forVariables(procedure);
-        for(Expression parameter : parameters)
-            parameter.forVariables(procedure);
-    }
     
     @Override
     public boolean isPattern(int arity) {