Builtin Library
README.md
procgen.flatten
Writes a node's code out in place of a call to it: the inverse of
procgen.collapse. The call becomes a do ... end block holding the node's
body, so the node's own locals stay its own:
- each input the node declares becomes a local holding what the call passed, or the default the node declares when the call passed nothing;
- the local the call declared is declared just above the block and given what the node gives: the node's value itself for a node with one output, a table of its outputs by name for a node with several;
g:describeand the node's other declarations about itself drop out, and a file-level local the node's body uses (local rand = ...) is carried into the graph's file.
The graph builds from the same calls and cooks to the same result.
callwrites out one call, named by the local it declares or a line it spans.nodewrites out every call of that node.- With neither, every call of a node or part outside the built-in library is written out, and again for the calls those bring in, until none is left.
The graph's new source is written only once it builds. Part of procgen.toolbox, called as tools.use("procgen", "flatten", ...) (zero procgen flatten in the engine shell). Returns { inlined, source, diagnostics }.