import org.simantics.scl.compiler.types.Types;
import org.simantics.scl.compiler.types.exceptions.MatchException;
-import gnu.trove.map.hash.TObjectIntHashMap;
-import gnu.trove.set.hash.THashSet;
-import gnu.trove.set.hash.TIntHashSet;
-
public class GuardedExpressionGroup extends Expression {
public GuardedExpression[] expressions;
this.expressions = expressions;
}
- @Override
- public void collectRefs(TObjectIntHashMap<Object> allRefs,
- TIntHashSet refs) {
- for(GuardedExpression expression : expressions) {
- for(Expression guard : expression.guards)
- guard.collectRefs(allRefs, refs);
- expression.value.collectRefs(allRefs, refs);
- }
- }
-
- @Override
- public void collectVars(TObjectIntHashMap<Variable> allVars,
- TIntHashSet vars) {
- for(GuardedExpression expression : expressions) {
- for(Expression guard : expression.guards)
- guard.collectVars(allVars, vars);
- expression.value.collectVars(allVars, vars);
- }
- }
-
@Override
protected void updateType() throws MatchException {
setType(expressions[0].value.getType());
//throw new InternalCompilerError("GuardedExpressionGroup should be handled in match compilation.");
}
- @Override
- public void collectFreeVariables(THashSet<Variable> vars) {
- for(GuardedExpression expression : expressions) {
- for(Expression guard : expression.guards)
- guard.collectFreeVariables(vars);
- expression.value.collectFreeVariables(vars);
- }
- }
-
@Override
public Expression simplify(SimplificationContext context) {
for(GuardedExpression expression : expressions) {
newExpressions[i] = expressions[i].replace(context);
return new GuardedExpressionGroup(newExpressions);
}
-
- @Override
- public void collectEffects(THashSet<Type> effects) {
- for(GuardedExpression ge : expressions) {
- for(Expression guard : ge.guards)
- guard.collectEffects(effects);
- ge.value.collectEffects(effects);
- }
- }
@Override
public void setLocationDeep(long loc) {