The type analyzer now better supports closured variables

thanks Marius for the report
Only defined locals go into the class dict

Before we would write all local names into the class dict;
this is close, but was including undefined names.

Have to get help from the IR generator to determine the live names,
so add a LOCALS opcode (CPython has a similar one), and use that to
generate the dict that a classdef returns.

The current support is not quite enough to support the locals() function,
since even though we have that information available at the IR generator,
it's not easy to make it available to the runtime.
Pass closures through classdefs

Ie if a class is defined in a function, and that class contains
a function which references variables from the enclosing function,
previously the classdef would not pass the closure through and
things would fail.

Now classdefs (and other scopes) can pass through closures even if
they don't add their own variables to the closured-set.

Also, fix some bugs along the way.