Skip to content

Commit

Permalink
More modifier lock down in pickling._
Browse files Browse the repository at this point in the history
  • Loading branch information
retronym committed Feb 23, 2013
1 parent 74aa068 commit 717f690
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import io.AbstractFile
* @author Philippe Altherr
* @version 1.0, 23/03/2004
*/
class AbstractFileReader(val file: AbstractFile) {
final class AbstractFileReader(val file: AbstractFile) {

/** the buffer containing the file
*/
Expand Down
8 changes: 4 additions & 4 deletions src/dotty/tools/dotc/core/pickling/ClassfileConstants.scala
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ object ClassfileConstants {
final val impdep1 = 0xfe
final val impdep2 = 0xff

abstract class FlagTranslation {
sealed abstract class FlagTranslation {
import Flags._

private var isAnnotation = false
Expand Down Expand Up @@ -360,16 +360,16 @@ object ClassfileConstants {
res
}

def classFlags(jflags: Int): FlagSet = {
final def classFlags(jflags: Int): FlagSet = {
initFields(jflags)
isClass = true
translateFlags(jflags, EmptyFlags)
}
def fieldFlags(jflags: Int): FlagSet = {
final def fieldFlags(jflags: Int): FlagSet = {
initFields(jflags)
translateFlags(jflags, if ((jflags & JAVA_ACC_FINAL) == 0) Mutable else EmptyFlags)
}
def methodFlags(jflags: Int): FlagSet = {
final def methodFlags(jflags: Int): FlagSet = {
initFields(jflags)
translateFlags(jflags, if ((jflags & JAVA_ACC_BRIDGE) != 0) Bridge else EmptyFlags)
}
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import scala.collection.mutable.{ ListBuffer, ArrayBuffer }
import scala.annotation.switch
import io.AbstractFile

class ClassfileParser(
final class ClassfileParser(
classfile: AbstractFile,
classRoot: LazyClassDenotation,
moduleRoot: LazyClassDenotation)(implicit cctx: CondensedContext) {
Expand Down
33 changes: 16 additions & 17 deletions src/dotty/tools/dotc/core/pickling/PickleBuffer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Flags._
* @param from The first index where defined data are found
* @param to The first index where new data can be written
*/
class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
abstract class PickleBuffer(data: Array[Byte], from: Int, to: Int) {

var bytes = data
var readIndex = from
Expand All @@ -24,13 +24,13 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
bytes = bytes1
}

def ensureCapacity(capacity: Int) =
final def ensureCapacity(capacity: Int) =
while (bytes.length < writeIndex + capacity) dble()

// -- Basic output routines --------------------------------------------

/** Write a byte of data */
def writeByte(b: Int) {
final def writeByte(b: Int) {
if (writeIndex == bytes.length) dble()
bytes(writeIndex) = b.toByte
writeIndex += 1
Expand All @@ -39,7 +39,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
/** Write a natural number in big endian format, base 128.
* All but the last digits have bit 0x80 set.
*/
def writeNat(x: Int) =
final def writeNat(x: Int) =
writeLongNat(x.toLong & 0x00000000FFFFFFFFL)

/**
Expand All @@ -49,7 +49,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
* if the long value is in the range Int.MIN_VALUE to
* Int.MAX_VALUE.
*/
def writeLongNat(x: Long) {
final def writeLongNat(x: Long) {
def writeNatPrefix(x: Long) {
val y = x >>> 7
if (y != 0L) writeNatPrefix(y)
Expand All @@ -66,7 +66,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
* @param pos ...
* @param x ...
*/
def patchNat(pos: Int, x: Int) {
final def patchNat(pos: Int, x: Int) {
def patchNatPrefix(x: Int) {
writeByte(0)
Array.copy(bytes, pos, bytes, pos+1, writeIndex - (pos+1))
Expand All @@ -83,7 +83,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
*
* @param x The long number to be written.
*/
def writeLong(x: Long) {
final def writeLong(x: Long) {
val y = x >> 8
val z = x & 0xff
if (-y != (z >> 7)) writeLong(y)
Expand All @@ -93,18 +93,18 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
// -- Basic input routines --------------------------------------------

/** Peek at the current byte without moving the read index */
def peekByte(): Int = bytes(readIndex)
final def peekByte(): Int = bytes(readIndex)

/** Read a byte */
def readByte(): Int = {
final def readByte(): Int = {
val x = bytes(readIndex); readIndex += 1; x
}

/** Read a natural number in big endian format, base 128.
* All but the last digits have bit 0x80 set.*/
def readNat(): Int = readLongNat().toInt
final def readNat(): Int = readLongNat().toInt

def readLongNat(): Long = {
final def readLongNat(): Long = {
var b = 0L
var x = 0L
do {
Expand All @@ -115,7 +115,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
}

/** Read a long number in signed big endian format, base 256. */
def readLong(len: Int): Long = {
final def readLong(len: Int): Long = {
var x = 0L
var i = 0
while (i < len) {
Expand All @@ -129,8 +129,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
/** Returns the buffer as a sequence of (Int, Array[Byte]) representing
* (tag, data) of the individual entries. Saves and restores buffer state.
*/

def toIndexedSeq: IndexedSeq[(Int, Array[Byte])] = {
final def toIndexedSeq: IndexedSeq[(Int, Array[Byte])] = {
val saved = readIndex
readIndex = 0
readNat() ; readNat() // discarding version
Expand All @@ -157,14 +156,14 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
* @param op ...
* @return ...
*/
def until[T](end: Int, op: () => T): List[T] =
final def until[T](end: Int, op: () => T): List[T] =
if (readIndex == end) List() else op() :: until(end, op);

/** Perform operation <code>op</code> the number of
* times specified. Concatenate the results into a list.
*/
def times[T](n: Int, op: ()=>T): List[T] =
final def times[T](n: Int, op: ()=>T): List[T] =
if (n == 0) List() else op() :: times(n-1, op)

def unpickleScalaFlags(sflags: Long): FlagSet = ???
final def unpickleScalaFlags(sflags: Long): FlagSet = ???
}
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/pickling/UnPickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ object UnPickler {
* @param moduleroot the top-level module class which is unpickled, or NoSymbol if inapplicable
* @param filename filename associated with bytearray, only used for error messages
*/
class UnPickler(bytes: Array[Byte], classRoot: LazyClassDenotation, moduleRoot: LazyClassDenotation)(implicit cctx: CondensedContext)
final class UnPickler(bytes: Array[Byte], classRoot: LazyClassDenotation, moduleRoot: LazyClassDenotation)(implicit cctx: CondensedContext)
extends PickleBuffer(bytes, 0, -1) {

import UnPickler._
Expand Down

0 comments on commit 717f690

Please sign in to comment.