On Dec 21, 2018, at 6:35 AM, Henrik Grubbström (Lysator) @ Pike (-) developers forum 10353@lyskom.lysator.liu.se wrote:
Most of the code for handling local variables and their types and names is located at the end of language.yacc. Of interest are probably the functions {low_,}add_local_name() and {low_,lexical_,}islocal() in language.yacc, as well as {low_,}pop_local_variables() in pike_compiler.cmod.
The main problem in the case of debugging, is that this information is thrown away by the compiler when no longer needed.
One possible place to store the information would be in the linenumber table, but doing that would probably require adding suitable new nodes to the parse-tree (las.c), corresponding new virtual opcodes (docode.c, et al) to let the code that generates the linenumber table (peep.c) reach it. Note also that adding these extra nodes and opcodes may affect some of the optimizers.
I looked at this code briefly last week but was wondering: would it be possible to store the variable definitions in a separate structure in the program and then use the INIT_FRAME opcode to also connect the variables up in the pike frame while allocating the locals?
/grubba