diff --git a/cmd/wuffs/gen.go b/cmd/wuffs/gen.go index f43c29ad..10f98224 100644 --- a/cmd/wuffs/gen.go +++ b/cmd/wuffs/gen.go @@ -264,7 +264,8 @@ func (h *genHelper) genWuffs(dirname string, qualifiedFilenames []string) error if !n.Public() { continue } - return fmt.Errorf("TODO: genWuffs for consts") + fmt.Fprintf(out, "pub const %s %s = %v\n", + n.QID().Str(&h.tm), n.XType().Str(&h.tm), n.Value().Str(&h.tm)) case a.KFunc: n := n.AsFunc() diff --git a/lang/check/check.go b/lang/check/check.go index 698b2528..5c82f7a2 100644 --- a/lang/check/check.go +++ b/lang/check/check.go @@ -220,7 +220,9 @@ func (c *Checker) checkUse(node *a.Node) error { switch n.Kind() { case a.KConst: - return fmt.Errorf("TODO: type-check a used-package const") + if err := c.checkConst(n); err != nil { + return err + } case a.KFunc: if err := c.checkFuncSignature(n); err != nil { return err diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index ba0478fe..300f5824 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -2647,6 +2647,9 @@ extern const char* wuffs_deflate__error__no_huffman_codes; // ---------------- Public Consts +WUFFS_BASE__MAYBE_STATIC const uint64_t wuffs_deflate__max_incl_workbuf_len + WUFFS_BASE__POTENTIALLY_UNUSED = 33280; + // ---------------- Struct Declarations typedef struct wuffs_deflate__decoder__struct wuffs_deflate__decoder; @@ -2814,6 +2817,9 @@ extern const char* wuffs_lzw__error__bad_code; // ---------------- Public Consts +WUFFS_BASE__MAYBE_STATIC const uint64_t wuffs_lzw__max_incl_workbuf_len + WUFFS_BASE__POTENTIALLY_UNUSED = 0; + // ---------------- Struct Declarations typedef struct wuffs_lzw__decoder__struct wuffs_lzw__decoder; @@ -2974,6 +2980,9 @@ extern const char* wuffs_gif__error__too_much_pixel_data; // ---------------- Public Consts +WUFFS_BASE__MAYBE_STATIC const uint64_t wuffs_gif__max_incl_workbuf_len + WUFFS_BASE__POTENTIALLY_UNUSED = 65535; + // ---------------- Struct Declarations typedef struct wuffs_gif__decoder__struct wuffs_gif__decoder; @@ -3264,6 +3273,9 @@ extern const char* wuffs_gzip__error__bad_header; // ---------------- Public Consts +WUFFS_BASE__MAYBE_STATIC const uint64_t wuffs_gzip__max_incl_workbuf_len + WUFFS_BASE__POTENTIALLY_UNUSED = 33280; + // ---------------- Struct Declarations typedef struct wuffs_gzip__decoder__struct wuffs_gzip__decoder; @@ -3402,6 +3414,9 @@ extern const char* wuffs_zlib__error__bad_parity_check; // ---------------- Public Consts +WUFFS_BASE__MAYBE_STATIC const uint64_t wuffs_zlib__max_incl_workbuf_len + WUFFS_BASE__POTENTIALLY_UNUSED = 33280; + // ---------------- Struct Declarations typedef struct wuffs_zlib__decoder__struct wuffs_zlib__decoder; diff --git a/std/deflate/decode_deflate.wuffs b/std/deflate/decode_deflate.wuffs index b40a27dc..0c16acd7 100644 --- a/std/deflate/decode_deflate.wuffs +++ b/std/deflate/decode_deflate.wuffs @@ -31,6 +31,8 @@ pri status "?internal error: inconsistent I/O" pri status "?internal error: inconsistent distance" pri status "?internal error: inconsistent n_bits" +pub const max_incl_workbuf_len base.u64 = 32768 + 512 + // The next two tables were created by script/print-deflate-magic-numbers.go. // // The u32 values' meanings are the same as the decoder.huffs u32 values. In diff --git a/std/gif/decode_gif.wuffs b/std/gif/decode_gif.wuffs index 5bdee2a3..bb2e4ad5 100644 --- a/std/gif/decode_gif.wuffs +++ b/std/gif/decode_gif.wuffs @@ -24,6 +24,9 @@ pub status "?too much pixel data" pri status "?internal error: inconsistent ri/wi" +// TODO: reference lzw.max_incl_workbuf_len. +pub const max_incl_workbuf_len base.u64 = 0xFFFF + // See the spec appendix E "Interlaced Images" on page 29. The first element // represents either that the frame was non-interlaced, or that all interlace // stages are complete. Otherwise, the four interlace stages are elements 4, 3, diff --git a/std/gzip/decode_gzip.wuffs b/std/gzip/decode_gzip.wuffs index 747f1d4f..e839ae0f 100644 --- a/std/gzip/decode_gzip.wuffs +++ b/std/gzip/decode_gzip.wuffs @@ -20,6 +20,9 @@ pub status "?bad compression method" pub status "?bad encoding flags" pub status "?bad header" +// TODO: reference deflate.max_incl_workbuf_len. +pub const max_incl_workbuf_len base.u64 = 32768 + 512 + pub struct decoder?( flate deflate.decoder, checksum crc32.ieee_hasher, diff --git a/std/lzw/decode_lzw.wuffs b/std/lzw/decode_lzw.wuffs index b0f65645..17ef800f 100644 --- a/std/lzw/decode_lzw.wuffs +++ b/std/lzw/decode_lzw.wuffs @@ -16,6 +16,10 @@ pub status "?bad code" pri status "?internal error: inconsistent I/O" +// TODO: move bulk data buffers like decoder.suffixes or decoder.output into +// the workbuf? +pub const max_incl_workbuf_len base.u64 = 0 + pub struct decoder?( // The value passed to set_literal_width. This lw field is copied to the // literal_width field at the start of the decode method. During that diff --git a/std/zlib/decode_zlib.wuffs b/std/zlib/decode_zlib.wuffs index 0520b06e..819f2723 100644 --- a/std/zlib/decode_zlib.wuffs +++ b/std/zlib/decode_zlib.wuffs @@ -22,6 +22,9 @@ pub status "?bad parity check" pri status "?TODO: unsupported preset dictionary" +// TODO: reference deflate.max_incl_workbuf_len. +pub const max_incl_workbuf_len base.u64 = 32768 + 512 + pub struct decoder?( flate deflate.decoder, checksum adler32.hasher,