Simplify code in proto's bytecode generator
Emit UCLO instructions when local variables goes out of scope

The UCLO instruction should be emitted when a block is left if there
was local variables declared in the block. This is required because a
closure may refer to the block specific local variables and since these are
going out of scope they should be closed when the block is left.

The flag need_close is also not cleared when a return instruction is
treated because other branches of the code may need to emit UCLO
instructions as well.
Fix a bug with missing RET0 for implicit return

Another approach is used by keeping trace of when an explicit return
instruction is given in the AST. The flag "explret" is set only in the
return instruction is given in the root scope of the function.
Fix error in "for" loop bytecode generation

The looping variable was assigned to the wrong register, the base
of the for loop. The right register to use is the base + 3.
Fix problem in bytecode generator for multi arguments function call
Fix bug with upvalues pointing to the outer scope of the enclosing function

The bug happens when a closure refer to a variable in the outer scope
of the enclosing function. If the variable is declared in an inner block
an assertion was raised.

Now, when the upvalue is first encountered we determine if is a local of
the enclosing function of if it is in an outer scope. In the first case
we just store the register index used for the variable. In the second case
the variable is declared as an upvalue in the enclosing function and its
upvalue index, in the context of the enclosing function, is stored.

This behavior is required by Lua upvalues as described in
"The implementation of Lua 5.0" by R. Ierusalimschy, L. H. de Figueiredo,
W. Celes. The second case is explicitly taken into account and this kind
of closures are called "flat closures".
Fix bug with local variables declaration

The declaration of the variables in the lhs of the assignment should be
done only after the code for rhs is generated.
Merge pull request #24 from franko/fix-closures-bugs

Fix closures bugs