HPCC-10942 Refactor some of the graph transformations

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
HPCC-10942 Fix some minor bugs found while trying to simplify processing

Prevent global(global(x)) being generated, and handle it correctly in the resourcing
if it does occur.  Could possibly have occured when generating a library.

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Merge pull request #5485 from ghalliday/issue10942

HPCC-10942 Refactor some of the graph transformations

Reviewed-By: Jamie Noss <james.noss@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>