diff options
Diffstat (limited to 'src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala index 00a1cc4c95..6c46e01af3 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala @@ -61,6 +61,19 @@ trait BasicBlocks requires ICodes { // public: + /** Return the index of inst. Uses reference equality. + * Returns -1 if not found. + */ + def indexOf(inst: Instruction): Int = { + assert(closed) + var i = 0; + while (i < instrs.length) { + if (instrs(i) eq inst) return i + i = i + 1 + } + -1 + } + /** Compute an hashCode for the block */ override def hashCode() = label; |