Lua-decided to start analyzing Lua's source code

Source: Internet
Author: User

  • 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 the this file open a ll 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 loops. See how all of the instructions is implemented. Skip the De Tails 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 your. Abstract interpretation is used to find object names for Tracebacks. Does bytecode verific ation, too.
  • lparser.c, lcode.c : Recursive descent parser, targetting a register-based VM. Start from Chunk () and work your IT through. Read the EXP Ression 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.

These are the LUA source reading sequences recommended by Luajit authors.

Leo, now written, is just a toy. If we want to improve him further, I think we have no such ability at present. So, I also want to turn to Lua. Even if it was a reference to Lua's internal design, the final imitation was made.

In the past, I have been searching the internet for a blog about LUA source analysis. These blogs really make me learn a lot, but not enough, because for me, these points of knowledge did not form a complete system. String, closure, virtual machine, memory management, co-process, ... I have only one-sided understanding of the internal realization principle of these things. So this time, I'm going to make a complete analysis of Lua's source code, take notes, and then continue playing with my Leo.

Lua-decided to start analyzing Lua's source code

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.