The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Language::Zcode::Translator::Perl - Translate Z-code into Perl code

routine_start

This sub writes out a string that starts a sub. Basically, we need to handle setting local variables the sub was called with, and declaring an empty eval stack.

The much more complicated situation is when we're restoring a game in which this sub was in the call stack when @save was called. If sub A called B called C, which saved, then when we restore the save, we'll start executing sub C, right after the @save command - and we need to set the local variables and eval stack in C to the values they had when we saved. When we return from C, z_call will call B, which needs to start executing at the command right after the call to C. But when we start executing B, for example, the local variables and eval stack need to be set to the values they had when we called C. (We get that information from the save file.)

Arg 0 of the created sub will be an arrayref. It's empty for normal calls. However, if we restored a game where this sub was in the call stack, then the sub will be called with information giving the sub's state when it called the next sub in the stack (or @save): namely, arg0 will then contain the PC where we should resume execution, and the values to set the eval stack to.

arg1-argn will contain input values for the local variables. If we're restoring, those values will be the values from the appropriate frame of the call stack.

Note: it's legal to pass in too many or too few args. Set only as many values as were passed in, & don't auto-expand array. (Important pre-V5, when local var initial values may not be 0)