summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2006-07-11 15:22:03 +0000
committerIulian Dragos <jaguarul@gmail.com>2006-07-11 15:22:03 +0000
commit5d6cd0185016591b93278dd8b277d8021479c7cd (patch)
treeff608442ca3d6f1b798772b3a5a8d5a94fb08a98
parent087920b5e307cfdbf4a0cf4b3ff8dd45db43ae36 (diff)
downloadscala-5d6cd0185016591b93278dd8b277d8021479c7cd.tar.gz
scala-5d6cd0185016591b93278dd8b277d8021479c7cd.tar.bz2
scala-5d6cd0185016591b93278dd8b277d8021479c7cd.zip
Fixed line numbers for pruned basic blocks
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala
index df0a85a0bb..ad5411ddc6 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala
@@ -115,11 +115,12 @@ trait BasicBlocks requires ICodes {
/**
* Replace the instruction at the given position. Used by labels when
- * they are anchored.
+ * they are anchored. It retains the position of the previous instruction.
*/
def replaceInstruction(pos: Int, instr: Instruction): Boolean = {
assert(closed, "Instructions can be replaced only after the basic block is closed");
+ instr.pos = instrs(pos).pos;
instrs(pos) = instr;
true
}
@@ -127,6 +128,7 @@ trait BasicBlocks requires ICodes {
/**
* Replace the given instruction with the new one.
* Returns `true' if it actually changed something.
+ * It retains the position of the previous instruction.
*/
def replaceInstruction(oldInstr: Instruction, newInstr: Instruction): Boolean = {
assert(closed, "Instructions can be replaced only after the basic block is closed");
@@ -135,6 +137,7 @@ trait BasicBlocks requires ICodes {
var changed = false;
while (i < instrs.length && !changed) {
if (instrs(i) == oldInstr) {
+ newInstr.pos = oldInstr.pos;
instrs(i) = newInstr;
changed = true;
}
@@ -143,6 +146,10 @@ trait BasicBlocks requires ICodes {
changed
}
+ /** Replaces iold with 'is'. It does not update the position field in the newly
+ * inserted instrucitons, so it behaves differently than the one-instruction
+ * versions of this function.
+ */
def replaceInstruction(iold: Instruction, is: List[Instruction]): Boolean = {
assert(closed, "Instructions can be replaced only after the basic block is closed");