summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorBurak Emir <emir@epfl.ch>2007-03-24 19:41:46 +0000
committerBurak Emir <emir@epfl.ch>2007-03-24 19:41:46 +0000
commitc5ebdc8ee58b610c041e20a4f3b7f18896c8d930 (patch)
tree29630fb1727fcbee5032946af5e611766e0c789d /src/compiler
parent5fc1ae9658fd6f3d406ce1c19ff4c2386316874f (diff)
downloadscala-c5ebdc8ee58b610c041e20a4f3b7f18896c8d930.tar.gz
scala-c5ebdc8ee58b610c041e20a4f3b7f18896c8d930.tar.bz2
scala-c5ebdc8ee58b610c041e20a4f3b7f18896c8d930.zip
ParallelMatching falls back when it cannot gene...
ParallelMatching falls back when it cannot generate optimized code for ints (@todo)
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/matching/ParallelMatching.scala23
-rw-r--r--src/compiler/scala/tools/nsc/matching/PatternMatchers.scala1
2 files changed, 21 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala
index 59882a116b..96d6d02a7b 100644
--- a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala
+++ b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala
@@ -8,13 +8,30 @@ trait ParallelMatching requires (transform.ExplicitOuter with PatternMatchers wi
import global._
- def DEBUG(x:String) = {if (settings.debug.value) Console.println(x)}
+ final def DEBUG(x:String) = {if (settings.debug.value) Console.println(x)}
// ---------------------------------- data
- trait RuleApplication
+ sealed trait RuleApplication
case class ErrorRule extends RuleApplication
case class VariableRule(subst:List[Pair[Symbol,Symbol]], guard: Tree, body: Tree) extends RuleApplication
- case class MixtureRule(scrutinee:Symbol, column:List[Tree], rest:Rep) extends RuleApplication {
+
+ def MixtureRule(scrutinee:Symbol, column:List[Tree], rest:Rep): MixtureRule = {
+ if((scrutinee.tpe =:= definitions.IntClass.tpe) && (column forall {case Literal(c) => true case _ => false})) {
+ throw CantOptimize
+ //@todo: add SwitchRule, a special case of MixtureRule
+ } else {
+ new MixtureRule(scrutinee, column, rest)
+ }
+ }
+ /*
+ class SwitchRule(val scrutinee:Symbol, val column:List[Tree], val rest:Rep) extends MixtureRule(scrutinee,column,rest) {
+ def getTransition() = {
+ //here, we generate a switch tree, bodies of the switch is the corresponding [[row in rest]]
+ //if a default case has to be handled, body is [[that row + the default row]]
+ }
+ }
+ */
+ class MixtureRule(val scrutinee:Symbol, val column:List[Tree], val rest:Rep) extends RuleApplication {
var parent: Rep = null
def setParent(rep:Rep) = { parent = rep; this }
diff --git a/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala b/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala
index c777fa9347..251a761afe 100644
--- a/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala
+++ b/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala
@@ -24,6 +24,7 @@ trait PatternMatchers requires (transform.ExplicitOuter with PatternNodes with P
object CantHandleApply extends CantHandle
object CantHandleIdent extends CantHandle
object CantHandleGuard extends CantHandle
+ object CantOptimize extends CantHandle
//object CantHandleLiteral extends Exception
var nPatterns = 0