Understanding the lambda form


I’m doing some research on the compiler, and from reading the architecture page, it sounds like the lambda form should contain all the information needed to create the js file.

I’ve run a few code snippets through, and I’m not sure how the record accessors are working.
For example:


type person = {
  name: string;
  age: int;
  job: string;
} [@@bs.deriving abstract]

let joe = person ~name:"Joe" ~age:20 ~job:"teacher"
let twenty = ageGet joe
let teacher = jobGet joe

gets converted to a lambda form of ->

(setglobal Demo!
    (include/1042 = (let (include/1043 = (makeblock 0)) (makeblock 0))
      joe/1028 = ( "Joe" 20 "teacher")
      twenty/1029 = ( joe/1028)
      teacher/1030 = ( joe/1028))
    (makeblock 0 joe/1028 twenty/1029 teacher/1030)))

Here, it looks like twenty/1029 and teacher/1030 are equal to the same value, but when it finally gets compiled to js, it becomes:

var joe = {
  name: "Joe",
  age: 20,
  job: "teacher"

var twenty = joe.age;

var teacher = joe.job;

Does anyone know how the compiler is able to get from that lambda form to the js output?
I’m guessing there is a step left out from the high-level architecture diagram shown here: https://bucklescript.github.io/docs/en/compiler-architecture-principles