From cd2843fa2689d8f4ecef3a25384b2ed62fe7b92e Mon Sep 17 00:00:00 2001 From: michelou Date: Tue, 21 Apr 2009 13:19:57 +0000 Subject: add serialization test, disabled patmat debug t... add serialization test, disabled patmat debug traces --- src/actors/scala/actors/Actor.scala | 12 +++---- .../scala/tools/nsc/ast/TreePrinters.scala | 8 +++-- .../tools/nsc/matching/ParallelMatching.scala | 11 +++--- .../scala/tools/nsc/matching/TransMatcher.scala | 40 ++++++++++++---------- src/library/scala/util/Marshal.scala | 6 ++-- 5 files changed, 42 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/actors/scala/actors/Actor.scala b/src/actors/scala/actors/Actor.scala index 4f71a1ab8d..0f5faedd50 100644 --- a/src/actors/scala/actors/Actor.scala +++ b/src/actors/scala/actors/Actor.scala @@ -907,10 +907,8 @@ trait Actor extends AbstractActor { */ def link(to: AbstractActor): AbstractActor = { assert(Actor.self == this, "link called on actor different from self") - synchronized { - links = to :: links - } - to.linkTo(this) + this linkTo to + to linkTo this to } @@ -937,10 +935,8 @@ trait Actor extends AbstractActor { */ def unlink(from: AbstractActor) { assert(Actor.self == this, "unlink called on actor different from self") - synchronized { - links = links.remove(from.==) - } - from.unlinkFrom(this) + this unlinkFrom from + from unlinkFrom this } private[actors] def unlinkFrom(from: AbstractActor) = synchronized { diff --git a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala index d6f16e3378..4deccddde6 100644 --- a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala +++ b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala @@ -116,12 +116,16 @@ abstract class TreePrinters { def printAnnotations(tree: Tree) { val annots = tree.symbol.attributes - if (!annots.isEmpty) + if (!annots.isEmpty) { annots foreach { annot => print("@"+annot+" ") } + println + } else { val annots = tree.asInstanceOf[MemberDef].mods.annotations - if (!annots.isEmpty) + if (!annots.isEmpty) { annots foreach { annot => print("@"+annot+" ") } + println + } } } diff --git a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala index 18aaa6d39f..61172ff6a2 100644 --- a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala +++ b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala @@ -28,8 +28,9 @@ import MatchUtil._ * * Row( p_m1 ... p_mn g_m b_m ) + subst * + * @author Burak Emir */ -trait ParallelMatching { +trait ParallelMatching { self: transform.ExplicitOuter with PatternNodes with CodeFactory => import global.{typer => _, _} @@ -45,8 +46,8 @@ trait ParallelMatching { * * results in Scrutinee(sym). * - * Note that we only ever match on Symbols, not Trees: A temporary variable is created for any - * expressions being matched on. + * Note that we only ever match on Symbols, not Trees: a temporary variable + * is created for any expressions being matched on. */ case class Scrutinee(val sym: Symbol) { import definitions._ @@ -911,13 +912,13 @@ trait ParallelMatching { val restTemp = temp.dropIndex(px) val restRows = row.map(r => r.replace(r.pat.dropIndex(px))) val mr = MixtureRule(new Scrutinee(t), column, rep.make(restTemp, restRows)) - DBG("\n---\nmixture rule is = " + mr.getClass) + //DBG("\n---\nmixture rule is = " + mr.getClass) return mr } } // Row( _ ... _ g_1 b_1 ) :: rows it's all default patterns val rest = if (g.isEmpty) null else rep.make(temp, xs) // TODO - why null? - DBG("\n---\nmixture rule is = VariableRule") + //DBG("\n---\nmixture rule is = VariableRule") VariableRule (bnd, g, rest, bx) } diff --git a/src/compiler/scala/tools/nsc/matching/TransMatcher.scala b/src/compiler/scala/tools/nsc/matching/TransMatcher.scala index 967c0938a6..b3ab6429b0 100644 --- a/src/compiler/scala/tools/nsc/matching/TransMatcher.scala +++ b/src/compiler/scala/tools/nsc/matching/TransMatcher.scala @@ -11,7 +11,8 @@ package scala.tools.nsc.matching * * @author Burak Emir */ -trait TransMatcher { self: transform.ExplicitOuter with PatternNodes with ParallelMatching with CodeFactory => +trait TransMatcher { + self: transform.ExplicitOuter with PatternNodes with ParallelMatching with CodeFactory => import global.{ typer => _, _ } import analyzer.Typer; @@ -22,8 +23,8 @@ trait TransMatcher { self: transform.ExplicitOuter with PatternNodes with Parall var resultType: Type = _ // cache these - final val settings_debug = settings.debug.value - final val settings_squeeze = settings.Xsqueeze.value == "on" + //final val settings_debug = settings.debug.value + final val settings_squeeze = settings.Xsqueeze.value == "on" // check special case Seq(p1,...,pk,_*) protected def isRightIgnoring(p: ArrayValue): Boolean = { @@ -44,11 +45,11 @@ trait TransMatcher { self: transform.ExplicitOuter with PatternNodes with Parall doCheckExhaustive: Boolean, owner: Symbol, handleOuter: Tree => Tree) - (implicit typer : Typer): Tree = + (implicit typer: Typer): Tree = { - DBG("****") - DBG("**** initalize, selector = "+selector+" selector.tpe = "+selector.tpe) - DBG("**** doCheckExhaustive == "+doCheckExhaustive) + //DBG("****") + //DBG("**** initalize, selector = "+selector+" selector.tpe = "+selector.tpe) + //DBG("**** doCheckExhaustive == "+doCheckExhaustive) implicit val theOwner = owner implicit val rep = new RepFactory(handleOuter) @@ -59,7 +60,9 @@ trait TransMatcher { self: transform.ExplicitOuter with PatternNodes with Parall case CaseDef(Ident(nme.WILDCARD), _, _) => true case _ => false } - def doApply(fn: Tree) = (fn.symbol eq selector.tpe.decls.lookup(nme.CONSTRUCTOR)) && (cases forall caseIsOk) + def doApply(fn: Tree): Boolean = + (fn.symbol eq selector.tpe.decls.lookup(nme.CONSTRUCTOR)) && + (cases forall caseIsOk) def processApply(app: Apply): (List[Symbol], List[Tree], Tree) = { val Apply(fn, args) = app @@ -76,7 +79,8 @@ trait TransMatcher { self: transform.ExplicitOuter with PatternNodes with Parall // sets temporaries, variable declarations, and the fail tree val (tmps, vds, theFailTree) = selector match { - case app @ Apply(fn, _) if isTupleType(selector.tpe) && doApply(fn) => processApply(app) + case app @ Apply(fn, _) if isTupleType(selector.tpe) && doApply(fn) => + processApply(app) case _ => val root: Symbol = newVar(selector.pos, selector.tpe, flags) val vdef: Tree = typer.typed(ValDef(root, selector)) @@ -85,25 +89,25 @@ trait TransMatcher { self: transform.ExplicitOuter with PatternNodes with Parall } implicit val fail: Tree = theFailTree - val irep = initRep(tmps, cases, rep) - val mch = typer.typed(irep.toTree) - var dfatree = typer.typed(Block(vds, mch)) + val irep = initRep(tmps, cases, rep) + val mch = typer.typed(irep.toTree) + var dfatree = typer.typed(Block(vds, mch)) // cannot use squeezedBlock because of side-effects, see t275 for ((cs, bx) <- cases.zipWithIndex) if (!rep.isReached(bx)) cunit.error(cs.body.pos, "unreachable code") dfatree = rep.cleanup(dfatree) - resetTrav.traverse(dfatree) + resetTraverser.traverse(dfatree) dfatree } - object resetTrav extends Traverser { + private object resetTraverser extends Traverser { override def traverse(x: Tree): Unit = x match { - case (vd: ValDef) => if (vd.symbol hasFlag Flags.SYNTHETIC) { - vd.symbol resetFlag Flags.TRANS_FLAG - vd.symbol resetFlag Flags.MUTABLE - } + case vd: ValDef => + if (vd.symbol hasFlag Flags.SYNTHETIC) { + vd.symbol resetFlag (Flags.TRANS_FLAG | Flags.MUTABLE) + } case _ => super.traverse(x) } diff --git a/src/library/scala/util/Marshal.scala b/src/library/scala/util/Marshal.scala index 9875a37c2a..a382265d6f 100644 --- a/src/library/scala/util/Marshal.scala +++ b/src/library/scala/util/Marshal.scala @@ -6,7 +6,7 @@ ** |/ ** \* */ -// $Id: $ +// $Id$ package scala.util @@ -38,7 +38,9 @@ object Marshal { throw new ClassCastException("type mismatch;"+ "\n found : "+found+ "\n required: "+expected) - in.readObject.asInstanceOf[A] + val o = in.readObject.asInstanceOf[A] + in.close() + o } } -- cgit v1.2.3