@@ -111,7 +111,7 @@ class ClassfileParser(
111
111
}
112
112
113
113
/** Return the class symbol of the given name. */
114
- def classNameToSymbol (name : Name )(using Context ): Symbol = innerClasses.get(name) match {
114
+ def classNameToSymbol (name : Name )(using Context , DataReader ): Symbol = innerClasses.get(name) match {
115
115
case Some (entry) => innerClasses.classSymbol(entry)
116
116
case None => requiredClass(name)
117
117
}
@@ -316,7 +316,7 @@ class ClassfileParser(
316
316
case BOOL_TAG => defn.BooleanType
317
317
}
318
318
319
- private def sigToType (sig : String , owner : Symbol = null , isVarargs : Boolean = false )(using Context ): Type = {
319
+ private def sigToType (sig : String , owner : Symbol = null , isVarargs : Boolean = false )(using Context , DataReader ): Type = {
320
320
var index = 0
321
321
val end = sig.length
322
322
def accept (ch : Char ): Unit = {
@@ -718,7 +718,7 @@ class ClassfileParser(
718
718
/** Enter own inner classes in the right scope. It needs the scopes to be set up,
719
719
* and implicitly current class' superclasses.
720
720
*/
721
- private def enterOwnInnerClasses ()(using Context ): Unit = {
721
+ private def enterOwnInnerClasses ()(using Context , DataReader ): Unit = {
722
722
def enterClassAndModule (entry : InnerClassEntry , file : AbstractFile , jflags : Int ) =
723
723
SymbolLoaders .enterClassAndModule(
724
724
getOwner(jflags),
@@ -921,20 +921,20 @@ class ClassfileParser(
921
921
}
922
922
923
923
/** An entry in the InnerClasses attribute of this class file. */
924
- case class InnerClassEntry (external : Int , outer : Int , name : Int , jflags : Int ) {
925
- def externalName : SimpleName = pool.getClassName(external).name
926
- def outerName : SimpleName = pool.getClassName(outer).name
927
- def originalName : SimpleName = pool.getName(name).name
924
+ private case class InnerClassEntry (external : Int , outer : Int , name : Int , jflags : Int ) {
925
+ def externalName ( using DataReader ) : SimpleName = pool.getClassName(external).name
926
+ def outerName ( using DataReader ) : SimpleName = pool.getClassName(outer).name
927
+ def originalName ( using DataReader ) : SimpleName = pool.getName(name).name
928
928
929
- override def toString : String =
929
+ def show ( using DataReader ) : String =
930
930
s " $originalName in $outerName( $externalName) "
931
931
}
932
932
933
- object innerClasses extends util.HashMap [Name , InnerClassEntry ] {
933
+ private object innerClasses extends util.HashMap [Name , InnerClassEntry ] {
934
934
/** Return the Symbol of the top level class enclosing `name`,
935
935
* or 'name's symbol if no entry found for `name`.
936
936
*/
937
- def topLevelClass (name : Name )(using Context ): Symbol = {
937
+ def topLevelClass (name : Name )(using Context , DataReader ): Symbol = {
938
938
val tlName = if (contains(name)) {
939
939
var entry = this (name)
940
940
while (contains(entry.outerName))
@@ -949,7 +949,7 @@ class ClassfileParser(
949
949
/** Return the class symbol for `entry`. It looks it up in its outer class.
950
950
* This might force outer class symbols.
951
951
*/
952
- def classSymbol (entry : InnerClassEntry )(using Context ): Symbol = {
952
+ def classSymbol (entry : InnerClassEntry )(using Context , DataReader ): Symbol = {
953
953
def getMember (sym : Symbol , name : Name )(using Context ): Symbol =
954
954
if (isStatic(entry.jflags))
955
955
if (sym == classRoot.symbol)
@@ -1024,7 +1024,7 @@ class ClassfileParser(
1024
1024
}
1025
1025
}
1026
1026
1027
- def getClassSymbol (name : SimpleName )(using Context ): Symbol =
1027
+ def getClassSymbol (name : SimpleName )(using Context , DataReader ): Symbol =
1028
1028
if (name.endsWith(" $" ) && (name ne nme.nothingRuntimeClass) && (name ne nme.nullRuntimeClass))
1029
1029
// Null$ and Nothing$ ARE classes
1030
1030
requiredModule(name.dropRight(1 ))
@@ -1061,7 +1061,7 @@ class ClassfileParser(
1061
1061
}
1062
1062
1063
1063
/** Return the name found at given index. */
1064
- def getName (index : Int ): NameOrString = {
1064
+ def getName (index : Int )( using in : DataReader ) : NameOrString = {
1065
1065
if (index <= 0 || len <= index)
1066
1066
errorBadIndex(index)
1067
1067
@@ -1078,7 +1078,7 @@ class ClassfileParser(
1078
1078
}
1079
1079
1080
1080
/** Return the name found at given index in the constant pool, with '/' replaced by '.'. */
1081
- def getExternalName (index : Int ): NameOrString = {
1081
+ def getExternalName (index : Int )( using in : DataReader ) : NameOrString = {
1082
1082
if (index <= 0 || len <= index)
1083
1083
errorBadIndex(index)
1084
1084
@@ -1088,7 +1088,7 @@ class ClassfileParser(
1088
1088
internalized(index)
1089
1089
}
1090
1090
1091
- def getClassSymbol (index : Int )(using Context ): Symbol = {
1091
+ def getClassSymbol (index : Int )(using ctx : Context , in : DataReader ): Symbol = {
1092
1092
if (index <= 0 || len <= index) errorBadIndex(index)
1093
1093
var c = values(index).asInstanceOf [Symbol ]
1094
1094
if (c eq null ) {
@@ -1104,7 +1104,7 @@ class ClassfileParser(
1104
1104
/** Return the external name of the class info structure found at 'index'.
1105
1105
* Use 'getClassSymbol' if the class is sure to be a top-level class.
1106
1106
*/
1107
- def getClassName (index : Int ): NameOrString = {
1107
+ def getClassName (index : Int )( using in : DataReader ) : NameOrString = {
1108
1108
val start = starts(index)
1109
1109
if (in.getByte(start).toInt != CONSTANT_CLASS ) errorBadTag(start)
1110
1110
getExternalName(in.getChar(start + 1 ))
@@ -1114,7 +1114,7 @@ class ClassfileParser(
1114
1114
* arrays are considered to be class types, they might
1115
1115
* appear as entries in 'newarray' or 'cast' opcodes.
1116
1116
*/
1117
- def getClassOrArrayType (index : Int )(using Context ): Type = {
1117
+ def getClassOrArrayType (index : Int )(using ctx : Context , in : DataReader ): Type = {
1118
1118
if (index <= 0 || len <= index) errorBadIndex(index)
1119
1119
val value = values(index)
1120
1120
var c : Type = null
@@ -1139,15 +1139,15 @@ class ClassfileParser(
1139
1139
c
1140
1140
}
1141
1141
1142
- def getType (index : Int , isVarargs : Boolean = false )(using Context ): Type =
1142
+ def getType (index : Int , isVarargs : Boolean = false )(using Context , DataReader ): Type =
1143
1143
sigToType(getExternalName(index).value, isVarargs = isVarargs)
1144
1144
1145
- def getSuperClass (index : Int )(using Context ): Symbol = {
1145
+ def getSuperClass (index : Int )(using Context , DataReader ): Symbol = {
1146
1146
assert(index != 0 , " attempt to parse java.lang.Object from classfile" )
1147
1147
getClassSymbol(index)
1148
1148
}
1149
1149
1150
- def getConstant (index : Int , pt : Type = WildcardType )(using Context ): Constant = {
1150
+ def getConstant (index : Int , pt : Type = WildcardType )(using ctx : Context , in : DataReader ): Constant = {
1151
1151
if (index <= 0 || len <= index) errorBadIndex(index)
1152
1152
var value = values(index)
1153
1153
if (value eq null ) {
@@ -1198,7 +1198,7 @@ class ClassfileParser(
1198
1198
arr
1199
1199
}
1200
1200
1201
- def getBytes (index : Int ): Array [Byte ] = {
1201
+ def getBytes (index : Int )( using in : DataReader ) : Array [Byte ] = {
1202
1202
if (index <= 0 || len <= index) errorBadIndex(index)
1203
1203
var value = values(index).asInstanceOf [Array [Byte ]]
1204
1204
if (value eq null ) {
@@ -1213,7 +1213,7 @@ class ClassfileParser(
1213
1213
value
1214
1214
}
1215
1215
1216
- def getBytes (indices : List [Int ]): Array [Byte ] = {
1216
+ def getBytes (indices : List [Int ])( using in : DataReader ) : Array [Byte ] = {
1217
1217
assert(! indices.isEmpty, indices)
1218
1218
var value = values(indices.head).asInstanceOf [Array [Byte ]]
1219
1219
if (value eq null ) {
@@ -1234,11 +1234,11 @@ class ClassfileParser(
1234
1234
}
1235
1235
1236
1236
/** Throws an exception signaling a bad constant index. */
1237
- private def errorBadIndex (index : Int ) =
1237
+ private def errorBadIndex (index : Int )( using in : DataReader ) =
1238
1238
throw new RuntimeException (" bad constant pool index: " + index + " at pos: " + in.bp)
1239
1239
1240
1240
/** Throws an exception signaling a bad tag at given address. */
1241
- private def errorBadTag (start : Int ) =
1241
+ private def errorBadTag (start : Int )( using in : DataReader ) =
1242
1242
throw new RuntimeException (" bad constant pool tag " + in.getByte(start) + " at byte " + start)
1243
1243
}
1244
1244
}
0 commit comments