From 1366d3c6d4dd8f0b06bb1f6e6c43ddf107203e71 Mon Sep 17 00:00:00 2001 From: Francesco Cozzuto Date: Thu, 18 Sep 2025 09:26:59 +0200 Subject: [PATCH] Fix warnings --- WL.c | 35 ++++++++++++++++++++++++----------- WL.h | 1 + 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/WL.c b/WL.c index b50e2de..5aa92f9 100644 --- a/WL.c +++ b/WL.c @@ -69,12 +69,14 @@ static bool is_hex_digit(char c) return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); } +#if 0 static char to_lower(char c) { if (c >= 'A' && c <= 'Z') return c - 'A' + 'a'; return c; } +#endif static int hex_digit_to_int(char c) { @@ -97,6 +99,7 @@ static bool streq(String a, String b) return true; } +#if 0 static bool streqcase(String a, String b) { if (a.len != b.len) @@ -106,7 +109,7 @@ static bool streqcase(String a, String b) return false; return true; } - +#endif #define REPORT(err, fmt, ...) report((err), __FILE__, __LINE__, fmt, ## __VA_ARGS__) static void report(Error *err, char *file, int line, char *fmt, ...) @@ -159,6 +162,7 @@ static bool grow_alloc(WL_Arena *a, char *p, int new_len) return true; } +#if 0 static String copystr(String s, WL_Arena *a) { char *p = alloc(a, s.len, 1); @@ -167,6 +171,7 @@ static String copystr(String s, WL_Arena *a) memcpy(p, s.ptr, s.len); return (String) { p, s.len }; } +#endif ///////////////////////////////////////////////////////////////////////// // WRITER @@ -189,14 +194,14 @@ static void write_raw_mem(Writer *w, void *ptr, int len) } static void write_raw_u8 (Writer *w, uint8_t x) { write_raw_mem(w, &x, SIZEOF(x)); } -static void write_raw_u16(Writer *w, uint16_t x) { write_raw_mem(w, &x, SIZEOF(x)); } +//static void write_raw_u16(Writer *w, uint16_t x) { write_raw_mem(w, &x, SIZEOF(x)); } static void write_raw_u32(Writer *w, uint32_t x) { write_raw_mem(w, &x, SIZEOF(x)); } -static void write_raw_u64(Writer *w, uint64_t x) { write_raw_mem(w, &x, SIZEOF(x)); } -static void write_raw_s8 (Writer *w, int8_t x) { write_raw_mem(w, &x, SIZEOF(x)); } -static void write_raw_s16(Writer *w, int16_t x) { write_raw_mem(w, &x, SIZEOF(x)); } -static void write_raw_s32(Writer *w, int32_t x) { write_raw_mem(w, &x, SIZEOF(x)); } +//static void write_raw_u64(Writer *w, uint64_t x) { write_raw_mem(w, &x, SIZEOF(x)); } +//static void write_raw_s8 (Writer *w, int8_t x) { write_raw_mem(w, &x, SIZEOF(x)); } +//static void write_raw_s16(Writer *w, int16_t x) { write_raw_mem(w, &x, SIZEOF(x)); } +//static void write_raw_s32(Writer *w, int32_t x) { write_raw_mem(w, &x, SIZEOF(x)); } static void write_raw_s64(Writer *w, int64_t x) { write_raw_mem(w, &x, SIZEOF(x)); } -static void write_raw_f32(Writer *w, float x) { write_raw_mem(w, &x, SIZEOF(x)); } +//static void write_raw_f32(Writer *w, float x) { write_raw_mem(w, &x, SIZEOF(x)); } static void write_raw_f64(Writer *w, double x) { write_raw_mem(w, &x, SIZEOF(x)); } static void write_text(Writer *w, String str) @@ -413,6 +418,7 @@ static bool consume_str(Scanner *s, String x) return true; } +#if 0 static void write_token(Writer *w, Token token) { switch (token.type) { @@ -467,6 +473,7 @@ static void write_token(Writer *w, Token token) } } +#endif static void parser_report(Parser *p, char *fmt, ...) { @@ -2018,6 +2025,14 @@ static void write_node(Writer *w, Node *node) write_text(w, S(")")); break; + case NODE_OPER_SHOVEL: + write_text(w, S("(")); + write_node(w, node->left); + write_text(w, S("<<")); + write_node(w, node->right); + write_text(w, S(")")); + break; + case NODE_VALUE_INT: write_text_s64(w, node->ival); break; @@ -2717,9 +2732,6 @@ static void walk_expr_node(Codegen *cg, Node *node, bool one) case NODE_OPER_SHOVEL: { - Node *dst = node->left; - Node *src = node->right; - walk_expr_node(cg, node->left, true); cg_push_scope(cg, SCOPE_ASSIGNMENT); @@ -4783,7 +4795,7 @@ static String rt_read_str(WL_Runtime *rt) ASSERT(rt->state == RUNTIME_LOOP); uint32_t off = rt_read_u32(rt); uint32_t len = rt_read_u32(rt); - ASSERT(off + len <= rt->data.len); + ASSERT(off + len <= (uint32_t) rt->data.len); return (String) { rt->data.ptr + off, len }; } @@ -5325,6 +5337,7 @@ WL_EvalResult wl_runtime_eval(WL_Runtime *rt) switch (rt->state) { + case RUNTIME_BEGIN: case RUNTIME_LOOP: UNREACHABLE; diff --git a/WL.h b/WL.h index d2657eb..ceebb50 100644 --- a/WL.h +++ b/WL.h @@ -1,4 +1,5 @@ #include +#include typedef struct WL_Runtime WL_Runtime; typedef struct WL_Compiler WL_Compiler;