[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 2/3] pkl: Fix codegen of printf
From: |
Jose E. Marchesi |
Subject: |
Re: [PATCH v2 2/3] pkl: Fix codegen of printf |
Date: |
Sat, 12 Jun 2021 15:40:41 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
This is OK for both master and maint/poke-1.
Thanks!
> 2021-06-06 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
>
> * libpoke/pkl-gen.c (pkl_gen_pr_type_function): Add comment.
> (pkl_gen_pr_type_array): Save computed closure for printer in
> AST node.
> (pkl_gen_pr_type_struct): Likewise.
> * libpoke/pkl-gen.pks (print_boffset): Use escape sequence in string
> literal to make RAS happy.
> (struct_printer): s/struct_type/@struct_type/.
> ---
> ChangeLog | 10 ++++++++++
> libpoke/pkl-gen.c | 4 +++-
> libpoke/pkl-gen.pks | 8 +++-----
> 3 files changed, 16 insertions(+), 6 deletions(-)
>
> diff --git a/ChangeLog b/ChangeLog
> index febeb753..9ecfdcab 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,13 @@
> +2021-06-06 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
> +
> + * libpoke/pkl-gen.c (pkl_gen_pr_type_function): Add comment.
> + (pkl_gen_pr_type_array): Save computed closure for printer in
> + AST node.
> + (pkl_gen_pr_type_struct): Likewise.
> + * libpoke/pkl-gen.pks (print_boffset): Use escape sequence in string
> + literal to make RAS happy.
> + (struct_printer): s/struct_type/@struct_type/.
> +
> 2021-06-06 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
>
> * libpoke/pvm.jitter (sprops): Add instruction for
> diff --git a/libpoke/pkl-gen.c b/libpoke/pkl-gen.c
> index 19d7fb9e..a57d4b58 100644
> --- a/libpoke/pkl-gen.c
> +++ b/libpoke/pkl-gen.c
> @@ -2843,7 +2843,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_type_function)
> {
> /* Stack: VAL DEPTH */
> pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_DROP); /* DEPTH is not used. */
> - pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_DROP);
> + pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_DROP); /* VAL is not used. */
> pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH,
> pvm_make_string ("#<closure>"));
> pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PRINTS);
> @@ -3082,6 +3082,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_type_array)
> RAS_FUNCTION_ARRAY_PRINTER (printer_closure, array_type);
> pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH, printer_closure);
> pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PEC);
> + PKL_AST_TYPE_A_PRINTER (array_type) = printer_closure;
> }
> else
> pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH, printer_closure);
> @@ -3482,6 +3483,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_type_struct)
> RAS_FUNCTION_STRUCT_PRINTER (printer_closure, struct_type);
> pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH, printer_closure);
> pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PEC);
> + PKL_AST_TYPE_S_PRINTER (struct_type) = printer_closure;
> }
> else
> pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH, printer_closure);
> diff --git a/libpoke/pkl-gen.pks b/libpoke/pkl-gen.pks
> index 1bd48fd1..eb0b60b8 100644
> --- a/libpoke/pkl-gen.pks
> +++ b/libpoke/pkl-gen.pks
> @@ -1918,10 +1918,8 @@
> printlu 64 ; _
> push "integer"
> endsc
> - ;; XXX RAS turns "#b" into "(B_arg)"
> - push "#"
> - prints
> - push "b"
> + ;; RAS turns "#b" into "(B_arg)"; so we use '\x62' for 'b'.
> + push "#\x62"
> prints
> push "offset"
> endsc
> @@ -2121,7 +2119,7 @@
> prints
> .c uint64_t i;
> .let @field
> - .c for (i = 0, @field = PKL_AST_TYPE_S_ELEMS (struct_type);
> + .c for (i = 0, @field = PKL_AST_TYPE_S_ELEMS (@struct_type);
> .c @field;
> .c @field = PKL_AST_CHAIN (@field))
> .c {
[PATCH v2 2/3] pkl: Fix codegen of printf, Mohammad-Reza Nabipoor, 2021/06/07
- Re: [PATCH v2 2/3] pkl: Fix codegen of printf,
Jose E. Marchesi <=