aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/core/tasty
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-03-27 10:08:59 +0200
committerMartin Odersky <odersky@gmail.com>2017-04-11 09:33:10 +0200
commit0698383d595fec40c70905eb0e06b430f93ba0b8 (patch)
tree03a44262dd7529370da08e7503d99ccd96b3a871 /compiler/src/dotty/tools/dotc/core/tasty
parent606294c5729a7b106964415af6304d60cc102810 (diff)
downloaddotty-0698383d595fec40c70905eb0e06b430f93ba0b8.tar.gz
dotty-0698383d595fec40c70905eb0e06b430f93ba0b8.tar.bz2
dotty-0698383d595fec40c70905eb0e06b430f93ba0b8.zip
Add NameExtractors
Use a new scheme for creating and accessing semantic names which is based on semantic name extractors with nested info classes.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/core/tasty')
-rw-r--r--compiler/src/dotty/tools/dotc/core/tasty/NameBuffer.scala27
-rw-r--r--compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala6
-rw-r--r--compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala5
3 files changed, 20 insertions, 18 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/tasty/NameBuffer.scala b/compiler/src/dotty/tools/dotc/core/tasty/NameBuffer.scala
index 61a2c7fc5..e82a9b618 100644
--- a/compiler/src/dotty/tools/dotc/core/tasty/NameBuffer.scala
+++ b/compiler/src/dotty/tools/dotc/core/tasty/NameBuffer.scala
@@ -4,8 +4,10 @@ package core
package tasty
import collection.mutable
-import Names.{Name, chrs, DerivedTermName, SimpleTermName}
-import Decorators._, NameOps._
+import Names.{Name, chrs, SimpleTermName}
+import NameOps.NameDecorator
+import NameExtractors._
+import Decorators._
import TastyBuffer._
import scala.io.Codec
import TastyName._
@@ -27,20 +29,19 @@ class NameBuffer extends TastyBuffer(10000) {
def nameIndex(name: Name, toTasty: SimpleTermName => TastyName): NameRef = {
val tname = name.toTermName match {
- case DerivedTermName(name1, NameInfo.ModuleClass) =>
+ case ModuleClassName(name1) =>
ModuleClass(nameIndex(name1, toTasty))
- case DerivedTermName(name1, NameInfo.SuperAccessor) =>
+ case SuperAccessorName(name1) =>
SuperAccessor(nameIndex(name1, toTasty))
- case DerivedTermName(prefix, qual: NameInfo.Qualified) =>
- val tcon: (NameRef, NameRef) => TastyName = qual match {
- case _: NameInfo.Select => Qualified
- case _: NameInfo.Flatten => Flattened
- case _: NameInfo.Expand => Expanded
- }
- tcon(nameIndex(prefix, toTasty), nameIndex(qual.name))
- case DerivedTermName(prefix, NameInfo.DefaultGetter(num)) =>
+ case QualifiedName(prefix, selector) =>
+ Qualified(nameIndex(prefix, toTasty), nameIndex(selector))
+ case FlattenedName(prefix, selector) =>
+ Flattened(nameIndex(prefix, toTasty), nameIndex(selector))
+ case XpandedName(prefix, selector) =>
+ Expanded(nameIndex(prefix, toTasty), nameIndex(selector))
+ case DefaultGetterName(prefix, num) =>
DefaultGetter(nameIndex(prefix, toTasty), num)
- case DerivedTermName(prefix, NameInfo.Variant(sign)) =>
+ case VariantName(prefix, sign) =>
Variant(nameIndex(prefix, toTasty), sign)
case name1 =>
if (name1.isShadowedName) Shadowed(nameIndex(name1.revertShadowed, toTasty))
diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala
index e73d6ed0d..d25adfd29 100644
--- a/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala
+++ b/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala
@@ -9,7 +9,7 @@ import TastyFormat._
import Contexts._, Symbols._, Types._, Names._, Constants._, Decorators._, Annotations._, StdNames.tpnme, NameOps._
import collection.mutable
import typer.Inliner
-import NameOps._
+import NameOps._, NameExtractors._
import StdNames.nme
import TastyBuffer._
import TypeApplications._
@@ -62,13 +62,13 @@ class TreePickler(pickler: TastyPickler) {
private def pickleName(sym: Symbol)(implicit ctx: Context): Unit = {
val nameRef =
if (Config.semanticNames) {
- if (sym is Flags.ExpandedName) assert(sym.name.is(NameInfo.ExpandKind))
+ if (sym is Flags.ExpandedName) assert(sym.name.is(XpandedName))
nameIndex(sym.name)
}
else {
def encodeSuper(name: Name): TastyName.NameRef =
if (sym is Flags.SuperAccessor) {
- val SuperAccessorName(n) = name
+ val NameOps.SuperAccessorName(n) = name
nameIndex(TastyName.SuperAccessor(nameIndex(n)))
} else nameIndex(name)
if (sym is Flags.ExpandedName)
diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
index e83a6f195..f74cdc36a 100644
--- a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
+++ b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
@@ -5,6 +5,7 @@ package tasty
import Contexts._, Symbols._, Types._, Scopes._, SymDenotations._, Names._, NameOps._
import StdNames._, Denotations._, Flags._, Constants._, Annotations._
+import NameExtractors._
import util.Positions._
import ast.{tpd, Trees, untpd}
import Trees._
@@ -91,11 +92,11 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table, posUnpickle
case ModuleClass(original) => toTermName(original).moduleClassName.toTermName
case SuperAccessor(accessed) => toTermName(accessed).superName
case DefaultGetter(meth, num) => toTermName(meth).defaultGetterName(num)
- case Variant(original, sign) => toTermName(original).derived(NameInfo.Variant(sign))
+ case Variant(original, sign) => VariantName(toTermName(original), sign)
}
private def qualTermName(qual: NameRef, name: NameRef, sep: String) =
- toTermName(qual).derived(NameInfo.qualifier(sep)(toTermName(name).asSimpleName))
+ separatorToQualified(sep)(toTermName(qual), toTermName(name).asSimpleName)
def toTermName(ref: NameRef): TermName = toTermName(tastyName(ref))
def toTypeName(ref: NameRef): TypeName = toTermName(ref).toTypeName