aboutsummaryrefslogblamecommitdiff
path: root/src/dotty/tools/dotc/core/Positions.scala
blob: 31537712fec07539546c807da0230eedb9fe2d35 (plain) (tree)





















                                                                       
package dotty.tools.dotc.core

object Positions {

  /** The bit position of the end part of a range position */
  private val Shift = 32

  class Position(val coords: Long) extends AnyVal {
    def isRange = coords < 0
    def point: Int = if (isRange) start else coords.toInt
    def start: Int = coords.abs.toInt
    def end: Int = if (isRange) start else (coords.abs >>> Shift).toInt
  }

  def rangePos(start: Int, end: Int) =
    new Position(-(start + (end.toLong << Shift)))

  def offsetPosition(point: Int) =
    new Position(point.toLong)


}