mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 00:52:18 +01:00
Generate code for "mark in.dst".
The generated code is ugly and the language design is not finalized, but the flate_backref_crosses_blocks test (testing a correctness bug) now passes. We can fix the ugliness in subsequent commits.
This commit is contained in:
1 parent
83c8faef4d
commit
21bbbd422f
11 files changed
+107
-24
No files matched your search
+34
-11
@@ -82,11 +82,21 @@ typedef struct puffs_base__limit1 {
|
||||
typedef struct {
|
||||
puffs_base__buf1* buf;
|
||||
puffs_base__limit1 limit;
|
||||
// Do not access the private_impl's fields directly. There is no API/ABI
|
||||
// compatibility or safety guarantee if you do so.
|
||||
struct {
|
||||
uint8_t* mark;
|
||||
} private_impl;
|
||||
} puffs_base__reader1;
|
||||
|
||||
typedef struct {
|
||||
puffs_base__buf1* buf;
|
||||
puffs_base__limit1 limit;
|
||||
// Do not access the private_impl's fields directly. There is no API/ABI
|
||||
// compatibility or safety guarantee if you do so.
|
||||
struct {
|
||||
uint8_t* mark;
|
||||
} private_impl;
|
||||
} puffs_base__writer1;
|
||||
|
||||
#endif // PUFFS_BASE_HEADER_H
|
||||
@@ -807,6 +817,7 @@ puffs_flate__status puffs_flate__flate_decoder__decode(
|
||||
uint8_t* b_wend_dst = NULL;
|
||||
if (a_dst.buf) {
|
||||
b_wptr_dst = a_dst.buf->ptr + a_dst.buf->wi;
|
||||
a_dst.private_impl.mark = b_wptr_dst;
|
||||
b_wstart_dst = b_wptr_dst;
|
||||
b_wend_dst = b_wptr_dst;
|
||||
if (!a_dst.buf->closed) {
|
||||
@@ -831,7 +842,6 @@ puffs_flate__status puffs_flate__flate_decoder__decode(
|
||||
switch (coro_susp_point) {
|
||||
PUFFS_BASE__COROUTINE_SUSPENSION_POINT(0);
|
||||
|
||||
/* placeholder */
|
||||
while (true) {
|
||||
PUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
if (a_dst.buf) {
|
||||
@@ -866,8 +876,10 @@ puffs_flate__status puffs_flate__flate_decoder__decode(
|
||||
PUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2);
|
||||
}
|
||||
v_written = ((puffs_base__slice_u8){
|
||||
.ptr = b_wstart_dst,
|
||||
.len = b_wptr_dst - b_wstart_dst,
|
||||
.ptr = (a_dst.private_impl.mark ? a_dst.private_impl.mark
|
||||
: b_wstart_dst),
|
||||
.len = b_wptr_dst - (a_dst.private_impl.mark ? a_dst.private_impl.mark
|
||||
: b_wstart_dst),
|
||||
});
|
||||
if (((uint64_t)(v_written.len)) >= 32768) {
|
||||
v_written = puffs_base__slice_u8_suffix(v_written, 32768);
|
||||
@@ -1539,10 +1551,15 @@ puffs_flate__status puffs_flate__flate_decoder__decode_huffman(
|
||||
v_n_copied = 0;
|
||||
while (true) {
|
||||
if (((uint64_t)(v_distance)) >
|
||||
((uint64_t)(b_wptr_dst - b_wstart_dst))) {
|
||||
((uint64_t)(b_wptr_dst - (a_dst.private_impl.mark
|
||||
? a_dst.private_impl.mark
|
||||
: b_wstart_dst)))) {
|
||||
v_hlen = 0;
|
||||
v_hdist = ((uint32_t)((((uint64_t)(v_distance)) -
|
||||
((uint64_t)(b_wptr_dst - b_wstart_dst)))));
|
||||
v_hdist = ((uint32_t)(
|
||||
(((uint64_t)(v_distance)) -
|
||||
((uint64_t)(b_wptr_dst - (a_dst.private_impl.mark
|
||||
? a_dst.private_impl.mark
|
||||
: b_wstart_dst))))));
|
||||
if (v_length > v_hdist) {
|
||||
v_length -= v_hdist;
|
||||
v_hlen = v_hdist;
|
||||
@@ -1603,7 +1620,9 @@ puffs_flate__status puffs_flate__flate_decoder__decode_huffman(
|
||||
}
|
||||
}
|
||||
v_n_copied = puffs_base__writer1__copy_from_history32(
|
||||
&b_wptr_dst, b_wstart_dst, b_wend_dst, v_distance, v_length);
|
||||
&b_wptr_dst,
|
||||
(a_dst.private_impl.mark ? a_dst.private_impl.mark : b_wstart_dst),
|
||||
b_wend_dst, v_distance, v_length);
|
||||
if (v_length <= v_n_copied) {
|
||||
v_length = 0;
|
||||
goto label_7_break;
|
||||
@@ -2433,10 +2452,14 @@ puffs_flate__status puffs_flate__zlib_decoder__decode(
|
||||
}
|
||||
v_z = t_2;
|
||||
v_checksum = puffs_flate__adler32__update(
|
||||
&self->private_impl.f_adler, ((puffs_base__slice_u8){
|
||||
.ptr = b_wstart_dst,
|
||||
.len = b_wptr_dst - b_wstart_dst,
|
||||
}));
|
||||
&self->private_impl.f_adler,
|
||||
((puffs_base__slice_u8){
|
||||
.ptr = (a_dst.private_impl.mark ? a_dst.private_impl.mark
|
||||
: b_wstart_dst),
|
||||
.len = b_wptr_dst - (a_dst.private_impl.mark
|
||||
? a_dst.private_impl.mark
|
||||
: b_wstart_dst),
|
||||
}));
|
||||
if (v_z == 0) {
|
||||
goto label_0_break;
|
||||
}
|
||||
|
||||
@@ -82,11 +82,21 @@ typedef struct puffs_base__limit1 {
|
||||
typedef struct {
|
||||
puffs_base__buf1* buf;
|
||||
puffs_base__limit1 limit;
|
||||
// Do not access the private_impl's fields directly. There is no API/ABI
|
||||
// compatibility or safety guarantee if you do so.
|
||||
struct {
|
||||
uint8_t* mark;
|
||||
} private_impl;
|
||||
} puffs_base__reader1;
|
||||
|
||||
typedef struct {
|
||||
puffs_base__buf1* buf;
|
||||
puffs_base__limit1 limit;
|
||||
// Do not access the private_impl's fields directly. There is no API/ABI
|
||||
// compatibility or safety guarantee if you do so.
|
||||
struct {
|
||||
uint8_t* mark;
|
||||
} private_impl;
|
||||
} puffs_base__writer1;
|
||||
|
||||
#endif // PUFFS_BASE_HEADER_H
|
||||
|
||||
Reference in new issue
Block a user