mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 00:32:11 +01:00
Add a yield keyword
This commit is contained in:
1 parent
93665d50fe
commit
65dcf6a5b9
19 files changed
+122
-89
No files matched your search
@@ -127,7 +127,6 @@ pub func flate_decoder.decode?(dst writer1, src reader1)() {
|
||||
in.dst.mark()
|
||||
var z status = try this.decode_blocks?(dst:in.dst, src:in.src)
|
||||
if not z.is_suspension() {
|
||||
// TODO: rename "return" to "raise"?
|
||||
return z
|
||||
}
|
||||
// TODO: should "since_mark" be "since_mark!", as the return value lets
|
||||
@@ -171,7 +170,7 @@ pub func flate_decoder.decode?(dst writer1, src reader1)() {
|
||||
this.history_index = (this.history_index & 0x7FFF) + ((n_copied & 0x7FFF) as u32) + already_full
|
||||
}
|
||||
}
|
||||
return z
|
||||
yield z
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,9 +238,9 @@ pri func flate_decoder.decode_uncompressed?(dst writer1, src reader1)() {
|
||||
length -= n_copied
|
||||
if in.dst.available() == 0 {
|
||||
// TODO: "closed for writes" instead?
|
||||
return suspension "short write"
|
||||
yield suspension "short write"
|
||||
} else {
|
||||
return suspension "short read"
|
||||
yield suspension "short read"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,13 +212,9 @@ pri func flate_decoder.decode_huffman_slow?(dst writer1, src reader1)() {
|
||||
}
|
||||
}
|
||||
// TODO: "closed for writes" instead?
|
||||
return suspension "short write"
|
||||
// TODO: this "assert false" should be a compiler error.
|
||||
// This might mean differentiating "return" and "raise".
|
||||
//
|
||||
yield suspension "short write"
|
||||
// TODO: invalidate this-related facts because the
|
||||
// suspension can change the state of this and its fields.
|
||||
assert false
|
||||
}
|
||||
// Copy from the start of this.history, if we wrapped around.
|
||||
if hlen > 0 {
|
||||
@@ -231,7 +227,7 @@ pri func flate_decoder.decode_huffman_slow?(dst writer1, src reader1)() {
|
||||
hlen -= n_copied
|
||||
hdist = (hdist + (n_copied & 0x7FFF)) & 0x7FFF
|
||||
// TODO: "closed for writes" instead?
|
||||
return suspension "short write"
|
||||
yield suspension "short write"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,7 +245,7 @@ pri func flate_decoder.decode_huffman_slow?(dst writer1, src reader1)() {
|
||||
}
|
||||
length -= n_copied
|
||||
// TODO: "closed for writes" instead?
|
||||
return suspension "short write"
|
||||
yield suspension "short write"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ pub func zlib_decoder.decode?(dst writer1, src reader1)() {
|
||||
if z.is_ok() {
|
||||
break
|
||||
}
|
||||
return z
|
||||
yield z
|
||||
}
|
||||
if checksum != in.src.read_u32be?() {
|
||||
return error "checksum mismatch"
|
||||
|
||||
@@ -182,7 +182,7 @@ pri func decoder.decode_id?(dst writer1, src reader1)() {
|
||||
if (block_size == 0) and (z == suspension "short read") {
|
||||
break
|
||||
}
|
||||
return z
|
||||
yield z
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,7 +118,7 @@ pub func lzw_decoder.decode?(dst writer1, src reader1)() {
|
||||
}
|
||||
s = (s + ((n_copied & 4095) as u32)) & 4095
|
||||
// TODO: "closed for writes" instead?
|
||||
return suspension "short write"
|
||||
yield suspension "short write"
|
||||
}
|
||||
|
||||
if save_code <= 4095 {
|
||||
|
||||
Reference in new issue
Block a user