Add scope chains to implement closures

Each function, when declared, now captures the scope at declaration
time, and a child of that scope is available when the function is
called.