[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/2] pkl: fix array-to-array casting to have the right bounder
|
From: |
Mohammad-Reza Nabipoor |
|
Subject: |
[PATCH 1/2] pkl: fix array-to-array casting to have the right bounder |
|
Date: |
Sat, 18 Feb 2023 13:48:16 +0100 |
Bounders in PVM arrays are closures that return one of these PVM
values: `PVM_NULL', an integer, an offset.
This commit fixes the cast operation to an unbounded array type.
2023-02-18 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
* libpoke/pkl-asm.c (pkl_asm_insn_atoa): Do not use `PVM_NULL' as
the bounder in the type of array. Use a closure that returns
`PVM_NULL'.
* testsuite/poke.pkl/cast-array-8.pk: New test.
* testsuite/Makefile.am (EXTRA_DIST): Update.
---
ChangeLog | 8 ++++++++
libpoke/pkl-asm.c | 11 ++++++++++-
testsuite/Makefile.am | 1 +
testsuite/poke.pkl/cast-array-8.pk | 9 +++++++++
4 files changed, 28 insertions(+), 1 deletion(-)
create mode 100644 testsuite/poke.pkl/cast-array-8.pk
diff --git a/ChangeLog b/ChangeLog
index f609f733..180b0902 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-02-18 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
+
+ * libpoke/pkl-asm.c (pkl_asm_insn_atoa): Do not use `PVM_NULL' as
+ the bounder in the type of array. Use a closure that returns
+ `PVM_NULL'.
+ * testsuite/poke.pkl/cast-array-8.pk: New test.
+ * testsuite/Makefile.am (EXTRA_DIST): Update.
+
2023-02-18 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
* libpoke/pvm.jitter (wrapped-globals): Remove
diff --git a/libpoke/pkl-asm.c b/libpoke/pkl-asm.c
index 899d8303..0fde2cd9 100644
--- a/libpoke/pkl-asm.c
+++ b/libpoke/pkl-asm.c
@@ -215,6 +215,8 @@ pkl_asm_insn_atoa (pkl_asm pasm,
/* Now process the array itself. */
if (bound == NULL)
{
+ pvm_val bounder;
+
if (from_type && from_bound == NULL)
/* Both array types are unbounded, hence they are identical =>
no need to do anything. */
@@ -222,7 +224,14 @@ pkl_asm_insn_atoa (pkl_asm pasm,
/* No checks are due in this case, but the value itself
should be typed as an unbound array. */
- pkl_asm_insn (pasm, PKL_INSN_PUSH, PVM_NULL); /* ARR NULL */
+
+ /* Because `bound' is NULL, the bounder closure for `to_type'
+ will do the right thing (which is returning PVM_NULL on
+ invocation). We set this bounder in the PVM type of
+ the array. */
+ bounder = PKL_AST_TYPE_A_BOUNDER (to_type);
+
+ pkl_asm_insn (pasm, PKL_INSN_PUSH, bounder); /* ARR CLS */
pkl_asm_insn (pasm, PKL_INSN_ASETTB); /* ARR */
}
else
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index 86a6478a..60cae4c1 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -1043,6 +1043,7 @@ EXTRA_DIST = \
poke.pkl/cast-array-5.pk \
poke.pkl/cast-array-6.pk \
poke.pkl/cast-array-7.pk \
+ poke.pkl/cast-array-8.pk \
poke.pkl/cast-array-diag-1.pk \
poke.pkl/cast-array-diag-2.pk \
poke.pkl/cast-array-diag-3.pk \
diff --git a/testsuite/poke.pkl/cast-array-8.pk
b/testsuite/poke.pkl/cast-array-8.pk
new file mode 100644
index 00000000..b466b463
--- /dev/null
+++ b/testsuite/poke.pkl/cast-array-8.pk
@@ -0,0 +1,9 @@
+/* { dg-do run } */
+
+var a = [1,2,3] as int[],
+ bounder_non_null_p =
+ asm int<32>: ("typof; nip; tyagetb; nip; nn; nip" : a);
+
+/* { dg-command {.set obase 10} } */
+/* { dg-command {bounder_non_null_p} } */
+/* { dg-output "1" } */
--
2.39.1
- [PATCH 1/2] pkl: fix array-to-array casting to have the right bounder,
Mohammad-Reza Nabipoor <=