poke-devel
[Top][All Lists]
Advanced

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

[PATCH 09/12] libpoke: Fix a bug and add assertions to pvm_make_*


From: Mohammad-Reza Nabipoor
Subject: [PATCH 09/12] libpoke: Fix a bug and add assertions to pvm_make_*
Date: Wed, 26 May 2021 02:51:12 +0430

2021-05-23  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>

        * libpoke/pkl-gen.pks (struct_constructor): s/uint<64>/ulong<64>.
        * libpoke/pvm-val.c (pvm_make_int): Add assertion for `size` argument.
        (pvm_make_uint): Likewise.
        (pvm_make_long): Likewise.
        (pvm_make_ulong): Likewise.
---
 ChangeLog           | 8 ++++++++
 libpoke/pkl-gen.pks | 2 +-
 libpoke/pvm-val.c   | 4 ++++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 08cbe123..77bc4ca7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2021-05-23  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>
+
+       * libpoke/pkl-gen.pks (struct_constructor): s/uint<64>/ulong<64>.
+       * libpoke/pvm-val.c (pvm_make_int): Add assertion for `size` argument.
+       (pvm_make_uint): Likewise.
+       (pvm_make_long): Likewise.
+       (pvm_make_ulong): Likewise.
+
 2021-05-22  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>
 
        * libpoke/pkl-rt.pk (_pkl_escape_string): New function.
diff --git a/libpoke/pkl-gen.pks b/libpoke/pkl-gen.pks
index 70f69485..1bd48fd1 100644
--- a/libpoke/pkl-gen.pks
+++ b/libpoke/pkl-gen.pks
@@ -1343,7 +1343,7 @@
         ;; with its size.
    .c if (PKL_AST_TYPE_S_PINNED_P (@type_struct))
    .c {
-        push uint<64>0         ; ... ENAME EVAL EBOFF
+        push ulong<64>0        ; ... ENAME EVAL EBOFF
         dup                    ; ... ENAME EVAL EBOFF NEBOFF
    .c }
    .c else
diff --git a/libpoke/pvm-val.c b/libpoke/pvm-val.c
index 217d6703..b938c3ea 100644
--- a/libpoke/pvm-val.c
+++ b/libpoke/pvm-val.c
@@ -43,24 +43,28 @@ static pvm_val any_type;
 pvm_val
 pvm_make_int (int32_t value, int size)
 {
+  assert (0 < size && size <= 32);
   return PVM_MAKE_INT (value, size);
 }
 
 pvm_val
 pvm_make_uint (uint32_t value, int size)
 {
+  assert (0 < size && size <= 32);
   return PVM_MAKE_UINT (value, size);
 }
 
 pvm_val
 pvm_make_long (int64_t value, int size)
 {
+  assert (0 < size && size <= 64);
   return PVM_MAKE_LONG_ULONG (value, size, PVM_VAL_TAG_LONG);
 }
 
 pvm_val
 pvm_make_ulong (uint64_t value, int size)
 {
+  assert (0 < size && size <= 64);
   return PVM_MAKE_LONG_ULONG (value, size, PVM_VAL_TAG_ULONG);
 }
 
-- 
2.31.1




reply via email to

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