mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 08:52:18 +01:00
Rename unread_u8? to undo_byte!; add can_undo_byte
This commit is contained in:
1 parent
ce3d99a6d5
commit
9e300fc4f8
14 files changed
+148
-154
No files matched your search
@@ -116,6 +116,14 @@ func (g *gen) writeBuiltinIO(b *buffer, recv *a.Expr, method t.ID, args []*a.Nod
|
|||||||
func (g *gen) writeBuiltinIOReader(b *buffer, recv *a.Expr, method t.ID, args []*a.Node, rp replacementPolicy, depth uint32) error {
|
func (g *gen) writeBuiltinIOReader(b *buffer, recv *a.Expr, method t.ID, args []*a.Node, rp replacementPolicy, depth uint32) error {
|
||||||
// TODO: don't hard-code the recv being a_src.
|
// TODO: don't hard-code the recv being a_src.
|
||||||
switch method {
|
switch method {
|
||||||
|
case t.IDUndoByte:
|
||||||
|
b.writes("(ioptr_src--, wuffs_base__return_empty_struct())")
|
||||||
|
return nil
|
||||||
|
|
||||||
|
case t.IDCanUndoByte:
|
||||||
|
b.writes("(ioptr_src > iobounds0orig_src)")
|
||||||
|
return nil
|
||||||
|
|
||||||
case t.IDSetLimit:
|
case t.IDSetLimit:
|
||||||
b.printf("wuffs_base__io_reader__set_limit(&%ssrc, ioptr_src,", aPrefix)
|
b.printf("wuffs_base__io_reader__set_limit(&%ssrc, ioptr_src,", aPrefix)
|
||||||
// TODO: update the ioptr variables?
|
// TODO: update the ioptr variables?
|
||||||
@@ -415,11 +423,6 @@ func (g *gen) writeBuiltinCallSuspendibles(b *buffer, n *a.Expr, depth uint32) e
|
|||||||
|
|
||||||
if recvTyp.QID()[1] == t.IDIOReader {
|
if recvTyp.QID()[1] == t.IDIOReader {
|
||||||
switch method.Ident() {
|
switch method.Ident() {
|
||||||
case t.IDUnreadU8:
|
|
||||||
b.writes("if (ioptr_src == iobounds0orig_src) {" +
|
|
||||||
"status = WUFFS_BASE__ERROR_INVALID_I_O_OPERATION; goto exit; } ioptr_src--;\n")
|
|
||||||
return nil
|
|
||||||
|
|
||||||
case t.IDReadU8:
|
case t.IDReadU8:
|
||||||
if g.currFunk.tempW > maxTemp {
|
if g.currFunk.tempW > maxTemp {
|
||||||
return fmt.Errorf("too many temporary variables required")
|
return fmt.Errorf("too many temporary variables required")
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
- Renamed `[N] T` and `[] T` types to `array[N] T` and `slice T`.
|
- Renamed `[N] T` and `[] T` types to `array[N] T` and `slice T`.
|
||||||
- Renamed `buf1`, `reader1`, etc to `io_buffer`, `io_reader`, etc.
|
- Renamed `buf1`, `reader1`, etc to `io_buffer`, `io_reader`, etc.
|
||||||
- Renamed `u32`, `io_reader`, etc to `base.u32`, `base.io_reader`, etc.
|
- Renamed `u32`, `io_reader`, etc to `base.u32`, `base.io_reader`, etc.
|
||||||
|
- Renamed `unread_u8?` to `undo_byte!`; added `can_undo_byte`.
|
||||||
- Redesigned iterate blocks.
|
- Redesigned iterate blocks.
|
||||||
- Added a `base.image_config` type.
|
- Added a `base.image_config` type.
|
||||||
- Added a `reset` method.
|
- Added a `reset` method.
|
||||||
|
|||||||
+61
-54
@@ -1774,10 +1774,12 @@ extern "C" {
|
|||||||
-1072893291 // 0xC00CF295
|
-1072893291 // 0xC00CF295
|
||||||
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_HUFFMAN_END_OF_BLOCK \
|
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_HUFFMAN_END_OF_BLOCK \
|
||||||
-1089670507 // 0xBF0CF295
|
-1089670507 // 0xBF0CF295
|
||||||
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_DISTANCE \
|
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_I_O \
|
||||||
-1106447723 // 0xBE0CF295
|
-1106447723 // 0xBE0CF295
|
||||||
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_N_BITS \
|
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_DISTANCE \
|
||||||
-1123224939 // 0xBD0CF295
|
-1123224939 // 0xBD0CF295
|
||||||
|
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_N_BITS \
|
||||||
|
-1140002155 // 0xBC0CF295
|
||||||
|
|
||||||
const char* wuffs_deflate__status__string(wuffs_base__status s);
|
const char* wuffs_deflate__status__string(wuffs_base__status s);
|
||||||
|
|
||||||
@@ -2618,52 +2620,56 @@ static const char wuffs_deflate__status__string_data[] = {
|
|||||||
0x64, 0x69, 0x73, 0x74, 0x61, 0x6E, 0x63, 0x65, 0x00, 0x64, 0x65, 0x66,
|
0x64, 0x69, 0x73, 0x74, 0x61, 0x6E, 0x63, 0x65, 0x00, 0x64, 0x65, 0x66,
|
||||||
0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x6E,
|
0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x6E,
|
||||||
0x61, 0x6C, 0x20, 0x65, 0x72, 0x72, 0x6F, 0x72, 0x3A, 0x20, 0x69, 0x6E,
|
0x61, 0x6C, 0x20, 0x65, 0x72, 0x72, 0x6F, 0x72, 0x3A, 0x20, 0x69, 0x6E,
|
||||||
0x63, 0x6F, 0x6E, 0x73, 0x69, 0x73, 0x74, 0x65, 0x6E, 0x74, 0x20, 0x48,
|
0x63, 0x6F, 0x6E, 0x73, 0x69, 0x73, 0x74, 0x65, 0x6E, 0x74, 0x20, 0x49,
|
||||||
0x75, 0x66, 0x66, 0x6D, 0x61, 0x6E, 0x20, 0x65, 0x6E, 0x64, 0x5F, 0x6F,
|
0x2F, 0x4F, 0x00, 0x64, 0x65, 0x66, 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20,
|
||||||
0x66, 0x5F, 0x62, 0x6C, 0x6F, 0x63, 0x6B, 0x00, 0x64, 0x65, 0x66, 0x6C,
|
0x69, 0x6E, 0x74, 0x65, 0x72, 0x6E, 0x61, 0x6C, 0x20, 0x65, 0x72, 0x72,
|
||||||
0x61, 0x74, 0x65, 0x3A, 0x20, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x6E, 0x61,
|
0x6F, 0x72, 0x3A, 0x20, 0x69, 0x6E, 0x63, 0x6F, 0x6E, 0x73, 0x69, 0x73,
|
||||||
0x6C, 0x20, 0x65, 0x72, 0x72, 0x6F, 0x72, 0x3A, 0x20, 0x69, 0x6E, 0x63,
|
0x74, 0x65, 0x6E, 0x74, 0x20, 0x48, 0x75, 0x66, 0x66, 0x6D, 0x61, 0x6E,
|
||||||
0x6F, 0x6E, 0x73, 0x69, 0x73, 0x74, 0x65, 0x6E, 0x74, 0x20, 0x48, 0x75,
|
0x20, 0x65, 0x6E, 0x64, 0x5F, 0x6F, 0x66, 0x5F, 0x62, 0x6C, 0x6F, 0x63,
|
||||||
0x66, 0x66, 0x6D, 0x61, 0x6E, 0x20, 0x64, 0x65, 0x63, 0x6F, 0x64, 0x65,
|
0x6B, 0x00, 0x64, 0x65, 0x66, 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x69,
|
||||||
0x72, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x00, 0x64, 0x65, 0x66, 0x6C,
|
0x6E, 0x74, 0x65, 0x72, 0x6E, 0x61, 0x6C, 0x20, 0x65, 0x72, 0x72, 0x6F,
|
||||||
0x61, 0x74, 0x65, 0x3A, 0x20, 0x6E, 0x6F, 0x20, 0x48, 0x75, 0x66, 0x66,
|
0x72, 0x3A, 0x20, 0x69, 0x6E, 0x63, 0x6F, 0x6E, 0x73, 0x69, 0x73, 0x74,
|
||||||
0x6D, 0x61, 0x6E, 0x20, 0x63, 0x6F, 0x64, 0x65, 0x73, 0x00, 0x64, 0x65,
|
0x65, 0x6E, 0x74, 0x20, 0x48, 0x75, 0x66, 0x66, 0x6D, 0x61, 0x6E, 0x20,
|
||||||
0x66, 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x6D, 0x69, 0x73, 0x73, 0x69,
|
0x64, 0x65, 0x63, 0x6F, 0x64, 0x65, 0x72, 0x20, 0x73, 0x74, 0x61, 0x74,
|
||||||
0x6E, 0x67, 0x20, 0x65, 0x6E, 0x64, 0x2D, 0x6F, 0x66, 0x2D, 0x62, 0x6C,
|
0x65, 0x00, 0x64, 0x65, 0x66, 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x6E,
|
||||||
0x6F, 0x63, 0x6B, 0x20, 0x63, 0x6F, 0x64, 0x65, 0x00, 0x64, 0x65, 0x66,
|
0x6F, 0x20, 0x48, 0x75, 0x66, 0x66, 0x6D, 0x61, 0x6E, 0x20, 0x63, 0x6F,
|
||||||
0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x69, 0x6E, 0x63, 0x6F, 0x6E, 0x73,
|
0x64, 0x65, 0x73, 0x00, 0x64, 0x65, 0x66, 0x6C, 0x61, 0x74, 0x65, 0x3A,
|
||||||
0x69, 0x73, 0x74, 0x65, 0x6E, 0x74, 0x20, 0x73, 0x74, 0x6F, 0x72, 0x65,
|
0x20, 0x6D, 0x69, 0x73, 0x73, 0x69, 0x6E, 0x67, 0x20, 0x65, 0x6E, 0x64,
|
||||||
0x64, 0x20, 0x62, 0x6C, 0x6F, 0x63, 0x6B, 0x20, 0x6C, 0x65, 0x6E, 0x67,
|
0x2D, 0x6F, 0x66, 0x2D, 0x62, 0x6C, 0x6F, 0x63, 0x6B, 0x20, 0x63, 0x6F,
|
||||||
0x74, 0x68, 0x00, 0x64, 0x65, 0x66, 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20,
|
|
||||||
0x62, 0x61, 0x64, 0x20, 0x6C, 0x69, 0x74, 0x65, 0x72, 0x61, 0x6C, 0x2F,
|
|
||||||
0x6C, 0x65, 0x6E, 0x67, 0x74, 0x68, 0x20, 0x63, 0x6F, 0x64, 0x65, 0x20,
|
|
||||||
0x63, 0x6F, 0x75, 0x6E, 0x74, 0x00, 0x64, 0x65, 0x66, 0x6C, 0x61, 0x74,
|
|
||||||
0x65, 0x3A, 0x20, 0x62, 0x61, 0x64, 0x20, 0x64, 0x69, 0x73, 0x74, 0x61,
|
|
||||||
0x6E, 0x63, 0x65, 0x20, 0x63, 0x6F, 0x64, 0x65, 0x20, 0x63, 0x6F, 0x75,
|
|
||||||
0x6E, 0x74, 0x00, 0x64, 0x65, 0x66, 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20,
|
|
||||||
0x62, 0x61, 0x64, 0x20, 0x64, 0x69, 0x73, 0x74, 0x61, 0x6E, 0x63, 0x65,
|
|
||||||
0x00, 0x64, 0x65, 0x66, 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x62, 0x61,
|
|
||||||
0x64, 0x20, 0x62, 0x6C, 0x6F, 0x63, 0x6B, 0x00, 0x64, 0x65, 0x66, 0x6C,
|
|
||||||
0x61, 0x74, 0x65, 0x3A, 0x20, 0x62, 0x61, 0x64, 0x20, 0x48, 0x75, 0x66,
|
|
||||||
0x66, 0x6D, 0x61, 0x6E, 0x20, 0x6D, 0x69, 0x6E, 0x69, 0x6D, 0x75, 0x6D,
|
|
||||||
0x20, 0x63, 0x6F, 0x64, 0x65, 0x20, 0x6C, 0x65, 0x6E, 0x67, 0x74, 0x68,
|
|
||||||
0x00, 0x64, 0x65, 0x66, 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x62, 0x61,
|
|
||||||
0x64, 0x20, 0x48, 0x75, 0x66, 0x66, 0x6D, 0x61, 0x6E, 0x20, 0x63, 0x6F,
|
|
||||||
0x64, 0x65, 0x00, 0x64, 0x65, 0x66, 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20,
|
0x64, 0x65, 0x00, 0x64, 0x65, 0x66, 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20,
|
||||||
0x62, 0x61, 0x64, 0x20, 0x48, 0x75, 0x66, 0x66, 0x6D, 0x61, 0x6E, 0x20,
|
0x69, 0x6E, 0x63, 0x6F, 0x6E, 0x73, 0x69, 0x73, 0x74, 0x65, 0x6E, 0x74,
|
||||||
0x63, 0x6F, 0x64, 0x65, 0x20, 0x6C, 0x65, 0x6E, 0x67, 0x74, 0x68, 0x20,
|
0x20, 0x73, 0x74, 0x6F, 0x72, 0x65, 0x64, 0x20, 0x62, 0x6C, 0x6F, 0x63,
|
||||||
0x72, 0x65, 0x70, 0x65, 0x74, 0x69, 0x74, 0x69, 0x6F, 0x6E, 0x00, 0x64,
|
0x6B, 0x20, 0x6C, 0x65, 0x6E, 0x67, 0x74, 0x68, 0x00, 0x64, 0x65, 0x66,
|
||||||
0x65, 0x66, 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x62, 0x61, 0x64, 0x20,
|
0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x62, 0x61, 0x64, 0x20, 0x6C, 0x69,
|
||||||
0x48, 0x75, 0x66, 0x66, 0x6D, 0x61, 0x6E, 0x20, 0x63, 0x6F, 0x64, 0x65,
|
0x74, 0x65, 0x72, 0x61, 0x6C, 0x2F, 0x6C, 0x65, 0x6E, 0x67, 0x74, 0x68,
|
||||||
0x20, 0x6C, 0x65, 0x6E, 0x67, 0x74, 0x68, 0x20, 0x63, 0x6F, 0x75, 0x6E,
|
0x20, 0x63, 0x6F, 0x64, 0x65, 0x20, 0x63, 0x6F, 0x75, 0x6E, 0x74, 0x00,
|
||||||
0x74, 0x00, 0x64, 0x65, 0x66, 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x62,
|
0x64, 0x65, 0x66, 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x62, 0x61, 0x64,
|
||||||
0x61, 0x64, 0x20, 0x48, 0x75, 0x66, 0x66, 0x6D, 0x61, 0x6E, 0x20, 0x63,
|
0x20, 0x64, 0x69, 0x73, 0x74, 0x61, 0x6E, 0x63, 0x65, 0x20, 0x63, 0x6F,
|
||||||
0x6F, 0x64, 0x65, 0x20, 0x28, 0x75, 0x6E, 0x64, 0x65, 0x72, 0x2D, 0x73,
|
0x64, 0x65, 0x20, 0x63, 0x6F, 0x75, 0x6E, 0x74, 0x00, 0x64, 0x65, 0x66,
|
||||||
0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x64, 0x29, 0x00, 0x64,
|
0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x62, 0x61, 0x64, 0x20, 0x64, 0x69,
|
||||||
0x65, 0x66, 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x62, 0x61, 0x64, 0x20,
|
0x73, 0x74, 0x61, 0x6E, 0x63, 0x65, 0x00, 0x64, 0x65, 0x66, 0x6C, 0x61,
|
||||||
0x48, 0x75, 0x66, 0x66, 0x6D, 0x61, 0x6E, 0x20, 0x63, 0x6F, 0x64, 0x65,
|
0x74, 0x65, 0x3A, 0x20, 0x62, 0x61, 0x64, 0x20, 0x62, 0x6C, 0x6F, 0x63,
|
||||||
0x20, 0x28, 0x6F, 0x76, 0x65, 0x72, 0x2D, 0x73, 0x75, 0x62, 0x73, 0x63,
|
0x6B, 0x00, 0x64, 0x65, 0x66, 0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x62,
|
||||||
0x72, 0x69, 0x62, 0x65, 0x64, 0x29, 0x00,
|
0x61, 0x64, 0x20, 0x48, 0x75, 0x66, 0x66, 0x6D, 0x61, 0x6E, 0x20, 0x6D,
|
||||||
|
0x69, 0x6E, 0x69, 0x6D, 0x75, 0x6D, 0x20, 0x63, 0x6F, 0x64, 0x65, 0x20,
|
||||||
|
0x6C, 0x65, 0x6E, 0x67, 0x74, 0x68, 0x00, 0x64, 0x65, 0x66, 0x6C, 0x61,
|
||||||
|
0x74, 0x65, 0x3A, 0x20, 0x62, 0x61, 0x64, 0x20, 0x48, 0x75, 0x66, 0x66,
|
||||||
|
0x6D, 0x61, 0x6E, 0x20, 0x63, 0x6F, 0x64, 0x65, 0x00, 0x64, 0x65, 0x66,
|
||||||
|
0x6C, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x62, 0x61, 0x64, 0x20, 0x48, 0x75,
|
||||||
|
0x66, 0x66, 0x6D, 0x61, 0x6E, 0x20, 0x63, 0x6F, 0x64, 0x65, 0x20, 0x6C,
|
||||||
|
0x65, 0x6E, 0x67, 0x74, 0x68, 0x20, 0x72, 0x65, 0x70, 0x65, 0x74, 0x69,
|
||||||
|
0x74, 0x69, 0x6F, 0x6E, 0x00, 0x64, 0x65, 0x66, 0x6C, 0x61, 0x74, 0x65,
|
||||||
|
0x3A, 0x20, 0x62, 0x61, 0x64, 0x20, 0x48, 0x75, 0x66, 0x66, 0x6D, 0x61,
|
||||||
|
0x6E, 0x20, 0x63, 0x6F, 0x64, 0x65, 0x20, 0x6C, 0x65, 0x6E, 0x67, 0x74,
|
||||||
|
0x68, 0x20, 0x63, 0x6F, 0x75, 0x6E, 0x74, 0x00, 0x64, 0x65, 0x66, 0x6C,
|
||||||
|
0x61, 0x74, 0x65, 0x3A, 0x20, 0x62, 0x61, 0x64, 0x20, 0x48, 0x75, 0x66,
|
||||||
|
0x66, 0x6D, 0x61, 0x6E, 0x20, 0x63, 0x6F, 0x64, 0x65, 0x20, 0x28, 0x75,
|
||||||
|
0x6E, 0x64, 0x65, 0x72, 0x2D, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69,
|
||||||
|
0x62, 0x65, 0x64, 0x29, 0x00, 0x64, 0x65, 0x66, 0x6C, 0x61, 0x74, 0x65,
|
||||||
|
0x3A, 0x20, 0x62, 0x61, 0x64, 0x20, 0x48, 0x75, 0x66, 0x66, 0x6D, 0x61,
|
||||||
|
0x6E, 0x20, 0x63, 0x6F, 0x64, 0x65, 0x20, 0x28, 0x6F, 0x76, 0x65, 0x72,
|
||||||
|
0x2D, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x64, 0x29,
|
||||||
|
0x00,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint16_t wuffs_deflate__status__string_offsets[] = {
|
static const uint16_t wuffs_deflate__status__string_offsets[] = {
|
||||||
@@ -2687,15 +2693,15 @@ static const uint16_t wuffs_deflate__status__string_offsets[] = {
|
|||||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001,
|
||||||
0x0001, 0x002E, 0x005D, 0x0098, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
0x002E, 0x005D, 0x0087, 0x00C2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||||
0x00D4, 0x00EE, 0x0111, 0x013B, 0x0162, 0x0183, 0x0199, 0x01AC, 0x01D5,
|
0x00FE, 0x0118, 0x013B, 0x0165, 0x018C, 0x01AD, 0x01C3, 0x01D6, 0x01FF,
|
||||||
0x01EF, 0x021B, 0x0242, 0x026F,
|
0x0219, 0x0245, 0x026C, 0x0299,
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* wuffs_deflate__status__string(wuffs_base__status s) {
|
const char* wuffs_deflate__status__string(wuffs_base__status s) {
|
||||||
@@ -4173,11 +4179,12 @@ label_0_continue:;
|
|||||||
label_0_break:;
|
label_0_break:;
|
||||||
while (v_n_bits >= 8) {
|
while (v_n_bits >= 8) {
|
||||||
v_n_bits -= 8;
|
v_n_bits -= 8;
|
||||||
if (ioptr_src == iobounds0orig_src) {
|
if (ioptr_src > iobounds0orig_src) {
|
||||||
status = WUFFS_BASE__ERROR_INVALID_I_O_OPERATION;
|
(ioptr_src--, wuffs_base__return_empty_struct());
|
||||||
|
} else {
|
||||||
|
status = WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_I_O;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
ioptr_src--;
|
|
||||||
}
|
}
|
||||||
self->private_impl.f_bits = (v_bits & ((((uint32_t)(1)) << v_n_bits) - 1));
|
self->private_impl.f_bits = (v_bits & ((((uint32_t)(1)) << v_n_bits) - 1));
|
||||||
self->private_impl.f_n_bits = v_n_bits;
|
self->private_impl.f_n_bits = v_n_bits;
|
||||||
|
|||||||
+4
-2
@@ -1774,10 +1774,12 @@ extern "C" {
|
|||||||
-1072893291 // 0xC00CF295
|
-1072893291 // 0xC00CF295
|
||||||
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_HUFFMAN_END_OF_BLOCK \
|
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_HUFFMAN_END_OF_BLOCK \
|
||||||
-1089670507 // 0xBF0CF295
|
-1089670507 // 0xBF0CF295
|
||||||
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_DISTANCE \
|
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_I_O \
|
||||||
-1106447723 // 0xBE0CF295
|
-1106447723 // 0xBE0CF295
|
||||||
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_N_BITS \
|
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_DISTANCE \
|
||||||
-1123224939 // 0xBD0CF295
|
-1123224939 // 0xBD0CF295
|
||||||
|
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_N_BITS \
|
||||||
|
-1140002155 // 0xBC0CF295
|
||||||
|
|
||||||
const char* wuffs_deflate__status__string(wuffs_base__status s);
|
const char* wuffs_deflate__status__string(wuffs_base__status s);
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -1872,10 +1872,12 @@ extern "C" {
|
|||||||
-1072893291 // 0xC00CF295
|
-1072893291 // 0xC00CF295
|
||||||
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_HUFFMAN_END_OF_BLOCK \
|
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_HUFFMAN_END_OF_BLOCK \
|
||||||
-1089670507 // 0xBF0CF295
|
-1089670507 // 0xBF0CF295
|
||||||
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_DISTANCE \
|
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_I_O \
|
||||||
-1106447723 // 0xBE0CF295
|
-1106447723 // 0xBE0CF295
|
||||||
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_N_BITS \
|
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_DISTANCE \
|
||||||
-1123224939 // 0xBD0CF295
|
-1123224939 // 0xBD0CF295
|
||||||
|
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_N_BITS \
|
||||||
|
-1140002155 // 0xBC0CF295
|
||||||
|
|
||||||
const char* wuffs_deflate__status__string(wuffs_base__status s);
|
const char* wuffs_deflate__status__string(wuffs_base__status s);
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -1872,10 +1872,12 @@ extern "C" {
|
|||||||
-1072893291 // 0xC00CF295
|
-1072893291 // 0xC00CF295
|
||||||
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_HUFFMAN_END_OF_BLOCK \
|
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_HUFFMAN_END_OF_BLOCK \
|
||||||
-1089670507 // 0xBF0CF295
|
-1089670507 // 0xBF0CF295
|
||||||
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_DISTANCE \
|
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_I_O \
|
||||||
-1106447723 // 0xBE0CF295
|
-1106447723 // 0xBE0CF295
|
||||||
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_N_BITS \
|
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_DISTANCE \
|
||||||
-1123224939 // 0xBD0CF295
|
-1123224939 // 0xBD0CF295
|
||||||
|
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_N_BITS \
|
||||||
|
-1140002155 // 0xBC0CF295
|
||||||
|
|
||||||
const char* wuffs_deflate__status__string(wuffs_base__status s);
|
const char* wuffs_deflate__status__string(wuffs_base__status s);
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -1871,10 +1871,12 @@ extern "C" {
|
|||||||
-1072893291 // 0xC00CF295
|
-1072893291 // 0xC00CF295
|
||||||
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_HUFFMAN_END_OF_BLOCK \
|
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_HUFFMAN_END_OF_BLOCK \
|
||||||
-1089670507 // 0xBF0CF295
|
-1089670507 // 0xBF0CF295
|
||||||
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_DISTANCE \
|
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_I_O \
|
||||||
-1106447723 // 0xBE0CF295
|
-1106447723 // 0xBE0CF295
|
||||||
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_N_BITS \
|
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_DISTANCE \
|
||||||
-1123224939 // 0xBD0CF295
|
-1123224939 // 0xBD0CF295
|
||||||
|
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_N_BITS \
|
||||||
|
-1140002155 // 0xBC0CF295
|
||||||
|
|
||||||
const char* wuffs_deflate__status__string(wuffs_base__status s);
|
const char* wuffs_deflate__status__string(wuffs_base__status s);
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -1871,10 +1871,12 @@ extern "C" {
|
|||||||
-1072893291 // 0xC00CF295
|
-1072893291 // 0xC00CF295
|
||||||
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_HUFFMAN_END_OF_BLOCK \
|
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_HUFFMAN_END_OF_BLOCK \
|
||||||
-1089670507 // 0xBF0CF295
|
-1089670507 // 0xBF0CF295
|
||||||
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_DISTANCE \
|
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_I_O \
|
||||||
-1106447723 // 0xBE0CF295
|
-1106447723 // 0xBE0CF295
|
||||||
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_N_BITS \
|
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_DISTANCE \
|
||||||
-1123224939 // 0xBD0CF295
|
-1123224939 // 0xBD0CF295
|
||||||
|
#define WUFFS_DEFLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_N_BITS \
|
||||||
|
-1140002155 // 0xBC0CF295
|
||||||
|
|
||||||
const char* wuffs_deflate__status__string(wuffs_base__status s);
|
const char* wuffs_deflate__status__string(wuffs_base__status s);
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,8 @@ var StatusList = [...]Status{
|
|||||||
|
|
||||||
{t.IDError, -0x20, "cannot return a suspension"},
|
{t.IDError, -0x20, "cannot return a suspension"},
|
||||||
|
|
||||||
{t.IDError, -0x30, "invalid I/O operation"},
|
{t.IDError, -0x30, "invalid I/O operation"}, // TODO: no longer used; delete.
|
||||||
|
|
||||||
{t.IDError, -0x31, "unexpected EOF"}, // Used if reading when closed == true.
|
{t.IDError, -0x31, "unexpected EOF"}, // Used if reading when closed == true.
|
||||||
{t.IDError, -0x32, "closed for writes"}, // TODO: is this unused? Should callee or caller check closed-ness?
|
{t.IDError, -0x32, "closed for writes"}, // TODO: is this unused? Should callee or caller check closed-ness?
|
||||||
|
|
||||||
@@ -140,7 +141,9 @@ var Funcs = []string{
|
|||||||
|
|
||||||
// ---- io_reader
|
// ---- io_reader
|
||||||
|
|
||||||
"io_reader.unread_u8?()()",
|
"io_reader.can_undo_byte()(ret bool)",
|
||||||
|
"io_reader.undo_byte!()()",
|
||||||
|
|
||||||
"io_reader.read_u8?()(ret u8)",
|
"io_reader.read_u8?()(ret u8)",
|
||||||
"io_reader.read_u16be?()(ret u16)",
|
"io_reader.read_u16be?()(ret u16)",
|
||||||
"io_reader.read_u16le?()(ret u16)",
|
"io_reader.read_u16le?()(ret u16)",
|
||||||
|
|||||||
+30
-23
@@ -214,10 +214,6 @@ loop:
|
|||||||
func (q *checker) bcheckStatement(n *a.Node) error {
|
func (q *checker) bcheckStatement(n *a.Node) error {
|
||||||
q.errFilename, q.errLine = n.AsRaw().FilenameLine()
|
q.errFilename, q.errLine = n.AsRaw().FilenameLine()
|
||||||
|
|
||||||
// TODO: be principled about checking for provenNotToSuspend. Should we
|
|
||||||
// call optimizeSuspendible only for assignments, for var statements too,
|
|
||||||
// or for all statements generally?
|
|
||||||
|
|
||||||
switch n.Kind() {
|
switch n.Kind() {
|
||||||
case a.KAssert:
|
case a.KAssert:
|
||||||
if err := q.bcheckAssert(n.AsAssert()); err != nil {
|
if err := q.bcheckAssert(n.AsAssert()); err != nil {
|
||||||
@@ -235,11 +231,6 @@ func (q *checker) bcheckStatement(n *a.Node) error {
|
|||||||
if _, err := q.bcheckExpr(n, 0); err != nil {
|
if _, err := q.bcheckExpr(n, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if n.Suspendible() {
|
|
||||||
if err := q.optimizeSuspendible(n, 0); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case a.KIOBind:
|
case a.KIOBind:
|
||||||
n := n.AsIOBind()
|
n := n.AsIOBind()
|
||||||
@@ -427,19 +418,6 @@ func (q *checker) bcheckAssignment(lhs *a.Expr, op t.ID, rhs *a.Expr) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: be principled about checking for provenNotToSuspend, and for
|
|
||||||
// updating facts like "in.src.available() >= 6" after "in.src.read_u8?()".
|
|
||||||
// In general, we need to invalidate any "foo.bar()" facts after a call to
|
|
||||||
// an impure function like "foo.meth0!()" or "foo.meth1?()".
|
|
||||||
//
|
|
||||||
// What's here is somewhat ad hoc. Perhaps we need a call keyword and an
|
|
||||||
// explicit "foo = call bar?()" syntax.
|
|
||||||
if rhs.Suspendible() {
|
|
||||||
if err := q.optimizeSuspendible(rhs, 0); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -985,7 +963,12 @@ func (q *checker) bcheckExprCallSpecialCases(n *a.Expr, depth uint32) (a.Bounds,
|
|||||||
} else if recvTyp.IsIOType() {
|
} else if recvTyp.IsIOType() {
|
||||||
advance, update := (*big.Int)(nil), false
|
advance, update := (*big.Int)(nil), false
|
||||||
|
|
||||||
if method == t.IDSkipFast {
|
if method == t.IDUndoByte {
|
||||||
|
if err := q.canUndoByte(recv); err != nil {
|
||||||
|
return a.Bounds{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if method == t.IDSkipFast {
|
||||||
args := n.Args()
|
args := n.Args()
|
||||||
if len(args) != 2 {
|
if len(args) != 2 {
|
||||||
return a.Bounds{}, fmt.Errorf("check: internal error: bad skip_fast arguments")
|
return a.Bounds{}, fmt.Errorf("check: internal error: bad skip_fast arguments")
|
||||||
@@ -1017,12 +1000,36 @@ func (q *checker) bcheckExprCallSpecialCases(n *a.Expr, depth uint32) (a.Bounds,
|
|||||||
return a.Bounds{}, fmt.Errorf("check: could not prove %s precondition: %s.available() >= %v",
|
return a.Bounds{}, fmt.Errorf("check: could not prove %s precondition: %s.available() >= %v",
|
||||||
method.Str(q.tm), recv.Str(q.tm), advance)
|
method.Str(q.tm), recv.Str(q.tm), advance)
|
||||||
}
|
}
|
||||||
|
// TODO: drop other recv-related facts?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return a.Bounds{}, errNotASpecialCase
|
return a.Bounds{}, errNotASpecialCase
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (q *checker) canUndoByte(recv *a.Expr) error {
|
||||||
|
for _, x := range q.facts {
|
||||||
|
if x.Operator() != t.IDOpenParen || len(x.Args()) != 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
x = x.LHS().AsExpr()
|
||||||
|
if x.Operator() != t.IDDot || x.Ident() != t.IDCanUndoByte {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
x = x.LHS().AsExpr()
|
||||||
|
if !x.Eq(recv) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
return q.facts.update(func(o *a.Expr) (*a.Expr, error) {
|
||||||
|
if o.Mentions(recv) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return o, nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return fmt.Errorf("check: could not prove %s.can_undo_byte()", recv.Str(q.tm))
|
||||||
|
}
|
||||||
|
|
||||||
var ioMethodAdvances = [...]struct {
|
var ioMethodAdvances = [...]struct {
|
||||||
advance *big.Int
|
advance *big.Int
|
||||||
update bool
|
update bool
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ package check
|
|||||||
// code but never actually suspend.
|
// code but never actually suspend.
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
a "github.com/google/wuffs/lang/ast"
|
a "github.com/google/wuffs/lang/ast"
|
||||||
@@ -175,46 +174,6 @@ check2:
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *checker) optimizeSuspendible(n *a.Expr, depth uint32) error {
|
|
||||||
if depth > a.MaxExprDepth {
|
|
||||||
return fmt.Errorf("check: expression recursion depth too large")
|
|
||||||
}
|
|
||||||
depth++
|
|
||||||
|
|
||||||
if !n.CallSuspendible() {
|
|
||||||
for _, o := range n.AsNode().AsRaw().SubNodes() {
|
|
||||||
if o != nil && o.Kind() == a.KExpr {
|
|
||||||
if err := q.optimizeSuspendible(o.AsExpr(), depth); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, o := range n.Args() {
|
|
||||||
if o != nil && o.Kind() == a.KExpr {
|
|
||||||
if err := q.optimizeSuspendible(o.AsExpr(), depth); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
nReceiver, nMethod, _ := splitReceiverMethodArgs(n)
|
|
||||||
if nReceiver == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: check that nReceiver's type is actually a io_reader or io_writer.
|
|
||||||
|
|
||||||
if nMethod == t.IDUnreadU8 {
|
|
||||||
// unread_u8 can never suspend, only succeed or fail.
|
|
||||||
n.SetProvenNotToSuspend()
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *checker) optimizeIOMethodAdvance(receiver *a.Expr, advance *big.Int, update bool) (retOK bool, retErr error) {
|
func (q *checker) optimizeIOMethodAdvance(receiver *a.Expr, advance *big.Int, update bool) (retOK bool, retErr error) {
|
||||||
// TODO: do two passes? The first one to non-destructively check retOK. The
|
// TODO: do two passes? The first one to non-destructively check retOK. The
|
||||||
// second one to drop facts if indeed retOK? Otherwise, an advance
|
// second one to drop facts if indeed retOK? Otherwise, an advance
|
||||||
|
|||||||
+14
-12
@@ -444,7 +444,7 @@ const (
|
|||||||
|
|
||||||
// TODO Read/Write 24 bits? It might be useful for RGB triples.
|
// TODO Read/Write 24 bits? It might be useful for RGB triples.
|
||||||
|
|
||||||
IDUnreadU8 = ID(0x140)
|
IDUndoByte = ID(0x140)
|
||||||
IDReadU8 = ID(0x141)
|
IDReadU8 = ID(0x141)
|
||||||
IDReadU16BE = ID(0x142)
|
IDReadU16BE = ID(0x142)
|
||||||
IDReadU16LE = ID(0x143)
|
IDReadU16LE = ID(0x143)
|
||||||
@@ -510,11 +510,12 @@ const (
|
|||||||
IDWriteFastU64BE = ID(0x17E)
|
IDWriteFastU64BE = ID(0x17E)
|
||||||
IDWriteFastU64LE = ID(0x17F)
|
IDWriteFastU64LE = ID(0x17F)
|
||||||
|
|
||||||
IDSetLimit = ID(0x180)
|
IDCanUndoByte = ID(0x180)
|
||||||
IDSetMark = ID(0x181)
|
IDSetLimit = ID(0x181)
|
||||||
IDSinceMark = ID(0x182)
|
IDSetMark = ID(0x182)
|
||||||
IDSkip = ID(0x183)
|
IDSinceMark = ID(0x183)
|
||||||
IDSkipFast = ID(0x184)
|
IDSkip = ID(0x184)
|
||||||
|
IDSkipFast = ID(0x185)
|
||||||
|
|
||||||
IDCopyFromSlice = ID(0x190)
|
IDCopyFromSlice = ID(0x190)
|
||||||
IDCopyNFromHistory = ID(0x191)
|
IDCopyNFromHistory = ID(0x191)
|
||||||
@@ -721,7 +722,7 @@ var builtInsByID = [nBuiltInIDs]string{
|
|||||||
IDOut: "out",
|
IDOut: "out",
|
||||||
IDBase: "base",
|
IDBase: "base",
|
||||||
|
|
||||||
IDUnreadU8: "unread_u8",
|
IDUndoByte: "undo_byte",
|
||||||
IDReadU8: "read_u8",
|
IDReadU8: "read_u8",
|
||||||
IDReadU16BE: "read_u16be",
|
IDReadU16BE: "read_u16be",
|
||||||
IDReadU16LE: "read_u16le",
|
IDReadU16LE: "read_u16le",
|
||||||
@@ -786,11 +787,12 @@ var builtInsByID = [nBuiltInIDs]string{
|
|||||||
IDWriteFastU64BE: "write_fast_u64be",
|
IDWriteFastU64BE: "write_fast_u64be",
|
||||||
IDWriteFastU64LE: "write_fast_u64le",
|
IDWriteFastU64LE: "write_fast_u64le",
|
||||||
|
|
||||||
IDSetLimit: "set_limit",
|
IDCanUndoByte: "can_undo_byte",
|
||||||
IDSetMark: "set_mark",
|
IDSetLimit: "set_limit",
|
||||||
IDSinceMark: "since_mark",
|
IDSetMark: "set_mark",
|
||||||
IDSkip: "skip",
|
IDSinceMark: "since_mark",
|
||||||
IDSkipFast: "skip_fast",
|
IDSkip: "skip",
|
||||||
|
IDSkipFast: "skip_fast",
|
||||||
|
|
||||||
IDCopyFromSlice: "copy_from_slice",
|
IDCopyFromSlice: "copy_from_slice",
|
||||||
IDCopyNFromHistory: "copy_n_from_history",
|
IDCopyNFromHistory: "copy_n_from_history",
|
||||||
|
|||||||
@@ -30,8 +30,9 @@ pub error (0x0D) "no Huffman codes"
|
|||||||
|
|
||||||
pri error (0x40) "internal error: inconsistent Huffman decoder state"
|
pri error (0x40) "internal error: inconsistent Huffman decoder state"
|
||||||
pri error (0x41) "internal error: inconsistent Huffman end_of_block"
|
pri error (0x41) "internal error: inconsistent Huffman end_of_block"
|
||||||
pri error (0x42) "internal error: inconsistent distance"
|
pub error (0x42) "internal error: inconsistent I/O"
|
||||||
pri error (0x43) "internal error: inconsistent n_bits"
|
pri error (0x43) "internal error: inconsistent distance"
|
||||||
|
pri error (0x44) "internal error: inconsistent n_bits"
|
||||||
|
|
||||||
// The next two tables were created by script/print-deflate-magic-numbers.go.
|
// The next two tables were created by script/print-deflate-magic-numbers.go.
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -368,21 +368,22 @@ pri func decoder.decode_huffman_fast?(dst base.io_writer, src base.io_reader)()
|
|||||||
// Ensure n_bits < 8 by rewindng in.src, if we loaded too many of its bytes
|
// Ensure n_bits < 8 by rewindng in.src, if we loaded too many of its bytes
|
||||||
// into the bits variable.
|
// into the bits variable.
|
||||||
//
|
//
|
||||||
// Note that we can unconditionally call unread_u8 (without resulting in an
|
// Note that we can unconditionally call undo_read (without resulting in an
|
||||||
// "invalid I/O operation" error code) only because this whole function can
|
// "invalid I/O operation" error code) only because this whole function can
|
||||||
// never suspend, as all of its I/O operations were checked beforehand for
|
// never suspend, as all of its I/O operations were checked beforehand for
|
||||||
// sufficient buffer space. Otherwise, resuming from the suspension could
|
// sufficient buffer space. Otherwise, resuming from the suspension could
|
||||||
// mean that the (possibly different) in.src is no longer rewindable, even
|
// mean that the (possibly different) in.src is no longer rewindable, even
|
||||||
// if conceptually, this function was responsible for reading the bytes we
|
// if conceptually, this function was responsible for reading the bytes we
|
||||||
// want to rewind.
|
// want to rewind.
|
||||||
//
|
|
||||||
// TODO: have the compiler enforce (via some explicit syntax) that this
|
|
||||||
// function is ProvenNotToSuspend?
|
|
||||||
while n_bits >= 8,
|
while n_bits >= 8,
|
||||||
post n_bits < 8,
|
post n_bits < 8,
|
||||||
{
|
{
|
||||||
n_bits -= 8
|
n_bits -= 8
|
||||||
in.src.unread_u8?()
|
if in.src.can_undo_byte() {
|
||||||
|
in.src.undo_byte!()
|
||||||
|
} else {
|
||||||
|
return error "internal error: inconsistent I/O"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.bits = bits & (((1 as base.u32) << n_bits) - 1)
|
this.bits = bits & (((1 as base.u32) << n_bits) - 1)
|
||||||
|
|||||||
Reference in new issue
Block a user