diff options
author | Martin Odersky <odersky@gmail.com> | 2013-04-23 17:04:34 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-04-23 17:04:34 +0200 |
commit | fc8fc177d2dfd270e57996099deef2e4a3a975ed (patch) | |
tree | c4c143f88249c6a40a9f1e4c886260d26267b75e /src/dotty/tools/dotc/util | |
parent | 8566b093c35d5cc5b29544b5b2c3f01b0ec4c1bd (diff) | |
download | dotty-fc8fc177d2dfd270e57996099deef2e4a3a975ed.tar.gz dotty-fc8fc177d2dfd270e57996099deef2e4a3a975ed.tar.bz2 dotty-fc8fc177d2dfd270e57996099deef2e4a3a975ed.zip |
Modifications in prepation of parsing.
Diffstat (limited to 'src/dotty/tools/dotc/util')
-rw-r--r-- | src/dotty/tools/dotc/util/Positions.scala | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/util/Positions.scala b/src/dotty/tools/dotc/util/Positions.scala index 2ab6c1920..056af00d1 100644 --- a/src/dotty/tools/dotc/util/Positions.scala +++ b/src/dotty/tools/dotc/util/Positions.scala @@ -11,12 +11,12 @@ package util object Positions { private val StartEndBits = 26 - private val StartEndMask = (1 << StartEndBits) - 1 + private val StartEndMask: Long = (1L << StartEndBits) - 1 private val PointOffsetLimit = 1L << (64 - StartEndBits * 2) class Position(val coords: Long) extends AnyVal { - def point: Int = start + (coords >>> (StartEndBits * 2)).toInt def start: Int = (coords & StartEndMask).toInt + def point: Int = start + (coords >>> (StartEndBits * 2)).toInt def end: Int = ((coords >>> StartEndBits) & StartEndMask).toInt /** The union of two positions. Tries to keep the point offset of @@ -59,6 +59,16 @@ object Positions { val NoPosition = new Position(-1L) + case class PositionPrefix(val coords: Long) extends AnyVal { + def start: Int = (coords & StartEndMask).toInt + def point: Int = start + (coords >>> StartEndBits).toInt + def toPosition(end: Int) = Position(start, end, point - start max 0) + } + + def PositionPrefix(start: Int, pointOffset: Int = 0): PositionPrefix = + new PositionPrefix( + (start & StartEndMask).toLong | pointOffset.toLong << StartEndBits) + case class SourcePosition(source: SourceFile, pos: Position) { def point: Int = pos.point def start: Int = pos.start |