twitter / rsc

Experimental Scala compiler focused on compilation speed
Apache License 2.0
1.24k stars 54 forks source link

Annotations #93

Open xeno-by opened 6 years ago

xeno-by commented 6 years ago

Annotations aren't properly supported by SemanticDB yet, so they don't have proper support in Rsc either. Remaining upstream tickets are:

xeno-by commented 6 years ago

Here's an unfinished sketch for lowlevel tags and entries necessary to implement annotation support:

final val TREE = 49
final val EMPTYtree = 1
final val PACKAGEDEFtree = 2
final val CLASSDEFtree = 3
final val MODULEDEFtree = 4
final val VALDEFtree = 5
final val DEFDEFtree = 6
final val TYPEDEFtree = 7
final val LABELDEFtree = 8
final val IMPORTtree = 9
final val TEMPLATEtree = 12
final val BLOCKtree = 13
final val CASEtree = 14
final val ALTERNATIVEtree = 16
final val STARtree = 17
final val BINDtree = 18
final val UNAPPLYtree = 19
final val ARRAYVALUEtree = 20
final val FUNCTIONtree = 21
final val ASSIGNtree = 22
final val IFtree = 23
final val MATCHtree = 24
final val RETURNtree = 25
final val TRYtree = 26
final val THROWtree = 27
final val NEWtree = 28
final val TYPEDtree = 29
final val TYPEAPPLYtree = 30
final val APPLYtree = 31
final val APPLYDYNAMICtree = 32
final val SUPERtree = 33
final val THIStree = 34
final val SELECTtree = 35
final val IDENTtree = 36
final val LITERALtree = 37
final val TYPEtree = 38
final val ANNOTATEDtree = 39
final val SINGLETONTYPEtree = 40
final val SELECTFROMTYPEtree = 41
final val COMPOUNDTYPEtree = 42
final val APPLIEDTYPEtree = 43
final val TYPEBOUNDStree = 44
final val EXISTENTIALTYPEtree = 45
final val MODIFIERS = 50

final val SYMANNOT = 40
final val ANNOTINFO = 43
final val ANNOTARGARRAY = 44
sealed trait Tree extends Entry
case object EmptyTree extends Tree
case class PackageDefTree(tpe: Ref, sym: Ref, mods: Ref, name: Ref, stats: List[Ref]) extends Tree
case class ClassDefTree(tpe: Ref, sym: Ref, mods: Ref, name: Ref, tparams: List[Ref], impl: Ref) extends Tree
case class ModuleDefTree(tpe: Ref, sym: Ref, mods: Ref, name: Ref, impl: Ref) extends Tree
case class ValDefTree(tpe: Ref, sym: Ref, mods: Ref, name: Ref, tpt: Ref, rhs: Ref) extends Tree
case class DefDefTree(tpe: Ref, sym: Ref, mods: Ref, name: Ref, tparams: List[Ref], paramss: List[List[Ref]], ret: Ref, rhs: Ref) extends Tree
case class TypeDefTree(tpe: Ref, sym: Ref, mods: Ref, name: Ref, tparams: List[Ref], tpt: Ref) extends Tree
case class LabelDefTree(tpe: Ref, sym: Ref, name: Ref, params: List[Ref], rhs: Ref) extends Tree
case class ImportTree(tpe: Ref, sym: Ref, selectors: Ref) extends Tree
case class TemplateTree(tpe: Ref, sym: Ref, parents: List[Ref], self: Ref, stats: List[Ref]) extends Tree
case class BlockTree(tpe: Ref, stats: List[Ref]) extends Tree
case class CaseTree(tpe: Ref, pat: Ref, guard: Ref, body: Ref) extends Tree
case class AlternativeTree(tpe: Ref, trees: List[Ref]) extends Tree
case class StarTree(tpe: Ref, elem: Ref) extends Tree
case class BindTree(tpe: Ref, sym: Ref, name: Ref, body: Ref) extends Tree
case class UnapplyTree(tpe: Ref, fun: Ref, args: List[Ref]) extends Tree
case class ArrayValueTree(tpe: Ref, elemtpt: Ref, elems: List[Ref]) extends Tree
case class FunctionTree(tpe: Ref, sym: Ref, params: List[Ref], body: Ref) extends Tree
case class AssignTree(tpe: Ref, lhs: Ref, rhs: Ref) extends Tree
case class IfTree(tpe: Ref, cond: Ref, thenp: Ref, elsep: Ref) extends Tree
case class MatchTree(tpe: Ref, scrut: Ref, cases: List[Ref]) extends Tree
case class ReturnTree(tpe: Ref, sym: Ref, expr: Ref) extends Tree
case class TryTree(tpe: Ref, expr: Ref, cases: List[Ref], fin: Ref) extends Tree
case class ThrowTree(tpe: Ref, expr: Ref) extends Tree
case class NewTree(tpe: Ref, tpt: Ref) extends Tree
case class TypedTree(tpe: Ref, expr: Ref, tpt: Ref) extends Tree
case class TypeApplyTree(tpe: Ref, fun: Ref, targs: List[Ref]) extends Tree
case class ApplyTree(tpe: Ref, fun: Ref, args: List[Ref]) extends Tree
case class ApplyDynamicTree(tpe: Ref, fun: Ref, args: List[Ref]) extends Tree
case class SuperTree(tpe: Ref, sym: Ref, qual: Ref, mix: Ref) extends Tree
case class ThisTree(tpe: Ref, sym: Ref, qual: Ref) extends Tree
case class SelectTree(tpe: Ref, sym: Ref, qual: Ref, name: Ref) extends Tree
case class IdentTree(tpe: Ref, sym: Ref, name: Ref) extends Tree
case class LiteralTree(tpe: Ref, lit: Ref) extends Tree
case class TypeTree(tpe: Ref) extends Tree
case class AnnotatedTree(tpe: Ref, annot: Ref, arg: Ref) extends Tree
case class SingletonTypeTree(tpe: Ref, ref: Ref) extends Tree
case class SelectFromTypeTree(tpe: Ref, qual: Ref, name: Ref) extends Tree
case class CompoundTypeTree(tpe: Ref, impl: Ref) extends Tree
case class AppliedTypeTree(tpe: Ref, fun: Ref, targs: List[Ref]) extends Tree
case class TypeBoundsTree(tpe: Ref, lo: Ref, hi: Ref) extends Tree
case class ExistentialTypeTree(tpe: Ref, tpt: Ref, decls: List[Ref]) extends Tree
case class Modifiers(flags: Long, within: Ref) extends Entry

case class SymbolAnnot(sym: Ref, info: Ref, scalaArgs: List[Ref], javaArgs: List[Ref]) extends Entry
case class AnnotInfo(info: Ref, scalaArgs: List[Ref], javaArgs: List[Ref]) extends Entry
case class AnnotArgArray(lits: List[Ref]) extends Entry
xeno-by commented 5 years ago

As of #327, our scalasig library supports reading and writing everything necessary to persist annotations in ScalaSignatures.