poke-devel
[Top][All Lists]
Advanced

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

[PATCH 1/2] pkl: make `exit_exception' optional in pkl_execute_* funcs


From: Mohammad-Reza Nabipoor
Subject: [PATCH 1/2] pkl: make `exit_exception' optional in pkl_execute_* funcs
Date: Sat, 23 Sep 2023 23:36:13 +0200

2023-09-23  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>

        * libpoke/pkl.c (pkl_execute_buffer): Don't dereference
        `exit_exception' unconditionally.
        (pkl_execute_statement): Likewise.
        (pkl_execute_expression): Likewise.
        (pkl_execute_file): Likewise.
---
 ChangeLog     |  8 ++++++++
 libpoke/pkl.c | 30 ++++++++++++++++++++----------
 2 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 498e34ee..4dc275cb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-09-23  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>
+
+       * libpoke/pkl.c (pkl_execute_buffer): Don't dereference
+       `exit_exception' unconditionally.
+       (pkl_execute_statement): Likewise.
+       (pkl_execute_expression): Likewise.
+       (pkl_execute_file): Likewise.
+
 2023-09-23  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>
 
        * etc/hacking.org (Maintainers): Update.
diff --git a/libpoke/pkl.c b/libpoke/pkl.c
index 2b352c64..17041be0 100644
--- a/libpoke/pkl.c
+++ b/libpoke/pkl.c
@@ -319,7 +319,7 @@ pkl_execute_buffer (pkl_compiler compiler,
   pvm_program program;
   int ret;
   pkl_env env = NULL;
-  pvm_val val;
+  pvm_val val, exception;
 
   env = pkl_env_dup_toplevel (compiler->env);
   if (!env)
@@ -347,10 +347,12 @@ pkl_execute_buffer (pkl_compiler compiler,
 
   /* Execute the program in the poke vm.  Note the return value is
      discarded.  */
-  pvm_run (compiler->vm, program, &val, exit_exception);
+  pvm_run (compiler->vm, program, &val, &exception);
   pvm_destroy_program (program);
 
-  if (*exit_exception == PVM_NULL)
+  if (exit_exception)
+    *exit_exception = exception;
+  if (exception == PVM_NULL)
     {
       pkl_env_free (compiler->env);
       compiler->env = env;
@@ -378,6 +380,7 @@ pkl_execute_statement (pkl_compiler compiler,
   pvm_program program;
   int ret;
   pkl_env env = NULL;
+  pvm_val exception;
 
   env = pkl_env_dup_toplevel (compiler->env);
   if (!env)
@@ -406,10 +409,12 @@ pkl_execute_statement (pkl_compiler compiler,
   pvm_program_make_executable (program);
 
   /* Execute the routine in the poke vm.  */
-  pvm_run (compiler->vm, program, val, exit_exception);
+  pvm_run (compiler->vm, program, val, &exception);
   pvm_destroy_program (program);
 
-  if (*exit_exception == PVM_NULL)
+  if (exit_exception)
+    *exit_exception = exception;
+  if (exception == PVM_NULL)
     {
       pkl_env_free (compiler->env);
       compiler->env = env;
@@ -482,6 +487,7 @@ pkl_execute_expression (pkl_compiler compiler,
   pvm_program program;
   int ret;
   pkl_env env = NULL;
+  pvm_val exception;
 
   env = pkl_env_dup_toplevel (compiler->env);
   if (!env)
@@ -510,10 +516,12 @@ pkl_execute_expression (pkl_compiler compiler,
   pvm_program_make_executable (program);
 
   /* Execute the routine in the poke vm.  */
-  pvm_run (compiler->vm, program, val, exit_exception);
+  pvm_run (compiler->vm, program, val, &exception);
   pvm_destroy_program (program);
 
-  if (*exit_exception == PVM_NULL)
+  if (exit_exception)
+    *exit_exception = exception;
+  if (exception == PVM_NULL)
     {
       pkl_env_free (compiler->env);
       compiler->env = env;
@@ -537,7 +545,7 @@ pkl_execute_file (pkl_compiler compiler, const char *fname,
   pvm_program program;
   FILE *fp;
   pkl_env env = NULL;
-  pvm_val val;
+  pvm_val val, exception;
 
   compiler->compiling = PKL_COMPILING_PROGRAM;
 
@@ -567,10 +575,12 @@ pkl_execute_file (pkl_compiler compiler, const char 
*fname,
   fclose (fp);
 
   /* Execute the program in the poke vm.  */
-  pvm_run (compiler->vm, program, &val, exit_exception);
+  pvm_run (compiler->vm, program, &val, &exception);
   pvm_destroy_program (program);
 
-  if (*exit_exception == PVM_NULL)
+  if (exit_exception)
+    *exit_exception = exception;
+  if (exception == PVM_NULL)
     {
       pkl_env_free (compiler->env);
       compiler->env = env;
-- 
2.42.0




reply via email to

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