diff options
author | Martin Odersky <odersky@gmail.com> | 2014-02-22 10:58:18 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-02-24 18:56:48 +0100 |
commit | afb74449e0443d321da4b79e776eab376fdc51b1 (patch) | |
tree | a8f9101da583018b398f18c8b95c9e5fd18e5110 /src/dotty/tools/dotc/ast | |
parent | a4e2a6ed89c33f8c79c7129cc493bff0f84e044c (diff) | |
download | dotty-afb74449e0443d321da4b79e776eab376fdc51b1.tar.gz dotty-afb74449e0443d321da4b79e776eab376fdc51b1.tar.bz2 dotty-afb74449e0443d321da4b79e776eab376fdc51b1.zip |
More statistics for created and retained trees
Diffstat (limited to 'src/dotty/tools/dotc/ast')
-rw-r--r-- | src/dotty/tools/dotc/ast/Trees.scala | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/ast/Trees.scala b/src/dotty/tools/dotc/ast/Trees.scala index f4f1260f4..12a635ce6 100644 --- a/src/dotty/tools/dotc/ast/Trees.scala +++ b/src/dotty/tools/dotc/ast/Trees.scala @@ -297,6 +297,18 @@ object Trees { def orElse[U >: Untyped <: T](that: => Tree[U]): Tree[U] = if (this eq genericEmptyTree) that else this + /** The number of nodes in this tree */ + def treeSize: Int = { + var s = 1 + def addSize(elem: Any): Unit = elem match { + case t: Tree[_] => s += t.treeSize + case ts: List[_] => ts foreach addSize + case _ => + } + productIterator foreach addSize + s + } + override def toText(printer: Printer) = printer.toText(this) override def hashCode(): Int = System.identityHashCode(this) |