From 8cec943e961c4d82c132855e56d1747cf968830b Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 25 Apr 2015 13:41:22 +0200 Subject: Allow separate compilation of Dotty using TASTY Classfile parser now reads TASTY attributes or annotations and unpickles them in order to allow for separate compilation. --- .../tools/dotc/core/pickling/ClassfileParser.scala | 29 ++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'src/dotty/tools/dotc/core/pickling/ClassfileParser.scala') diff --git a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala index 3d47678b7..21c9aa84d 100644 --- a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala +++ b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala @@ -664,11 +664,17 @@ class ClassfileParser( i < attrs } - def unpickle(bytes: Array[Byte]): Boolean = { + def unpickleScala(bytes: Array[Byte]): Boolean = { new UnPickler(bytes, classRoot, moduleRoot)(ctx).run() true } + def unpickleTASTY(bytes: Array[Byte]): Boolean = { + new DottyUnpickler(bytes) + .enter(roots = Set(classRoot, moduleRoot, moduleRoot.sourceModule)) + true + } + def parseScalaSigBytes: Array[Byte] = { val tag = in.nextByte.toChar assert(tag == STRING_TAG, tag) @@ -688,6 +694,11 @@ class ClassfileParser( pool.getBytes(entries.toList) } + if (scan(tpnme.TASTYATTR)) { + val attrLen = in.nextInt + return unpickleTASTY(in.nextBytes(attrLen)) + } + if (scan(tpnme.RuntimeAnnotationATTR)) { val attrLen = in.nextInt val nAnnots = in.nextChar @@ -698,12 +709,16 @@ class ClassfileParser( var j = 0 while (j < nArgs) { val argName = pool.getName(in.nextChar) - if (attrClass == defn.ScalaSignatureAnnot && argName == nme.bytes) - return unpickle(parseScalaSigBytes) - else if (attrClass == defn.ScalaLongSignatureAnnot && argName == nme.bytes) - return unpickle(parseScalaLongSigBytes) - else - parseAnnotArg(skip = true) + if (argName == nme.bytes) + if (attrClass == defn.ScalaSignatureAnnot) + return unpickleScala(parseScalaSigBytes) + else if (attrClass == defn.ScalaLongSignatureAnnot) + return unpickleScala(parseScalaLongSigBytes) + else if (attrClass == defn.TASTYSignatureAnnot) + return unpickleTASTY(parseScalaSigBytes) + else if (attrClass == defn.TASTYLongSignatureAnnot) + return unpickleTASTY(parseScalaLongSigBytes) + parseAnnotArg(skip = true) j += 1 } i += 1 -- cgit v1.2.3