simple stack machine
perform pre-traversal for global variables (steps 1 & 2)