]> git.eshelyaron.com Git - emacs.git/commitdiff
Support compiled queries in pdump by dumping source (bug#69952)
authorSergey Vinokurov <serg.foo@gmail.com>
Sun, 6 Aug 2023 15:24:29 +0000 (16:24 +0100)
committerEshel Yaron <me@eshelyaron.com>
Mon, 22 Jul 2024 10:38:10 +0000 (12:38 +0200)
* src/pdumper.c (dump_vectorlike): Dump compiled queries.
* src/pdumper.c (dump_treesit_compiled_query): New function.

(cherry picked from commit 1eca867e1b60acef7f4343bc5c70340de58f1079)

src/pdumper.c

index bc5748c8c475a83ff322eb8b070f92572c8aee42..07fb1d569dabb114afe6d61e3476c95bc0fb0d16 100644 (file)
@@ -44,6 +44,7 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
 #include "systime.h"
 #include "thread.h"
 #include "bignum.h"
+#include "treesit.h"
 
 #ifdef CHECK_STRUCTS
 # include "dmpstruct.h"
@@ -2214,6 +2215,21 @@ dump_finalizer (struct dump_context *ctx,
   return finish_dump_pvec (ctx, &out->header);
 }
 
+#ifdef HAVE_TREE_SITTER
+static dump_off
+dump_treesit_compiled_query (struct dump_context *ctx,
+                            struct Lisp_TS_Query *query)
+{
+  START_DUMP_PVEC (ctx, &query->header, struct Lisp_TS_Query, out);
+  dump_field_lv (ctx, &out->language, query, &query->language, WEIGHT_STRONG);
+  dump_field_lv (ctx, &out->source, query, &query->source, WEIGHT_STRONG);
+  /* Recompile these after load */
+  out->query = NULL;
+  out->cursor = NULL;
+  return finish_dump_pvec (ctx, &out->header);
+}
+#endif
+
 struct bignum_reload_info
 {
   dump_off data_location;
@@ -3107,6 +3123,12 @@ dump_vectorlike (struct dump_context *ctx,
           return DUMP_OBJECT_IS_RUNTIME_MAGIC;
         }
       break;
+#ifdef HAVE_TREE_SITTER
+    case PVEC_TS_COMPILED_QUERY:
+      return dump_treesit_compiled_query (ctx, XTS_COMPILED_QUERY (lv));
+#else
+    case PVEC_TS_COMPILED_QUERY:
+#endif
     case PVEC_WINDOW_CONFIGURATION:
     case PVEC_OTHER:
     case PVEC_XWIDGET:
@@ -3121,7 +3143,6 @@ dump_vectorlike (struct dump_context *ctx,
     case PVEC_FREE:
     case PVEC_TS_PARSER:
     case PVEC_TS_NODE:
-    case PVEC_TS_COMPILED_QUERY:
       break;
     }
   char msg[60];