Lua code reading (LUA source reading)

Source: Internet
Author: User

http://blog.csdn.net/cnjet/article/details/7023526

Online Lua 5.1 Source Code Browser

Recommended reading order:

  • LMATHLIB.C, lstrlib.c:get familiar with the external C API. Don ' t bother with the pattern matcher though. Just the easy functions.
  • Lapi.c:check how the API is implemented internally. Only skim this to get a feeling for the code. Cross-Reference to Lua.h and luaconf.h as needed.
  • Lobject.h:tagged values and object representation. Skim through this first. You'll want to keep a window with this file open all the time.
  • Lstate.h:state objects. Ditto.
  • Lopcodes.h:bytecode instruction format and opcode definitions. Easy.
  • Lvm.c:scroll down to Luav_execute, the main interpreter loop. See how all of the instructions is implemented. Skip the details for now. Reread later.
  • Ldo.c:calls, stacks, exceptions, coroutines. Tough read.
  • Lstring.c:string interning. Cute, huh?
  • Ltable.c:hash tables and arrays. Tricky code.
  • Ltm.c:metamethod handling, reread all of LVM.C now.
  • Want to reread lapi.c now.
  • Ldebug.c:surprise waiting for you. Abstract interpretation is used to the Find object names for Tracebacks. Does bytecode verification, too.
  • LPARSER.C, Lcode.c:recursive descent parser, targetting a register-based VM. Start from chunk () and work your The through. Read the expression parser and the code generator parts last.
  • Lgc.c:incremental garbage collector. Take your time.
  • Read all the other files as you see references to them. Don ' t let the your stack get too deep though.

If you ' re-done before X-mas and understood all of it, you ' re good. The information density of the code is rather high.

Adapt from http://lua.iteye.com/blog/492260.

Ps:an optimized and extended LUA implementation, http://www.luajit.org.

Lua code reading (LUA source reading)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.