]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApply.java
(refs #7375) Replace collectRefs by CollectRefsVisitor
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / elaboration / expressions / EApply.java
old mode 100755 (executable)
new mode 100644 (file)
index fd58227..4065f46
@@ -3,6 +3,8 @@ package org.simantics.scl.compiler.elaboration.expressions;
 import java.util.ArrayList;
 
 import org.simantics.scl.compiler.common.names.Name;
+import org.simantics.scl.compiler.common.names.Names;
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.constants.NoRepConstant;
 import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext;
 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
@@ -14,11 +16,9 @@ import org.simantics.scl.compiler.elaboration.expressions.lhstype.PatternMatchin
 import org.simantics.scl.compiler.elaboration.java.ListConstructor;
 import org.simantics.scl.compiler.elaboration.macros.MacroRule;
 import org.simantics.scl.compiler.elaboration.modules.SCLValue;
-import org.simantics.scl.compiler.environment.Environment;
 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;
@@ -76,13 +76,6 @@ public class EApply extends Expression {
         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)
@@ -100,11 +93,11 @@ public class EApply extends Expression {
        }
 
        @Override
-       public IVal toVal(Environment env, CodeWriter w) {
-        IVal functionVal = function.toVal(env, w);
+       public IVal toVal(CompilationContext context, CodeWriter w) {
+        IVal functionVal = function.toVal(context, w);
         IVal[] parameterVals = new IVal[parameters.length];
         for(int i=0;i<parameters.length;++i)
-            parameterVals[i] = parameters[i].toVal(env, w);
+            parameterVals[i] = parameters[i].toVal(context, w);
         Type type = getType();
         effect = Types.simplifyFinalEffect(effect);
         return w.applyWithEffect(location, effect, type, functionVal, parameterVals);
@@ -287,27 +280,21 @@ public class EApply extends Expression {
     
     @Override
     public Expression inferType(TypingContext context) {
+        if(parameters.length == 2 && function instanceof EConstant && ((EConstant)function).value.getName() == Names.Prelude_dollar)
+            return new EApply(location, parameters[0], parameters[1]).inferType(context);
         inferType(context, false);
         return this;
     }
     
     @Override
     public Expression checkIgnoredType(TypingContext context) {
+        if(parameters.length == 2 && function instanceof EConstant && ((EConstant)function).value.getName() == Names.Prelude_dollar)
+            return new EApply(location, parameters[0], parameters[1]).inferType(context);
         inferType(context, true);
         if(Types.canonical(getType()) != Types.UNIT)
             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;
@@ -375,13 +362,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) {