aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-02-19 14:36:37 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-03-18 11:14:08 +0100
commit30f08b095192435b080afe4b1734b8ce48039f84 (patch)
treeaa0fa6e87098c1388663d560fc93ca6ae97b6f39
parented986b5256a535a50fe3c6095fe7a93376edb0fc (diff)
downloaddotty-30f08b095192435b080afe4b1734b8ce48039f84.tar.gz
dotty-30f08b095192435b080afe4b1734b8ce48039f84.tar.bz2
dotty-30f08b095192435b080afe4b1734b8ce48039f84.zip
Changes to pickling annotations
Problem is that we need to be strict in the annotation symbol (need to force at the latest when checking whether a definition has some specific class of annotation), but should be lazy in the rest of the tree. This is achieved by pickling annotations with a symbol and a full tree. At the same time, Annotated trees can be ignored because they are eliminated by Typer. We only need AnnotatedTypes.
-rw-r--r--src/dotty/tools/dotc/core/pickling/PickleFormat.scala10
-rw-r--r--src/dotty/tools/dotc/core/pickling/TreePickler.scala14
2 files changed, 14 insertions, 10 deletions
diff --git a/src/dotty/tools/dotc/core/pickling/PickleFormat.scala b/src/dotty/tools/dotc/core/pickling/PickleFormat.scala
index decc9a887..9e4992ffd 100644
--- a/src/dotty/tools/dotc/core/pickling/PickleFormat.scala
+++ b/src/dotty/tools/dotc/core/pickling/PickleFormat.scala
@@ -81,13 +81,13 @@ Standard-Section: "ASTs" Tree*
BIND Length boundName_NameRef patType_Type pat_Term
ALTERNATIVE Length alt_Term*
UNAPPLY Length fun_Term ImplicitArg* pat_Term*
- ANNOTATED Length annot_Term underlying_Term
EMPTYTREE
CaseDef = CASEDEF Length pat_Tree guard_Tree rhs_Tree
ImplicitArg = IMPLICITARG Length arg_Tree
Template = TEMPLATE Length parent_Tree* SelfDef? Stat* // Stat* always starts with the primary constructor.
SelfDef = Param
+ Annotation = ANNOTATION Length tycon_Symbol fullAnnotation_Tree
ASTRef = Nat // byte position in AST payload
Path = Constant
@@ -174,7 +174,7 @@ Standard-Section: "ASTs" Tree*
DEFAULTparameterized // Method with default params
DEFAULTinit // variable with “_” initializer
INSUPERCALL // defined the argument of a constructor supercall
- annotation_Term
+ Annotation
Note: Tree tags are grouped into 4 categories that determine what follows, and thus allow to compute the size of the tagged tree in a generic way.
@@ -320,8 +320,9 @@ object PickleFormat {
final val POLYtype = 175
final val PARAMtype = 176
final val IMPLICITARG = 177
- final val PRIVATEqualified = 178
- final val PROTECTEDqualified = 179
+ final val ANNOTATION = 178
+ final val PRIVATEqualified = 179
+ final val PROTECTEDqualified = 180
final val firstSimpleTreeTag = EMPTYTREE
final val firstNatTreeTag = SHARED
@@ -450,6 +451,7 @@ object PickleFormat {
case METHODtype => "METHODtype"
case PARAMtype => "PARAMtype"
case IMPLICITARG => "IMPLICITARG"
+ case ANNOTATION => "ANNOTATION"
case PRIVATEqualified => "PRIVATEqualified"
case PROTECTEDqualified => "PROTECTEDqualified"
}
diff --git a/src/dotty/tools/dotc/core/pickling/TreePickler.scala b/src/dotty/tools/dotc/core/pickling/TreePickler.scala
index 801d3edb6..b842a5985 100644
--- a/src/dotty/tools/dotc/core/pickling/TreePickler.scala
+++ b/src/dotty/tools/dotc/core/pickling/TreePickler.scala
@@ -6,7 +6,7 @@ package pickling
import ast.Trees._
import PickleFormat._
import core._
-import Contexts._, Symbols._, Types._, Names._, Constants._, Decorators._
+import Contexts._, Symbols._, Types._, Names._, Constants._, Decorators._, Annotations._
import collection.mutable
import TastyBuffer._
@@ -187,7 +187,7 @@ class TreePickler(pickler: TastyPickler, picklePositions: Boolean) {
withLength { pickleType(tpe.lo, richTypes); pickleType(tpe.hi, richTypes) }
case tpe: AnnotatedType =>
writeByte(ANNOTATED)
- withLength { pickleTree(tpe.annot.tree); pickleType(tpe.tpe, richTypes) }
+ withLength { pickleAnnotation(tpe.annot); pickleType(tpe.tpe, richTypes) }
case tpe: AndOrType =>
writeByte(if (tpe.isAnd) ANDtype else ORtype)
withLength { pickleType(tpe.tp1, richTypes); pickleType(tpe.tp2, richTypes) }
@@ -385,9 +385,6 @@ class TreePickler(pickler: TastyPickler, picklePositions: Boolean) {
case PackageDef(pid, stats) =>
writeByte(PACKAGE)
withLength { pickleType(pid.tpe); stats.foreach(pickleTree) }
- case Annotated(annot, arg) =>
- writeByte(ANNOTATED)
- withLength { pickleTree(annot); pickleTree(arg) }
case EmptyTree =>
writeByte(EMPTYTREE)
}}
@@ -450,7 +447,12 @@ class TreePickler(pickler: TastyPickler, picklePositions: Boolean) {
if (flags is Covariant) writeByte(COVARIANT)
if (flags is Contravariant) writeByte(CONTRAVARIANT)
}
- sym.annotations.foreach(ann => pickleTree(ann.tree))
+ sym.annotations.foreach(pickleAnnotation)
+ }
+
+ def pickleAnnotation(ann: Annotation) = {
+ writeByte(ANNOTATION)
+ withLength { pickleType(ann.symbol.typeRef); pickleTree(ann.tree) }
}
pickleTree(tree)