X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Felaboration%2Fexpressions%2FEMatch.java;h=ba9cee65edc0cc7daa1bfc8cfb652514da64933c;hp=eef72f9de4f192f4ca44725a519024fb3add2bda;hb=6dfe20b0f514b91337fcac4de0267ffd8268be07;hpb=862c09c9608329f326404342d12da61792eece2c diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EMatch.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EMatch.java index eef72f9de..ba9cee65e 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EMatch.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EMatch.java @@ -13,13 +13,11 @@ 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.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; import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.THashSet; import gnu.trove.set.hash.TIntHashSet; public class EMatch extends Expression { @@ -42,51 +40,36 @@ public class EMatch extends Expression { this.cases = cases; } - public void collectRefs(TObjectIntHashMap allRefs, TIntHashSet refs) { + @Override + public void collectVars(TObjectIntHashMap allVars, + TIntHashSet vars) { for(Expression s : scrutinee) - s.collectRefs(allRefs, refs); - for(Case case_ : cases) - case_.collectRefs(allRefs, refs); - } - - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - for(Expression s : scrutinee) s.collectVars(allVars, vars); - for(Case case_ : cases) + for(Case case_ : cases) case_.collectVars(allVars, vars); - } - - @Override - protected void updateType() { - setType(cases[0].value.getType()); - } + } - @Override - public IVal toVal(CompilationContext context, CodeWriter w) { - ArrayList rows = new ArrayList(cases.length); - for(Case case_ : cases) - rows.add(new Row(case_.patterns, case_.value)); - - IVal[] scrutineeVals = new IVal[scrutinee.length]; - for(int i=0;i vars) { - for(Expression s : scrutinee) - s.collectFreeVariables(vars); + public IVal toVal(CompilationContext context, CodeWriter w) { + ArrayList rows = new ArrayList(cases.length); for(Case case_ : cases) - case_.collectFreeVariables(vars); + rows.add(new Row(case_.patterns, case_.value)); + + IVal[] scrutineeVals = new IVal[scrutinee.length]; + for(int i=0;i effects) { - for(Expression s : scrutinee) - s.collectEffects(effects); - for(Case case_ : cases) { - for(Expression pattern : case_.patterns) - pattern.collectEffects(effects); - case_.value.collectEffects(effects); - } - } @Override public void accept(ExpressionVisitor visitor) { @@ -196,14 +159,6 @@ public class EMatch extends Expression { public Case[] getCases() { return cases; } - - @Override - public void forVariables(VariableProcedure procedure) { - for(Expression s : scrutinee) - s.forVariables(procedure); - for(Case case_ : cases) - case_.forVariables(procedure); - } @Override public Expression accept(ExpressionTransformer transformer) {