diff options
author | Martin Odersky <odersky@gmail.com> | 2016-10-17 15:49:42 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-10-17 15:51:22 +0200 |
commit | 6ce403eb0c6b630f925db38b7538e0f9b8c892ea (patch) | |
tree | 1a395799f4aeee5a7295378c361966566c8c35ab /src/dotty/tools/dotc | |
parent | 2fe0f674124c5be064d1cbf80594fb8e7d5d78be (diff) | |
download | dotty-6ce403eb0c6b630f925db38b7538e0f9b8c892ea.tar.gz dotty-6ce403eb0c6b630f925db38b7538e0f9b8c892ea.tar.bz2 dotty-6ce403eb0c6b630f925db38b7538e0f9b8c892ea.zip |
Pickle Inlined trees
Inlined trees should be preserved by pickling so that we keep
positions accurate.
With that change now all tasty tests are tested for position
accuracy.
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r-- | src/dotty/tools/dotc/core/tasty/TastyFormat.scala | 3 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/tasty/TreePickler.scala | 13 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala | 19 |
3 files changed, 20 insertions, 15 deletions
diff --git a/src/dotty/tools/dotc/core/tasty/TastyFormat.scala b/src/dotty/tools/dotc/core/tasty/TastyFormat.scala index fc551658b..a8725136d 100644 --- a/src/dotty/tools/dotc/core/tasty/TastyFormat.scala +++ b/src/dotty/tools/dotc/core/tasty/TastyFormat.scala @@ -79,6 +79,7 @@ Standard-Section: "ASTs" TopLevelStat* NAMEDARG Length paramName_NameRef arg_Term ASSIGN Length lhs_Term rhs_Term BLOCK Length expr_Term Stat* + INLINED Length call_Term expr_Term Stat* LAMBDA Length meth_Term target_Type IF Length cond_Term then_Term else_Term MATCH Length sel_Term CaseDef* @@ -306,6 +307,7 @@ object TastyFormat { final val MATCH = 149 final val RETURN = 150 final val TRY = 151 + final val INLINED = 152 final val REPEATED = 153 final val BIND = 154 final val ALTERNATIVE = 155 @@ -456,6 +458,7 @@ object TastyFormat { case LAMBDA => "LAMBDA" case MATCH => "MATCH" case RETURN => "RETURN" + case INLINED => "INLINED" case TRY => "TRY" case REPEATED => "REPEATED" case BIND => "BIND" diff --git a/src/dotty/tools/dotc/core/tasty/TreePickler.scala b/src/dotty/tools/dotc/core/tasty/TreePickler.scala index a5f421888..7f1895cc3 100644 --- a/src/dotty/tools/dotc/core/tasty/TreePickler.scala +++ b/src/dotty/tools/dotc/core/tasty/TreePickler.scala @@ -438,15 +438,10 @@ class TreePickler(pickler: TastyPickler) { case SeqLiteral(elems, elemtpt) => writeByte(REPEATED) withLength { pickleTree(elemtpt); elems.foreach(pickleTree) } - case tree: Inlined => - // Why drop Inlined info when pickling? - // Since we never inline inside an inlined method, we know that - // any code that continas an Inlined tree is not inlined itself. - // So position information for inline expansion is no longer needed. - // The only reason to keep the inline info around would be to have fine-grained - // position information in the linker. We should come back to this - // point once we know more what we would do with such information. - pickleTree(Inliner.dropInlined(tree)) + case Inlined(call, bindings, expansion) => + writeByte(INLINED) + bindings.foreach(preRegister) + withLength { pickleTree(call); pickleTree(expansion); bindings.foreach(pickleTree) } case TypeTree() => pickleTpt(tree) case Bind(name, body) => diff --git a/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index 57c0fe32d..35613c08d 100644 --- a/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -905,6 +905,15 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table, posUnpickle def readLengthTerm(): Tree = { val end = readEnd() + def readBlock(mkTree: (List[Tree], Tree) => Tree): Tree = { + val exprReader = fork + skipTree() + val localCtx = ctx.fresh.setNewScope + val stats = readStats(ctx.owner, end)(localCtx) + val expr = exprReader.readTerm()(localCtx) + mkTree(stats, expr) + } + val result = (tag: @switch) match { case SUPER => @@ -937,12 +946,10 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table, posUnpickle case ASSIGN => Assign(readTerm(), readTerm()) case BLOCK => - val exprReader = fork - skipTree() - val localCtx = ctx.fresh.setNewScope - val stats = readStats(ctx.owner, end)(localCtx) - val expr = exprReader.readTerm()(localCtx) - Block(stats, expr) + readBlock(Block) + case INLINED => + val call = readTerm() + readBlock((defs, expr) => Inlined(call, defs.asInstanceOf[List[MemberDef]], expr)) case IF => If(readTerm(), readTerm(), readTerm()) case LAMBDA => |