diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2005-09-27 16:04:41 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2005-09-27 16:04:41 +0000 |
commit | 8565ad9661f109e35285ac498e7fdefd2e9ccde3 (patch) | |
tree | 3aedfb1adfc9fb40629917f428e25360018dd9e1 | |
parent | ec620e79d02ae45cd9b7f21e0260081a96618e5e (diff) | |
download | scala-8565ad9661f109e35285ac498e7fdefd2e9ccde3.tar.gz scala-8565ad9661f109e35285ac498e7fdefd2e9ccde3.tar.bz2 scala-8565ad9661f109e35285ac498e7fdefd2e9ccde3.zip |
Fixed some bugs.
6 files changed, 33 insertions, 15 deletions
diff --git a/sources/scala/tools/nsc/backend/ScalaPrimitives.scala b/sources/scala/tools/nsc/backend/ScalaPrimitives.scala index d03ffdb484..14754a8a46 100644 --- a/sources/scala/tools/nsc/backend/ScalaPrimitives.scala +++ b/sources/scala/tools/nsc/backend/ScalaPrimitives.scala @@ -643,7 +643,7 @@ abstract class ScalaPrimitives { case LONG => LARRAY_GET; case FLOAT => FARRAY_GET; case DOUBLE => DARRAY_GET; - case REFERENCE(_) => OARRAY_GET; + case REFERENCE(_) | ARRAY(_) => OARRAY_GET; case _ => abort("Unexpected array element type: " + elem); } @@ -658,7 +658,7 @@ abstract class ScalaPrimitives { case LONG => LARRAY_SET; case FLOAT => FARRAY_SET; case DOUBLE => DARRAY_SET; - case REFERENCE(_) => OARRAY_SET; + case REFERENCE(_) | ARRAY(_) => OARRAY_SET; case _ => abort("Unexpected array element type: " + elem); } @@ -673,7 +673,7 @@ abstract class ScalaPrimitives { case LONG => LARRAY_LENGTH; case FLOAT => FARRAY_LENGTH; case DOUBLE => DARRAY_LENGTH; - case REFERENCE(_) => OARRAY_LENGTH; + case REFERENCE(_) | ARRAY(_) => OARRAY_LENGTH; case _ => abort("Unexpected array element type: " + elem); } diff --git a/sources/scala/tools/nsc/backend/icode/BasicBlocks.scala b/sources/scala/tools/nsc/backend/icode/BasicBlocks.scala index 558a983586..f127ee0803 100644 --- a/sources/scala/tools/nsc/backend/icode/BasicBlocks.scala +++ b/sources/scala/tools/nsc/backend/icode/BasicBlocks.scala @@ -123,7 +123,7 @@ trait BasicBlocks: ICodes { /** Add a new instruction at the end of the block */ def emit(instr: Instruction) = { - assert (!closed, "BasicBlock closed."); + assert (!closed, "BasicBlock closed"); instructionList = instr :: instructionList; _lastInstruction = instr; } diff --git a/sources/scala/tools/nsc/backend/icode/Checkers.scala b/sources/scala/tools/nsc/backend/icode/Checkers.scala index da37f4e525..1a1ad103d0 100644 --- a/sources/scala/tools/nsc/backend/icode/Checkers.scala +++ b/sources/scala/tools/nsc/backend/icode/Checkers.scala @@ -290,7 +290,7 @@ abstract class Checkers { case Negation(kind) => checkType(kind, BOOL, BYTE, CHAR, SHORT, INT, LONG, FLOAT, DOUBLE); checkType(stack.pop, kind); - stack push BOOL; + stack push kind; case Test(op, kind, zero) => if (zero) { diff --git a/sources/scala/tools/nsc/backend/icode/GenICode.scala b/sources/scala/tools/nsc/backend/icode/GenICode.scala index d749adcfb8..bcf7316c97 100644 --- a/sources/scala/tools/nsc/backend/icode/GenICode.scala +++ b/sources/scala/tools/nsc/backend/icode/GenICode.scala @@ -240,11 +240,11 @@ abstract class GenICode extends SubComponent { case scalaPrimitives.XOR => ctx1.bb.emit(CALL_PRIMITIVE(Logical(XOR, resKind))); case scalaPrimitives.AND => ctx1.bb.emit(CALL_PRIMITIVE(Logical(AND, resKind))); case scalaPrimitives.LSL => ctx1.bb.emit(CALL_PRIMITIVE(Shift(LSL, resKind))); - generatedType = INT; + generatedType = resKind; case scalaPrimitives.LSR => ctx1.bb.emit(CALL_PRIMITIVE(Shift(LSR, resKind))); - generatedType = INT; + generatedType = resKind; case scalaPrimitives.ASR => ctx1.bb.emit(CALL_PRIMITIVE(Shift(ASR, resKind))); - generatedType = INT; + generatedType = resKind; case _ => abort("Unknown primitive: " + fun.symbol + "[" + code + "]"); } @@ -400,7 +400,7 @@ abstract class GenICode extends SubComponent { val ctx1 = genLoad(expr, ctx, THROWABLE); ctx1.bb.emit(THROW()); generatedType = SCALA_ALL; - ctx; + ctx1; case New(tpt) => abort("Unexpected New"); @@ -464,7 +464,7 @@ abstract class GenICode extends SubComponent { scanForLabels(ctx.defdef, ctx); ctx.labels.get(sym) match { case Some(l) => l; - case _ => abort("Unknown label target: " + sym); + case _ => abort("Unknown label target: " + sym + " at: " + unit.position(fun.pos) + ": ctx: " + ctx); } } val ctx1 = genLoadLabelArguments(args, label, ctx); @@ -794,14 +794,17 @@ abstract class GenICode extends SubComponent { * Since it is expensive to traverse each method twice, this method is called * only when forward jumps really happen, and then it re-traverses the whole * method, scanning for LabelDefs. + * + * TODO: restrict the scanning to smaller subtrees than the whole method. + * It is sufficient to scan the trees of the innermost enclosing block. */ private def scanForLabels(tree: Tree, ctx: Context): Unit = new Traverser() { override def traverse(tree: Tree): Unit = tree match { - case LabelDef(name, params, _) => - // TODO: check that previously entered labels survive the scan + case LabelDef(name, params, rhs) => ctx.labels += tree.symbol -> (new Label(tree.symbol) setParams(params map (.symbol))); + //super.traverse(rhs); case _ => super.traverse(tree); } @@ -996,6 +999,17 @@ abstract class GenICode extends SubComponent { var handlerCount = 0; + override def toString(): String = { + val buf = new StringBuffer(); + buf.append("\tpackage: ").append(packg).append('\n'); + buf.append("\tclazz: ").append(clazz).append('\n'); + buf.append("\tmethod: ").append(method).append('\n'); + buf.append("\tbb: ").append(bb).append('\n'); + buf.append("\tlabels: ").append(labels).append('\n'); + buf.toString() + } + + def this(other: Context) = { this(); this.packg = other.packg; diff --git a/sources/scala/tools/nsc/backend/icode/Opcodes.scala b/sources/scala/tools/nsc/backend/icode/Opcodes.scala index 7f744da83f..c57074799f 100644 --- a/sources/scala/tools/nsc/backend/icode/Opcodes.scala +++ b/sources/scala/tools/nsc/backend/icode/Opcodes.scala @@ -317,7 +317,8 @@ abstract class Opcodes: ICodes { { /** Returns a string representation of this instruction */ - override def toString(): String ="CJUMP "+cond.toString()+" ? "+successBlock.label+" : "+failureBlock.label; + override def toString(): String ="CJUMP (" + kind + ")" + + cond.toString()+" ? "+successBlock.label+" : "+failureBlock.label; override def consumed = 2; override def produced = 0; @@ -333,7 +334,8 @@ abstract class Opcodes: ICodes { cond: TestOp, kind: TypeKind) extends Instruction { /** Returns a string representation of this instruction */ - override def toString(): String ="CZJUMP "+cond.toString()+" ? "+successBlock.label+" : "+failureBlock.label; + override def toString(): String ="CZJUMP )" + kind + ")" + + cond.toString()+" ? "+successBlock.label+" : "+failureBlock.label; override def consumed = 1; override def produced = 0; diff --git a/sources/scala/tools/nsc/backend/icode/TypeKinds.scala b/sources/scala/tools/nsc/backend/icode/TypeKinds.scala index 88f2223bc8..7d67b682cc 100644 --- a/sources/scala/tools/nsc/backend/icode/TypeKinds.scala +++ b/sources/scala/tools/nsc/backend/icode/TypeKinds.scala @@ -71,7 +71,7 @@ abstract class TypeKinds: ICodes { def isArrayType: Boolean = false; def isIntType: Boolean = this match { - case BYTE | SHORT | INT | LONG => true; + case BYTE | SHORT | INT | LONG | CHAR => true; case _ => false; } @@ -235,6 +235,8 @@ abstract class TypeKinds: ICodes { else other match { case REFERENCE(cls2) => cls.tpe <:< cls2.tpe; + case ARRAY(_) => + cls == definitions.AllRefClass; case _ => false; } |