Lua's bytecode specification [closed]

2019-02-03 05:53发布

Can anyone tell me where to find Lua's bytecode specification? I've been searching for 15 minutes, and I can't find anything.

4条回答
Animai°情兽
2楼-- · 2019-02-03 06:30

The official definition is in lopcodes.h.

查看更多
狗以群分
3楼-- · 2019-02-03 06:32
神经病院院长
4楼-- · 2019-02-03 06:42

Maybe A No-Frills Introduction to Lua 5.1 VM Instructions contains what you're looking for?

There is also a table of the Lua 5.0 instruction set (Figure 5) in:

Ierusalimschy, R.; Figueiredo, L. H.; Celes, W. (2005), "The implementation of Lua 5.0", J. of Universal Comp. Sci. 11 (7): 1159-1176

You can find the full text with a search on Google Scholar and I believe it's on lua.org as well. This reference is used by the Lua page on Wikipedia, which is always a good place to look for such things. :-)

查看更多
Juvenile、少年°
5楼-- · 2019-02-03 06:53

The only specifications for Lua are the language, standard libraries, and the C API. The creators of Lua intentionally left the VM unspecified for a couple main reasons:

  • Lua can be fully implemented with any underlying architecture (VM, interpreter, compiler, etc.)
  • The official Lua distribution doesn't have to worry about maintaining VM compatibility between versions

This means, for example, that you generally shouldn't use the Lua VM as a target for a compiler. If you'd like to know how the official Lua distribution's VM works as an example for your own curiosity, see the other answers.

查看更多
登录 后发表回答