Skip to content

Commit ff01f5f

Browse files
committed
Merge branch 'master' into chore/embeded_lua_filesystem_sync_master
2 parents 4b55230 + c3199cb commit ff01f5f

File tree

11 files changed

+1059
-217
lines changed

11 files changed

+1059
-217
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ Libraries for GopherLua
869869
- `gluasql <https://github.com/tengattack/gluasql>`_ : A native Go implementation of SQL client for the GopherLua VM.
870870
- `purr <https://github.com/leyafo/purr>`_ : A http mock testing tool.
871871
- `vadv/gopher-lua-libs <https://github.com/vadv/gopher-lua-libs>`_ : Some usefull libraries for GopherLua VM.
872-
- `gluaperiphery <https://github.com/BixData/gluaperiphery>`_ : A periphery library for the GopherLua VM (GPIO, SPI, I2C, MMIO, and Serial peripheral I/O for Linux).
872+
- `gluasocket <https://gitlab.com/megalithic-llc/gluasocket>`_ : A native Go implementation of LuaSocket for the GopherLua VM.
873873
- `glua-async <https://github.com/CuberL/glua-async>`_ : An async/await implement for gopher-lua.
874874
- `gopherlua-debugger <https://github.com/edolphin-ydf/gopherlua-debugger>`_ : A debugger for gopher-lua
875875
- `gluamahonia <https://github.com/super1207/gluamahonia>`_ : An encoding converter for gopher-lua

_glua-tests/issues.lua

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,3 +457,36 @@ function test()
457457
assert(c == 1)
458458
assert(type(c) == "number")
459459
end
460+
test()
461+
462+
-- issue #452
463+
function test()
464+
local ok, msg = pcall(function()
465+
local ok, msg = xpcall(function() error("fn") end, function(err) error("handler") end)
466+
assert(not ok and msg)
467+
error("expected to reach this.")
468+
end)
469+
assert(not ok)
470+
end
471+
test()
472+
473+
-- issue #455
474+
function test()
475+
local path = "."
476+
local fd, _, code = io.open(path, "r")
477+
assert(fd ~= nil)
478+
local _, _, ecode = fd:read(1)
479+
assert(ecode == 1)
480+
end
481+
test()
482+
483+
-- issue #459
484+
function test()
485+
local a, b = io.popen("ls", nil)
486+
assert(a)
487+
assert(b == nil)
488+
local a, b = io.popen("ls", nil, nil)
489+
assert(a)
490+
assert(b == nil)
491+
end
492+
test()

_state.go

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -400,25 +400,26 @@ func (rg *registry) forceResize(newSize int) {
400400
copy(newSlice, rg.array[:rg.top]) // should we copy the area beyond top? there shouldn't be any valid values there so it shouldn't be necessary.
401401
rg.array = newSlice
402402
}
403-
func (rg *registry) SetTop(top int) {
404-
// +inline-call rg.checkSize top
405-
oldtop := rg.top
406-
rg.top = top
407-
for i := oldtop; i < rg.top; i++ {
403+
404+
func (rg *registry) SetTop(topi int) { // +inline-start
405+
// +inline-call rg.checkSize topi
406+
oldtopi := rg.top
407+
rg.top = topi
408+
for i := oldtopi; i < rg.top; i++ {
408409
rg.array[i] = LNil
409410
}
410411
// values beyond top don't need to be valid LValues, so setting them to nil is fine
411412
// setting them to nil rather than LNil lets us invoke the golang memclr opto
412-
if rg.top < oldtop {
413-
nilRange := rg.array[rg.top:oldtop]
413+
if rg.top < oldtopi {
414+
nilRange := rg.array[rg.top:oldtopi]
414415
for i := range nilRange {
415416
nilRange[i] = nil
416417
}
417418
}
418419
//for i := rg.top; i < oldtop; i++ {
419420
// rg.array[i] = LNil
420421
//}
421-
}
422+
} // +inline-end
422423

423424
func (rg *registry) Top() int {
424425
return rg.top
@@ -500,34 +501,34 @@ func (rg *registry) FillNil(regm, n int) { // +inline-start
500501
func (rg *registry) Insert(value LValue, reg int) {
501502
top := rg.Top()
502503
if reg >= top {
503-
rg.Set(reg, value)
504+
// +inline-call rg.Set reg value
504505
return
505506
}
506507
top--
507508
for ; top >= reg; top-- {
508509
// FIXME consider using copy() here if Insert() is called enough
509-
rg.Set(top+1, rg.Get(top))
510+
// +inline-call rg.Set top+1 rg.Get(top)
510511
}
511-
rg.Set(reg, value)
512+
// +inline-call rg.Set reg value
512513
}
513514

514-
func (rg *registry) Set(reg int, val LValue) {
515-
newSize := reg + 1
515+
func (rg *registry) Set(regi int, vali LValue) { // +inline-start
516+
newSize := regi + 1
516517
// +inline-call rg.checkSize newSize
517-
rg.array[reg] = val
518-
if reg >= rg.top {
519-
rg.top = reg + 1
518+
rg.array[regi] = vali
519+
if regi >= rg.top {
520+
rg.top = regi + 1
520521
}
521-
}
522+
} // +inline-end
522523

523-
func (rg *registry) SetNumber(reg int, val LNumber) {
524-
newSize := reg + 1
524+
func (rg *registry) SetNumber(regi int, vali LNumber) { // +inline-start
525+
newSize := regi + 1
525526
// +inline-call rg.checkSize newSize
526-
rg.array[reg] = rg.alloc.LNumber2I(val)
527-
if reg >= rg.top {
528-
rg.top = reg + 1
527+
rg.array[regi] = rg.alloc.LNumber2I(vali)
528+
if regi >= rg.top {
529+
rg.top = regi + 1
529530
}
530-
}
531+
} // +inline-end
531532

532533
func (rg *registry) IsFull() bool {
533534
return rg.top >= cap(rg.array)
@@ -1879,6 +1880,9 @@ func (ls *LState) PCall(nargs, nret int, errfunc *LFunction) (err error) {
18791880
err = rcv.(*ApiError)
18801881
err.(*ApiError).StackTrace = ls.stackTrace(0)
18811882
}
1883+
ls.stack.SetSp(sp)
1884+
ls.currentFrame = ls.stack.Last()
1885+
ls.reg.SetTop(base)
18821886
}
18831887
}()
18841888
ls.Call(1, 1)

0 commit comments

Comments
 (0)