poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[COMMITTED] pkl: Pk_Type fields `signed_p' and `size' are not exposed in


From: Jose E. Marchesi
Subject: [COMMITTED] pkl: Pk_Type fields `signed_p' and `size' are not exposed in non-integral structs
Date: Mon, 23 Jan 2023 00:24:24 +0100
User-agent: Gnus/5.13 (Gnus v5.13)


2023-01-23  Jose E. Marchesi  <jemarch@gnu.org>

        * testsuite/poke.pkl/typeof-struct-2.pk: Likewise.

        * testsuite/poke.pkl/typeof-struct-1.pk: Update test.

        * libpoke/pkl-gen.pks (typeof): Initialize integral_p.
---
 ChangeLog                             |  8 ++++++++
 libpoke/pkl-gen.pks                   | 21 +++++++++++++++++----
 libpoke/pkl-rt.pk                     |  6 +++---
 testsuite/poke.pkl/typeof-struct-1.pk |  4 ----
 testsuite/poke.pkl/typeof-struct-2.pk |  4 ----
 5 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 29084fb2..e3b6a1d1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-01-23  Jose E. Marchesi  <jemarch@gnu.org>
+
+       * testsuite/poke.pkl/typeof-struct-2.pk: Likewise.
+
+       * testsuite/poke.pkl/typeof-struct-1.pk: Update test.
+
+       * libpoke/pkl-gen.pks (typeof): Initialize integral_p.
+
 2023-01-22  Jose E. Marchesi  <jemarch@gnu.org>
 
        * poke/poke.c (pk_print_version): Bump copyright year to 2023 and
diff --git a/libpoke/pkl-gen.pks b/libpoke/pkl-gen.pks
index 21f52771..32f76218 100644
--- a/libpoke/pkl-gen.pks
+++ b/libpoke/pkl-gen.pks
@@ -2828,10 +2828,23 @@
                                             "Pk_Type")
         .let #pktype_constructor = PKL_AST_TYPE_S_CONSTRUCTOR (@pktype)
         ;; Create a Pk_Type on the stack calling its constructor
-        ;; with a single constructor field `code'.
+        ;; with constructor fields `code' and `integral_p'.  Note that
+        ;; the initializer for integral_p will only be used if the
+        ;; type is a struct type.
         push ulong<64>0         ; OFF
         push ulong<64>0         ; OFF EOFF
-        push "code"             ; OFF EOFF ENAME
+        push "integral_p"       ; OFF EOFF ENAME
+  .c if (PKL_AST_TYPE_CODE (@type) == PKL_TYPE_STRUCT
+  .c         && PKL_AST_TYPE_S_ITYPE (@type))
+  .c {
+        push int<32>1
+  .c }
+  .c else
+  .c {
+        push int<32>0
+  .c }
+        push ulong<64>32        ; OFF ... EOFF
+        push "code"             ; OFF ... EOFF ENAME
   .c  int pk_type_code;
   .c  int pk_type_unknown = PK_TYPE_CODE ("PK_TYPE_UNKNOWN");
   .c  switch (PKL_AST_TYPE_CODE (@type))
@@ -2865,12 +2878,12 @@
         ;; Number of methods
         push ulong<64>0         ; OFF EOFF ENAME EVAL 0UL
         ;; Number of fields
-        push ulong<64>1         ; OFF EOFF ENAME EVAL 0UL 1UL
+        push ulong<64>2         ; OFF EOFF ENAME EVAL 0UL 2UL
         ;; Type of the Pk_Type struct
   .c    PKL_GEN_PUSH_SET_CONTEXT (PKL_GEN_CTX_IN_TYPE);
   .c    PKL_PASS_SUBPASS (@pktype);
   .c    PKL_GEN_POP_CONTEXT;
-                                ; OFF EOFF ENAME EVAL 0UL 1UL TYP
+                                ; OFF EOFF ENAME EVAL 0UL 2UL TYP
         mksct
         push #pktype_constructor
         call                    ; PkType
diff --git a/libpoke/pkl-rt.pk b/libpoke/pkl-rt.pk
index 35fb1b58..f39d012a 100644
--- a/libpoke/pkl-rt.pk
+++ b/libpoke/pkl-rt.pk
@@ -632,13 +632,13 @@ immutable type Pk_Type =
     uint<32> code;
     string name;
     uint<32> complete_p;
-    int<32> signed_p    if code in [PK_TYPE_INTEGRAL, PK_TYPE_OFFSET, 
PK_TYPE_STRUCT];
-    uint<64> size       if code in [PK_TYPE_INTEGRAL, PK_TYPE_OFFSET, 
PK_TYPE_STRUCT];
+    int<32> integral_p  if code == PK_TYPE_STRUCT;
+    int<32> signed_p    if code in [PK_TYPE_INTEGRAL, PK_TYPE_OFFSET] || code 
== PK_TYPE_STRUCT && integral_p;
+    uint<64> size       if code in [PK_TYPE_INTEGRAL, PK_TYPE_OFFSET] || code 
== PK_TYPE_STRUCT && integral_p;
     uint<64> _unit      if code == PK_TYPE_OFFSET;
     int<32> bounded_p   if code == PK_TYPE_ARRAY;
     int<32> union_p     if code == PK_TYPE_STRUCT;
     int<32> pinned_p    if code == PK_TYPE_STRUCT;
-    int<32> integral_p  if code == PK_TYPE_STRUCT;
     int<32> nfields     if code == PK_TYPE_STRUCT;
     int<32> nmethods    if code == PK_TYPE_STRUCT;
     string[] fnames     if code == PK_TYPE_STRUCT;
diff --git a/testsuite/poke.pkl/typeof-struct-1.pk 
b/testsuite/poke.pkl/typeof-struct-1.pk
index 48e8fc26..d7582c07 100644
--- a/testsuite/poke.pkl/typeof-struct-1.pk
+++ b/testsuite/poke.pkl/typeof-struct-1.pk
@@ -10,10 +10,6 @@ var t = typeof (Foo);
 /* { dg-output "\n0" } */
 /* { dg-command { t.integral_p } } */
 /* { dg-output "\n0" } */
-/* { dg-command { t.signed_p } } */
-/* { dg-output "\n0" } */
-/* { dg-command { t.size } } */
-/* { dg-output "\n0UL" } */
 /* { dg-command { t.nfields } } */
 /* { dg-output "\n0" } */
 /* { dg-command { t.nmethods } } */
diff --git a/testsuite/poke.pkl/typeof-struct-2.pk 
b/testsuite/poke.pkl/typeof-struct-2.pk
index 37d41f98..8e7504e7 100644
--- a/testsuite/poke.pkl/typeof-struct-2.pk
+++ b/testsuite/poke.pkl/typeof-struct-2.pk
@@ -10,10 +10,6 @@ var t = typeof (Foo);
 /* { dg-output "\n1" } */
 /* { dg-command { t.integral_p } } */
 /* { dg-output "\n0" } */
-/* { dg-command { t.signed_p } } */
-/* { dg-output "\n0" } */
-/* { dg-command { t.size } } */
-/* { dg-output "\n0UL" } */
 /* { dg-command { t.nfields } } */
 /* { dg-output "\n0" } */
 /* { dg-command { t.nmethods } } */
-- 
2.30.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]