Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/utils/huffman.effekt
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ record ContentsData(table: AsciiDictionary[String], content: ByteArray)
/// Read chunk of the stream and make a character-frequency map (dictionary)
/// from it. Return the map, read chunk and its length.
///
def characterCompressionReader(): (AsciiDictionary[Int], Int, ByteArray) / read[Byte] = {
def characterCompressionReader(): (AsciiDictionary[Int], Int, ByteArray) / next[Byte] = {
var dict = emptyDict[Int]()

val chunkSize = 4096
val buffer = bytearray::allocate(chunkSize)
var offset = 0

def go(): Unit = try {
val readByte = do read[Byte]()
val readByte = do next[Byte]()

buffer.set(offset, readByte)
offset = offset + 1
Expand Down
6 changes: 3 additions & 3 deletions src/utils/lzss.effekt
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import bytearray
/// The offset is the starting position of a match. It is the number of bytes one needs to go back in the search buffer.
/// The length is the number of bytes to copy from the search buffer.

def chunkReader(): (Int, ByteArray) / read[Byte] = {
def chunkReader(): (Int, ByteArray) / next[Byte] = {
val chunkSize = 2 * 4096
val buffer = bytearray::allocate(chunkSize)
var offset = 0

def go(): Unit = try {
val readByte = do read[Byte]()
val readByte = do next[Byte]()

buffer.set(offset, readByte)
offset = offset + 1
Expand Down Expand Up @@ -182,7 +182,7 @@ def count_tokens(buffer: ByteArray, byteCount: Int): Int = {

/// Compress the data chunk (block) into the output stream.
/// Count the tokens first and then compress the data chunk.
def writeCompressedBlockStream(buffer: ByteArray, byteCount: Int): Unit / { emit[Byte], read[Byte]} = {
def writeCompressedBlockStream(buffer: ByteArray, byteCount: Int): Unit / { emit[Byte], next[Byte]} = {
with streamWriter
with on[OutOfBounds].report

Expand Down
12 changes: 6 additions & 6 deletions src/utils/stream_io.effekt
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ def numberToBitsStream(number: Int, bitsToWrite: Int) = {

/// Object representing bit/byte reading operations
interface StreamReader {
def readBit(): Bool / read[Byte]
def readByte(): Byte / read[Byte]
def readBit(): Bool / next[Byte]
def readByte(): Byte / next[Byte]
}

/// Handler for StreamReader interface.
/// Keeps an internal buffer for reading bits and bytes, so no data is lost.
def streamReader { prog: => Unit / StreamReader }: Unit / {read[Byte], stop} = {
def streamReader { prog: => Unit / StreamReader }: Unit / {next[Byte], stop} = {
var buffer = 0
var curBit = 0
var readBits = 0
Expand All @@ -145,7 +145,7 @@ def streamReader { prog: => Unit / StreamReader }: Unit / {read[Byte], stop} = {
def readBit() = {
resume {
if (curBit <= 0) {
val readByte = do read[Byte]
val readByte = do next[Byte]
buffer = readByte.toInt
curBit = 128
readBits = 0
Expand All @@ -166,9 +166,9 @@ def streamReader { prog: => Unit / StreamReader }: Unit / {read[Byte], stop} = {
def readByte() = {
resume {
if (readBits == 0) {
do read[Byte]
do next[Byte]
} else {
val readByte = do read[Byte]
val readByte = do next[Byte]

val newBuffer = readByte.toInt
val unreadBits = 8 - readBits
Expand Down
Loading