3 ms·
From a quick glance at the source, it looks like this may be a port of the existing Lua VM for C into Go. For example, it appears to use the same opcodes and t
by haberman 12y ago
From a quick glance at the source, it looks like this may be a port of the existing Lua VM for C into Go.
For example, it appears to use the same opcodes and the main VM loop looks very similar:
http://www.lua.org/source/5.1/lvm.c.html http://www.lua.org/source/5.1/lvm.c.html
https://github.com/yuin/gopher-lua/blob/master/vm.go https://github.com/yuin/gopher-lua/blob/master/vm.go
It's interesting because the Go source appears to be annotating certain patterns with comments where the C version uses a macro. Compare the C version:
case OP_LOADK: {
setobj2s(L, ra, KBx(i));
With the Go version:
case OP_LOADK:
Bx = int(inst & 0x3ffff) //GETBX
reg.Set(RA, cf.Fn.Proto.Constants[Bx])
- SixSigma 12y agoAnd what a useless comment GETBX is.
- Intermernet 12y agoThis in itself isn't a bad thing. When I'm porting code, I try to start with a proven code-base and port from there, while iterating the code to make it more idiomatic (e.g. "case OP_LOADK" is not idiomatic Go). The problem is, if the author has based their code on this library, they seem not to have credited it (At least, I couldn't find it on my cursory look at the file headers).