On Thu, 2026-05-07 at 11:28 +0200, Basile STARYNKEVITCH wrote: > Hello all, > > I do have (and even compiled it from source code a few days ago) GCC > 16 > with libgccjit enabled (this on Linux/x86-64). > > gcc-16 (Debian 16-20260425-1) 16.0.1 20260425 (prerelease) [gcc-16 > r16- > 8812-gd9c07462a22] > > https://gcc.gnu.org/onlinedocs/jit/topics/objects.html > mentions upcasting > > casting methods for upcasting from subclasses to parent classes > > But is there any dynamic downcasting (or way to dynamically query the > GCCJIT "class" of any gcc_jit_object pointer)? > > E.g. suppose I have some gcc_jit_object* jp pointer. > > How can I know if jp is representing a struct, a left value, a field, > a > parameter, a number constant etc....
I don't think there is a way to do this built into libgccjit. One way to do it when working with libgccjit is to store the information yourself when the process creates the various gcc_jit_objects (e.g. a mapping from gcc_jit_object * back to the underlying objects in your program), and to access that when writing out the json. Dave > > I am serializing GCCJIT representation to JSON in my open source > RefPerSys software, its commit 94d149cbaa71 > > Thanks for your insights >
