@@ -30,7 +30,7 @@ import Decorators._
30
30
import tpd ._
31
31
32
32
import scala .tools .asm
33
- import StdNames .nme
33
+ import StdNames .{ nme , str }
34
34
import NameOps ._
35
35
import NameKinds .DefaultGetterName
36
36
import dotty .tools .dotc .core
@@ -161,7 +161,8 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
161
161
def boxMethods : Map [Symbol , Symbol ] = defn.ScalaValueClasses ().map{x => // @darkdimius Are you sure this should be a def?
162
162
(x, Erasure .Boxing .boxMethod(x.asClass))
163
163
}.toMap
164
- def unboxMethods : Map [Symbol , Symbol ] = defn.ScalaValueClasses ().map(x => (x, Erasure .Boxing .unboxMethod(x.asClass))).toMap
164
+ def unboxMethods : Map [Symbol , Symbol ] =
165
+ defn.ScalaValueClasses ().map(x => (x, Erasure .Boxing .unboxMethod(x.asClass))).toMap
165
166
166
167
override def isSyntheticArrayConstructor (s : Symbol ) = {
167
168
s eq defn.newArrayMethod
@@ -244,15 +245,15 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
244
245
case ClazzTag => av.visit(name, const.typeValue.toTypeKind(bcodeStore)(innerClasesStore).toASMType)
245
246
case EnumTag =>
246
247
val edesc = innerClasesStore.typeDescriptor(const.tpe.asInstanceOf [bcodeStore.int.Type ]) // the class descriptor of the enumeration class.
247
- val evalue = const.symbolValue.name.toString // value the actual enumeration value.
248
+ val evalue = const.symbolValue.name.mangledString // value the actual enumeration value.
248
249
av.visitEnum(name, edesc, evalue)
249
250
}
250
251
case t : TypeApply if (t.fun.symbol == Predef_classOf ) =>
251
252
av.visit(name, t.args.head.tpe.classSymbol.denot.info.toTypeKind(bcodeStore)(innerClasesStore).toASMType)
252
253
case t : tpd.Select =>
253
254
if (t.symbol.denot.is(Flags .Enum )) {
254
255
val edesc = innerClasesStore.typeDescriptor(t.tpe.asInstanceOf [bcodeStore.int.Type ]) // the class descriptor of the enumeration class.
255
- val evalue = t.symbol.name.toString // value the actual enumeration value.
256
+ val evalue = t.symbol.name.mangledString // value the actual enumeration value.
256
257
av.visitEnum(name, edesc, evalue)
257
258
} else {
258
259
assert(toDenot(t.symbol).name.is(DefaultGetterName )) // this should be default getter. do not emmit.
@@ -262,8 +263,8 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
262
263
for (arg <- t.elems) { emitArgument(arrAnnotV, null , arg, bcodeStore)(innerClasesStore) }
263
264
arrAnnotV.visitEnd()
264
265
265
- case Apply (fun, args) if ( fun.symbol == defn.ArrayClass .primaryConstructor ||
266
- ( toDenot(fun.symbol).owner == defn.ArrayClass .linkedClass && fun.symbol.name == nme_apply)) =>
266
+ case Apply (fun, args) if fun.symbol == defn.ArrayClass .primaryConstructor ||
267
+ toDenot(fun.symbol).owner == defn.ArrayClass .linkedClass && fun.symbol.name == nme_apply =>
267
268
val arrAnnotV : AnnotationVisitor = av.visitArray(name)
268
269
269
270
var actualArgs = if (fun.tpe.isInstanceOf [ImplicitMethodType ]) {
@@ -311,7 +312,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
311
312
private def emitAssocs (av : asm.AnnotationVisitor , assocs : List [(Name , Object )], bcodeStore : BCodeHelpers )
312
313
(innerClasesStore : bcodeStore.BCInnerClassGen ) = {
313
314
for ((name, value) <- assocs)
314
- emitArgument(av, name.toString , value.asInstanceOf [Tree ], bcodeStore)(innerClasesStore)
315
+ emitArgument(av, name.mangledString , value.asInstanceOf [Tree ], bcodeStore)(innerClasesStore)
315
316
av.visitEnd()
316
317
}
317
318
@@ -360,9 +361,8 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
360
361
else clazz.getName
361
362
}
362
363
363
- def requiredClass [T ](implicit evidence : ClassTag [T ]): Symbol = {
364
+ def requiredClass [T ](implicit evidence : ClassTag [T ]): Symbol =
364
365
ctx.requiredClass(erasureString(evidence.runtimeClass).toTermName)
365
- }
366
366
367
367
def requiredModule [T ](implicit evidence : ClassTag [T ]): Symbol = {
368
368
val moduleName = erasureString(evidence.runtimeClass)
@@ -404,16 +404,15 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
404
404
def newAnyRefMap [K <: AnyRef , V ](): mutable.AnyRefMap [K , V ] = new mutable.AnyRefMap [K , V ]()
405
405
def newWeakMap [K , V ](): mutable.WeakHashMap [K , V ] = new mutable.WeakHashMap [K , V ]()
406
406
def recordCache [T <: Clearable ](cache : T ): T = cache
407
- def newWeakSet [K <: AnyRef ](): WeakHashSet [K ] = new WeakHashSet [K ]()
407
+ def newWeakSet [K >: Null <: AnyRef ](): WeakHashSet [K ] = new WeakHashSet [K ]()
408
408
def newMap [K , V ](): mutable.HashMap [K , V ] = new mutable.HashMap [K , V ]()
409
409
def newSet [K ](): mutable.Set [K ] = new mutable.HashSet [K ]
410
410
}
411
411
412
+ val MODULE_INSTANCE_FIELD : String = str.MODULE_INSTANCE_FIELD
412
413
413
-
414
- val MODULE_INSTANCE_FIELD : String = nme.MODULE_INSTANCE_FIELD .toString
415
-
416
- def internalNameString (offset : Int , length : Int ): String = new String (Names .chrs, offset, length)
414
+ def dropModule (str : String ) =
415
+ if (! str.isEmpty && str.last == '$' ) str.take(str.length - 1 ) else str
417
416
418
417
def newTermName (prefix : String ): Name = prefix.toTermName
419
418
@@ -424,7 +423,6 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
424
423
Flags .Bridge | Flags .VBridge | Flags .Private | Flags .Macro
425
424
}.bits
426
425
427
-
428
426
def isQualifierSafeToElide (qual : Tree ): Boolean = tpd.isIdempotentExpr(qual)
429
427
def desugarIdent (i : Ident ): Option [tpd.Select ] = {
430
428
i.tpe match {
@@ -537,32 +535,25 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
537
535
}
538
536
}
539
537
540
-
541
538
implicit def nameHelper (n : Name ): NameHelper = new NameHelper {
542
- def toTypeName : Name = n.toTypeName
543
539
def isTypeName : Boolean = n.isTypeName
544
- def toTermName : Name = n.toTermName
545
- def dropModule : Name = n.stripModuleClassSuffix
546
-
547
- def len : Int = n.toSimpleName.length
548
- def offset : Int = n.toSimpleName.start
549
540
def isTermName : Boolean = n.isTermName
550
541
def startsWith (s : String ): Boolean = n.startsWith(s)
542
+ def mangledString : String = n.mangledString
551
543
}
552
544
553
-
554
545
implicit def symHelper (sym : Symbol ): SymbolHelper = new SymbolHelper {
555
546
// names
556
547
def fullName (sep : Char ): String = sym.showFullName
557
548
def fullName : String = sym.showFullName
558
549
def simpleName : Name = sym.name
559
- def javaSimpleName : Name = toDenot(sym).name // addModuleSuffix(simpleName.dropLocal)
560
- def javaBinaryName : Name = javaClassName.replace('.' , '/' ).toTypeName // TODO: can we make this a string? addModuleSuffix(fullNameInternal('/'))
561
- def javaClassName : String = toDenot(sym).fullName.toString // addModuleSuffix(fullNameInternal('.')).toString
550
+ def javaSimpleName : String = toDenot(sym).name.mangledString // addModuleSuffix(simpleName.dropLocal)
551
+ def javaBinaryName : String = javaClassName.replace('.' , '/' ) // TODO: can we make this a string? addModuleSuffix(fullNameInternal('/'))
552
+ def javaClassName : String = toDenot(sym).fullName.mangledString // addModuleSuffix(fullNameInternal('.')).toString
562
553
def name : Name = sym.name
563
- def rawname : Name = {
554
+ def rawname : String = {
564
555
val original = toDenot(sym).initial
565
- sym.name(ctx.withPhase(original.validFor.phaseId))
556
+ sym.name(ctx.withPhase(original.validFor.phaseId)).mangledString
566
557
}
567
558
568
559
// types
@@ -675,9 +666,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
675
666
}
676
667
def enclClass : Symbol = toDenot(sym).enclosingClass
677
668
def linkedClassOfClass : Symbol = linkedClass
678
- def linkedClass : Symbol = {
679
- toDenot(sym)(ctx).linkedClass(ctx)
680
- } // exitingPickler(sym.linkedClassOfClass)
669
+ def linkedClass : Symbol = toDenot(sym)(ctx).linkedClass(ctx) // exitingPickler(sym.linkedClassOfClass)
681
670
def companionClass : Symbol = toDenot(sym).companionClass
682
671
def companionModule : Symbol = toDenot(sym).companionModule
683
672
def companionSymbol : Symbol = if (sym is Flags .Module ) companionClass else companionModule
0 commit comments