@@ -32,7 +32,7 @@ object Scopes {
32
32
* This value must be a power of two, so that the index of an element can
33
33
* be computed as element.hashCode & (hashTable.length - 1)
34
34
*/
35
- private final val MinHash = 8
35
+ final val MinHashedScopeSize = 8
36
36
37
37
/** The maximal permissible number of recursions when creating
38
38
* a hashtable
@@ -144,11 +144,6 @@ object Scopes {
144
144
final def toText (printer : Printer ): Text = printer.toText(this )
145
145
146
146
def checkConsistent ()(implicit ctx : Context ) = ()
147
-
148
- /** Hook for transforming a name before it is used in a lookup or creation.
149
- * Used to mangle names in package scopes.
150
- */
151
- protected def normalize (name : Name ): Name = name
152
147
}
153
148
154
149
/** A subclass of Scope that defines methods for entering and
@@ -163,7 +158,7 @@ object Scopes {
163
158
/** Scope shares elements with `base` */
164
159
protected [Scopes ] def this (base : Scope )(implicit ctx : Context ) = {
165
160
this (base.lastEntry, base.size, base.nestingLevel + 1 )
166
- ensureCapacity(MinHash )(ctx) // WTH? it seems the implicit is not in scope for a secondary constructor call.
161
+ ensureCapacity(MinHashedScopeSize )(ctx) // WTH? it seems the implicit is not in scope for a secondary constructor call.
167
162
}
168
163
169
164
def this () = this (null , 0 , 0 )
@@ -205,8 +200,8 @@ object Scopes {
205
200
206
201
/** create and enter a scope entry with given name and symbol */
207
202
protected def newScopeEntry (name : Name , sym : Symbol )(implicit ctx : Context ): ScopeEntry = {
208
- ensureCapacity(if (hashTable ne null ) hashTable.length else MinHash )
209
- val e = new ScopeEntry (normalize( name) , sym, this )
203
+ ensureCapacity(if (hashTable ne null ) hashTable.length else MinHashedScopeSize )
204
+ val e = new ScopeEntry (name, sym, this )
210
205
e.prev = lastEntry
211
206
lastEntry = e
212
207
if (hashTable ne null ) enterInHash(e)
@@ -242,7 +237,7 @@ object Scopes {
242
237
enter(sym)
243
238
}
244
239
245
- protected def ensureCapacity (tableSize : Int )(implicit ctx : Context ): Unit =
240
+ private def ensureCapacity (tableSize : Int )(implicit ctx : Context ): Unit =
246
241
if (size >= tableSize * FillFactor ) createHash(tableSize * 2 )
247
242
248
243
private def createHash (tableSize : Int )(implicit ctx : Context ): Unit =
@@ -318,16 +313,15 @@ object Scopes {
318
313
/** Lookup a symbol entry matching given name.
319
314
*/
320
315
override def lookupEntry (name : Name )(implicit ctx : Context ): ScopeEntry = {
321
- val normalized = normalize(name)
322
316
var e : ScopeEntry = null
323
317
if (hashTable ne null ) {
324
- e = hashTable(normalized .hashCode & (hashTable.length - 1 ))
325
- while ((e ne null ) && e.name != normalized ) {
318
+ e = hashTable(name .hashCode & (hashTable.length - 1 ))
319
+ while ((e ne null ) && e.name != name ) {
326
320
e = e.tail
327
321
}
328
322
} else {
329
323
e = lastEntry
330
- while ((e ne null ) && e.name != normalized ) {
324
+ while ((e ne null ) && e.name != name ) {
331
325
e = e.prev
332
326
}
333
327
}
@@ -403,25 +397,6 @@ object Scopes {
403
397
}
404
398
}
405
399
406
- /** The scope of a package. This is different from a normal scope
407
- * in that names of scope entries are kept in mangled form.
408
- */
409
- class PackageScope protected [Scopes ](initElems : ScopeEntry , initSize : Int , nestingLevel : Int )
410
- extends MutableScope (initElems, initSize, nestingLevel) {
411
-
412
- /** Scope shares elements with `base` */
413
- def this (base : Scope )(implicit ctx : Context ) = {
414
- this (base.lastEntry, base.size, base.nestingLevel + 1 )
415
- ensureCapacity(MinHash )(ctx) // WTH? it seems the implicit is not in scope for a secondary constructor call.
416
- }
417
-
418
- def this () = this (null , 0 , 0 )
419
-
420
- override def newScopeLikeThis () = new PackageScope ()
421
-
422
- override protected def normalize (name : Name ) = name.mangled
423
- }
424
-
425
400
/** Create a new scope */
426
401
def newScope : MutableScope = new MutableScope ()
427
402
@@ -435,9 +410,6 @@ object Scopes {
435
410
scope
436
411
}
437
412
438
- /** Create new scope for the members of package `pkg` */
439
- def newPackageScope (pkgClass : Symbol ): MutableScope = new PackageScope ()
440
-
441
413
/** Transform scope of members of `owner` using operation `op`
442
414
* This is overridden by the reflective compiler to avoid creating new scopes for packages
443
415
*/
0 commit comments