harec

[hare] Hare compiler, written in C11 for POSIX OSs
Log | Files | Refs | README | LICENSE

commit 4afbfe036d2a30cbc67333c58bfdddc49f991210
parent 33c9cbc5a7fc1e3b3c418847479f1c5aa6f05f65
Author: Bor Grošelj Simić <bgs@turminal.net>
Date:   Wed,  8 Feb 2023 05:15:58 +0100

make gen_context.id an int

We print it with %d and this is more practical than changing every %d to
PRIu64something. It also makes sense to make it match check_context.id

Signed-off-by: Bor Grošelj Simić <bgs@turminal.net>

Diffstat:
Minclude/gen.h | 2+-
Minclude/qbe.h | 4++--
Msrc/qbe.c | 4++--
Msrc/qtype.c | 8++++----
4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/include/gen.h b/include/gen.h @@ -67,7 +67,7 @@ struct gen_context { struct type_store *store; struct identifier *ns; - uint64_t id; + int id; struct qbe_func *current; const struct type *functype; diff --git a/include/qbe.h b/include/qbe.h @@ -265,10 +265,10 @@ struct qbe_program { void qbe_append_def(struct qbe_program *prog, struct qbe_def *def); void geni(struct qbe_statement *stmt, const struct qbe_value *out, enum qbe_instr instr, ...); -const char *genl(struct qbe_statement *stmt, uint64_t *id, const char *fmt); +const char *genl(struct qbe_statement *stmt, int *id, const char *fmt); void pushi(struct qbe_func *func, const struct qbe_value *out, enum qbe_instr instr, ...); void pushprei(struct qbe_func *func, const struct qbe_value *out, enum qbe_instr instr, ...); -const char *pushl(struct qbe_func *func, uint64_t *id, const char *fmt); +const char *pushl(struct qbe_func *func, int *id, const char *fmt); void pushc(struct qbe_func *func, const char *fmt, ...); void push(struct qbe_statements *stmts, struct qbe_statement *stmt); diff --git a/src/qbe.c b/src/qbe.c @@ -187,7 +187,7 @@ geni(struct qbe_statement *stmt, const struct qbe_value *out, } const char * -genl(struct qbe_statement *stmt, uint64_t *id, const char *fmt) +genl(struct qbe_statement *stmt, int *id, const char *fmt) { stmt->type = Q_LABEL; int n = snprintf(NULL, 0, fmt, *id); @@ -248,7 +248,7 @@ pushprei(struct qbe_func *func, const struct qbe_value *out, } const char * -pushl(struct qbe_func *func, uint64_t *id, const char *fmt) +pushl(struct qbe_func *func, int *id, const char *fmt) { struct qbe_statement stmt = {0}; const char *l = genl(&stmt, id, fmt); diff --git a/src/qtype.c b/src/qtype.c @@ -19,9 +19,9 @@ sf_compar(const void *_a, const void *_b) static const struct qbe_type * tagged_qtype(struct gen_context *ctx, const struct type *type) { - int n = snprintf(NULL, 0, "tags.%" PRIu64, ctx->id); + int n = snprintf(NULL, 0, "tags.%d", ctx->id); char *name = xcalloc(1, n + 1); - snprintf(name, n + 1, "tags.%" PRIu64, ctx->id); + snprintf(name, n + 1, "tags.%d", ctx->id); ++ctx->id; struct qbe_def *def = xcalloc(1, sizeof(struct qbe_def)); @@ -66,9 +66,9 @@ aggregate_lookup(struct gen_context *ctx, const struct type *type) } } - int n = snprintf(NULL, 0, "type.%" PRIu64, ctx->id); + int n = snprintf(NULL, 0, "type.%d", ctx->id); char *name = xcalloc(1, n + 1); - snprintf(name, n + 1, "type.%" PRIu64, ctx->id); + snprintf(name, n + 1, "type.%d", ctx->id); ++ctx->id; struct qbe_def *def = xcalloc(1, sizeof(struct qbe_def));