diff options
Diffstat (limited to 'src/compiler/scala/tools/nsc/matching/Matrix.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/matching/Matrix.scala | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/compiler/scala/tools/nsc/matching/Matrix.scala b/src/compiler/scala/tools/nsc/matching/Matrix.scala index 44387b59fb..d2f5a98411 100644 --- a/src/compiler/scala/tools/nsc/matching/Matrix.scala +++ b/src/compiler/scala/tools/nsc/matching/Matrix.scala @@ -140,7 +140,7 @@ trait Matrix extends MatrixAdditions { cases: List[CaseDef], default: Tree ) { - // def tvars = roots map (_.lhs) + def tvars = roots map (_.lhs) def valDefs = roots map (_.valDef) override def toString() = "MatrixInit(roots = %s, %d cases)".format(pp(roots), cases.size) } @@ -153,25 +153,25 @@ trait Matrix extends MatrixAdditions { def apply(xs: List[PatternVar]) = new PatternVarGroup(xs) // XXX - transitional - // def fromBindings(vlist: List[Binding], freeVars: List[Symbol] = Nil) = { - // def vmap(v: Symbol): Option[Binding] = vlist find (_.pvar eq v) - // val info = - // if (freeVars.isEmpty) vlist - // else (freeVars map vmap).flatten - - // val xs = - // for (Binding(lhs, rhs) <- info) yield - // new PatternVar(lhs, Ident(rhs) setType lhs.tpe, !(rhs hasFlag NO_EXHAUSTIVE)) - - // new PatternVarGroup(xs) - // } + def fromBindings(vlist: List[Binding], freeVars: List[Symbol] = Nil) = { + def vmap(v: Symbol): Option[Binding] = vlist find (_.pvar eq v) + val info = + if (freeVars.isEmpty) vlist + else (freeVars map vmap).flatten + + val xs = + for (Binding(lhs, rhs) <- info) yield + new PatternVar(lhs, Ident(rhs) setType lhs.tpe, !(rhs hasFlag NO_EXHAUSTIVE)) + + new PatternVarGroup(xs) + } } val emptyPatternVarGroup = PatternVarGroup() class PatternVarGroup(val pvs: List[PatternVar]) { def syms = pvs map (_.sym) def valDefs = pvs map (_.valDef) - // def idents = pvs map (_.ident) + def idents = pvs map (_.ident) def extractIndex(index: Int): (PatternVar, PatternVarGroup) = { val (t, ts) = self.extractIndex(pvs, index) @@ -180,16 +180,16 @@ trait Matrix extends MatrixAdditions { def isEmpty = pvs.isEmpty def size = pvs.size - // def head = pvs.head - // def ::(t: PatternVar) = PatternVarGroup(t :: pvs) + def head = pvs.head + def ::(t: PatternVar) = PatternVarGroup(t :: pvs) def :::(ts: List[PatternVar]) = PatternVarGroup(ts ::: pvs) - // def ++(other: PatternVarGroup) = PatternVarGroup(pvs ::: other.pvs) + def ++(other: PatternVarGroup) = PatternVarGroup(pvs ::: other.pvs) def apply(i: Int) = pvs(i) def zipWithIndex = pvs.zipWithIndex def indices = pvs.indices - // def map[T](f: PatternVar => T) = pvs map f - // def filter(p: PatternVar => Boolean) = PatternVarGroup(pvs filter p) + def map[T](f: PatternVar => T) = pvs map f + def filter(p: PatternVar => Boolean) = PatternVarGroup(pvs filter p) override def toString() = pp(pvs) } @@ -237,12 +237,12 @@ trait Matrix extends MatrixAdditions { tracing("create")(new PatternVar(lhs, rhs, checked)) } - // def createLazy(tpe: Type, f: Symbol => Tree, checked: Boolean) = { - // val lhs = newVar(owner.pos, tpe, Flags.LAZY :: flags(checked)) - // val rhs = f(lhs) + def createLazy(tpe: Type, f: Symbol => Tree, checked: Boolean) = { + val lhs = newVar(owner.pos, tpe, Flags.LAZY :: flags(checked)) + val rhs = f(lhs) - // tracing("createLazy")(new PatternVar(lhs, rhs, checked)) - // } + tracing("createLazy")(new PatternVar(lhs, rhs, checked)) + } private def newVar( pos: Position, |