Lua stack issues with +=

The important change is just the conditional freereg += 1 lines - the conditions we had before were too loose and were incrementing freereg in some incorrect situations, leading to gaps in the stack.

I ended up rewriting the function for the most part, which might not be necessary.  In case there are other contexts I hadn't considered, I thought it would be good to have the code match existing Lua code as closely as possible.

I tested with my project at work and I checked the bytecode output for the following examples:

m1
```lua
makevars = {}
mylist = 'foo bar baz'
lval = 'foo'
for value in string.gmatch(mylist, "%S+") do
	makevars[lval] += value
end
```

m2
```lua
function ld_linux(objlist, obj)
	objlist.order_only += 'foo.h'
	tup.rule(objlist, 'cat foo.h foo.c; touch %o', obj)
end

tup.rule('touch %o', {'foo.h'})
objlist = {'foo.c'}
obj = 'output.txt'
ld_linux(objlist, obj)
```

env_env
```lua
local w1 = 1
local w2 = 1
x += y
```

indenv_indenv
```lua
local w1 = 1
local w2 = 1
x[1] += y[1]
```

indenv_indenv2
```lua
local w1 = 1
local w2 = 1
x[a] += y[b]
```

indloc_indloc
```lua
local x = {}
local y = {}
local w1 = 1
local w2 = 1
x[1] += y[1]
```

indloc_indloc2
```lua
local x = {}
local y = {}
local w1 = 1
local w2 = 1
x[a] += y[b]
```

loc_loc
```lua
local x = {}
local y = {}
local w1 = 1
local w2 = 1
x += y
```