Skip to content

Commit a4a2d04

Browse files
committed
Refactor NameTags
- drop tags that cannot be part of Tasty trees from TastyFormat - move them to a new object, NameTags. - add comments explaining what each name tag represents.
1 parent 986ad10 commit a4a2d04

File tree

4 files changed

+208
-172
lines changed

4 files changed

+208
-172
lines changed

compiler/src/dotty/tools/dotc/core/NameKinds.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Names._
66
import NameOps._
77
import StdNames._
88
import util.DotClass
9-
import tasty.TastyFormat._
9+
import NameTags._
1010
import Decorators._
1111
import Contexts.Context
1212
import collection.mutable
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package dotty.tools
2+
package dotc
3+
package core
4+
5+
import tasty.TastyFormat
6+
7+
/** The possible tags of a NameKind */
8+
object NameTags extends TastyFormat.NameTags {
9+
10+
final val FLATTENED = 5 // A flat name, generated by Flatten
11+
12+
final val TRAITSETTER = 6 // A Scala-2 trait setter, generated by AugmentScala2Traits
13+
14+
final val INITIALIZER = 24 // A mixin initializer method
15+
16+
final val AVOIDCLASH = 25 // Adds a suffix to avoid a name clash;
17+
// Used in FirstTransform for synthesized companion objects of classes
18+
// if they would clash with another value.
19+
20+
final val DIRECT = 26 // Used by ShortCutImplicits for the name of methods that
21+
// implement implicit function result types directly.
22+
23+
final val FIELD = 27 // Used by Memoize to tag the name of a class member field.
24+
25+
final val EXTMETH = 28 // Used by ExtensionMethods for the name of an extension method
26+
// implementing a value class method.
27+
28+
final val ADAPTEDCLOSURE = 29 // Used in Erasure to adapt closures over primitive types.
29+
30+
final val IMPLMETH = 30 // Used to define methods in implementation classes
31+
// (can probably be removed).
32+
33+
def nameTagToString(tag: Int): String = tag match {
34+
case UTF8 => "UTF8"
35+
case QUALIFIED => "QUALIFIED"
36+
case FLATTENED => "FLATTENED"
37+
case EXPANDED => "EXPANDED"
38+
case EXPANDPREFIX => "EXPANDPREFIX"
39+
case TRAITSETTER => "TRAITSETTER"
40+
case UNIQUE => "UNIQUE"
41+
case DEFAULTGETTER => "DEFAULTGETTER"
42+
case VARIANT => "VARIANT"
43+
case OUTERSELECT => "OUTERSELECT"
44+
45+
case SUPERACCESSOR => "SUPERACCESSOR"
46+
case PROTECTEDACCESSOR => "PROTECTEDACCESSOR"
47+
case PROTECTEDSETTER => "PROTECTEDSETTER"
48+
case INITIALIZER => "INITIALIZER"
49+
case AVOIDCLASH => "AVOIDCLASH"
50+
case DIRECT => "DIRECT"
51+
case FIELD => "FIELD"
52+
case EXTMETH => "EXTMETH"
53+
case ADAPTEDCLOSURE => "ADAPTEDCLOSURE"
54+
case OBJECTCLASS => "OBJECTCLASS"
55+
56+
case SIGNED => "SIGNED"
57+
}
58+
}

0 commit comments

Comments
 (0)