summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sources/scala/tools/scalap/Classfile.scala24
-rw-r--r--sources/scala/tools/scalap/Main.scala28
2 files changed, 35 insertions, 17 deletions
diff --git a/sources/scala/tools/scalap/Classfile.scala b/sources/scala/tools/scalap/Classfile.scala
index 71b7818eb7..9bb5ae672c 100644
--- a/sources/scala/tools/scalap/Classfile.scala
+++ b/sources/scala/tools/scalap/Classfile.scala
@@ -63,32 +63,32 @@ class Classfile(in: ByteArrayReader) {
while (i < pool.length) {
val tag: Int = in.nextByte;
tag match {
- case 1 => // CONSTANT_UTF8
+ case CONSTANT_UTF8 =>
pool(i) = UTF8(in.nextUTF8(in.nextChar));
- case 2 => // CONSTANT_UNICODE
+ case CONSTANT_UNICODE =>
in.skip(in.nextChar);
pool(i) = Empty();
- case 7 => // CONSTANT_CLASS
+ case CONSTANT_CLASS =>
pool(i) = ClassRef(in.nextChar);
- case 8 => // CONSTANT_STRING
+ case CONSTANT_STRING =>
pool(i) = StringConst(in.nextChar);
- case 9 => // CONSTANT_FIELDREF
+ case CONSTANT_FIELDREF =>
pool(i) = FieldRef(in.nextChar, in.nextChar);
- case 10 => // CONSTANT_METHODREF
+ case CONSTANT_METHODREF =>
pool(i) = MethodRef(in.nextChar, in.nextChar);
- case 11 => // CONSTANT_INTFMETHODREF
+ case CONSTANT_INTFMETHODREF =>
pool(i) = IntfMethodRef(in.nextChar, in.nextChar);
- case 12 => // CONSTANT_NAMEANDTYPE
+ case CONSTANT_NAMEANDTYPE =>
pool(i) = NameAndType(in.nextChar, in.nextChar);
- case 3 => // CONSTANT_INTEGER
+ case CONSTANT_INTEGER =>
pool(i) = IntegerConst(in.nextInt);
- case 4 => // CONSTANT_FLOAT
+ case CONSTANT_FLOAT =>
pool(i) = FloatConst(in.nextFloat);
- case 5 => // CONSTANT_LONG
+ case CONSTANT_LONG =>
pool(i) = LongConst(in.nextLong);
i = i + 1;
pool(i) = Empty();
- case 6 => // CONSTANT_DOUBLE
+ case CONSTANT_DOUBLE =>
pool(i) = DoubleConst(in.nextDouble);
i = i + 1;
pool(i) = Empty();
diff --git a/sources/scala/tools/scalap/Main.scala b/sources/scala/tools/scalap/Main.scala
index da928d9ebe..203a9d427f 100644
--- a/sources/scala/tools/scalap/Main.scala
+++ b/sources/scala/tools/scalap/Main.scala
@@ -30,7 +30,8 @@ object Main {
}
def process(args: Arguments, path: ClassPath)(classname: String): Unit = {
- val file = path.openClass(Names.encode(classname));
+ val file = path.openClass(Names.encode(
+ if (classname == "scala.AnyRef") "java.lang.Object" else classname));
if (file.exists) {
if (verbose)
Console.println(Console.BOLD + "FILENAME" + Console.RESET +
@@ -41,10 +42,7 @@ object Main {
attrib match {
case Some(a) =>
val info = new ScalaAttribute(a.reader);
- //Console.println("read attribute");
val symtab = new EntityTable(info);
- //Console.println("read entities");
- //symtab.print;
val out = new OutputStreamWriter(System.out);
val writer = new ScalaWriter(args, out);
symtab.root.elements foreach (
@@ -52,8 +50,28 @@ object Main {
writer.println*; });
out.flush();
case None =>
- Console.println("Java classes not supported yet.");
+ val out = new OutputStreamWriter(System.out);
+ val writer = new JavaWriter(clazz, out);
+ writer.printClass;
+ out.flush();
}
+ } else if (classname == "scala.Any") {
+ Console.println("package scala;");
+ Console.println("class Any {");
+ Console.println(" def eq(scala.Any): scala.Boolean;");
+ Console.println(" final def ==(scala.Any): scala.Boolean;");
+ Console.println(" final def !=(scala.Any): scala.Boolean;");
+ Console.println(" def equals(scala.Any): scala.Boolean;");
+ Console.println(" def hashCode(): scala.Int;");
+ Console.println(" def toString(): java.lang.String;");
+ Console.println(" final def isInstanceOf[T]: scala.Boolean;");
+ Console.println(" final def asInstanceOf[T]: T;");
+ Console.println(" def match[S, T](f: S => T): T;");
+ Console.println("}");
+ } else if (classname == "scala.All") {
+ Console.println("Type scala.All is artificial; it is a subtype of all types.");
+ } else if (classname == "scala.AllRef") {
+ Console.println("Type scala.AllRef is artificial; it is a subtype of all subtypes of scala.AnyRef.");
} else
Console.println("class/object not found.");
}