summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2006-11-21 10:58:17 +0000
committerIulian Dragos <jaguarul@gmail.com>2006-11-21 10:58:17 +0000
commit54ad97b77d34a977c4cf2fc10c38593a7aa4106e (patch)
treec36ed4fe7620b8c459682a32052990a61e6b35c6 /src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
parent63ceabef32e3b26d188dc6eda39eb9bf6d549bd8 (diff)
downloadscala-54ad97b77d34a977c4cf2fc10c38593a7aa4106e.tar.gz
scala-54ad97b77d34a977c4cf2fc10c38593a7aa4106e.tar.bz2
scala-54ad97b77d34a977c4cf2fc10c38593a7aa4106e.zip
Added support for modules in icode reader.
Diffstat (limited to 'src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala')
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
index 3640cbbb5e..0cf3714328 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
@@ -169,18 +169,21 @@ abstract class ClassfileParser {
val name = getExternalName(in.getChar(start + 1))
if (name.endsWith("$"))
c = definitions.getModule(name.subName(0, name.length - 1))
- else if (name.pos('.') == name.length)
- c = definitions.getMember(definitions.EmptyPackageClass, name.toTypeName)
else
- c = definitions.getClass(name)
+ c = classNameToSymbol(name)
values(index) = c
}
c
}
/** Return the symbol of the class member at <code>index</code>.
- * If the member refers to special MODULE$ static field, return
+ * The following special cases exist:
+ * - If the member refers to special MODULE$ static field, return
* the symbol of the corresponding module.
+ * - If the member is a field, and is not found with the given name,
+ * another try is made by appending nme.LOCAL_SUFFIX
+ * - If no symbol is found in the right tpe, a new try is made in the
+ * companion class, in case the owner is an implementation class.
*/
def getMemberSymbol(index: Int, static: Boolean): Symbol = {
if (index <= 0 || len <= index) errorBadIndex(index)
@@ -200,6 +203,8 @@ abstract class ClassfileParser {
} else {
val owner = if (static) cls.linkedClassOfClass else cls
f = owner.info.decl(name).suchThat(.tpe.=:=(tpe))
+ if (f == NoSymbol)
+ f = owner.info.decl(newTermName(name.toString + nme.LOCAL_SUFFIX)).suchThat(.tpe.=:=(tpe))
if (f == NoSymbol) {
// if it's an impl class, try to find it's static member inside the class
assert(cls.isImplClass, "Not an implementation class: " + owner + " couldn't find " + name + ": " + tpe);
@@ -320,11 +325,7 @@ abstract class ClassfileParser {
while (name(index) != ';') { index = index + 1 }
val end = index
index = index + 1
- val clsName = name.subName(start, end)
- if (clsName.pos('.') == clsName.length)
- definitions.getMember(definitions.EmptyPackageClass, clsName.toTypeName).tpe
- else
- definitions.getClass(clsName).tpe
+ classNameToSymbol(name.subName(start, end)).tpe
case ARRAY_TAG =>
while ('0' <= name(index) && name(index) <= '9') index = index + 1
appliedType(definitions.ArrayClass.tpe, List(sig2type))
@@ -335,6 +336,14 @@ abstract class ClassfileParser {
sig2type
}
+ /** Return the class symbol of the given name. */
+ def classNameToSymbol(name: Name) =
+ if (name.pos('.') == name.length)
+ definitions.getMember(definitions.EmptyPackageClass, name.toTypeName)
+ else
+ definitions.getClass(name)
+
+
var sawPrivateConstructor = false
def parseClass(): unit = {
@@ -405,7 +414,7 @@ abstract class ClassfileParser {
val jflags = in.nextChar
var sflags = transFlags(jflags)
if ((sflags & FINAL) == 0) sflags = sflags | MUTABLE
- if ((sflags & PRIVATE) != 0) {
+ if ((sflags & PRIVATE) != 0 && !global.settings.XbytecodeRead.value) {
in.skip(4); skipAttributes()
} else {
val name = pool.getName(in.nextChar)
@@ -422,14 +431,14 @@ abstract class ClassfileParser {
def parseMethod(): unit = {
val jflags = in.nextChar
var sflags = transFlags(jflags)
- if ((jflags & JAVA_ACC_PRIVATE) != 0) {
+ if ((jflags & JAVA_ACC_PRIVATE) != 0 && !global.settings.XbytecodeRead.value) {
val name = pool.getName(in.nextChar)
if (name == nme.CONSTRUCTOR)
sawPrivateConstructor = true
in.skip(2); skipAttributes()
} else {
if ((jflags & JAVA_ACC_BRIDGE) != 0) sflags = sflags | PRIVATE
- if ((sflags & PRIVATE) != 0) {
+ if ((sflags & PRIVATE) != 0 && !global.settings.XbytecodeRead.value) {
in.skip(4); skipAttributes()
} else {
val name = pool.getName(in.nextChar)