import org.simantics.scl.compiler.elaboration.expressions.Variable;
import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.errors.Locations;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.types.Type;
import gnu.trove.map.hash.TObjectIntHashMap;
right.collectFreeVariables(vars);
}
- @Override
- public void decorate(ExpressionDecorator decorator) {
- left = left.decorate(decorator);
- right = right.decorate(decorator);
- }
-
@Override
public void collectEffects(THashSet<Type> effects) {
left.collectEffects(effects);
import org.simantics.scl.compiler.elaboration.expressions.Variable;
import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.errors.Locations;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.types.Type;
import gnu.trove.map.hash.TObjectIntHashMap;
guard.collectFreeVariables(vars);
}
- @Override
- public void decorate(ExpressionDecorator decorator) {
- guard = guard.decorate(decorator);
- }
-
@Override
public void collectEffects(THashSet<Type> effects) {
guard.collectEffects(effects);
import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
import org.simantics.scl.compiler.elaboration.expressions.Variable;
import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.internal.parsing.Symbol;
import org.simantics.scl.compiler.types.Type;
public abstract void forVariables(VariableProcedure procedure);
public abstract void collectFreeVariables(THashSet<Variable> vars);
- public abstract void decorate(ExpressionDecorator decorator);
public abstract void collectEffects(THashSet<Type> effects);
public abstract void checkType(TypingContext context);
public abstract void collectRefs(TObjectIntHashMap<Object> allRefs, TIntHashSet refs);
import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
import org.simantics.scl.compiler.errors.Locations;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.exceptions.MatchException;
throw new InternalCompilerError(getClass().getSimpleName() + " does not support updateType.");
}
- @Override
- final public Expression decorate(ExpressionDecorator decorator) {
- throw new InternalCompilerError(getClass().getSimpleName() + " does not support decorate.");
- }
-
@Override
final public void collectEffects(THashSet<Type> effects) {
throw new InternalCompilerError(getClass().getSimpleName() + " does not support collectEffects.");
package org.simantics.scl.compiler.elaboration.expressions;
import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.types.Type;
public class Assignment {
return new Assignment(newPattern, newValue);
}
- public void decorate(ExpressionDecorator decorator) {
- pattern = pattern.decorate(decorator);
- value = value.decorate(decorator);
- }
-
public void setLocationDeep(long loc) {
pattern.setLocationDeep(loc);
value.setLocationDeep(loc);
import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
import org.simantics.scl.compiler.errors.Locations;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.internal.parsing.Symbol;
import org.simantics.scl.compiler.types.Type;
patterns[i] = patterns[i].checkTypeAsPattern(context, parameterTypes[i]);
value = value.checkIgnoredType(context);
}
-
- public void decorate(ExpressionDecorator decorator) {
- for(int i=0;i<patterns.length;++i)
- patterns[i] = patterns[i].decorate(decorator);
- value = value.decorate(decorator);
- }
public void forVariables(VariableProcedure procedure) {
value.forVariables(procedure);
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.types.Type;
import org.simantics.scl.compiler.types.exceptions.MatchException;
return expression.getFunctionDefinitionPatternArity();
}
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- expression = expression.decorate(decorator);
- return this;
- }
-
@Override
public void collectEffects(THashSet<Type> effects) {
expression.collectEffects(effects);
import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
import org.simantics.scl.compiler.errors.ErrorLog;
import org.simantics.scl.compiler.errors.Locations;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.types.Skeletons;
import org.simantics.scl.compiler.types.TMetaVar;
import org.simantics.scl.compiler.types.Type;
location = loc;
}
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- return this;
- }
-
@Override
public void collectEffects(THashSet<Type> effects) {
// TODO Auto-generated method stub
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;
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;
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.IExpression;
import org.simantics.scl.compiler.top.ExpressionInterpretationContext;
import org.simantics.scl.compiler.types.Type;
public Expression inferType(TypingContext context) {
throw new InternalCompilerError("Should not type check " + getClass().getSimpleName() + ".");
}
-
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- expression = expression.decorate(decorator);
- return decorator.decorate(this);
- }
@Override
public boolean isEffectful() {
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.types.Type;
import org.simantics.scl.compiler.types.exceptions.MatchException;
var.setType(pattern.getType());
return this;
}
-
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- pattern = pattern.decorate(decorator);
- return decorator.decorate(this);
- }
@Override
public Expression replace(ReplaceContext context) {
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.types.Type;
import org.simantics.scl.compiler.types.Types;
import org.simantics.scl.compiler.types.exceptions.MatchException;
return this;
}
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- pattern = pattern.decorate(decorator);
- value = value.decorate(decorator);
- in = in.decorate(decorator);
- return decorator.decorate(this);
- }
-
@Override
public void collectEffects(THashSet<Type> effects) {
pattern.collectEffects(effects);
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.IExpression;
import org.simantics.scl.compiler.top.ExpressionInterpretationContext;
import org.simantics.scl.compiler.types.Type;
}
}
@Override
- public Expression decorate(ExpressionDecorator decorator) {
- in = in.decorate(decorator);
- return this;
- }
- @Override
public void collectEffects(THashSet<Type> effects) {
ruleset.collectEffects(effects);
in.collectEffects(effects);
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.IExpression;
import org.simantics.scl.compiler.top.ExpressionInterpretationContext;
import org.simantics.scl.compiler.types.Type;
}
}
@Override
- public Expression decorate(ExpressionDecorator decorator) {
- return this;
- }
- @Override
public void collectEffects(THashSet<Type> effects) {
ruleset.collectEffects(effects);
}
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.types.Type;
import org.simantics.scl.compiler.types.Types;
import org.simantics.scl.compiler.types.exceptions.MatchException;
}
}
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- this.expression = decorator.decorate(expression);
- return this;
- }
-
@Override
public void collectEffects(THashSet<Type> effects) {
expression.collectEffects(effects);
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.top.ExpressionInterpretationContext;
else
return applyPUnit(context);
}
-
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- return decorator.decorate(this);
- }
@Override
public boolean isEffectful() {
import org.simantics.scl.compiler.elaboration.query.Query;
import org.simantics.scl.compiler.elaboration.query.compilation.EnforcingContext;
import org.simantics.scl.compiler.errors.Locations;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
import org.simantics.scl.compiler.types.exceptions.MatchException;
query = new QExists(variables, query);
return this;
}
-
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- return decorator.decorate(this);
- }
@Override
public void setLocationDeep(long loc) {
import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
import org.simantics.scl.compiler.elaboration.equation.Equation;
import org.simantics.scl.compiler.errors.Locations;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
import org.simantics.scl.compiler.types.exceptions.MatchException;
equation.collectFreeVariables(vars);
}
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- if(decorator.decorateSubstructure(this)) {
- for(Equation equation : equations)
- equation.decorate(decorator);
- }
- return this;
- }
-
@Override
public void collectEffects(THashSet<Type> effects) {
for(Equation equation : equations)
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.types.Type;
import org.simantics.scl.compiler.types.Types;
import org.simantics.scl.compiler.types.exceptions.MatchException;
return this;
}
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- return this;
- }
-
@Override
public void collectEffects(THashSet<Type> effects) {
}
import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
-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.codegen.writer.ModuleWriter;
-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.top.ExpressionInterpretationContext;
return this;
}
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- return decorator.decorate(this);
- }
-
@Override
public void collectEffects(THashSet<Type> effects) {
}
import org.simantics.scl.compiler.elaboration.expressions.accessor.FieldAccessor;
import org.simantics.scl.compiler.elaboration.expressions.accessor.IdAccessor;
import org.simantics.scl.compiler.errors.Locations;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.internal.header.ModuleHeader;
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
return this;
}
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- return decorator.decorate(this);
- }
-
@Override
public void collectEffects(THashSet<Type> effects) {
// FIXME
import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
import org.simantics.scl.compiler.errors.Locations;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.types.TPred;
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.exceptions.MatchException;
return this;
}
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- return decorator.decorate(this);
- }
-
@Override
public void collectEffects(THashSet<Type> effects) {
}
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;
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());
import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
import org.simantics.scl.compiler.errors.Locations;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
import org.simantics.scl.compiler.types.exceptions.MatchException;
copy.constraint = (EVariable)constraint.replace(context);
return copy;
}
-
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- return decorator.decorate(this);
- }
@Override
public boolean isEffectful() {
import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
import org.simantics.scl.compiler.errors.Locations;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
import org.simantics.scl.compiler.types.exceptions.MatchException;
context.popEffectUpperBound();
return this;
}
-
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- if(decorator.decorateSubstructure(this))
- for(Case case_ : cases)
- case_.decorate(decorator);
- return decorator.decorate(this);
- }
@Override
public boolean isEffectful() {
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.IExpression;
import org.simantics.scl.compiler.top.ExpressionInterpretationContext;
import org.simantics.scl.compiler.types.TVar;
public Expression inferType(TypingContext context) {
throw new InternalCompilerError("Should not type check " + getClass().getSimpleName() + ".");
}
-
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- value = value.decorate(decorator);
- return decorator.decorate(this);
- }
@Override
public void collectEffects(THashSet<Type> effects) {
import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
import org.simantics.scl.compiler.internal.codegen.writer.RecursiveDefinitionWriter;
import org.simantics.scl.compiler.internal.elaboration.decomposed.DecomposedExpression;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.internal.elaboration.utils.StronglyConnectedComponents;
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
return this;
}
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- in = in.decorate(decorator);
- for(Assignment assignment : assignments)
- assignment.decorate(decorator);
- return decorator.decorate(this);
- }
-
@Override
public void collectEffects(THashSet<Type> effects) {
for(Assignment assignment : assignments) {
import org.simantics.scl.compiler.elaboration.expressions.list.CompiledQualifier;
import org.simantics.scl.compiler.elaboration.expressions.list.ListQualifier;
import org.simantics.scl.compiler.errors.Locations;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
import org.simantics.scl.compiler.types.exceptions.MatchException;
return this;
}
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- head = head.decorate(decorator);
- qualifier.decorate(decorator);
- return decorator.decorate(this);
- }
-
@Override
public void collectEffects(THashSet<Type> effects) {
head.collectEffects(effects);
import org.simantics.scl.compiler.elaboration.java.ListConstructor;
import org.simantics.scl.compiler.errors.Locations;
import org.simantics.scl.compiler.internal.codegen.utils.Constants;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.internal.interpreted.IExpression;
import org.simantics.scl.compiler.internal.interpreted.IListLiteral;
import org.simantics.scl.compiler.top.ExpressionInterpretationContext;
return this;
}
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- for(int i=0;i<components.length;++i)
- components[i] = components[i].decorate(decorator);
- return decorator.decorate(this);
- }
-
@Override
public void collectEffects(THashSet<Type> effects) {
for(Expression component : components)
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.top.ExpressionInterpretationContext;
return this;
}
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- return decorator.decorate(this);
- }
-
@Override
public void collectEffects(THashSet<Type> effects) {
}
import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
import org.simantics.scl.compiler.internal.elaboration.matching.PatternMatchingCompiler;
import org.simantics.scl.compiler.internal.elaboration.matching.Row;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
import org.simantics.scl.compiler.types.kinds.Kinds;
return this;
}
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- for(int i=0;i<scrutinee.length;++i)
- scrutinee[i] = scrutinee[i].decorate(decorator);
- for(Case case_ : cases)
- case_.decorate(decorator);
- return decorator.decorate(this);
- }
-
@Override
public void collectEffects(THashSet<Type> effects) {
for(Expression s : scrutinee)
import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
public class EPlaceholder extends DecoratingExpression {
public EPlaceholder(long loc, Expression expression) {
public Expression resolveAsPattern(TranslationContext context) {
return expression.resolveAsPattern(context);
}
-
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- return expression.decorate(decorator);
- }
}
import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
import org.simantics.scl.compiler.errors.ErrorLog;
import org.simantics.scl.compiler.errors.Locations;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
import org.simantics.scl.compiler.types.exceptions.MatchException;
copy.setType(getType().replace(context.tvarMap));
return copy;
}
-
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- return decorator.decorate(this);
- }
@Override
public void collectEffects(THashSet<Type> effects) {
import org.simantics.scl.compiler.elaboration.relations.LocalRelation;
import org.simantics.scl.compiler.elaboration.relations.SCLRelation;
import org.simantics.scl.compiler.errors.Locations;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.internal.elaboration.utils.ForcedClosure;
import org.simantics.scl.compiler.internal.elaboration.utils.StronglyConnectedComponents;
import org.simantics.scl.compiler.top.SCLCompilerConfiguration;
throw new InternalCompilerError(location, getClass().getSimpleName() + " does not support collectEffects.");
}
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- return decorator.decorate(this);
- }
-
@Override
public Expression resolve(TranslationContext context) {
throw new InternalCompilerError();
import org.simantics.scl.compiler.elaboration.query.compilation.QueryCompilationMode;
import org.simantics.scl.compiler.elaboration.query.compilation.UnsolvableQueryException;
import org.simantics.scl.compiler.errors.Locations;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.internal.parsing.parser.SCLTerminals;
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
variables = context.popExistentialFrame();
return this;
}
-
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- return decorator.decorate(this);
- }
@Override
public void setLocationDeep(long loc) {
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.IExpression;
import org.simantics.scl.compiler.internal.interpreted.ILambda;
import org.simantics.scl.compiler.top.ExpressionInterpretationContext;
return this;
}
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- if(decorator.decorateSubstructure(this))
- value = value.decorate(decorator);
- return decorator.decorate(this);
- }
-
@Override
public boolean isEffectful() {
return false;
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.IExpression;
import org.simantics.scl.compiler.internal.interpreted.ILet;
import org.simantics.scl.compiler.internal.interpreted.ISeq;
return this;
}
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- value = value.decorate(decorator);
- in = in.decorate(decorator);
- return decorator.decorate(this);
- }
-
@Override
public void collectEffects(THashSet<Type> effects) {
value.collectEffects(effects);
import org.simantics.scl.compiler.elaboration.rules.TransformationRule;
import org.simantics.scl.compiler.errors.Locations;
import org.simantics.scl.compiler.internal.elaboration.transformations.TransformationBuilder;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.top.SCLCompilerConfiguration;
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
}
}
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- return decorator.decorate(this);
- }
-
@Override
public void collectEffects(THashSet<Type> effects) {
effects.add(Types.PROC);
import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
import org.simantics.scl.compiler.errors.Locations;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.internal.parsing.types.TypeAst;
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.exceptions.MatchException;
public Expression inferType(TypingContext context) {
return value.checkType(context, type);
}
-
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- value = value.decorate(decorator);
- return decorator.decorate(this);
- }
-
+
@Override
public void collectEffects(THashSet<Type> effects) {
value.collectEffects(effects);
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.IExpression;
import org.simantics.scl.compiler.internal.interpreted.IVariable;
import org.simantics.scl.compiler.top.ExpressionInterpretationContext;
return context.subsume(this, requiredType);
}
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- return decorator.decorate(this);
- }
-
@Override
public boolean isEffectful() {
return false;
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.types.Type;
import org.simantics.scl.compiler.types.Types;
import org.simantics.scl.compiler.types.exceptions.MatchException;
}
}
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- expression = expression.decorate(decorator);
- return this;
- }
-
@Override
public void collectEffects(THashSet<Type> effects) {
expression.collectEffects(effects);
import org.simantics.scl.compiler.elaboration.query.compilation.QueryCompilationMode;
import org.simantics.scl.compiler.elaboration.query.compilation.UnsolvableQueryException;
import org.simantics.scl.compiler.errors.Locations;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
import org.simantics.scl.compiler.types.exceptions.MatchException;
variables = context.popExistentialFrame();
return this;
}
-
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- return decorator.decorate(this);
- }
@Override
public Expression replace(ReplaceContext context) {
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.decomposed.DecomposedExpression;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.internal.interpreted.IExpression;
import org.simantics.scl.compiler.internal.parsing.Symbol;
import org.simantics.scl.compiler.top.ExpressionInterpretationContext;
public Expression applyType(Type type) {
return new EApplyType(location, this, type);
}
-
- public abstract Expression decorate(ExpressionDecorator decorator);
public boolean isEffectful() {
return true;
import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext;
import org.simantics.scl.compiler.errors.Locations;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.internal.parsing.Symbol;
public class GuardedExpression extends Symbol {
value.replace(context));
}
- public void decorate(ExpressionDecorator decorator) {
- for(int i=0;i<guards.length;++i)
- guards[i] = guards[i].decorate(decorator);
- value = value.decorate(decorator);
- }
-
public void setLocationDeep(long loc) {
if(location == Locations.NO_LOCATION) {
location = loc;
import org.simantics.scl.compiler.internal.codegen.references.IVal;
import org.simantics.scl.compiler.internal.codegen.ssa.exits.Throw;
import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
import org.simantics.scl.compiler.types.exceptions.MatchException;
return new GuardedExpressionGroup(newExpressions);
}
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- for(GuardedExpression expression : expressions)
- expression.decorate(decorator);
- return decorator.decorate(this);
- }
-
@Override
public void collectEffects(THashSet<Type> effects) {
for(GuardedExpression ge : expressions) {
@Override
public Expression transform(EAmbiguous expression) {
+ if(expression.resolvedExpression != null)
+ expression.resolvedExpression = expression.resolvedExpression.accept(this);
return expression;
}
import org.simantics.scl.compiler.elaboration.expressions.Variable;
import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.errors.Locations;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.types.Types;
import gnu.trove.map.hash.TObjectIntHashMap;
fieldName.collectVars(allVars, vars);
}
- @Override
- public void decorate(ExpressionDecorator decorator) {
- fieldName = fieldName.decorate(decorator);
- }
-
@Override
public void resolve(TranslationContext context) {
fieldName = fieldName.resolve(context);
import org.simantics.scl.compiler.elaboration.expressions.Expression;
import org.simantics.scl.compiler.elaboration.expressions.Variable;
import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.internal.parsing.Symbol;
import gnu.trove.map.hash.TObjectIntHashMap;
public void resolve(TranslationContext context) {
}
- public void decorate(ExpressionDecorator decorator) {
- }
-
public void checkType(TypingContext context) {
}
import org.simantics.scl.compiler.elaboration.expressions.Variable;
import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.errors.Locations;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.types.Type;
import gnu.trove.map.hash.TObjectIntHashMap;
pattern = pattern.resolveAsPattern(context);
}
- @Override
- public void decorate(ExpressionDecorator decorator) {
- value = value.decorate(decorator);
- pattern = pattern.decorate(decorator);
- }
-
@Override
public void collectEffects(THashSet<Type> effects) {
pattern.collectEffects(effects);
import org.simantics.scl.compiler.elaboration.expressions.Variable;
import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.errors.Locations;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.types.TMetaVar;
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
pattern = pattern.resolveAsPattern(context);
}
- @Override
- public void decorate(ExpressionDecorator decorator) {
- value = value.decorate(decorator);
- pattern = pattern.decorate(decorator);
- }
-
@Override
public void collectEffects(THashSet<Type> effects) {
pattern.collectEffects(effects);
import org.simantics.scl.compiler.elaboration.expressions.Variable;
import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.errors.Locations;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
public void resolve(TranslationContext context) {
condition = condition.resolve(context);
}
-
- @Override
- public void decorate(ExpressionDecorator decorator) {
- condition = condition.decorate(decorator);
- }
@Override
public void collectEffects(THashSet<Type> effects) {
import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
import org.simantics.scl.compiler.elaboration.expressions.Variable;
import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.internal.parsing.Symbol;
import org.simantics.scl.compiler.types.Type;
*/
public abstract CompiledQualifier compile(SimplificationContext context);
public abstract void resolve(TranslationContext context);
- public abstract void decorate(ExpressionDecorator decorator);
public abstract void collectEffects(THashSet<Type> effects);
public abstract void setLocationDeep(long loc);
public abstract void accept(ListQualifierVisitor visitor);
import org.simantics.scl.compiler.elaboration.expressions.Variable;
import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.errors.Locations;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.types.Type;
import gnu.trove.map.hash.TObjectIntHashMap;
b.resolve(context);
}
- @Override
- public void decorate(ExpressionDecorator decorator) {
- a.decorate(decorator);
- b.decorate(decorator);
- }
-
@Override
public void collectEffects(THashSet<Type> effects) {
a.collectEffects(effects);
import org.simantics.scl.compiler.elaboration.expressions.Variable;
import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
import org.simantics.scl.compiler.errors.Locations;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.types.TMetaVar;
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
by = by.resolve(context);
}
- @Override
- public void decorate(ExpressionDecorator decorator) {
- transformer = transformer.decorate(decorator);
- if(by != null)
- by = by.decorate(decorator);
- left.decorate(decorator);
- }
-
@Override
public void collectEffects(THashSet<Type> effects) {
left.collectEffects(effects);
+++ /dev/null
-package org.simantics.scl.compiler.internal.elaboration.utils;
-
-import org.simantics.scl.compiler.elaboration.expressions.Expression;
-
-public interface ExpressionDecorator {
-
- Expression decorate(Expression expression);
- boolean decorateSubstructure(Expression expression);
-
-}
import org.simantics.scl.compiler.internal.codegen.writer.ExternalConstant;
import org.simantics.scl.compiler.internal.codegen.writer.ModuleWriter;
import org.simantics.scl.compiler.internal.elaboration.decomposed.DecomposedExpression;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.internal.interpreted.IExpression;
import org.simantics.scl.compiler.internal.parsing.exceptions.SCLSyntaxErrorException;
import org.simantics.scl.compiler.internal.parsing.parser.SCLBlockParser;
if(!errorLog.hasNoErrors())
throw new SCLExpressionCompilationException(errorLog.getErrors());
if(decorateExpression && Types.canonical(expectedEffect) != Types.NO_EFFECTS) {
- ExpressionDecorator decorator =
+ ToplevelEffectDecorator decorator =
new ToplevelEffectDecorator(errorLog, environment);
- expression = expression.decorate(decorator);
+ expression = expression.accept(decorator);
}
expression = context.solveConstraints(environment, expression);
expressionType = expression.getType();
import org.simantics.scl.compiler.common.names.Name;
import org.simantics.scl.compiler.common.names.Names;
+import org.simantics.scl.compiler.elaboration.expressions.Case;
import org.simantics.scl.compiler.elaboration.expressions.EApply;
+import org.simantics.scl.compiler.elaboration.expressions.ECHRRuleset;
import org.simantics.scl.compiler.elaboration.expressions.EConstant;
import org.simantics.scl.compiler.elaboration.expressions.EEnforce;
import org.simantics.scl.compiler.elaboration.expressions.EFieldAccess;
import org.simantics.scl.compiler.elaboration.expressions.ESimpleLambda;
import org.simantics.scl.compiler.elaboration.expressions.EWhen;
import org.simantics.scl.compiler.elaboration.expressions.Expression;
+import org.simantics.scl.compiler.elaboration.expressions.StandardExpressionTransformer;
import org.simantics.scl.compiler.elaboration.expressions.Variable;
import org.simantics.scl.compiler.elaboration.modules.SCLValue;
import org.simantics.scl.compiler.environment.Environment;
import org.simantics.scl.compiler.errors.ErrorLog;
import org.simantics.scl.compiler.errors.Locations;
-import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
import org.simantics.scl.compiler.types.TCon;
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
-public class ToplevelEffectDecorator implements ExpressionDecorator {
+import gnu.trove.map.hash.THashMap;
+
+public class ToplevelEffectDecorator extends StandardExpressionTransformer {
ErrorLog errorLog;
Environment environment;
this.environment = environment;
}
- private static Expression decorate(SCLValue transactionFunction, Type effect, Expression expression) {
- Variable var = new Variable("_");
- var.setType(Types.UNIT);
- Expression trans = new EApply(expression.getLocation(), Types.PROC,
- new EConstant(transactionFunction,
- expression.getType()),
- new ESimpleLambda(Locations.NO_LOCATION, var, effect, expression)
- );
- if(expression instanceof EApply) {
- EApply apply = (EApply)expression;
- trans = apply.toANormalForm(trans);
- }
- return trans;
+ @Override
+ public Expression transform(EEnforce expression) {
+ return decorateByEffect(expression, expression.getEffect());
+ }
+
+ @Override
+ public Expression transform(EWhen expression) {
+ return decorateByEffect(expression, expression.getEffect());
+ }
+
+ @Override
+ public Expression transform(ERuleset expression) {
+ return decorateByEffect(expression, expression.getEffect());
+ }
+
+ @Override
+ public Expression transform(ECHRRuleset expression) {
+ return decorateByEffect(expression, expression.getEffect());
+ }
+
+ @Override
+ public Expression transform(EFieldAccess expression) {
+ // Can we encounter EFieldAccess in this transformer?
+ return decorateByEffect(expression, expression.getEffect());
+ }
+
+ @Override
+ public Expression transform(ESelect expression) {
+ return decorateByEffect(expression, expression.getEffect());
}
- private static final TCon R = Types.con("R/R", "R");
+ @Override
+ public Expression transform(EApply expression) {
+ return decorateByEffect(super.transform(expression), expression.getLocalEffect());
+ }
@Override
- public Expression decorate(Expression expression) {
- if(expression instanceof EApply)
- return decorateByEffect(expression, ((EApply)expression).getLocalEffect());
- else if(expression instanceof ESelect
- || expression instanceof EEnforce
- || expression instanceof EWhen
- || expression instanceof EFieldAccess
- || expression instanceof ERuleset)
- return decorateByEffect(expression, expression.getEffect());
+ public Expression transform(ESimpleLambda expression) {
+ // Never has side effects
return expression;
}
+ @Override
+ public Expression transform(ELambda expression) {
+ // Never has side effects
+ return expression;
+ }
+
+ @Override
+ protected void transformCases(Case[] cases) {
+ for(Case case_ : cases)
+ case_.value = case_.value.accept(this);
+ }
+
+ private static final THashMap<TCon, Name> DECORATION_MAP = new THashMap<TCon, Name>();
+
+ static {
+ DECORATION_MAP.put(Types.WRITE_GRAPH, Names.Simantics_DB_syncWrite);
+ DECORATION_MAP.put(Types.READ_GRAPH, Names.Simantics_DB_syncRead);
+ DECORATION_MAP.put(Types.con("R/R", "R"), Names.R_R_runR);
+ DECORATION_MAP.put(Types.RANDOM, Names.Random_runRandom);
+ }
+
private Expression decorateByEffect(Expression expression, Type effect) {
if(effect == Types.NO_EFFECTS)
return expression;
- //System.out.println("decorateByEffect(" + expression + ", " + effect + ")");
-
ArrayList<TCon> concreteEffects = new ArrayList<TCon>();
effect.collectConcreteEffects(concreteEffects);
- if(concreteEffects.contains(Types.WRITE_GRAPH)) {
- Name name = Names.Simantics_DB_syncWrite;
- SCLValue transactionFunction = environment.getValue(name);
+ for(TCon ce : concreteEffects) {
+ Name transactionFunctionName = DECORATION_MAP.get(ce);
+ if(transactionFunctionName == null)
+ continue;
+ SCLValue transactionFunction = environment.getValue(transactionFunctionName);
if(transactionFunction == null) {
- errorLog.log(expression.location, "Cannot locate " + name);
- return expression;
+ errorLog.log(expression.location, "Cannot locate " + transactionFunctionName);
+ continue;
}
-
- expression = decorate(transactionFunction, Types.WRITE_GRAPH, expression);
+ expression = decorate(transactionFunction, ce, expression);
}
- else if(concreteEffects.contains(Types.READ_GRAPH)) {
- Name name = Names.Simantics_DB_syncRead;
- SCLValue transactionFunction = environment.getValue(name);
- if(transactionFunction == null) {
- errorLog.log(expression.location, "Cannot locate " + name);
- return expression;
- }
-
- expression = decorate(transactionFunction, Types.READ_GRAPH, expression);
- }
- if(concreteEffects.contains(R)) {
- Name name = Names.R_R_runR;
- SCLValue transactionFunction = environment.getValue(name);
- if(transactionFunction == null) {
- errorLog.log(expression.location, "Cannot locate " + name);
- return expression;
- }
-
- expression = decorate(transactionFunction, R, expression);
- }
- if(concreteEffects.contains(Types.RANDOM)) {
- Name name = Names.Random_runRandom;
- SCLValue transactionFunction = environment.getValue(name);
- if(transactionFunction == null) {
- errorLog.log(expression.location, "Cannot locate " + name);
- return expression;
- }
- expression = decorate(transactionFunction, Types.RANDOM, expression);
- }
return expression;
}
- @Override
- public boolean decorateSubstructure(Expression expression) {
- if(expression instanceof ELambda || expression instanceof ESimpleLambda)
- return false;
- return true;
+ private static Expression decorate(SCLValue transactionFunction, Type effect, Expression expression) {
+ Variable var = new Variable("_");
+ var.setType(effect == Types.RANDOM ? Types.PUNIT : Types.UNIT);
+ Expression trans = new EApply(expression.getLocation(), Types.PROC,
+ effect == Types.RANDOM ? new EConstant(transactionFunction, Types.PROC, expression.getType()) : new EConstant(transactionFunction, expression.getType()),
+ new ESimpleLambda(Locations.NO_LOCATION, var, effect, expression)
+ );
+ if(expression instanceof EApply) {
+ EApply apply = (EApply)expression;
+ trans = apply.toANormalForm(trans);
+ }
+ return trans;
}
-
}