diff options
author | buraq <buraq@epfl.ch> | 2005-06-16 16:38:35 +0000 |
---|---|---|
committer | buraq <buraq@epfl.ch> | 2005-06-16 16:38:35 +0000 |
commit | 95bafdf4ead36bb13e16c6ffb8e653b443405651 (patch) | |
tree | fd57764e9baab29c396d641a8b7183d4ebad6e47 | |
parent | 1ea7ccc409b2f08cb90f099edbb3de164947ed2c (diff) | |
download | scala-95bafdf4ead36bb13e16c6ffb8e653b443405651.tar.gz scala-95bafdf4ead36bb13e16c6ffb8e653b443405651.tar.bz2 scala-95bafdf4ead36bb13e16c6ffb8e653b443405651.zip |
ok, kicked out handling of "alternative" patter...
ok, kicked out handling of "alternative" patterns in Matthias' matcher
3 files changed, 29 insertions, 42 deletions
diff --git a/sources/scala/tools/scalac/transformer/TransMatch.scala b/sources/scala/tools/scalac/transformer/TransMatch.scala index d48bf41d44..9cb31d25c2 100644 --- a/sources/scala/tools/scalac/transformer/TransMatch.scala +++ b/sources/scala/tools/scalac/transformer/TransMatch.scala @@ -40,11 +40,11 @@ class TransMatch( global:scalac_Global ) var cunit:CompilationUnit = null; - def debugLog(s:String) = { - //if(currentOwner.toString().indexOf("traverse") != -1) { - //Console.println(s); + //def debugLog(s:String) = { + //if(currentOwner.toString().indexOf("fetchToken") != -1) { + //Console.println(s); //} - } + //} override def apply( cunit:CompilationUnit ):unit = { this.cunit = cunit; @@ -125,6 +125,13 @@ class TransMatch( global:scalac_Global ) */ def removeAlterns(cases: Array[CaseDef]) = { + //debugLog("removeAlterns called![ currentOwner = "+currentOwner+" ["); + // var jjj = 0; while (jjj<cases.length) { + // debugLog(cases(jjj).toString()); + // jjj = jjj + 1; + //} + //debugLog("]"); + def lst2arr(l:List[Tree]):Array[Tree] = { val res = new Array[Tree](l.length); val it = l.elements; var i = 0; while(it.hasNext) { @@ -233,12 +240,11 @@ class TransMatch( global:scalac_Global ) res } val zs:Seq[CaseDef] = cases; - val ncases: List[List[Tree]] = zs.toList map { x => x match { case CaseDef(pat,guard,body) => - //Console.println("removeAlterns - ("+x+"), currentOwner = "+currentOwner); + //debugLog("removeAlterns - ("+x+")"); remove(pat) match { case List(p) => List(x); case pats => @@ -308,19 +314,18 @@ class TransMatch( global:scalac_Global ) val pm = new matching.PatternMatcher( cunit ); pm.initialize(root, currentOwner, restpe, true ); try{ - /* + val ncases = removeAlterns(cases); - if(ncases.length > cases.length) { - debugLog("did some removal!"); - var kk = 0; while (kk<ncases.length) { - debugLog(ncases(kk).toString()); - kk = kk + 1; - } - } - else - //debugLog("did NOT do removal!"); - */ - pm.construct( cases.asInstanceOf[Array[Tree]] ); + //if(ncases.length > cases.length) { + // debugLog("did some removal!"); + // var kk = 0; while (kk<ncases.length) { + // debugLog(ncases(kk).toString()); + // kk = kk + 1; + // } + //} else + //else debugLog("did NOT do removal!"); + + pm.construct( ncases.asInstanceOf[Array[Tree]] ); } catch { case e:Throwable => e.printStackTrace(); diff --git a/sources/scala/tools/scalac/transformer/matching/PatternMatcher.scala b/sources/scala/tools/scalac/transformer/matching/PatternMatcher.scala index 641d3dd6cf..d55fcdaa73 100644 --- a/sources/scala/tools/scalac/transformer/matching/PatternMatcher.scala +++ b/sources/scala/tools/scalac/transformer/matching/PatternMatcher.scala @@ -280,6 +280,8 @@ class PatternMatcher(unit: CompilationUnit) extends PatternTool(unit) { mk.SeqContainerPat(tree.pos, tree.getType(), tree); } case Alternative(branches) => + throw new ApplicationError("kicked out Alternatives"); + /* if(branches.length < 2) throw new ApplicationError("ill-formed Alternative"); val subroot = mk.ConstrPat(header.pos, header.getTpe()); @@ -291,7 +293,7 @@ class PatternMatcher(unit: CompilationUnit) extends PatternTool(unit) { i = i + 1 } mk.AltPat(tree.pos, subroot.and.asInstanceOf[Header]); - + */ case _ => throw new ApplicationError("unit = " + unit + "; tree = "+tree); } diff --git a/sources/scala/tools/scalac/transformer/matching/PatternNode.scala b/sources/scala/tools/scalac/transformer/matching/PatternNode.scala index 28ac14d26c..37e1fdbd33 100644 --- a/sources/scala/tools/scalac/transformer/matching/PatternNode.scala +++ b/sources/scala/tools/scalac/transformer/matching/PatternNode.scala @@ -63,8 +63,8 @@ package scala.tools.scalac.transformer.matching { case VariablePat(tree) => res = VariablePat(tree); - case AltPat(subheader) => - res = AltPat(subheader); + //case AltPat(subheader) => + // res = AltPat(subheader); case _ => throw new ApplicationError(); @@ -147,16 +147,6 @@ package scala.tools.scalac.transformer.matching { q match { case ConstrPat(_) => q.getTpe().isSubType(this.getTpe()); - /* TEST - case AltPat(subroot) => - var node = subroot.and.or; - var res = false; - while(node!=null && !false) { - res = this subsumes(node); - node = node.or; - } - res - */ case _ => false; } @@ -184,16 +174,6 @@ package scala.tools.scalac.transformer.matching { case _ => false; } - /* TEST - case AltPat(subroot) => - var node = subroot.and.or; - var res = false; - while(node!=null && !false) { - res = node subsumes q; - node = node.or; - } - res - */ case _ => false; } @@ -238,7 +218,7 @@ package scala.tools.scalac.transformer.matching { case class ConstrPat(casted:Symbol )extends PatternNode; case class ConstantPat(value:AConstant )extends PatternNode; case class VariablePat(tree:Tree )extends PatternNode; - case class AltPat(subheader:Header )extends PatternNode; + //case class AltPat(subheader:Header )extends PatternNode; case class SequencePat( casted:Symbol, len:int)extends PatternNode; // only used in PatternMatcher case class SeqContainerPat(casted:Symbol , seqpat:Tree)extends PatternNode; // in AlgebraicMatcher } |