Enable serialization of Prognode instances
See: https://github.com/gnudatalanguage/gdl/issues/116#issuecomment-380076124
I'm the one who created the feature request number 100 on sf.net in 2011, mentioned by @slayoo on #116.
As @GillesDuvert said this is "easy as a breeze", I want to implement this issue, but I've never worked with GDL's source code and I need some guidance on how to do this.
I could see that the gdl_save() and gdl_restore() functions are pretty simple, but I'm not sure where to get the ProgNode objects to serialize them. I guess I should reach them via the EnvT parameter received in the gdl_save() function, but I decided to ask for help after spending half an hour trying to understand it.
Can someone point me in the right direction? Is there any documentation available regarding the EnvT and ProgNode classes?
I'm worried that the only thing that was ever written on these matters is the HACKING file: https://github.com/gnudatalanguage/gdl/blob/master/HACKING
@swrh, thank you very much for your proposal.
Indeed compiling a function/procedure returns just a pointer to a serie of 'ProgNodes'.
when compiled, the series of ProgNodes that makes the code are pointed to by 'tree' in the DSubUD:: class in dpro.hpp
ProgNodeP tree; // the 'code'
(compiled procedures added to the ProListT vector, functions added to the FunListT vector)
for example, resolve_routine (in basic_pro.cpp) shows how to search for a Fun or Pro.
Save/Restore could indeed xdr-encode/decode the prognodes in a architecture-independent way, but probably safer using an intermediate bytecode, see the antlr::print_tree() output in GDLInterpreter::CompileFile() (file dinterpreter.cpp) available when GDL_DEBUG is defined.
HIH